[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260206115100.84852-1-adarshdas950@gmail.com>
Date: Fri, 6 Feb 2026 17:21:00 +0530
From: Adarsh Das <adarshdas950@...il.com>
To: dwmw2@...radead.org,
richard@....at
Cc: linux-mtd@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Adarsh Das <adarshdas950@...il.com>
Subject: [PATCH] jffs2: use fs_umode_to_dtype() for dirent type
Use fs_umode_to_dtype() instead of direct bit shifting when
setting directory entry type.
Signed-off-by: Adarsh Das <adarshdas950@...il.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;
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();
--
2.53.0
Powered by blists - more mailing lists