fs: common implementation of file type
RFC PATCH v3 1/10 fs: common implementation of file type
Many file systems use a copy&paste implementation
of dirent to on-disk file type conversions.
Create a common implementation to be used by file systems with some useful conversion helpers to reduce open coded file type conversions in file system code.
Signed-off-by Amir Goldstein <[email protected]>
Signed-off-by Phillip Potter <[email protected]>
--- MAINTAINERS | 1 + fs/Makefile | 3 +- fs/fs_types.c | 105 +++++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 17 +------ include/linux/fs_types.h | 73 +++++++++++++++++++++++++++ 5 files changed, 182 insertions(+), 17 deletions(-) create mode 100644 fs/fs_types.c create mode 100644 include/linux/fs_types.h
MAINTAINERS +1 -0
@@ -5711,6 +5711,7 @@ L: [email protected] S: Maintained F: fs/* F: include/linux/fs.h +F: include/linux/fs_types.h F: include/uapi/linux/fs.h FINTEK F75375S HARDWARE MONITOR AND FAN CONTROLLER DRIVER
fs/Makefile +2 -1
@@ -12,7 +12,8 @@ obj-y := open.o read_write.o file_table.o super.o \ attr.o bad_inode.o file.o filesystems.o namespace.o \ seq_file.o xattr.o libfs.o fs-writeback.o \ pnode.o splice.o sync.o utimes.o d_path.o \ - stack.o fs_struct.o statfs.o fs_pin.o nsfs.o + stack.o fs_struct.o statfs.o fs_pin.o nsfs.o \ + fs_types.o ifeq ($(CONFIG_BLOCK),y) obj-y += buffer.o block_dev.o direct-io.o mpage.o
fs/fs_types.c new file +105 -0
105 lines not on this page · raw message
include/linux/fs.h +1 -16
@@ -37,6 +37,7 @@#include <linux/uuid.h> #include <linux/errseq.h> #include <linux/ioprio.h> +#include <linux/fs_types.h> #include <asm/byteorder.h> #include <uapi/linux/fs.h>
@@ -1663,22 +1664,6 @@ int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, u64 phys, u64 len, u32 flags);int fiemap_check_flags (struct fiemap_extent_info *fieinfo,u32 fs_flags); -/* -* File types -* -* NOTE! These match bits 12..15 of stat.st_mode -* (ie "(i_mode >> 12) & 15"). -*/ -#define DT_UNKNOWN 0 -#define DT_FIFO 1 -#define DT_CHR 2 -#define DT_DIR 4 -#define DT_BLK 6 -#define DT_REG 8 -#define DT_LNK 10 -#define DT_SOCK 12 -#define DT_WHT 14 -/* * This is the "filldir" function type, used by readdir() to let * the kernel specify what kind of dirent layout it wants to have.
include/linux/fs_types.h new file +73 -0
73 lines not on this page · raw message
Signature · 1 line
2.17.2