[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <50090c2e-d882-507f-43a7-5ed76c36390c@acm.org>
Date: Mon, 20 Apr 2020 06:34:24 -0700
From: Bart Van Assche <bvanassche@....org>
To: Martijn Coenen <maco@...roid.com>, axboe@...nel.dk, hch@....de,
ming.lei@...hat.com
Cc: narayan@...gle.com, zezeozue@...gle.com, kernel-team@...roid.com,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
maco@...gle.com, Chaitanya.Kulkarni@....com
Subject: Re: [PATCH 2/4] loop: Factor out configuring loop from status.
On 4/20/20 1:04 AM, Martijn Coenen wrote:
No trailing dot at the end of a patch subject please.
> static int
> -loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
> +loop_set_from_status(struct loop_device *lo, const struct loop_info64 *info)
> {
> int err;
> struct loop_func_table *xfer;
> kuid_t uid = current_uid();
> +
> + if ((unsigned int) info->lo_encrypt_key_size > LO_KEY_SIZE)
> + return -EINVAL;
> +
> + err = loop_release_xfer(lo);
> + if (err)
> + return err;
> +
> + if (info->lo_encrypt_type) {
> + unsigned int type = info->lo_encrypt_type;
> +
> + if (type >= MAX_LO_CRYPT)
> + return -EINVAL;
> + xfer = xfer_funcs[type];
> + if (xfer == NULL)
> + return -EINVAL;
> + } else
> + xfer = NULL;
> +
> + err = loop_init_xfer(lo, xfer, info);
> + if (err)
> + return err;
> +
> + lo->lo_offset = info->lo_offset;
> + lo->lo_sizelimit = info->lo_sizelimit;
> + memcpy(lo->lo_file_name, info->lo_file_name, LO_NAME_SIZE);
> + memcpy(lo->lo_crypt_name, info->lo_crypt_name, LO_NAME_SIZE);
> + lo->lo_file_name[LO_NAME_SIZE-1] = 0;
> + lo->lo_crypt_name[LO_NAME_SIZE-1] = 0;
> +
> + if (!xfer)
> + xfer = &none_funcs;
> + lo->transfer = xfer->transfer;
> + lo->ioctl = xfer->ioctl;
> +
> + if ((lo->lo_flags & LO_FLAGS_AUTOCLEAR) !=
> + (info->lo_flags & LO_FLAGS_AUTOCLEAR))
> + lo->lo_flags ^= LO_FLAGS_AUTOCLEAR;
> +
> + lo->lo_encrypt_key_size = info->lo_encrypt_key_size;
> + lo->lo_init[0] = info->lo_init[0];
> + lo->lo_init[1] = info->lo_init[1];
> + if (info->lo_encrypt_key_size) {
> + memcpy(lo->lo_encrypt_key, info->lo_encrypt_key,
> + info->lo_encrypt_key_size);
> + lo->lo_key_owner = uid;
> + }
> +
> + return 0;
> +}
Please add a (one line?) comment above this function that explains the
purpose of this function. Is the purpose of this function perhaps to
initialize loop device parameters based on the information received from
user space (the 'info' argument)?
Thanks,
Bart.
Powered by blists - more mailing lists