Linux filesystem development
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christian Brauner <brauner@kernel.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] fat: add msdos_format_new_name()
Date: Sat, 05 Dec 2026 16:43:32 +0900	[thread overview]
Message-ID: <87a4mk2mvv.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <20261130-work-fat-tmpfile-v2-2-99af97d95683@kernel.org>

Christian Brauner <brauner@kernel.org> writes:

> msdos_create() and msdos_mkdir() both format the new name, figure out
> whether it's hidden and refuse it if it clashes with an existing entry
> because of foo vs. .foo. Move that into msdos_format_new_name(). The
> msdos O_TMPFILE support in the following patches uses it as well.
>
> No functional changes.
>
> Suggested-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>

Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

Thanks.

> ---
>  fs/fat/namei_msdos.c | 40 ++++++++++++++++++++++------------------
>  1 file changed, 22 insertions(+), 18 deletions(-)
>
> diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
> index 5a43d042eb01f..36e6a14f1b134 100644
> --- a/fs/fat/namei_msdos.c
> +++ b/fs/fat/namei_msdos.c
> @@ -262,6 +262,26 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
>  	return 0;
>  }
>  
> +/***** Formats the name of a new entry. Rejects foo vs. .foo clashes. */
> +static int msdos_format_new_name(struct inode *dir, struct dentry *dentry,
> +				 unsigned char *msdos_name, int *is_hid)
> +{
> +	struct fat_slot_info sinfo;
> +	int err;
> +
> +	err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
> +				msdos_name, &MSDOS_SB(dir->i_sb)->options);
> +	if (err)
> +		return err;
> +	*is_hid = (dentry->d_name.name[0] == '.') && (msdos_name[0] != '.');
> +	/* Have to do it due to foo vs. .foo conflicts */
> +	if (!fat_scan(dir, msdos_name, &sinfo)) {
> +		brelse(sinfo.bh);
> +		return -EINVAL;
> +	}
> +	return 0;
> +}
> +
>  /***** Create a file */
>  static int msdos_create(const struct mnt_idmap *idmap, struct inode *dir,
>  			struct dentry *dentry, umode_t mode)
> @@ -275,17 +295,9 @@ static int msdos_create(const struct mnt_idmap *idmap, struct inode *dir,
>  
>  	mutex_lock(&MSDOS_SB(sb)->s_lock);
>  
> -	err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
> -				msdos_name, &MSDOS_SB(sb)->options);
> +	err = msdos_format_new_name(dir, dentry, msdos_name, &is_hid);
>  	if (err)
>  		goto out;
> -	is_hid = (dentry->d_name.name[0] == '.') && (msdos_name[0] != '.');
> -	/* Have to do it due to foo vs. .foo conflicts */
> -	if (!fat_scan(dir, msdos_name, &sinfo)) {
> -		brelse(sinfo.bh);
> -		err = -EINVAL;
> -		goto out;
> -	}
>  
>  	ts = current_time(dir);
>  	err = msdos_add_entry(dir, msdos_name, 0, is_hid, 0, &ts, &sinfo);
> @@ -358,17 +370,9 @@ static struct dentry *msdos_mkdir(const struct mnt_idmap *idmap, struct inode *d
>  
>  	mutex_lock(&MSDOS_SB(sb)->s_lock);
>  
> -	err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
> -				msdos_name, &MSDOS_SB(sb)->options);
> +	err = msdos_format_new_name(dir, dentry, msdos_name, &is_hid);
>  	if (err)
>  		goto out;
> -	is_hid = (dentry->d_name.name[0] == '.') && (msdos_name[0] != '.');
> -	/* foo vs .foo situation */
> -	if (!fat_scan(dir, msdos_name, &sinfo)) {
> -		brelse(sinfo.bh);
> -		err = -EINVAL;
> -		goto out;
> -	}
>  
>  	ts = current_time(dir);
>  	cluster = fat_alloc_new_dir(dir, &ts);

-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

  reply	other threads:[~2026-12-05  7:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  8:57 [PATCH v2 0/6] fat: support O_TMPFILE Christian Brauner
2026-11-30  8:57 ` [PATCH v2 1/6] fat: add fat_new_inode() Christian Brauner
2026-12-05  7:43   ` OGAWA Hirofumi
2026-11-30  8:57 ` [PATCH v2 2/6] fat: add msdos_format_new_name() Christian Brauner
2026-12-05  7:43   ` OGAWA Hirofumi [this message]
2026-11-30  8:57 ` [PATCH v2 3/6] fat: add fat_tmpfile() Christian Brauner
2026-12-05  7:43   ` OGAWA Hirofumi
2026-11-30  8:57 ` [PATCH v2 4/6] fat: support O_TMPFILE on vfat Christian Brauner
2026-12-05  7:44   ` OGAWA Hirofumi
2026-11-30  8:57 ` [PATCH v2 5/6] fat: support O_TMPFILE on msdos Christian Brauner
2026-12-05  7:44   ` OGAWA Hirofumi
2026-11-30  8:57 ` [PATCH v2 6/6] selftests/filesystems: add FAT O_TMPFILE tests Christian Brauner
2026-12-05  7:44   ` OGAWA Hirofumi

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=87a4mk2mvv.fsf@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --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