Re: [PATCH] loop: Add LOOP_SET_FD_WITH_OFFSET ioctl.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-03-29 07:04, Martijn Coenen wrote:
> -static int loop_set_fd(struct loop_device *lo, fmode_t mode,
> -		       struct block_device *bdev, unsigned int arg)
> +static int loop_set_fd_with_offset(struct loop_device *lo, fmode_t mode,
> +		struct block_device *bdev, unsigned int arg, loff_t offset)

Since this function has to be modified, please add an additional patch
to rename 'arg' into 'fd'. Additionally, how about renaming
"loop_set_fd_with_offset" into "loop_set_fd_and_offset"? I think the
latter name reflects more clearly the purpose of this function.

> @@ -1624,6 +1625,17 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
>  		break;
>  	case LOOP_GET_STATUS64:
>  		return loop_get_status64(lo, (struct loop_info64 __user *) arg);
> +	case LOOP_SET_FD_WITH_OFFSET: {
> +		struct loop_fd_with_offset fdwo;
> +
> +		if (copy_from_user(&fdwo,
> +				(struct loop_fd_with_offset __user *) arg,
> +				sizeof(struct loop_fd_with_offset)))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The kernel code that I'm familiar with uses sizeof(<variable name>)
instead of sizeof(<struct name>). That makes it less likely that
changing the type of the variable will introduce a mismatch between the
sizeof() expression and the size of the variable.

Thanks,

Bart.



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux