blob: d001eb862daece4420aacc6fa450a8a35d64d7f9 [file] [log] [blame]
Ryusuke Konishiae980432018-09-04 15:46:30 -07001/* SPDX-License-Identifier: GPL-2.0+ */
Vyacheslav Dubeykoaebe17f2014-08-08 14:20:37 -07002/*
3 * sysfs.h - sysfs support declarations.
4 *
5 * Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation.
6 * Copyright (C) 2014 HGST, Inc., a Western Digital Company.
7 *
Vyacheslav Dubeykoaebe17f2014-08-08 14:20:37 -07008 * 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
Vyacheslav Dubeykocaa05d42014-08-08 14:20:42 -070018/*
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
Vyacheslav Dubeykoabc968d2014-08-08 14:20:44 -070022 * @sg_segctor_kobj: /sys/fs/<nilfs>/<device>/segctor
23 * @sg_segctor_kobj_unregister: completion state
Vyacheslav Dubeykoa2ecb792014-08-08 14:20:50 -070024 * @sg_mounted_snapshots_kobj: /sys/fs/<nilfs>/<device>/mounted_snapshots
25 * @sg_mounted_snapshots_kobj_unregister: completion state
Vyacheslav Dubeyko02a0ba12014-08-08 14:20:48 -070026 * @sg_checkpoints_kobj: /sys/fs/<nilfs>/<device>/checkpoints
27 * @sg_checkpoints_kobj_unregister: completion state
Vyacheslav Dubeykoef43d5c2014-08-08 14:20:46 -070028 * @sg_segments_kobj: /sys/fs/<nilfs>/<device>/segments
29 * @sg_segments_kobj_unregister: completion state
Vyacheslav Dubeykocaa05d42014-08-08 14:20:42 -070030 */
31struct nilfs_sysfs_dev_subgroups {
32 /* /sys/fs/<nilfs>/<device>/superblock */
33 struct kobject sg_superblock_kobj;
34 struct completion sg_superblock_kobj_unregister;
Vyacheslav Dubeykoabc968d2014-08-08 14:20:44 -070035
36 /* /sys/fs/<nilfs>/<device>/segctor */
37 struct kobject sg_segctor_kobj;
38 struct completion sg_segctor_kobj_unregister;
Vyacheslav Dubeykoef43d5c2014-08-08 14:20:46 -070039
Vyacheslav Dubeykoa2ecb792014-08-08 14:20:50 -070040 /* /sys/fs/<nilfs>/<device>/mounted_snapshots */
41 struct kobject sg_mounted_snapshots_kobj;
42 struct completion sg_mounted_snapshots_kobj_unregister;
43
Vyacheslav Dubeyko02a0ba12014-08-08 14:20:48 -070044 /* /sys/fs/<nilfs>/<device>/checkpoints */
45 struct kobject sg_checkpoints_kobj;
46 struct completion sg_checkpoints_kobj_unregister;
47
Vyacheslav Dubeykoef43d5c2014-08-08 14:20:46 -070048 /* /sys/fs/<nilfs>/<device>/segments */
49 struct kobject sg_segments_kobj;
50 struct completion sg_segments_kobj_unregister;
Vyacheslav Dubeykocaa05d42014-08-08 14:20:42 -070051};
52
Vyacheslav Dubeykoaebe17f2014-08-08 14:20:37 -070053#define NILFS_COMMON_ATTR_STRUCT(name) \
54struct 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); \
Ryusuke Konishifacb9ec2016-05-23 16:23:28 -070060}
Vyacheslav Dubeykoaebe17f2014-08-08 14:20:37 -070061
62NILFS_COMMON_ATTR_STRUCT(feature);
63
Vyacheslav Dubeykoda7141f2014-08-08 14:20:39 -070064#define NILFS_DEV_ATTR_STRUCT(name) \
65struct 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); \
Ryusuke Konishifacb9ec2016-05-23 16:23:28 -070071}
Vyacheslav Dubeykoda7141f2014-08-08 14:20:39 -070072
73NILFS_DEV_ATTR_STRUCT(dev);
Vyacheslav Dubeykoef43d5c2014-08-08 14:20:46 -070074NILFS_DEV_ATTR_STRUCT(segments);
Vyacheslav Dubeykoa2ecb792014-08-08 14:20:50 -070075NILFS_DEV_ATTR_STRUCT(mounted_snapshots);
Vyacheslav Dubeyko02a0ba12014-08-08 14:20:48 -070076NILFS_DEV_ATTR_STRUCT(checkpoints);
Vyacheslav Dubeykocaa05d42014-08-08 14:20:42 -070077NILFS_DEV_ATTR_STRUCT(superblock);
Vyacheslav Dubeykoabc968d2014-08-08 14:20:44 -070078NILFS_DEV_ATTR_STRUCT(segctor);
Vyacheslav Dubeykoda7141f2014-08-08 14:20:39 -070079
Vyacheslav Dubeykoa5a73322014-08-08 14:20:52 -070080#define NILFS_CP_ATTR_STRUCT(name) \
81struct 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); \
Ryusuke Konishifacb9ec2016-05-23 16:23:28 -070087}
Vyacheslav Dubeykoa5a73322014-08-08 14:20:52 -070088
89NILFS_CP_ATTR_STRUCT(snapshot);
90
Vyacheslav Dubeykoaebe17f2014-08-08 14:20:37 -070091#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
Vyacheslav Dubeykoda7141f2014-08-08 14:20:39 -0700111#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
Vyacheslav Dubeykoef43d5c2014-08-08 14:20:46 -0700118#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
Vyacheslav Dubeykoa2ecb792014-08-08 14:20:50 -0700123#define NILFS_MOUNTED_SNAPSHOTS_RO_ATTR(name) \
124 NILFS_RO_ATTR(mounted_snapshots, name)
125
Vyacheslav Dubeyko02a0ba12014-08-08 14:20:48 -0700126#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
Vyacheslav Dubeykoa5a73322014-08-08 14:20:52 -0700131#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
Vyacheslav Dubeykocaa05d42014-08-08 14:20:42 -0700138#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
Vyacheslav Dubeykoabc968d2014-08-08 14:20:44 -0700143#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
Vyacheslav Dubeykoaebe17f2014-08-08 14:20:37 -0700150#define NILFS_FEATURE_ATTR_LIST(name) \
151 (&nilfs_feature_attr_##name.attr)
Vyacheslav Dubeykoda7141f2014-08-08 14:20:39 -0700152#define NILFS_DEV_ATTR_LIST(name) \
153 (&nilfs_dev_attr_##name.attr)
Vyacheslav Dubeykoef43d5c2014-08-08 14:20:46 -0700154#define NILFS_SEGMENTS_ATTR_LIST(name) \
155 (&nilfs_segments_attr_##name.attr)
Vyacheslav Dubeykoa2ecb792014-08-08 14:20:50 -0700156#define NILFS_MOUNTED_SNAPSHOTS_ATTR_LIST(name) \
157 (&nilfs_mounted_snapshots_attr_##name.attr)
Vyacheslav Dubeyko02a0ba12014-08-08 14:20:48 -0700158#define NILFS_CHECKPOINTS_ATTR_LIST(name) \
159 (&nilfs_checkpoints_attr_##name.attr)
Vyacheslav Dubeykoa5a73322014-08-08 14:20:52 -0700160#define NILFS_SNAPSHOT_ATTR_LIST(name) \
161 (&nilfs_snapshot_attr_##name.attr)
Vyacheslav Dubeykocaa05d42014-08-08 14:20:42 -0700162#define NILFS_SUPERBLOCK_ATTR_LIST(name) \
163 (&nilfs_superblock_attr_##name.attr)
Vyacheslav Dubeykoabc968d2014-08-08 14:20:44 -0700164#define NILFS_SEGCTOR_ATTR_LIST(name) \
165 (&nilfs_segctor_attr_##name.attr)
Vyacheslav Dubeykoaebe17f2014-08-08 14:20:37 -0700166
167#endif /* _NILFS_SYSFS_H */