• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
45 #define F2FS_IOCTL_MAGIC		0xf5
46 #define F2FS_IOC_GETFLAGS		FS_IOC_GETFLAGS
47 
48 #define F2FS_IOC_START_ATOMIC_WRITE	_IO(F2FS_IOCTL_MAGIC, 1)
49 #define F2FS_IOC_COMMIT_ATOMIC_WRITE	_IO(F2FS_IOCTL_MAGIC, 2)
50 #define F2FS_IOC_START_VOLATILE_WRITE	_IO(F2FS_IOCTL_MAGIC, 3)
51 #define F2FS_IOC_RELEASE_VOLATILE_WRITE	_IO(F2FS_IOCTL_MAGIC, 4)
52 #define F2FS_IOC_ABORT_VOLATILE_WRITE	_IO(F2FS_IOCTL_MAGIC, 5)
53 #define F2FS_IOC_GARBAGE_COLLECT	_IOW(F2FS_IOCTL_MAGIC, 6, __u32)
54 #define F2FS_IOC_WRITE_CHECKPOINT	_IO(F2FS_IOCTL_MAGIC, 7)
55 #define F2FS_IOC_DEFRAGMENT		_IOWR(F2FS_IOCTL_MAGIC, 8,	\
56 						struct f2fs_defragment)
57 #define F2FS_IOC_MOVE_RANGE		_IOWR(F2FS_IOCTL_MAGIC, 9,	\
58 						struct f2fs_move_range)
59 #define F2FS_IOC_FLUSH_DEVICE		_IOW(F2FS_IOCTL_MAGIC, 10,	\
60 						struct f2fs_flush_device)
61 #define F2FS_IOC_GARBAGE_COLLECT_RANGE	_IOW(F2FS_IOCTL_MAGIC, 11,	\
62 						struct f2fs_gc_range)
63 #define F2FS_IOC_GET_FEATURES		_IOR(F2FS_IOCTL_MAGIC, 12, __u32)
64 #define F2FS_IOC_SET_PIN_FILE		_IOW(F2FS_IOCTL_MAGIC, 13, __u32)
65 #define F2FS_IOC_GET_PIN_FILE		_IOR(F2FS_IOCTL_MAGIC, 14, __u32)
66 #define F2FS_IOC_PRECACHE_EXTENTS	_IO(F2FS_IOCTL_MAGIC, 15)
67 
68 #define F2FS_IOC_SET_ENCRYPTION_POLICY	FS_IOC_SET_ENCRYPTION_POLICY
69 #define F2FS_IOC_GET_ENCRYPTION_POLICY	FS_IOC_GET_ENCRYPTION_POLICY
70 #define F2FS_IOC_GET_ENCRYPTION_PWSALT	FS_IOC_GET_ENCRYPTION_PWSALT
71 
72 /*
73  * Inode flags
74  */
75 #define F2FS_NOCOW_FL			0x00800000 /* Do not cow file */
76 
77 /*
78  * should be same as XFS_IOC_GOINGDOWN.
79  * Flags for going down operation used by FS_IOC_GOINGDOWN
80  */
81 #define F2FS_IOC_SHUTDOWN	_IOR('X', 125, __u32)	/* Shutdown */
82 #define F2FS_GOING_DOWN_FULLSYNC	0x0	/* going down with full sync */
83 #define F2FS_GOING_DOWN_METASYNC	0x1	/* going down with metadata */
84 #define F2FS_GOING_DOWN_NOSYNC		0x2	/* going down */
85 #define F2FS_GOING_DOWN_METAFLUSH	0x3	/* going down with meta flush */
86 #define F2FS_GOING_DOWN_NEED_FSCK	0x4	/* going down to trigger fsck */
87 #define F2FS_GOING_DOWN_MAX		0x5
88 
89 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
90 /*
91  * ioctl commands in 32 bit emulation
92  */
93 #define F2FS_IOC32_GETFLAGS		FS_IOC32_GETFLAGS
94 #define F2FS_IOC32_SETFLAGS		FS_IOC32_SETFLAGS
95 #define F2FS_IOC32_GETVERSION		FS_IOC32_GETVERSION
96 #endif
97 
98 #define F2FS_IOC_FSGETXATTR		FS_IOC_FSGETXATTR
99 #define F2FS_IOC_FSSETXATTR		FS_IOC_FSSETXATTR
100 
101 struct f2fs_gc_range {
102 	u32 sync;
103 	u64 start;
104 	u64 len;
105 };
106 
107 struct f2fs_defragment {
108 	u64 start;
109 	u64 len;
110 };
111 
112 struct f2fs_move_range {
113 	u32 dst_fd;		/* destination fd */
114 	u64 pos_in;		/* start position in src_fd */
115 	u64 pos_out;		/* start position in dst_fd */
116 	u64 len;		/* size to move */
117 };
118 
119 struct f2fs_flush_device {
120 	u32 dev_num;		/* device number to flush */
121 	u32 segments;		/* # of segments to flush */
122 };
123