From: Christoph Hellwig <hch@infradead.org>
To: Ondrej Kozina <okozina@redhat.com>
Cc: linux-block@vger.kernel.org, bluca@debian.org,
gmazyland@gmail.com, axboe@kernel.dk, hch@infradead.org,
brauner@kernel.org, rafael.antognolli@intel.com
Subject: Re: [PATCH 2/5] sed-opal: add helper for adding user authorities in ACE.
Date: Tue, 4 Apr 2023 08:25:36 -0700 [thread overview]
Message-ID: <ZCxBcOBSfmf58Yxd@infradead.org> (raw)
In-Reply-To: <20230322151604.401680-3-okozina@redhat.com>
On Wed, Mar 22, 2023 at 04:16:01PM +0100, Ondrej Kozina wrote:
> Moves ACE construction away from add_user_to_lr routine
> to be used later in added code.
>
> Signed-off-by: Ondrej Kozina <okozina@redhat.com>
> Tested-by: Luca Boccassi <bluca@debian.org>
> Tested-by: Milan Broz <gmazyland@gmail.com>
> ---
> block/sed-opal.c | 64 +++++++++++++++++++++++++++++++++---------------
> 1 file changed, 44 insertions(+), 20 deletions(-)
>
> diff --git a/block/sed-opal.c b/block/sed-opal.c
> index d86d3e5f5a44..2c3e38df9c65 100644
> --- a/block/sed-opal.c
> +++ b/block/sed-opal.c
> @@ -1759,25 +1759,16 @@ static int set_sid_cpin_pin(struct opal_dev *dev, void *data)
> return finalize_and_send(dev, parse_and_check_status);
> }
>
> -static int add_user_to_lr(struct opal_dev *dev, void *data)
> +static int set_lr_boolean_ace(struct opal_dev *dev, unsigned int opal_uid, u8 lr,
> + const u8 *users, size_t users_len)
Please avoid the overly long line here.
> + for (u = 0; u < users_len; u++) {
> + if (users[u] == OPAL_ADMIN1)
> + memcpy(user_uid, opaluid[OPAL_ADMIN1_UID], OPAL_UID_LENGTH);
> + else {
> + memcpy(user_uid, opaluid[OPAL_USER1_UID], OPAL_UID_LENGTH);
> + user_uid[7] = users[u];
> + }
> + add_token_u8(&err, dev, OPAL_STARTNAME);
> + add_token_bytestring(&err, dev,
> + opaluid[OPAL_HALF_UID_AUTHORITY_OBJ_REF],
> + OPAL_UID_LENGTH/2);
> + add_token_bytestring(&err, dev, user_uid, OPAL_UID_LENGTH);
> + add_token_u8(&err, dev, OPAL_ENDNAME);
Please facto the logic for adding each user into a nice little helper,
which wil also avoid the overly long lines.
> + if (u > 0) {
> + add_token_u8(&err, dev, OPAL_STARTNAME);
> + add_token_bytestring(&err, dev, opaluid[OPAL_HALF_UID_BOOLEAN_ACE],
> + OPAL_UID_LENGTH/2);
> + add_token_u8(&err, dev, 1);
> + add_token_u8(&err, dev, OPAL_ENDNAME);
> + }
And this would also benefit from both a helper and a comment.
next prev parent reply other threads:[~2023-04-04 15:25 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 15:15 [PATCH 0/5] sed-opal: add command to read locking range attributes Ondrej Kozina
2023-03-22 15:16 ` [PATCH 1/5] sed-opal: do not add user authority twice in boolean ace Ondrej Kozina
2023-03-29 14:15 ` Christian Brauner
2023-03-29 15:20 ` Ondrej Kozina
2023-04-04 15:23 ` Christoph Hellwig
2023-04-05 8:18 ` Christian Brauner
2023-03-22 15:16 ` [PATCH 2/5] sed-opal: add helper for adding user authorities in ACE Ondrej Kozina
2023-03-29 15:28 ` Christian Brauner
2023-04-04 15:25 ` Christoph Hellwig [this message]
2023-03-22 15:16 ` [PATCH 3/5] sed-opal: allow user authority to get locking range attributes Ondrej Kozina
2023-03-29 15:31 ` Christian Brauner
2023-04-04 15:26 ` Christoph Hellwig
2023-03-22 15:16 ` [PATCH 4/5] sed-opal: add helper to get multiple columns at once Ondrej Kozina
2023-03-29 15:32 ` Christian Brauner
2023-04-04 15:26 ` Christoph Hellwig
2023-03-22 15:16 ` [PATCH 5/5] sed-opal: Add command to read locking range parameters Ondrej Kozina
2023-04-04 15:27 ` Christoph Hellwig
2023-04-05 8:27 ` Christian Brauner
2023-04-05 9:39 ` Ondrej Kozina
2023-04-05 10:53 ` Luca Boccassi
2023-04-02 14:49 ` [PATCH 0/5] sed-opal: add command to read locking range attributes Luca Boccassi
2023-04-05 11:12 ` [PATCH v2 " Ondrej Kozina
2023-04-05 11:12 ` [PATCH v2 1/5] sed-opal: do not add same authority twice in boolean ace Ondrej Kozina
2023-04-05 11:12 ` [PATCH v2 2/5] sed-opal: add helper for adding user authorities in ACE Ondrej Kozina
2023-04-05 11:12 ` [PATCH v2 3/5] sed-opal: allow user authority to get locking range attributes Ondrej Kozina
2023-04-05 11:12 ` [PATCH v2 4/5] sed-opal: add helper to get multiple columns at once Ondrej Kozina
2023-04-05 11:12 ` [PATCH v2 5/5] sed-opal: Add command to read locking range parameters Ondrej Kozina
2023-04-05 13:46 ` [PATCH v2 0/5] sed-opal: add command to read locking range attributes Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZCxBcOBSfmf58Yxd@infradead.org \
--to=hch@infradead.org \
--cc=axboe@kernel.dk \
--cc=bluca@debian.org \
--cc=brauner@kernel.org \
--cc=gmazyland@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=okozina@redhat.com \
--cc=rafael.antognolli@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox