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