* [RFC][PATCH v4 02/09] ufs: use fs_umode_to_dtype() helper
@ 2018-11-21 19:06 Phillip Potter
2018-11-22 11:41 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Phillip Potter @ 2018-11-21 19:06 UTC (permalink / raw)
To: dushistov; +Cc: amir73il, viro, linux-fsdevel
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 <amir73il@gmail.com>
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
fs/ufs/util.h | 29 +----------------------------
1 file changed, 1 insertion(+), 28 deletions(-)
diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index 1fd3011ea623..8c7759860739 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -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
--
2.19.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [RFC][PATCH v4 02/09] ufs: use fs_umode_to_dtype() helper
2018-11-21 19:06 [RFC][PATCH v4 02/09] ufs: use fs_umode_to_dtype() helper Phillip Potter
@ 2018-11-22 11:41 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2018-11-22 11:41 UTC (permalink / raw)
To: Phillip Potter; +Cc: dushistov, amir73il, viro, linux-fsdevel
On Wed 21-11-18 19:06:50, Phillip Potter wrote:
> 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 <amir73il@gmail.com>
> Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
> ---
> fs/ufs/util.h | 29 +----------------------------
> 1 file changed, 1 insertion(+), 28 deletions(-)
Looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
>
> diff --git a/fs/ufs/util.h b/fs/ufs/util.h
> index 1fd3011ea623..8c7759860739 100644
> --- a/fs/ufs/util.h
> +++ b/fs/ufs/util.h
> @@ -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
> --
> 2.19.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-22 22:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-21 19:06 [RFC][PATCH v4 02/09] ufs: use fs_umode_to_dtype() helper Phillip Potter
2018-11-22 11:41 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).