blob: f3cea3710d44f74edfebb0264b6136d75ee678b0 [file] [log] [blame]
Jeff Mahoney079b72b2013-11-01 13:06:57 -04001#ifndef _BTRFS_SYSFS_H_
2#define _BTRFS_SYSFS_H_
3
4enum btrfs_feature_set {
5 FEAT_COMPAT,
6 FEAT_COMPAT_RO,
7 FEAT_INCOMPAT,
8 FEAT_MAX
9};
10
11#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \
12{ \
13 .attr = { .name = __stringify(_name), .mode = _mode }, \
14 .show = _show, \
15 .store = _store, \
16}
17
Jeff Mahoney5ac1d202013-11-01 13:06:58 -040018#define BTRFS_ATTR_RW(_name, _mode, _show, _store) \
19static struct kobj_attribute btrfs_attr_##_name = \
20 __INIT_KOBJ_ATTR(_name, _mode, _show, _store)
21#define BTRFS_ATTR(_name, _mode, _show) \
22 BTRFS_ATTR_RW(_name, _mode, _show, NULL)
23#define BTRFS_ATTR_PTR(_name) (&btrfs_attr_##_name.attr)
24
Jeff Mahoney6ab0a202013-11-01 13:07:04 -040025#define BTRFS_RAID_ATTR(_name, _show) \
26static struct kobj_attribute btrfs_raid_attr_##_name = \
27 __INIT_KOBJ_ATTR(_name, 0444, _show, NULL)
28#define BTRFS_RAID_ATTR_PTR(_name) (&btrfs_raid_attr_##_name.attr)
29
30
Jeff Mahoney079b72b2013-11-01 13:06:57 -040031struct btrfs_feature_attr {
32 struct kobj_attribute kobj_attr;
33 enum btrfs_feature_set feature_set;
34 u64 feature_bit;
35};
36
37#define BTRFS_FEAT_ATTR(_name, _feature_set, _prefix, _feature_bit) \
38static struct btrfs_feature_attr btrfs_attr_##_name = { \
39 .kobj_attr = __INIT_KOBJ_ATTR(_name, S_IRUGO, \
Jeff Mahoneyba631942013-11-01 13:07:01 -040040 btrfs_feature_attr_show, \
41 btrfs_feature_attr_store), \
Jeff Mahoney079b72b2013-11-01 13:06:57 -040042 .feature_set = _feature_set, \
43 .feature_bit = _prefix ##_## _feature_bit, \
44}
45#define BTRFS_FEAT_ATTR_PTR(_name) (&btrfs_attr_##_name.kobj_attr.attr)
46
47#define BTRFS_FEAT_ATTR_COMPAT(name, feature) \
48 BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature)
49#define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \
50 BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT, feature)
51#define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \
52 BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature)
53
54/* convert from attribute */
55#define to_btrfs_feature_attr(a) \
56 container_of(a, struct btrfs_feature_attr, kobj_attr)
Jeff Mahoney5ac1d202013-11-01 13:06:58 -040057#define attr_to_btrfs_attr(a) container_of(a, struct kobj_attribute, attr)
58#define attr_to_btrfs_feature_attr(a) \
59 to_btrfs_feature_attr(attr_to_btrfs_attr(a))
Jeff Mahoney3b02a682013-11-01 13:07:02 -040060char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
61extern const char * const btrfs_feature_set_names[3];
Jeff Mahoney6ab0a202013-11-01 13:07:04 -040062extern struct kobj_type space_info_ktype;
63extern struct kobj_type btrfs_raid_ktype;
Jeff Mahoney079b72b2013-11-01 13:06:57 -040064#endif /* _BTRFS_SYSFS_H_ */