Skip to contentSkip to conversation

ufs: use fs_umode_to_dtype() for d_type table lookup

PATCH New Yuto Ohnuki 1 participant 1 message Jan 21 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/ufs/util.h | 30 ++----------------------------
 1 file changed, 2 insertions(+), 28 deletions(-)
fs/ufs/util.h +2 -28
index 391bb4f11d74..e03d768b982d 100644
@@ -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
Signature · 8 lines
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