From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Adarsh Das <adarshdas950@gmail.com>, <dwmw2@infradead.org>,
<richard@nod.at>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] jffs2: use fs_umode_to_dtype() for dirent type
Date: Sat, 7 Feb 2026 10:36:29 +0800 [thread overview]
Message-ID: <134dec36-3bcf-89a4-2817-a880afa4280f@huawei.com> (raw)
In-Reply-To: <20260206115100.84852-1-adarshdas950@gmail.com>
在 2026/2/6 19:51, Adarsh Das 写道:
> Use fs_umode_to_dtype() instead of direct bit shifting when
> setting directory entry type.
>
> Signed-off-by: Adarsh Das <adarshdas950@gmail.com>
> ---
> fs/jffs2/dir.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
> index dd91f725ded6..185cf76a061e 100644
> --- a/fs/jffs2/dir.c
> +++ b/fs/jffs2/dir.c
> @@ -261,8 +261,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de
> if (d_is_dir(old_dentry))
> return -EPERM;
>
> - /* XXX: This is ugly */
> - type = (d_inode(old_dentry)->i_mode & S_IFMT) >> 12;
> + type = fs_umode_to_dtype(d_inode(old_dentry)->i_mode);
> if (!type) type = DT_REG;
Hi Adarsh,
The convertion result is wrong for jffs2_do_link.
The i_mode of old_dentry is 'S_IFIFO', the jffs2 gets type DT_FIFO(1)
and pass it to 'rd->type' by jffs2_do_link. However, after the patch
applied, jffs2 gets type FT_FIFO(5), which will confuse other 'rd->type'
accessing processes(eg. jffs2_scan_dirent_node[rd->type],
jffs2_build_filesystem[fd->type]).
>
> now = JFFS2_NOW();
> @@ -730,10 +729,7 @@ static int jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i,
> rd->ino = cpu_to_je32(inode->i_ino);
> rd->mctime = cpu_to_je32(JFFS2_NOW());
> rd->nsize = namelen;
> -
> - /* XXX: This is ugly. */
> - rd->type = (mode & S_IFMT) >> 12;
> -
> + rd->type = fs_umode_to_dtype(mode);
> rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
> rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));
>
> @@ -811,8 +807,7 @@ static int jffs2_rename (struct mnt_idmap *idmap,
>
> /* Make a hard link */
>
> - /* XXX: This is ugly */
> - type = (d_inode(old_dentry)->i_mode & S_IFMT) >> 12;
> + type = fs_umode_to_dtype(d_inode(old_dentry)->i_mode);
> if (!type) type = DT_REG;
>
> now = JFFS2_NOW();
>
next prev parent reply other threads:[~2026-02-07 2:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 11:51 [PATCH] jffs2: use fs_umode_to_dtype() for dirent type Adarsh Das
2026-02-07 2:36 ` Zhihao Cheng [this message]
2026-02-07 7:39 ` Adarsh Das
2026-02-07 7:59 ` Zhihao Cheng
2026-02-07 8:00 ` Zhihao Cheng
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=134dec36-3bcf-89a4-2817-a880afa4280f@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=adarshdas950@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/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