public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: ChenGuanqiao <chen.chenchacha@foxmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] fs: fat: add ioctl method in fat filesystem driver
Date: Wed, 27 Dec 2017 01:16:57 +0900	[thread overview]
Message-ID: <87po71wjk6.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <20171225112020.2267-3-chen.chenchacha@foxmail.com> (ChenGuanqiao's message of "Mon, 25 Dec 2017 19:20:20 +0800")

ChenGuanqiao <chen.chenchacha@foxmail.com> 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@mail.parknet.co.jp>

      reply	other threads:[~2017-12-26 16:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-25 11:20 [PATCH v4 0/2] fs: fat: add ioctl to modify fat filesystem partion volume label ChenGuanqiao
2017-12-25 11:20 ` [PATCH v4 1/2] fs: fat: Add fat filesystem partition volume label in local structure ChenGuanqiao
2017-12-25 11:20 ` [PATCH v4 2/2] fs: fat: add ioctl method in fat filesystem driver ChenGuanqiao
2017-12-26 16:16   ` OGAWA Hirofumi [this message]

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=87po71wjk6.fsf@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=chen.chenchacha@foxmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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