Commit | Line | Data |
---|---|---|
079b72bc JM |
1 | #ifndef _BTRFS_SYSFS_H_ |
2 | #define _BTRFS_SYSFS_H_ | |
3 | ||
1bae3098 DS |
4 | /* |
5 | * Data exported through sysfs | |
6 | */ | |
7 | extern u64 btrfs_debugfs_test; | |
8 | ||
079b72bc JM |
9 | enum btrfs_feature_set { |
10 | FEAT_COMPAT, | |
11 | FEAT_COMPAT_RO, | |
12 | FEAT_INCOMPAT, | |
13 | FEAT_MAX | |
14 | }; | |
15 | ||
16 | #define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \ | |
17 | { \ | |
18 | .attr = { .name = __stringify(_name), .mode = _mode }, \ | |
19 | .show = _show, \ | |
20 | .store = _store, \ | |
21 | } | |
22 | ||
20ee0825 | 23 | #define BTRFS_ATTR_RW(_name, _show, _store) \ |
98b3d389 | 24 | static struct kobj_attribute btrfs_attr_##_name = \ |
20ee0825 | 25 | __INIT_KOBJ_ATTR(_name, 0644, _show, _store) |
98b3d389 AJ |
26 | |
27 | #define BTRFS_ATTR(_name, _show) \ | |
20ee0825 AJ |
28 | static struct kobj_attribute btrfs_attr_##_name = \ |
29 | __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) | |
98b3d389 | 30 | |
5ac1d209 JM |
31 | #define BTRFS_ATTR_PTR(_name) (&btrfs_attr_##_name.attr) |
32 | ||
6ab0a202 | 33 | #define BTRFS_RAID_ATTR(_name, _show) \ |
98b3d389 | 34 | static struct kobj_attribute btrfs_raid_attr_##_name = \ |
6ab0a202 | 35 | __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) |
98b3d389 | 36 | |
6ab0a202 JM |
37 | #define BTRFS_RAID_ATTR_PTR(_name) (&btrfs_raid_attr_##_name.attr) |
38 | ||
39 | ||
079b72bc JM |
40 | struct btrfs_feature_attr { |
41 | struct kobj_attribute kobj_attr; | |
42 | enum btrfs_feature_set feature_set; | |
43 | u64 feature_bit; | |
44 | }; | |
45 | ||
46 | #define BTRFS_FEAT_ATTR(_name, _feature_set, _prefix, _feature_bit) \ | |
47 | static struct btrfs_feature_attr btrfs_attr_##_name = { \ | |
48 | .kobj_attr = __INIT_KOBJ_ATTR(_name, S_IRUGO, \ | |
ba631941 JM |
49 | btrfs_feature_attr_show, \ |
50 | btrfs_feature_attr_store), \ | |
079b72bc JM |
51 | .feature_set = _feature_set, \ |
52 | .feature_bit = _prefix ##_## _feature_bit, \ | |
53 | } | |
54 | #define BTRFS_FEAT_ATTR_PTR(_name) (&btrfs_attr_##_name.kobj_attr.attr) | |
55 | ||
56 | #define BTRFS_FEAT_ATTR_COMPAT(name, feature) \ | |
57 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature) | |
58 | #define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \ | |
59 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT, feature) | |
60 | #define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \ | |
61 | BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature) | |
62 | ||
63 | /* convert from attribute */ | |
64 | #define to_btrfs_feature_attr(a) \ | |
65 | container_of(a, struct btrfs_feature_attr, kobj_attr) | |
5ac1d209 JM |
66 | #define attr_to_btrfs_attr(a) container_of(a, struct kobj_attribute, attr) |
67 | #define attr_to_btrfs_feature_attr(a) \ | |
68 | to_btrfs_feature_attr(attr_to_btrfs_attr(a)) | |
3b02a68a JM |
69 | char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags); |
70 | extern const char * const btrfs_feature_set_names[3]; | |
6ab0a202 JM |
71 | extern struct kobj_type space_info_ktype; |
72 | extern struct kobj_type btrfs_raid_ktype; | |
0d39376a AJ |
73 | int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info, |
74 | struct btrfs_device *one_device); | |
99994cde AJ |
75 | int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info, |
76 | struct btrfs_device *one_device); | |
079b72bc | 77 | #endif /* _BTRFS_SYSFS_H_ */ |