diff options
author | Jeff Layton <jlayton@kernel.org> | 2023-03-30 06:41:43 -0400 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2023-04-03 09:23:54 +0200 |
commit | 364595a6851bf64e1c38224ae68f5dd6651906d1 (patch) | |
tree | 65fa876608fb79e96d9928685bffba7a6e172856 /fs/configfs | |
parent | 4f704d9a8352f5c0a8fcdb6213b934630342bd44 (diff) | |
download | lwn-364595a6851bf64e1c38224ae68f5dd6651906d1.tar.gz lwn-364595a6851bf64e1c38224ae68f5dd6651906d1.zip |
fs: consolidate duplicate dt_type helpers
There are three copies of the same dt_type helper sprinkled around the
tree. Convert them to use the common fs_umode_to_dtype function instead,
which has the added advantage of properly returning DT_UNKNOWN when
given a mode that contains an unrecognized type.
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: Phillip Potter <phil@philpotter.co.uk>
Suggested-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Message-Id: <20230330104144.75547-1-jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/configfs')
-rw-r--r-- | fs/configfs/dir.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 4afcbbe63e68..18677cd4e62f 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -1599,12 +1599,6 @@ static int configfs_dir_close(struct inode *inode, struct file *file) return 0; } -/* Relationship between s_mode and the DT_xxx types */ -static inline unsigned char dt_type(struct configfs_dirent *sd) -{ - return (sd->s_mode >> 12) & 15; -} - static int configfs_readdir(struct file *file, struct dir_context *ctx) { struct dentry *dentry = file->f_path.dentry; @@ -1654,7 +1648,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx) name = configfs_get_name(next); len = strlen(name); - if (!dir_emit(ctx, name, len, ino, dt_type(next))) + if (!dir_emit(ctx, name, len, ino, + fs_umode_to_dtype(next->s_mode))) return 0; spin_lock(&configfs_dirent_lock); |