]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
079b72bc JM |
2 | #ifndef _BTRFS_SYSFS_H_ |
3 | #define _BTRFS_SYSFS_H_ | |
4 | ||
1bae3098 DS |
5 | /* |
6 | * Data exported through sysfs | |
7 | */ | |
8 | extern u64 btrfs_debugfs_test; | |
9 | ||
079b72bc JM |
10 | enum btrfs_feature_set { |
11 | FEAT_COMPAT, | |
12 | FEAT_COMPAT_RO, | |
13 | FEAT_INCOMPAT, | |
14 | FEAT_MAX | |
15 | }; | |
16 | ||
17 | #define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \ | |
18 | { \ | |
19 | .attr = { .name = __stringify(_name), .mode = _mode }, \ | |
20 | .show = _show, \ | |
21 | .store = _store, \ | |
22 | } | |
23 | ||
a969f4cc HK |
24 | #define BTRFS_ATTR_RW(_prefix, _name, _show, _store) \ |
25 | static struct kobj_attribute btrfs_attr_##_prefix##_##_name = \ | |
20ee0825 | 26 | __INIT_KOBJ_ATTR(_name, 0644, _show, _store) |
98b3d389 | 27 | |
a969f4cc HK |
28 | #define BTRFS_ATTR(_prefix, _name, _show) \ |
29 | static struct kobj_attribute btrfs_attr_##_prefix##_##_name = \ | |
20ee0825 | 30 | __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) |
98b3d389 | 31 | |
a969f4cc HK |
32 | #define BTRFS_ATTR_PTR(_prefix, _name) \ |
33 | (&btrfs_attr_##_prefix##_##_name.attr) | |
6ab0a202 JM |
34 | |
35 | ||
079b72bc JM |
36 | struct btrfs_feature_attr { |
37 | struct kobj_attribute kobj_attr; | |
38 | enum btrfs_feature_set feature_set; | |
39 | u64 feature_bit; | |
40 | }; | |
41 | ||
a969f4cc HK |
42 | #define BTRFS_FEAT_ATTR(_name, _feature_set, _feature_prefix, _feature_bit) \ |
43 | static struct btrfs_feature_attr btrfs_attr_features_##_name = { \ | |
079b72bc | 44 | .kobj_attr = __INIT_KOBJ_ATTR(_name, S_IRUGO, \ |
ba631941 JM |
45 | btrfs_feature_attr_show, \ |
46 | btrfs_feature_attr_store), \ | |
079b72bc | 47 | .feature_set = _feature_set, \ |
a969f4cc | 48 | .feature_bit = _feature_prefix ##_## _feature_bit, \ |
079b72bc | 49 | } |
a969f4cc HK |
50 | #define BTRFS_FEAT_ATTR_PTR(_name) \ |
51 | (&btrfs_attr_features_##_name.kobj_attr.attr) | |
079b72bc JM |
52 | |
53 | #define BTRFS_FEAT_ATTR_COMPAT(name, feature) \ | |
54 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature) | |
55 | #define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \ | |
ba2d0840 | 56 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT_RO, feature) |
079b72bc JM |
57 | #define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \ |
58 | BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature) | |
59 | ||
60 | /* convert from attribute */ | |
093adbce DS |
61 | static inline struct btrfs_feature_attr * |
62 | to_btrfs_feature_attr(struct kobj_attribute *a) | |
63 | { | |
64 | return container_of(a, struct btrfs_feature_attr, kobj_attr); | |
65 | } | |
66 | ||
67 | static inline struct kobj_attribute *attr_to_btrfs_attr(struct attribute *attr) | |
68 | { | |
69 | return container_of(attr, struct kobj_attribute, attr); | |
70 | } | |
71 | ||
72 | static inline struct btrfs_feature_attr * | |
73 | attr_to_btrfs_feature_attr(struct attribute *attr) | |
74 | { | |
75 | return to_btrfs_feature_attr(attr_to_btrfs_attr(attr)); | |
76 | } | |
77 | ||
3b02a68a JM |
78 | char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags); |
79 | extern const char * const btrfs_feature_set_names[3]; | |
6ab0a202 JM |
80 | extern struct kobj_type space_info_ktype; |
81 | extern struct kobj_type btrfs_raid_ktype; | |
e3bd6973 | 82 | int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices, |
0d39376a | 83 | struct btrfs_device *one_device); |
32576040 | 84 | int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices, |
99994cde | 85 | struct btrfs_device *one_device); |
0c10e2d4 AJ |
86 | int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs, |
87 | struct kobject *parent); | |
ef1a0daa | 88 | int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs); |
1d1c1be3 | 89 | void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs); |
444e7516 DS |
90 | void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, |
91 | u64 bit, enum btrfs_feature_set set); | |
92 | ||
079b72bc | 93 | #endif /* _BTRFS_SYSFS_H_ */ |