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