Jeff Mahoney | 079b72b | 2013-11-01 13:06:57 -0400 | [diff] [blame^] | 1 | #ifndef _BTRFS_SYSFS_H_ |
| 2 | #define _BTRFS_SYSFS_H_ |
| 3 | |
| 4 | enum 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 | |
| 18 | struct btrfs_feature_attr { |
| 19 | struct kobj_attribute kobj_attr; |
| 20 | enum btrfs_feature_set feature_set; |
| 21 | u64 feature_bit; |
| 22 | }; |
| 23 | |
| 24 | #define BTRFS_FEAT_ATTR(_name, _feature_set, _prefix, _feature_bit) \ |
| 25 | static struct btrfs_feature_attr btrfs_attr_##_name = { \ |
| 26 | .kobj_attr = __INIT_KOBJ_ATTR(_name, S_IRUGO, \ |
| 27 | btrfs_feature_attr_show, NULL), \ |
| 28 | .feature_set = _feature_set, \ |
| 29 | .feature_bit = _prefix ##_## _feature_bit, \ |
| 30 | } |
| 31 | #define BTRFS_FEAT_ATTR_PTR(_name) (&btrfs_attr_##_name.kobj_attr.attr) |
| 32 | |
| 33 | #define BTRFS_FEAT_ATTR_COMPAT(name, feature) \ |
| 34 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature) |
| 35 | #define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \ |
| 36 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT, feature) |
| 37 | #define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \ |
| 38 | BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature) |
| 39 | |
| 40 | /* convert from attribute */ |
| 41 | #define to_btrfs_feature_attr(a) \ |
| 42 | container_of(a, struct btrfs_feature_attr, kobj_attr) |
| 43 | #endif /* _BTRFS_SYSFS_H_ */ |