Re: [PATCH RFC] Add FAT_IOCTL_GET_VOLUME_ID
From: OGAWA Hirofumi
Date: Mon Jul 01 2013 - 08:01:07 EST
bintian.wang@xxxxxxxxxx writes:
>
From: Mike Lockwood <lockwood@xxxxxxxxxxx>
>
>
Adds vfat ioctl command FAT_IOCTL_GET_VOLUME_ID, with this command
>
we can get the vfat volume ID using following code:
>
>
ioctl(fd, FAT_IOCTL_GET_VOLUME_ID, &volume_ID)
>
>
This patch is a modified version of the android kernel patch by Mike Lockwood,
>
the original patch makes the return value of ioctl() as the volume ID,
>
Dmitry Pervushin noticed some volume IDs abiguous with error returns:
>
for example, if volume id is set to "0xFFFFFDAD", that matches -ENOIOCTLCMD,
>
we get a wrong volume ID "0xFFFFFFFF" from the user space.
>
>
This patch fixes above bug by adding a parameter to ioctl to get the correct
>
volume ID.
Personally, I have no objection to do this small one in kernel
though. Please add use case of android to changelog, it would help to
understand.
>
+static unsigned int fat_ioctl_volume_id(struct inode *inode)
>
+{
>
+ struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
>
+ return sbi->vol_id;
>
+}
>
+
>
long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>
{
>
struct inode *inode = file_inode(filp);
>
@@ -124,6 +130,8 @@ long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>
return fat_ioctl_get_attributes(inode, user_attr);
>
case FAT_IOCTL_SET_ATTRIBUTES:
>
return fat_ioctl_set_attributes(filp, user_attr);
>
+ case FAT_IOCTL_GET_VOLUME_ID:
>
+ return put_user(fat_ioctl_volume_id(inode), user_attr);
>
default:
>
return -ENOTTY; /* Inappropriate ioctl for device */
>
}
Please push put_user() down into fat_ioctl_volume_id() like others. So,
generic_ioctl() itself can forget about the detail of each ioctl.
Thanks.
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/