Jeff Mahoney | 079b72b | 2013-11-01 13:06:57 -0400 | [diff] [blame] | 1 | #ifndef _BTRFS_SYSFS_H_ |
| 2 | #define _BTRFS_SYSFS_H_ |
| 3 | |
David Sterba | 1bae309 | 2014-02-05 15:36:18 +0100 | [diff] [blame^] | 4 | /* |
| 5 | * Data exported through sysfs |
| 6 | */ |
| 7 | extern u64 btrfs_debugfs_test; |
| 8 | |
Jeff Mahoney | 079b72b | 2013-11-01 13:06:57 -0400 | [diff] [blame] | 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 | |
Jeff Mahoney | 5ac1d20 | 2013-11-01 13:06:58 -0400 | [diff] [blame] | 23 | #define BTRFS_ATTR_RW(_name, _mode, _show, _store) \ |
| 24 | static struct kobj_attribute btrfs_attr_##_name = \ |
| 25 | __INIT_KOBJ_ATTR(_name, _mode, _show, _store) |
| 26 | #define BTRFS_ATTR(_name, _mode, _show) \ |
| 27 | BTRFS_ATTR_RW(_name, _mode, _show, NULL) |
| 28 | #define BTRFS_ATTR_PTR(_name) (&btrfs_attr_##_name.attr) |
| 29 | |
Jeff Mahoney | 6ab0a20 | 2013-11-01 13:07:04 -0400 | [diff] [blame] | 30 | #define BTRFS_RAID_ATTR(_name, _show) \ |
| 31 | static struct kobj_attribute btrfs_raid_attr_##_name = \ |
| 32 | __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) |
| 33 | #define BTRFS_RAID_ATTR_PTR(_name) (&btrfs_raid_attr_##_name.attr) |
| 34 | |
| 35 | |
Jeff Mahoney | 079b72b | 2013-11-01 13:06:57 -0400 | [diff] [blame] | 36 | struct btrfs_feature_attr { |
| 37 | struct kobj_attribute kobj_attr; |
| 38 | enum btrfs_feature_set feature_set; |
| 39 | u64 feature_bit; |
| 40 | }; |
| 41 | |
| 42 | #define BTRFS_FEAT_ATTR(_name, _feature_set, _prefix, _feature_bit) \ |
| 43 | static struct btrfs_feature_attr btrfs_attr_##_name = { \ |
| 44 | .kobj_attr = __INIT_KOBJ_ATTR(_name, S_IRUGO, \ |
Jeff Mahoney | ba63194 | 2013-11-01 13:07:01 -0400 | [diff] [blame] | 45 | btrfs_feature_attr_show, \ |
| 46 | btrfs_feature_attr_store), \ |
Jeff Mahoney | 079b72b | 2013-11-01 13:06:57 -0400 | [diff] [blame] | 47 | .feature_set = _feature_set, \ |
| 48 | .feature_bit = _prefix ##_## _feature_bit, \ |
| 49 | } |
| 50 | #define BTRFS_FEAT_ATTR_PTR(_name) (&btrfs_attr_##_name.kobj_attr.attr) |
| 51 | |
| 52 | #define BTRFS_FEAT_ATTR_COMPAT(name, feature) \ |
| 53 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature) |
| 54 | #define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \ |
| 55 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT, feature) |
| 56 | #define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \ |
| 57 | BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature) |
| 58 | |
| 59 | /* convert from attribute */ |
| 60 | #define to_btrfs_feature_attr(a) \ |
| 61 | container_of(a, struct btrfs_feature_attr, kobj_attr) |
Jeff Mahoney | 5ac1d20 | 2013-11-01 13:06:58 -0400 | [diff] [blame] | 62 | #define attr_to_btrfs_attr(a) container_of(a, struct kobj_attribute, attr) |
| 63 | #define attr_to_btrfs_feature_attr(a) \ |
| 64 | to_btrfs_feature_attr(attr_to_btrfs_attr(a)) |
Jeff Mahoney | 3b02a68 | 2013-11-01 13:07:02 -0400 | [diff] [blame] | 65 | char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags); |
| 66 | extern const char * const btrfs_feature_set_names[3]; |
Jeff Mahoney | 6ab0a20 | 2013-11-01 13:07:04 -0400 | [diff] [blame] | 67 | extern struct kobj_type space_info_ktype; |
| 68 | extern struct kobj_type btrfs_raid_ktype; |
Jeff Mahoney | 079b72b | 2013-11-01 13:06:57 -0400 | [diff] [blame] | 69 | #endif /* _BTRFS_SYSFS_H_ */ |