1 /* 2 * ioctl.h - f2fs ioctl header 3 * 4 * Authors: Jaegeuk Kim <jaegeuk@kernel.org> 5 */ 6 7 #include <sys/types.h> 8 #include <sys/ioctl.h> 9 10 #ifdef HAVE_LINUX_TYPES_H 11 #include <linux/types.h> 12 #endif 13 #include <sys/types.h> 14 15 #ifdef UNUSED 16 #elif defined(__GNUC__) 17 # define UNUSED(x) UNUSED_ ## x __attribute__((unused)) 18 #elif defined(__LCLINT__) 19 # define UNUSED(x) x 20 #elif defined(__cplusplus) 21 # define UNUSED(x) 22 #else 23 # define UNUSED(x) x 24 #endif 25 26 typedef u_int64_t u64; 27 typedef u_int32_t u32; 28 typedef u_int16_t u16; 29 typedef u_int8_t u8; 30 31 #ifndef HAVE_LINUX_TYPES_H 32 typedef u8 __u8; 33 typedef u16 __u16; 34 typedef u32 __u32; 35 typedef u16 __le16; 36 typedef u32 __le32; 37 typedef u16 __be16; 38 typedef u32 __be32; 39 #endif 40 41 #ifndef FS_IOC_GETFLAGS 42 #define FS_IOC_GETFLAGS _IOR('f', 1, long) 43 #endif 44 #ifndef FS_IOC_SETFLAGS 45 #define FS_IOC_SETFLAGS _IOW('f', 2, long) 46 #endif 47 48 #define F2FS_IOCTL_MAGIC 0xf5 49 #define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS 50 #define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS 51 52 #define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1) 53 #define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2) 54 #define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3) 55 #define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4) 56 #define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5) 57 #define F2FS_IOC_GARBAGE_COLLECT _IOW(F2FS_IOCTL_MAGIC, 6, __u32) 58 #define F2FS_IOC_WRITE_CHECKPOINT _IO(F2FS_IOCTL_MAGIC, 7) 59 #define F2FS_IOC_DEFRAGMENT _IOWR(F2FS_IOCTL_MAGIC, 8, \ 60 struct f2fs_defragment) 61 #define F2FS_IOC_MOVE_RANGE _IOWR(F2FS_IOCTL_MAGIC, 9, \ 62 struct f2fs_move_range) 63 #define F2FS_IOC_FLUSH_DEVICE _IOW(F2FS_IOCTL_MAGIC, 10, \ 64 struct f2fs_flush_device) 65 #define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \ 66 struct f2fs_gc_range) 67 #define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32) 68 #define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32) 69 #define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32) 70 #define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15) 71 #define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64) 72 #define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64) 73 #define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \ 74 _IOR(F2FS_IOCTL_MAGIC, 18, __u64) 75 #define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \ 76 _IOR(F2FS_IOCTL_MAGIC, 19, __u64) 77 78 #define F2FS_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY 79 #define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY 80 #define F2FS_IOC_GET_ENCRYPTION_PWSALT FS_IOC_GET_ENCRYPTION_PWSALT 81 82 #define FS_IOC_ENABLE_VERITY _IO('f', 133) 83 84 /* 85 * Inode flags 86 */ 87 #define F2FS_NOCOW_FL 0x00800000 /* Do not cow file */ 88 89 /* 90 * should be same as XFS_IOC_GOINGDOWN. 91 * Flags for going down operation used by FS_IOC_GOINGDOWN 92 */ 93 #define F2FS_IOC_SHUTDOWN _IOR('X', 125, __u32) /* Shutdown */ 94 #define F2FS_GOING_DOWN_FULLSYNC 0x0 /* going down with full sync */ 95 #define F2FS_GOING_DOWN_METASYNC 0x1 /* going down with metadata */ 96 #define F2FS_GOING_DOWN_NOSYNC 0x2 /* going down */ 97 #define F2FS_GOING_DOWN_METAFLUSH 0x3 /* going down with meta flush */ 98 #define F2FS_GOING_DOWN_NEED_FSCK 0x4 /* going down to trigger fsck */ 99 #define F2FS_GOING_DOWN_MAX 0x5 100 101 #if defined(__KERNEL__) && defined(CONFIG_COMPAT) 102 /* 103 * ioctl commands in 32 bit emulation 104 */ 105 #define F2FS_IOC32_GETFLAGS FS_IOC32_GETFLAGS 106 #define F2FS_IOC32_SETFLAGS FS_IOC32_SETFLAGS 107 #define F2FS_IOC32_GETVERSION FS_IOC32_GETVERSION 108 #endif 109 110 #define F2FS_IOC_FSGETXATTR FS_IOC_FSGETXATTR 111 #define F2FS_IOC_FSSETXATTR FS_IOC_FSSETXATTR 112 113 #ifndef FS_ENCRYPT_FL 114 #define FS_ENCRYPT_FL 0x00000800 /* Encrypted file */ 115 #endif 116 #ifndef FS_VERITY_FL 117 #define FS_VERITY_FL 0x00100000 /* Verity protected inode */ 118 #endif 119 #ifndef FS_INLINE_DATA_FL 120 #define FS_INLINE_DATA_FL 0x10000000 /* Inline data for regular/symlink files */ 121 #endif 122 #ifndef FS_NOCOW_FL 123 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */ 124 #endif 125 #ifndef FS_NOCOMP_FL 126 #define FS_NOCOMP_FL 0x00000400 /* Don't compress */ 127 #endif 128 #ifndef FS_COMPR_FL 129 #define FS_COMPR_FL 0x00000004 /* Compress file */ 130 #endif 131 #ifndef FS_CASEFOLD_FL 132 #define FS_CASEFOLD_FL 0x40000000 /* Folder is case insensitive */ 133 #endif 134 135 struct f2fs_gc_range { 136 u32 sync; 137 u64 start; 138 u64 len; 139 }; 140 141 struct f2fs_defragment { 142 u64 start; 143 u64 len; 144 }; 145 146 struct f2fs_move_range { 147 u32 dst_fd; /* destination fd */ 148 u64 pos_in; /* start position in src_fd */ 149 u64 pos_out; /* start position in dst_fd */ 150 u64 len; /* size to move */ 151 }; 152 153 struct f2fs_flush_device { 154 u32 dev_num; /* device number to flush */ 155 u32 segments; /* # of segments to flush */ 156 }; 157