ufs: use fs_umode_to_dtype() helper
RFC PATCH v4 2/9 ufs: use fs_umode_to_dtype() helper
Replace switch statement with common lookup table implementation - file systems that use the same file types as defined by POSIX do not need to define their own versions and can use the common helper functions decared in fs_types.h and implemented in fs_types.c
Signed-off-by Amir Goldstein <[email protected]>
Signed-off-by Phillip Potter <[email protected]>
--- fs/ufs/util.h | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-)
fs/ufs/util.h +1 -28
@@ -158,34 +158,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.19.1
Quoted 10 lines · Phillip Potter
Replace switch statement with common lookup table implementation - file systems that use the same file types as defined by POSIX do not need to define their own versions and can use the common helper functions decared in
fs_types.hand implemented infs_types.cSigned-off-by Amir Goldstein <[email protected]>Signed-off-by Phillip Potter <[email protected]>--- fs/ufs/util.h | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-)
Looks good. You can add:
Reviewed-by Jan Kara <[email protected]>
Honza
Quoted 44 lines
fs/ufs/util.h +1
-28@@ -158,34 +158,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 u32Signature · 1 line
2.19.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR