]>
Commit | Line | Data |
---|---|---|
aebe17f6 VD |
1 | /* |
2 | * sysfs.h - sysfs support declarations. | |
3 | * | |
4 | * Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation. | |
5 | * Copyright (C) 2014 HGST, Inc., a Western Digital Company. | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * Written by Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com> | |
18 | */ | |
19 | ||
20 | #ifndef _NILFS_SYSFS_H | |
21 | #define _NILFS_SYSFS_H | |
22 | ||
23 | #include <linux/sysfs.h> | |
24 | ||
25 | #define NILFS_ROOT_GROUP_NAME "nilfs2" | |
26 | ||
caa05d49 VD |
27 | /* |
28 | * struct nilfs_sysfs_dev_subgroups - device subgroup kernel objects | |
29 | * @sg_superblock_kobj: /sys/fs/<nilfs>/<device>/superblock | |
30 | * @sg_superblock_kobj_unregister: completion state | |
abc968db VD |
31 | * @sg_segctor_kobj: /sys/fs/<nilfs>/<device>/segctor |
32 | * @sg_segctor_kobj_unregister: completion state | |
ef43d5cd VD |
33 | * @sg_segments_kobj: /sys/fs/<nilfs>/<device>/segments |
34 | * @sg_segments_kobj_unregister: completion state | |
caa05d49 VD |
35 | */ |
36 | struct nilfs_sysfs_dev_subgroups { | |
37 | /* /sys/fs/<nilfs>/<device>/superblock */ | |
38 | struct kobject sg_superblock_kobj; | |
39 | struct completion sg_superblock_kobj_unregister; | |
abc968db VD |
40 | |
41 | /* /sys/fs/<nilfs>/<device>/segctor */ | |
42 | struct kobject sg_segctor_kobj; | |
43 | struct completion sg_segctor_kobj_unregister; | |
ef43d5cd VD |
44 | |
45 | /* /sys/fs/<nilfs>/<device>/segments */ | |
46 | struct kobject sg_segments_kobj; | |
47 | struct completion sg_segments_kobj_unregister; | |
caa05d49 VD |
48 | }; |
49 | ||
aebe17f6 VD |
50 | #define NILFS_COMMON_ATTR_STRUCT(name) \ |
51 | struct nilfs_##name##_attr { \ | |
52 | struct attribute attr; \ | |
53 | ssize_t (*show)(struct kobject *, struct attribute *, \ | |
54 | char *); \ | |
55 | ssize_t (*store)(struct kobject *, struct attribute *, \ | |
56 | const char *, size_t); \ | |
57 | }; | |
58 | ||
59 | NILFS_COMMON_ATTR_STRUCT(feature); | |
60 | ||
da7141fb VD |
61 | #define NILFS_DEV_ATTR_STRUCT(name) \ |
62 | struct nilfs_##name##_attr { \ | |
63 | struct attribute attr; \ | |
64 | ssize_t (*show)(struct nilfs_##name##_attr *, struct the_nilfs *, \ | |
65 | char *); \ | |
66 | ssize_t (*store)(struct nilfs_##name##_attr *, struct the_nilfs *, \ | |
67 | const char *, size_t); \ | |
68 | }; | |
69 | ||
70 | NILFS_DEV_ATTR_STRUCT(dev); | |
ef43d5cd | 71 | NILFS_DEV_ATTR_STRUCT(segments); |
caa05d49 | 72 | NILFS_DEV_ATTR_STRUCT(superblock); |
abc968db | 73 | NILFS_DEV_ATTR_STRUCT(segctor); |
da7141fb | 74 | |
aebe17f6 VD |
75 | #define NILFS_ATTR(type, name, mode, show, store) \ |
76 | static struct nilfs_##type##_attr nilfs_##type##_attr_##name = \ | |
77 | __ATTR(name, mode, show, store) | |
78 | ||
79 | #define NILFS_INFO_ATTR(type, name) \ | |
80 | NILFS_ATTR(type, name, 0444, NULL, NULL) | |
81 | #define NILFS_RO_ATTR(type, name) \ | |
82 | NILFS_ATTR(type, name, 0444, nilfs_##type##_##name##_show, NULL) | |
83 | #define NILFS_RW_ATTR(type, name) \ | |
84 | NILFS_ATTR(type, name, 0644, \ | |
85 | nilfs_##type##_##name##_show, \ | |
86 | nilfs_##type##_##name##_store) | |
87 | ||
88 | #define NILFS_FEATURE_INFO_ATTR(name) \ | |
89 | NILFS_INFO_ATTR(feature, name) | |
90 | #define NILFS_FEATURE_RO_ATTR(name) \ | |
91 | NILFS_RO_ATTR(feature, name) | |
92 | #define NILFS_FEATURE_RW_ATTR(name) \ | |
93 | NILFS_RW_ATTR(feature, name) | |
94 | ||
da7141fb VD |
95 | #define NILFS_DEV_INFO_ATTR(name) \ |
96 | NILFS_INFO_ATTR(dev, name) | |
97 | #define NILFS_DEV_RO_ATTR(name) \ | |
98 | NILFS_RO_ATTR(dev, name) | |
99 | #define NILFS_DEV_RW_ATTR(name) \ | |
100 | NILFS_RW_ATTR(dev, name) | |
101 | ||
ef43d5cd VD |
102 | #define NILFS_SEGMENTS_RO_ATTR(name) \ |
103 | NILFS_RO_ATTR(segments, name) | |
104 | #define NILFS_SEGMENTS_RW_ATTR(name) \ | |
105 | NILFS_RW_ATTR(segs_info, name) | |
106 | ||
caa05d49 VD |
107 | #define NILFS_SUPERBLOCK_RO_ATTR(name) \ |
108 | NILFS_RO_ATTR(superblock, name) | |
109 | #define NILFS_SUPERBLOCK_RW_ATTR(name) \ | |
110 | NILFS_RW_ATTR(superblock, name) | |
111 | ||
abc968db VD |
112 | #define NILFS_SEGCTOR_INFO_ATTR(name) \ |
113 | NILFS_INFO_ATTR(segctor, name) | |
114 | #define NILFS_SEGCTOR_RO_ATTR(name) \ | |
115 | NILFS_RO_ATTR(segctor, name) | |
116 | #define NILFS_SEGCTOR_RW_ATTR(name) \ | |
117 | NILFS_RW_ATTR(segctor, name) | |
118 | ||
aebe17f6 VD |
119 | #define NILFS_FEATURE_ATTR_LIST(name) \ |
120 | (&nilfs_feature_attr_##name.attr) | |
da7141fb VD |
121 | #define NILFS_DEV_ATTR_LIST(name) \ |
122 | (&nilfs_dev_attr_##name.attr) | |
ef43d5cd VD |
123 | #define NILFS_SEGMENTS_ATTR_LIST(name) \ |
124 | (&nilfs_segments_attr_##name.attr) | |
caa05d49 VD |
125 | #define NILFS_SUPERBLOCK_ATTR_LIST(name) \ |
126 | (&nilfs_superblock_attr_##name.attr) | |
abc968db VD |
127 | #define NILFS_SEGCTOR_ATTR_LIST(name) \ |
128 | (&nilfs_segctor_attr_##name.attr) | |
aebe17f6 VD |
129 | |
130 | #endif /* _NILFS_SYSFS_H */ |