![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 #ifndef _LINUX_FS_TYPES_H 0003 #define _LINUX_FS_TYPES_H 0004 0005 /* 0006 * This is a header for the common implementation of dirent 0007 * to fs on-disk file type conversion. Although the fs on-disk 0008 * bits are specific to every file system, in practice, many 0009 * file systems use the exact same on-disk format to describe 0010 * the lower 3 file type bits that represent the 7 POSIX file 0011 * types. 0012 * 0013 * It is important to note that the definitions in this 0014 * header MUST NOT change. This would break both the 0015 * userspace ABI and the on-disk format of filesystems 0016 * using this code. 0017 * 0018 * All those file systems can use this generic code for the 0019 * conversions. 0020 */ 0021 0022 /* 0023 * struct dirent file types 0024 * exposed to user via getdents(2), readdir(3) 0025 * 0026 * These match bits 12..15 of stat.st_mode 0027 * (ie "(i_mode >> 12) & 15"). 0028 */ 0029 #define S_DT_SHIFT 12 0030 #define S_DT(mode) (((mode) & S_IFMT) >> S_DT_SHIFT) 0031 #define S_DT_MASK (S_IFMT >> S_DT_SHIFT) 0032 0033 /* these are defined by POSIX and also present in glibc's dirent.h */ 0034 #define DT_UNKNOWN 0 0035 #define DT_FIFO 1 0036 #define DT_CHR 2 0037 #define DT_DIR 4 0038 #define DT_BLK 6 0039 #define DT_REG 8 0040 #define DT_LNK 10 0041 #define DT_SOCK 12 0042 #define DT_WHT 14 0043 0044 #define DT_MAX (S_DT_MASK + 1) /* 16 */ 0045 0046 /* 0047 * fs on-disk file types. 0048 * Only the low 3 bits are used for the POSIX file types. 0049 * Other bits are reserved for fs private use. 0050 * These definitions are shared and used by multiple filesystems, 0051 * and MUST NOT change under any circumstances. 0052 * 0053 * Note that no fs currently stores the whiteout type on-disk, 0054 * so whiteout dirents are exposed to user as DT_CHR. 0055 */ 0056 #define FT_UNKNOWN 0 0057 #define FT_REG_FILE 1 0058 #define FT_DIR 2 0059 #define FT_CHRDEV 3 0060 #define FT_BLKDEV 4 0061 #define FT_FIFO 5 0062 #define FT_SOCK 6 0063 #define FT_SYMLINK 7 0064 0065 #define FT_MAX 8 0066 0067 /* 0068 * declarations for helper functions, accompanying implementation 0069 * is in fs/fs_types.c 0070 */ 0071 extern unsigned char fs_ftype_to_dtype(unsigned int filetype); 0072 extern unsigned char fs_umode_to_ftype(umode_t mode); 0073 extern unsigned char fs_umode_to_dtype(umode_t mode); 0074 0075 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |