Re: [PATCH v4 2/2] fs: fat: add ioctl method in fat filesystem driver

From: OGAWA Hirofumi
Date: Tue Dec 26 2017 - 11:17:07 EST


ChenGuanqiao <chen.chenchacha@xxxxxxxxxxx> writes:

> +static int fat_check_volume_label(const char *label)
> +{
> + int i;
> +
> + for (i=0; i<11; ++i) {
> + if (islower(label[i]))
> + return -EINVAL;
> + }
> + return 0;
> +}

What happen if '\0' is included, or invalid chars as FAT filename?

> +static int fat_ioctl_get_volume_label(struct inode *inode,
> + u8 __user *vol_label)
> +{
> + int err = 0;
> + struct buffer_head *bh;
> + struct msdos_dir_entry *de;
> + struct super_block *sb = inode->i_sb;
> + struct msdos_sb_info *sbi = MSDOS_SB(sb);
> +
> + if (sbi->fat_bits == 32)
> + bh = sb_bread(sb, sbi->data_start);
> + else
> + bh = sb_bread(sb, sbi->dir_start);
> +
> + if (bh == NULL) {
> + fat_msg(sb, KERN_ERR, "unable to read root directory");
> + err = -EIO;
> + goto out;
> + }
> +
> + de = (struct msdos_dir_entry *)bh->b_data;

The volume label is not fixed place in root dir. You have to find
ATTR_VOLUME, but not ATTR_EXT.

Thanks.
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>