Commit | Line | Data |
---|---|---|
ae98043f | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
aebe17f6 | 2 | /* |
94ee1d91 | 3 | * Sysfs support declarations. |
aebe17f6 VD |
4 | * |
5 | * Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation. | |
6 | * Copyright (C) 2014 HGST, Inc., a Western Digital Company. | |
7 | * | |
aebe17f6 VD |
8 | * Written by Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com> |
9 | */ | |
10 | ||
11 | #ifndef _NILFS_SYSFS_H | |
12 | #define _NILFS_SYSFS_H | |
13 | ||
14 | #include <linux/sysfs.h> | |
15 | ||
16 | #define NILFS_ROOT_GROUP_NAME "nilfs2" | |
17 | ||
caa05d49 VD |
18 | /* |
19 | * struct nilfs_sysfs_dev_subgroups - device subgroup kernel objects | |
20 | * @sg_superblock_kobj: /sys/fs/<nilfs>/<device>/superblock | |
21 | * @sg_superblock_kobj_unregister: completion state | |
abc968db VD |
22 | * @sg_segctor_kobj: /sys/fs/<nilfs>/<device>/segctor |
23 | * @sg_segctor_kobj_unregister: completion state | |
a2ecb791 VD |
24 | * @sg_mounted_snapshots_kobj: /sys/fs/<nilfs>/<device>/mounted_snapshots |
25 | * @sg_mounted_snapshots_kobj_unregister: completion state | |
02a0ba1c VD |
26 | * @sg_checkpoints_kobj: /sys/fs/<nilfs>/<device>/checkpoints |
27 | * @sg_checkpoints_kobj_unregister: completion state | |
ef43d5cd VD |
28 | * @sg_segments_kobj: /sys/fs/<nilfs>/<device>/segments |
29 | * @sg_segments_kobj_unregister: completion state | |
caa05d49 VD |
30 | */ |
31 | struct nilfs_sysfs_dev_subgroups { | |
32 | /* /sys/fs/<nilfs>/<device>/superblock */ | |
33 | struct kobject sg_superblock_kobj; | |
34 | struct completion sg_superblock_kobj_unregister; | |
abc968db VD |
35 | |
36 | /* /sys/fs/<nilfs>/<device>/segctor */ | |
37 | struct kobject sg_segctor_kobj; | |
38 | struct completion sg_segctor_kobj_unregister; | |
ef43d5cd | 39 | |
a2ecb791 VD |
40 | /* /sys/fs/<nilfs>/<device>/mounted_snapshots */ |
41 | struct kobject sg_mounted_snapshots_kobj; | |
42 | struct completion sg_mounted_snapshots_kobj_unregister; | |
43 | ||
02a0ba1c VD |
44 | /* /sys/fs/<nilfs>/<device>/checkpoints */ |
45 | struct kobject sg_checkpoints_kobj; | |
46 | struct completion sg_checkpoints_kobj_unregister; | |
47 | ||
ef43d5cd VD |
48 | /* /sys/fs/<nilfs>/<device>/segments */ |
49 | struct kobject sg_segments_kobj; | |
50 | struct completion sg_segments_kobj_unregister; | |
caa05d49 VD |
51 | }; |
52 | ||
aebe17f6 VD |
53 | #define NILFS_COMMON_ATTR_STRUCT(name) \ |
54 | struct nilfs_##name##_attr { \ | |
55 | struct attribute attr; \ | |
56 | ssize_t (*show)(struct kobject *, struct attribute *, \ | |
57 | char *); \ | |
58 | ssize_t (*store)(struct kobject *, struct attribute *, \ | |
59 | const char *, size_t); \ | |
facb9ec5 | 60 | } |
aebe17f6 VD |
61 | |
62 | NILFS_COMMON_ATTR_STRUCT(feature); | |
63 | ||
da7141fb VD |
64 | #define NILFS_DEV_ATTR_STRUCT(name) \ |
65 | struct nilfs_##name##_attr { \ | |
66 | struct attribute attr; \ | |
67 | ssize_t (*show)(struct nilfs_##name##_attr *, struct the_nilfs *, \ | |
68 | char *); \ | |
69 | ssize_t (*store)(struct nilfs_##name##_attr *, struct the_nilfs *, \ | |
70 | const char *, size_t); \ | |
facb9ec5 | 71 | } |
da7141fb VD |
72 | |
73 | NILFS_DEV_ATTR_STRUCT(dev); | |
ef43d5cd | 74 | NILFS_DEV_ATTR_STRUCT(segments); |
a2ecb791 | 75 | NILFS_DEV_ATTR_STRUCT(mounted_snapshots); |
02a0ba1c | 76 | NILFS_DEV_ATTR_STRUCT(checkpoints); |
caa05d49 | 77 | NILFS_DEV_ATTR_STRUCT(superblock); |
abc968db | 78 | NILFS_DEV_ATTR_STRUCT(segctor); |
da7141fb | 79 | |
a5a7332a VD |
80 | #define NILFS_CP_ATTR_STRUCT(name) \ |
81 | struct nilfs_##name##_attr { \ | |
82 | struct attribute attr; \ | |
83 | ssize_t (*show)(struct nilfs_##name##_attr *, struct nilfs_root *, \ | |
84 | char *); \ | |
85 | ssize_t (*store)(struct nilfs_##name##_attr *, struct nilfs_root *, \ | |
86 | const char *, size_t); \ | |
facb9ec5 | 87 | } |
a5a7332a VD |
88 | |
89 | NILFS_CP_ATTR_STRUCT(snapshot); | |
90 | ||
aebe17f6 VD |
91 | #define NILFS_ATTR(type, name, mode, show, store) \ |
92 | static struct nilfs_##type##_attr nilfs_##type##_attr_##name = \ | |
93 | __ATTR(name, mode, show, store) | |
94 | ||
95 | #define NILFS_INFO_ATTR(type, name) \ | |
96 | NILFS_ATTR(type, name, 0444, NULL, NULL) | |
97 | #define NILFS_RO_ATTR(type, name) \ | |
98 | NILFS_ATTR(type, name, 0444, nilfs_##type##_##name##_show, NULL) | |
99 | #define NILFS_RW_ATTR(type, name) \ | |
100 | NILFS_ATTR(type, name, 0644, \ | |
101 | nilfs_##type##_##name##_show, \ | |
102 | nilfs_##type##_##name##_store) | |
103 | ||
104 | #define NILFS_FEATURE_INFO_ATTR(name) \ | |
105 | NILFS_INFO_ATTR(feature, name) | |
106 | #define NILFS_FEATURE_RO_ATTR(name) \ | |
107 | NILFS_RO_ATTR(feature, name) | |
108 | #define NILFS_FEATURE_RW_ATTR(name) \ | |
109 | NILFS_RW_ATTR(feature, name) | |
110 | ||
da7141fb VD |
111 | #define NILFS_DEV_INFO_ATTR(name) \ |
112 | NILFS_INFO_ATTR(dev, name) | |
113 | #define NILFS_DEV_RO_ATTR(name) \ | |
114 | NILFS_RO_ATTR(dev, name) | |
115 | #define NILFS_DEV_RW_ATTR(name) \ | |
116 | NILFS_RW_ATTR(dev, name) | |
117 | ||
ef43d5cd VD |
118 | #define NILFS_SEGMENTS_RO_ATTR(name) \ |
119 | NILFS_RO_ATTR(segments, name) | |
120 | #define NILFS_SEGMENTS_RW_ATTR(name) \ | |
121 | NILFS_RW_ATTR(segs_info, name) | |
122 | ||
a2ecb791 VD |
123 | #define NILFS_MOUNTED_SNAPSHOTS_RO_ATTR(name) \ |
124 | NILFS_RO_ATTR(mounted_snapshots, name) | |
125 | ||
02a0ba1c VD |
126 | #define NILFS_CHECKPOINTS_RO_ATTR(name) \ |
127 | NILFS_RO_ATTR(checkpoints, name) | |
128 | #define NILFS_CHECKPOINTS_RW_ATTR(name) \ | |
129 | NILFS_RW_ATTR(checkpoints, name) | |
130 | ||
a5a7332a VD |
131 | #define NILFS_SNAPSHOT_INFO_ATTR(name) \ |
132 | NILFS_INFO_ATTR(snapshot, name) | |
133 | #define NILFS_SNAPSHOT_RO_ATTR(name) \ | |
134 | NILFS_RO_ATTR(snapshot, name) | |
135 | #define NILFS_SNAPSHOT_RW_ATTR(name) \ | |
136 | NILFS_RW_ATTR(snapshot, name) | |
137 | ||
caa05d49 VD |
138 | #define NILFS_SUPERBLOCK_RO_ATTR(name) \ |
139 | NILFS_RO_ATTR(superblock, name) | |
140 | #define NILFS_SUPERBLOCK_RW_ATTR(name) \ | |
141 | NILFS_RW_ATTR(superblock, name) | |
142 | ||
abc968db VD |
143 | #define NILFS_SEGCTOR_INFO_ATTR(name) \ |
144 | NILFS_INFO_ATTR(segctor, name) | |
145 | #define NILFS_SEGCTOR_RO_ATTR(name) \ | |
146 | NILFS_RO_ATTR(segctor, name) | |
147 | #define NILFS_SEGCTOR_RW_ATTR(name) \ | |
148 | NILFS_RW_ATTR(segctor, name) | |
149 | ||
aebe17f6 VD |
150 | #define NILFS_FEATURE_ATTR_LIST(name) \ |
151 | (&nilfs_feature_attr_##name.attr) | |
da7141fb VD |
152 | #define NILFS_DEV_ATTR_LIST(name) \ |
153 | (&nilfs_dev_attr_##name.attr) | |
ef43d5cd VD |
154 | #define NILFS_SEGMENTS_ATTR_LIST(name) \ |
155 | (&nilfs_segments_attr_##name.attr) | |
a2ecb791 VD |
156 | #define NILFS_MOUNTED_SNAPSHOTS_ATTR_LIST(name) \ |
157 | (&nilfs_mounted_snapshots_attr_##name.attr) | |
02a0ba1c VD |
158 | #define NILFS_CHECKPOINTS_ATTR_LIST(name) \ |
159 | (&nilfs_checkpoints_attr_##name.attr) | |
a5a7332a VD |
160 | #define NILFS_SNAPSHOT_ATTR_LIST(name) \ |
161 | (&nilfs_snapshot_attr_##name.attr) | |
caa05d49 VD |
162 | #define NILFS_SUPERBLOCK_ATTR_LIST(name) \ |
163 | (&nilfs_superblock_attr_##name.attr) | |
abc968db VD |
164 | #define NILFS_SEGCTOR_ATTR_LIST(name) \ |
165 | (&nilfs_segctor_attr_##name.attr) | |
aebe17f6 VD |
166 | |
167 | #endif /* _NILFS_SYSFS_H */ |