5 #include <linux/ioctl.h>
7 #define BTRFS_SUPER_MAGIC 0x9123683E
8 #define BTRFS_SUPER_INFO_OFFSET (64 * 1024)
9 #define BTRFS_SUPER_INFO_SIZE 4096
10 #define BTRFS_MAGIC "_BHRfS_M"
11 #define BTRFS_MAGIC_L 8
12 #define BTRFS_CSUM_SIZE 32
13 #define BTRFS_FSID_SIZE 16
14 #define BTRFS_UUID_SIZE 16
23 #define BTRFS_ROOT_BACKREF_KEY 144
24 #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
25 #define BTRFS_DIR_ITEM_KEY 84
28 * * this is used for both forward and backward root refs
30 struct btrfs_root_ref
{
34 } __attribute__ ((__packed__
));
36 struct btrfs_disk_key
{
40 } __attribute__ ((__packed__
));
42 struct btrfs_dir_item
{
43 struct btrfs_disk_key location
;
48 } __attribute__ ((__packed__
));
50 struct btrfs_super_block
{
60 uint64_t log_root_transid
;
63 uint64_t root_dir_objectid
;
69 uint32_t sys_chunk_array_size
;
70 uint64_t chunk_root_generation
;
71 uint64_t compat_flags
;
72 uint64_t compat_ro_flags
;
73 uint64_t incompat_flags
;
76 uint8_t chunk_root_level
;
77 uint8_t log_root_level
;
78 struct btrfs_dev_item
{
87 uint64_t start_offset
;
93 } __attribute__ ((__packed__
)) dev_item
;
95 } __attribute__ ((__packed__
));
97 #define BTRFS_IOCTL_MAGIC 0x94
98 #define BTRFS_VOL_NAME_MAX 255
99 #define BTRFS_PATH_NAME_MAX 4087
101 struct btrfs_ioctl_vol_args
{
103 char name
[BTRFS_PATH_NAME_MAX
+ 1];
106 struct btrfs_ioctl_search_key
{
107 /* which root are we searching. 0 is the tree of tree roots */
110 /* keys returned will be >= min and <= max */
114 /* keys returned will be >= min and <= max */
118 /* max and min transids to search for */
122 /* keys returned will be >= min and <= max */
127 * how many items did userland ask for, and how many are we
132 /* align to 64 bits */
135 /* some extra for later */
142 struct btrfs_ioctl_search_header
{
148 } __attribute__((may_alias
));
150 #define BTRFS_DEVICE_PATH_NAME_MAX 1024
151 struct btrfs_ioctl_dev_info_args
{
152 __u64 devid
; /* in/out */
153 __u8 uuid
[BTRFS_UUID_SIZE
]; /* in/out */
154 __u64 bytes_used
; /* out */
155 __u64 total_bytes
; /* out */
156 __u64 unused
[379]; /* pad to 4k */
157 __u8 path
[BTRFS_DEVICE_PATH_NAME_MAX
]; /* out */
160 struct btrfs_ioctl_fs_info_args
{
161 __u64 max_id
; /* out */
162 __u64 num_devices
; /* out */
163 __u8 fsid
[BTRFS_FSID_SIZE
]; /* out */
164 __u64 reserved
[124]; /* pad to 1k */
167 #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
169 * the buf is an array of search headers where
170 * each header is followed by the actual item
171 * the type field is expanded to 32 bits for alignment
173 struct btrfs_ioctl_search_args
{
174 struct btrfs_ioctl_search_key key
;
175 char buf
[BTRFS_SEARCH_ARGS_BUFSIZE
];
178 #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
179 struct btrfs_ioctl_search_args)
180 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
181 struct btrfs_ioctl_dev_info_args)
182 #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
183 struct btrfs_ioctl_fs_info_args)