]>
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 | ||
27 | #define NILFS_COMMON_ATTR_STRUCT(name) \ | |
28 | struct nilfs_##name##_attr { \ | |
29 | struct attribute attr; \ | |
30 | ssize_t (*show)(struct kobject *, struct attribute *, \ | |
31 | char *); \ | |
32 | ssize_t (*store)(struct kobject *, struct attribute *, \ | |
33 | const char *, size_t); \ | |
34 | }; | |
35 | ||
36 | NILFS_COMMON_ATTR_STRUCT(feature); | |
37 | ||
38 | #define NILFS_ATTR(type, name, mode, show, store) \ | |
39 | static struct nilfs_##type##_attr nilfs_##type##_attr_##name = \ | |
40 | __ATTR(name, mode, show, store) | |
41 | ||
42 | #define NILFS_INFO_ATTR(type, name) \ | |
43 | NILFS_ATTR(type, name, 0444, NULL, NULL) | |
44 | #define NILFS_RO_ATTR(type, name) \ | |
45 | NILFS_ATTR(type, name, 0444, nilfs_##type##_##name##_show, NULL) | |
46 | #define NILFS_RW_ATTR(type, name) \ | |
47 | NILFS_ATTR(type, name, 0644, \ | |
48 | nilfs_##type##_##name##_show, \ | |
49 | nilfs_##type##_##name##_store) | |
50 | ||
51 | #define NILFS_FEATURE_INFO_ATTR(name) \ | |
52 | NILFS_INFO_ATTR(feature, name) | |
53 | #define NILFS_FEATURE_RO_ATTR(name) \ | |
54 | NILFS_RO_ATTR(feature, name) | |
55 | #define NILFS_FEATURE_RW_ATTR(name) \ | |
56 | NILFS_RW_ATTR(feature, name) | |
57 | ||
58 | #define NILFS_FEATURE_ATTR_LIST(name) \ | |
59 | (&nilfs_feature_attr_##name.attr) | |
60 | ||
61 | #endif /* _NILFS_SYSFS_H */ |