Skip to contentSkip to conversation

ufs: replace d_type switch with fs_umode_to_dtype()

PATCH New Adarsh Das 1 participant 1 message Feb 7

lore
Share & tools
lore

Adarsh Das

author
#0 lore raw

PATCH 1/1 ufs: replace d_type switch with fs_umode_to_dtype()

ufs_set_de_type() was setting d_type via a switch over S_IFMT. Replace this with fs_umode_to_dtype(), which provides the same mapping and is the standard VFS helper for this purpose.

This also resolves the existing TODO comment.

---
 fs/ufs/util.h | 29 +----------------------------
 1 file changed, 1 insertion(+), 28 deletions(-)
fs/ufs/util.h +1 -28
index 391bb4f11d74..055b4543ad2a 100644
@@ -152,34 +152,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 · 1 line
2.53.0