Pull dtype handling cleanups from Jan Kara: "A reworked dtype cleanup patches based on your feedback to the previous version of these. Again the series includes only the generic code and ext2 cleanup as a sample. The plan is to push cleanups for other filesystems separately through respective trees once the generic code lands to reduce the number of conflicts" * tag 'dtype_for_v5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: ext2: use common file type conversion fs: common implementation of file type
Showing the changes to include/linux (2 of 7 files). Show all
Unified · Split
| @@ -37,6 +37,7 @@ · 36 unmodified lines | |||
| 37 | #include <linux/uuid.h> | 37 | #include <linux/uuid.h> |
| 38 | #include <linux/errseq.h> | 38 | #include <linux/errseq.h> |
| 39 | #include <linux/ioprio.h> | 39 | #include <linux/ioprio.h> |
| 40 | #include <linux/fs_types.h> | ||
| 40 | 41 | ||
| 41 | #include <asm/byteorder.h> | 42 | #include <asm/byteorder.h> |
| 42 | #include <uapi/linux/fs.h> | 43 | #include <uapi/linux/fs.h> |
| @@ -1706,22 +1707,6 @@ int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, · 1663 unmodified lines | |||
| 1706 | u64 phys, u64 len, u32 flags); | 1707 | u64 phys, u64 len, u32 flags); |
| 1707 | int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags); | 1708 | int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags); |
| 1708 | 1709 | ||
| 1709 | /* | ||
| 1710 | * File types | ||
| 1711 | * | ||
| 1712 | * NOTE! These match bits 12..15 of stat.st_mode | ||
| 1713 | * (ie "(i_mode >> 12) & 15"). | ||
| 1714 | */ | ||
| 1715 | #define DT_UNKNOWN 0 | ||
| 1716 | #define DT_FIFO 1 | ||
| 1717 | #define DT_CHR 2 | ||
| 1718 | #define DT_DIR 4 | ||
| 1719 | #define DT_BLK 6 | ||
| 1720 | #define DT_REG 8 | ||
| 1721 | #define DT_LNK 10 | ||
| 1722 | #define DT_SOCK 12 | ||
| 1723 | #define DT_WHT 14 | ||
| 1724 | |||
| 1725 | /* | 1710 | /* |
| 1726 | * This is the "filldir" function type, used by readdir() to let | 1711 | * This is the "filldir" function type, used by readdir() to let |
| 1727 | * the kernel specify what kind of dirent layout it wants to have. | 1712 | * the kernel specify what kind of dirent layout it wants to have. |
| @@ -0,0 +1,75 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | #ifndef _LINUX_FS_TYPES_H | ||
| 3 | #define _LINUX_FS_TYPES_H | ||
| 4 | |||
| 5 | /* | ||
| 6 | * This is a header for the common implementation of dirent | ||
| 7 | * to fs on-disk file type conversion. Although the fs on-disk | ||
| 8 | * bits are specific to every file system, in practice, many | ||
| 9 | * file systems use the exact same on-disk format to describe | ||
| 10 | * the lower 3 file type bits that represent the 7 POSIX file | ||
| 11 | * types. | ||
| 12 | * | ||
| 13 | * It is important to note that the definitions in this | ||
| 14 | * header MUST NOT change. This would break both the | ||
| 15 | * userspace ABI and the on-disk format of filesystems | ||
| 16 | * using this code. | ||
| 17 | * | ||
| 18 | * All those file systems can use this generic code for the | ||
| 19 | * conversions. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * struct dirent file types | ||
| 24 | * exposed to user via getdents(2), readdir(3) | ||
| 25 | * | ||
| 26 | * These match bits 12..15 of stat.st_mode | ||
| 27 | * (ie "(i_mode >> 12) & 15"). | ||
| 28 | */ | ||
| 29 | #define S_DT_SHIFT 12 | ||
| 30 | #define S_DT(mode) (((mode) & S_IFMT) >> S_DT_SHIFT) | ||
| 31 | #define S_DT_MASK (S_IFMT >> S_DT_SHIFT) | ||
| 32 | |||
| 33 | /* these are defined by POSIX and also present in glibc's dirent.h */ | ||
| 34 | #define DT_UNKNOWN 0 | ||
| 35 | #define DT_FIFO 1 | ||
| 36 | #define DT_CHR 2 | ||
| 37 | #define DT_DIR 4 | ||
| 38 | #define DT_BLK 6 | ||
| 39 | #define DT_REG 8 | ||
| 40 | #define DT_LNK 10 | ||
| 41 | #define DT_SOCK 12 | ||
| 42 | #define DT_WHT 14 | ||
| 43 | |||
| 44 | #define DT_MAX (S_DT_MASK + 1) /* 16 */ | ||
| 45 | |||
| 46 | /* | ||
| 47 | * fs on-disk file types. | ||
| 48 | * Only the low 3 bits are used for the POSIX file types. | ||
| 49 | * Other bits are reserved for fs private use. | ||
| 50 | * These definitions are shared and used by multiple filesystems, | ||
| 51 | * and MUST NOT change under any circumstances. | ||
| 52 | * | ||
| 53 | * Note that no fs currently stores the whiteout type on-disk, | ||
| 54 | * so whiteout dirents are exposed to user as DT_CHR. | ||
| 55 | */ | ||
| 56 | #define FT_UNKNOWN 0 | ||
| 57 | #define FT_REG_FILE 1 | ||
| 58 | #define FT_DIR 2 | ||
| 59 | #define FT_CHRDEV 3 | ||
| 60 | #define FT_BLKDEV 4 | ||
| 61 | #define FT_FIFO 5 | ||
| 62 | #define FT_SOCK 6 | ||
| 63 | #define FT_SYMLINK 7 | ||
| 64 | |||
| 65 | #define FT_MAX 8 | ||
| 66 | |||
| 67 | /* | ||
| 68 | * declarations for helper functions, accompanying implementation | ||
| 69 | * is in fs/fs_types.c | ||
| 70 | */ | ||
| 71 | extern unsigned char fs_ftype_to_dtype(unsigned int filetype); | ||
| 72 | extern unsigned char fs_umode_to_ftype(umode_t mode); | ||
| 73 | extern unsigned char fs_umode_to_dtype(umode_t mode); | ||
| 74 | |||
| 75 | #endif | ||