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
16 /* Fixed areas reserved for the boot loader */
17 #define BTRFS_BOOT_AREA_A_OFFSET 0
18 #define BTRFS_BOOT_AREA_A_SIZE BTRFS_SUPER_INFO_OFFSET
19 #define BTRFS_BOOT_AREA_B_OFFSET (256 * 1024)
20 #define BTRFS_BOOT_AREA_B_SIZE ((1024-256) * 1024)
29 #define BTRFS_ROOT_BACKREF_KEY 144
30 #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
31 #define BTRFS_DIR_ITEM_KEY 84
34 * * this is used for both forward and backward root refs
36 struct btrfs_root_ref
{
40 } __attribute__ ((__packed__
));
42 struct btrfs_disk_key
{
46 } __attribute__ ((__packed__
));
48 struct btrfs_dir_item
{
49 struct btrfs_disk_key location
;
54 } __attribute__ ((__packed__
));
56 struct btrfs_super_block
{
66 uint64_t log_root_transid
;
69 uint64_t root_dir_objectid
;
75 uint32_t sys_chunk_array_size
;
76 uint64_t chunk_root_generation
;
77 uint64_t compat_flags
;
78 uint64_t compat_ro_flags
;
79 uint64_t incompat_flags
;
82 uint8_t chunk_root_level
;
83 uint8_t log_root_level
;
84 struct btrfs_dev_item
{
93 uint64_t start_offset
;
99 } __attribute__ ((__packed__
)) dev_item
;
101 } __attribute__ ((__packed__
));
103 #define BTRFS_IOCTL_MAGIC 0x94
104 #define BTRFS_VOL_NAME_MAX 255
105 #define BTRFS_PATH_NAME_MAX 4087
107 struct btrfs_ioctl_vol_args
{
109 char name
[BTRFS_PATH_NAME_MAX
+ 1];
112 struct btrfs_ioctl_search_key
{
113 /* which root are we searching. 0 is the tree of tree roots */
116 /* keys returned will be >= min and <= max */
120 /* keys returned will be >= min and <= max */
124 /* max and min transids to search for */
128 /* keys returned will be >= min and <= max */
133 * how many items did userland ask for, and how many are we
138 /* align to 64 bits */
141 /* some extra for later */
148 struct btrfs_ioctl_search_header
{
154 } __attribute__((may_alias
));
156 #define BTRFS_DEVICE_PATH_NAME_MAX 1024
157 struct btrfs_ioctl_dev_info_args
{
158 __u64 devid
; /* in/out */
159 __u8 uuid
[BTRFS_UUID_SIZE
]; /* in/out */
160 __u64 bytes_used
; /* out */
161 __u64 total_bytes
; /* out */
162 __u64 unused
[379]; /* pad to 4k */
163 __u8 path
[BTRFS_DEVICE_PATH_NAME_MAX
]; /* out */
166 struct btrfs_ioctl_fs_info_args
{
167 __u64 max_id
; /* out */
168 __u64 num_devices
; /* out */
169 __u8 fsid
[BTRFS_FSID_SIZE
]; /* out */
170 __u64 reserved
[124]; /* pad to 1k */
173 #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
175 * the buf is an array of search headers where
176 * each header is followed by the actual item
177 * the type field is expanded to 32 bits for alignment
179 struct btrfs_ioctl_search_args
{
180 struct btrfs_ioctl_search_key key
;
181 char buf
[BTRFS_SEARCH_ARGS_BUFSIZE
];
184 #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
185 struct btrfs_ioctl_search_args)
186 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
187 struct btrfs_ioctl_dev_info_args)
188 #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
189 struct btrfs_ioctl_fs_info_args)