root/extlinux/btrfs.h

Revision 9bba61ccd4b4515bcf4d2dc06ddc4f6329318547, 2.8 KB (checked in by H. Peter Anvin <hpa@…>, 10 months ago)

btrfs: Correctly determine the installation subvolume

There are multiple ways to set up subvolumes in btrfs. Use a general
determination method which works for all schemes.

Signed-off-by: H. Peter Anvin <hpa@…>

  • Property mode set to 100644
Line 
1#ifndef _BTRFS_H_
2#define _BTRFS_H_
3
4#include <asm/types.h>
5#include <linux/ioctl.h>
6
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_CSUM_SIZE 32
12#define BTRFS_FSID_SIZE 16
13
14typedef __u64 u64;
15typedef __u32 u32;
16typedef __u16 u16;
17typedef __u8 u8;
18typedef u64 __le64;
19typedef u16 __le16;
20
21#define BTRFS_ROOT_BACKREF_KEY  144
22#define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
23#define BTRFS_DIR_ITEM_KEY      84
24
25/*
26 *  * this is used for both forward and backward root refs
27 *   */
28struct btrfs_root_ref {
29        __le64 dirid;
30        __le64 sequence;
31        __le16 name_len;
32} __attribute__ ((__packed__));
33
34struct btrfs_disk_key {
35        __le64 objectid;
36        u8 type;
37        __le64 offset;
38} __attribute__ ((__packed__));
39
40struct btrfs_dir_item {
41        struct btrfs_disk_key location;
42        __le64 transid;
43        __le16 data_len;
44        __le16 name_len;
45        u8 type;
46} __attribute__ ((__packed__));
47
48struct btrfs_super_block {
49        unsigned char csum[BTRFS_CSUM_SIZE];
50        /* the first 3 fields must match struct btrfs_header */
51        unsigned char fsid[BTRFS_FSID_SIZE];    /* FS specific uuid */
52        u64 bytenr; /* this block number */
53        u64 flags;
54
55        /* allowed to be different from the btrfs_header from here own down */
56        u64 magic;
57} __attribute__ ((__packed__));
58
59
60#define BTRFS_IOCTL_MAGIC 0x94
61#define BTRFS_VOL_NAME_MAX 255
62#define BTRFS_PATH_NAME_MAX 4087
63
64struct btrfs_ioctl_vol_args {
65        __s64 fd;
66        char name[BTRFS_PATH_NAME_MAX + 1];
67};
68
69struct btrfs_ioctl_search_key {
70        /* which root are we searching.  0 is the tree of tree roots */
71        __u64 tree_id;
72
73        /* keys returned will be >= min and <= max */
74        __u64 min_objectid;
75        __u64 max_objectid;
76
77        /* keys returned will be >= min and <= max */
78        __u64 min_offset;
79        __u64 max_offset;
80
81        /* max and min transids to search for */
82        __u64 min_transid;
83        __u64 max_transid;
84
85        /* keys returned will be >= min and <= max */
86        __u32 min_type;
87        __u32 max_type;
88
89        /*
90         * how many items did userland ask for, and how many are we
91         * returning
92         */
93        __u32 nr_items;
94
95        /* align to 64 bits */
96        __u32 unused;
97
98        /* some extra for later */
99        __u64 unused1;
100        __u64 unused2;
101        __u64 unused3;
102        __u64 unused4;
103};
104
105struct btrfs_ioctl_search_header {
106        __u64 transid;
107        __u64 objectid;
108        __u64 offset;
109        __u32 type;
110        __u32 len;
111} __attribute__((may_alias));
112
113#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
114/*
115 * the buf is an array of search headers where
116 * each header is followed by the actual item
117 * the type field is expanded to 32 bits for alignment
118 */
119struct btrfs_ioctl_search_args {
120        struct btrfs_ioctl_search_key key;
121        char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
122};
123
124#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
125                                   struct btrfs_ioctl_search_args)
126
127#endif
Note: See TracBrowser for help on using the browser.