]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - fs/nilfs2/sysfs.h
nilfs2: add /sys/fs/nilfs2/<device>/segctor group
[karo-tx-linux.git] / fs / nilfs2 / sysfs.h
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
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
31  * @sg_segctor_kobj: /sys/fs/<nilfs>/<device>/segctor
32  * @sg_segctor_kobj_unregister: completion state
33  */
34 struct nilfs_sysfs_dev_subgroups {
35         /* /sys/fs/<nilfs>/<device>/superblock */
36         struct kobject sg_superblock_kobj;
37         struct completion sg_superblock_kobj_unregister;
38
39         /* /sys/fs/<nilfs>/<device>/segctor */
40         struct kobject sg_segctor_kobj;
41         struct completion sg_segctor_kobj_unregister;
42 };
43
44 #define NILFS_COMMON_ATTR_STRUCT(name) \
45 struct nilfs_##name##_attr { \
46         struct attribute attr; \
47         ssize_t (*show)(struct kobject *, struct attribute *, \
48                         char *); \
49         ssize_t (*store)(struct kobject *, struct attribute *, \
50                          const char *, size_t); \
51 };
52
53 NILFS_COMMON_ATTR_STRUCT(feature);
54
55 #define NILFS_DEV_ATTR_STRUCT(name) \
56 struct nilfs_##name##_attr { \
57         struct attribute attr; \
58         ssize_t (*show)(struct nilfs_##name##_attr *, struct the_nilfs *, \
59                         char *); \
60         ssize_t (*store)(struct nilfs_##name##_attr *, struct the_nilfs *, \
61                          const char *, size_t); \
62 };
63
64 NILFS_DEV_ATTR_STRUCT(dev);
65 NILFS_DEV_ATTR_STRUCT(superblock);
66 NILFS_DEV_ATTR_STRUCT(segctor);
67
68 #define NILFS_ATTR(type, name, mode, show, store) \
69         static struct nilfs_##type##_attr nilfs_##type##_attr_##name = \
70                 __ATTR(name, mode, show, store)
71
72 #define NILFS_INFO_ATTR(type, name) \
73         NILFS_ATTR(type, name, 0444, NULL, NULL)
74 #define NILFS_RO_ATTR(type, name) \
75         NILFS_ATTR(type, name, 0444, nilfs_##type##_##name##_show, NULL)
76 #define NILFS_RW_ATTR(type, name) \
77         NILFS_ATTR(type, name, 0644, \
78                     nilfs_##type##_##name##_show, \
79                     nilfs_##type##_##name##_store)
80
81 #define NILFS_FEATURE_INFO_ATTR(name) \
82         NILFS_INFO_ATTR(feature, name)
83 #define NILFS_FEATURE_RO_ATTR(name) \
84         NILFS_RO_ATTR(feature, name)
85 #define NILFS_FEATURE_RW_ATTR(name) \
86         NILFS_RW_ATTR(feature, name)
87
88 #define NILFS_DEV_INFO_ATTR(name) \
89         NILFS_INFO_ATTR(dev, name)
90 #define NILFS_DEV_RO_ATTR(name) \
91         NILFS_RO_ATTR(dev, name)
92 #define NILFS_DEV_RW_ATTR(name) \
93         NILFS_RW_ATTR(dev, name)
94
95 #define NILFS_SUPERBLOCK_RO_ATTR(name) \
96         NILFS_RO_ATTR(superblock, name)
97 #define NILFS_SUPERBLOCK_RW_ATTR(name) \
98         NILFS_RW_ATTR(superblock, name)
99
100 #define NILFS_SEGCTOR_INFO_ATTR(name) \
101         NILFS_INFO_ATTR(segctor, name)
102 #define NILFS_SEGCTOR_RO_ATTR(name) \
103         NILFS_RO_ATTR(segctor, name)
104 #define NILFS_SEGCTOR_RW_ATTR(name) \
105         NILFS_RW_ATTR(segctor, name)
106
107 #define NILFS_FEATURE_ATTR_LIST(name) \
108         (&nilfs_feature_attr_##name.attr)
109 #define NILFS_DEV_ATTR_LIST(name) \
110         (&nilfs_dev_attr_##name.attr)
111 #define NILFS_SUPERBLOCK_ATTR_LIST(name) \
112         (&nilfs_superblock_attr_##name.attr)
113 #define NILFS_SEGCTOR_ATTR_LIST(name) \
114         (&nilfs_segctor_attr_##name.attr)
115
116 #endif /* _NILFS_SYSFS_H */