lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20260121194128.61320-1-ytohnuki@amazon.com>
Date: Wed, 21 Jan 2026 19:41:28 +0000
From: Yuto Ohnuki <ytohnuki@...zon.com>
To: <linux-fsdevel@...r.kernel.org>
CC: <linux-kernel@...r.kernel.org>, Yuto Ohnuki <ytohnuki@...zon.com>
Subject: [PATCH] ufs: use fs_umode_to_dtype() for d_type table lookup

Replace the switch statement in ufs_set_de_type() with
fs_umode_to_dtype() as suggested by the TODO comment.

This improves maintainability by using the helper function. No
functional change intended.

Signed-off-by: Yuto Ohnuki <ytohnuki@...zon.com>
---
 fs/ufs/util.h | 30 ++----------------------------
 1 file changed, 2 insertions(+), 28 deletions(-)

diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index 391bb4f11d74..e03d768b982d 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -9,6 +9,7 @@
 
 #include <linux/buffer_head.h>
 #include <linux/fs.h>
+#include <linux/fs_dirent.h>
 #include "swab.h"
 
 /*
@@ -152,34 +153,7 @@ ufs_set_de_type(struct super_block *sb, struct ufs_dir_entry *de, int mode)
 	if ((UFS_SB(sb)->s_flags & UFS_DE_MASK) != UFS_DE_44BSD)
 		return;
 
-	/*
-	 * TODO turn this into a table lookup
-	 */
-	switch (mode & S_IFMT) {
-	case S_IFSOCK:
-		de->d_u.d_44.d_type = DT_SOCK;
-		break;
-	case S_IFLNK:
-		de->d_u.d_44.d_type = DT_LNK;
-		break;
-	case S_IFREG:
-		de->d_u.d_44.d_type = DT_REG;
-		break;
-	case S_IFBLK:
-		de->d_u.d_44.d_type = DT_BLK;
-		break;
-	case S_IFDIR:
-		de->d_u.d_44.d_type = DT_DIR;
-		break;
-	case S_IFCHR:
-		de->d_u.d_44.d_type = DT_CHR;
-		break;
-	case S_IFIFO:
-		de->d_u.d_44.d_type = DT_FIFO;
-		break;
-	default:
-		de->d_u.d_44.d_type = DT_UNKNOWN;
-	}
+	de->d_u.d_44.d_type = fs_umode_to_dtype(mode);
 }
 
 static inline u32
-- 
2.50.1




Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg, R.C.S. Luxembourg B186284

Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlington Road, Dublin 4, Ireland, branch registration number 908705




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ