Releasing debian version 6.00~pre4+dfsg-7.
[syslinux-debian/hramrach.git] / extlinux / btrfs.h
blob4e2cb31721335da6d57dcc4167a9a88b710b5758
1 #ifndef _BTRFS_H_
2 #define _BTRFS_H_
4 #include <asm/types.h>
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 typedef __u64 u64;
17 typedef __u32 u32;
18 typedef __u16 u16;
19 typedef __u8 u8;
20 typedef u64 __le64;
21 typedef u16 __le16;
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
29 * */
30 struct btrfs_root_ref {
31 __le64 dirid;
32 __le64 sequence;
33 __le16 name_len;
34 } __attribute__ ((__packed__));
36 struct btrfs_disk_key {
37 __le64 objectid;
38 u8 type;
39 __le64 offset;
40 } __attribute__ ((__packed__));
42 struct btrfs_dir_item {
43 struct btrfs_disk_key location;
44 __le64 transid;
45 __le16 data_len;
46 __le16 name_len;
47 u8 type;
48 } __attribute__ ((__packed__));
50 struct btrfs_super_block {
51 uint8_t csum[32];
52 uint8_t fsid[16];
53 uint64_t bytenr;
54 uint64_t flags;
55 uint8_t magic[8];
56 uint64_t generation;
57 uint64_t root;
58 uint64_t chunk_root;
59 uint64_t log_root;
60 uint64_t log_root_transid;
61 uint64_t total_bytes;
62 uint64_t bytes_used;
63 uint64_t root_dir_objectid;
64 uint64_t num_devices;
65 uint32_t sectorsize;
66 uint32_t nodesize;
67 uint32_t leafsize;
68 uint32_t stripesize;
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;
74 uint16_t csum_type;
75 uint8_t root_level;
76 uint8_t chunk_root_level;
77 uint8_t log_root_level;
78 struct btrfs_dev_item {
79 uint64_t devid;
80 uint64_t total_bytes;
81 uint64_t bytes_used;
82 uint32_t io_align;
83 uint32_t io_width;
84 uint32_t sector_size;
85 uint64_t type;
86 uint64_t generation;
87 uint64_t start_offset;
88 uint32_t dev_group;
89 uint8_t seek_speed;
90 uint8_t bandwidth;
91 uint8_t uuid[16];
92 uint8_t fsid[16];
93 } __attribute__ ((__packed__)) dev_item;
94 uint8_t label[256];
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 {
102 __s64 fd;
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 */
108 __u64 tree_id;
110 /* keys returned will be >= min and <= max */
111 __u64 min_objectid;
112 __u64 max_objectid;
114 /* keys returned will be >= min and <= max */
115 __u64 min_offset;
116 __u64 max_offset;
118 /* max and min transids to search for */
119 __u64 min_transid;
120 __u64 max_transid;
122 /* keys returned will be >= min and <= max */
123 __u32 min_type;
124 __u32 max_type;
127 * how many items did userland ask for, and how many are we
128 * returning
130 __u32 nr_items;
132 /* align to 64 bits */
133 __u32 unused;
135 /* some extra for later */
136 __u64 unused1;
137 __u64 unused2;
138 __u64 unused3;
139 __u64 unused4;
142 struct btrfs_ioctl_search_header {
143 __u64 transid;
144 __u64 objectid;
145 __u64 offset;
146 __u32 type;
147 __u32 len;
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)
185 #endif