VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / include / linux / sysfs.h
1 /*
2  * sysfs.h - definitions for the device driver filesystem
3  *
4  * Copyright (c) 2001,2002 Patrick Mochel
5  *
6  * Please see Documentation/filesystems/sysfs.txt for more information.
7  */
8
9 #ifndef _SYSFS_H_
10 #define _SYSFS_H_
11
12 #define SYSFS_SUPER_MAGIC       0x62656572
13
14 struct kobject;
15 struct module;
16
17 struct attribute {
18         char                    * name;
19         struct module           * owner;
20         mode_t                  mode;
21 };
22
23 struct attribute_group {
24         char                    * name;
25         struct attribute        ** attrs;
26 };
27
28
29
30 /**
31  * Use these macros to make defining attributes easier. See include/linux/device.h
32  * for examples..
33  */
34
35 #define __ATTR(_name,_mode,_show,_store) { \
36         .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE },     \
37         .show   = _show,                                        \
38         .store  = _store,                                       \
39 }
40
41 #define __ATTR_RO(_name) { \
42         .attr   = { .name = __stringify(_name), .mode = 0444, .owner = THIS_MODULE },   \
43         .show   = _name##_show, \
44 }
45
46 #define __ATTR_NULL { .attr = { .name = NULL } }
47
48 #define attr_name(_attr) (_attr).attr.name
49
50 struct bin_attribute {
51         struct attribute        attr;
52         size_t                  size;
53         ssize_t (*read)(struct kobject *, char *, loff_t, size_t);
54         ssize_t (*write)(struct kobject *, char *, loff_t, size_t);
55 };
56
57 struct sysfs_ops {
58         ssize_t (*show)(struct kobject *, struct attribute *,char *);
59         ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
60 };
61
62 #ifdef CONFIG_SYSFS
63
64 extern int
65 sysfs_create_dir(struct kobject *);
66
67 extern void
68 sysfs_remove_dir(struct kobject *);
69
70 extern int
71 sysfs_rename_dir(struct kobject *, const char *new_name);
72
73 extern int
74 sysfs_create_file(struct kobject *, const struct attribute *);
75
76 extern int
77 sysfs_update_file(struct kobject *, const struct attribute *);
78
79 extern void
80 sysfs_remove_file(struct kobject *, const struct attribute *);
81
82 extern int 
83 sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name);
84
85 extern void
86 sysfs_remove_link(struct kobject *, char * name);
87
88 int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
89 int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
90
91 int sysfs_create_group(struct kobject *, const struct attribute_group *);
92 void sysfs_remove_group(struct kobject *, const struct attribute_group *);
93
94 #else /* CONFIG_SYSFS */
95
96 static inline int sysfs_create_dir(struct kobject * k)
97 {
98         return 0;
99 }
100
101 static inline void sysfs_remove_dir(struct kobject * k)
102 {
103         ;
104 }
105
106 static inline int sysfs_rename_dir(struct kobject * k, const char *new_name)
107 {
108         return 0;
109 }
110
111 static inline int sysfs_create_file(struct kobject * k, const struct attribute * a)
112 {
113         return 0;
114 }
115
116 static inline int sysfs_update_file(struct kobject * k, const struct attribute * a)
117 {
118         return 0;
119 }
120
121 static inline void sysfs_remove_file(struct kobject * k, const struct attribute * a)
122 {
123         ;
124 }
125
126 static inline int sysfs_create_link(struct kobject * k, struct kobject * t, char * n)
127 {
128         return 0;
129 }
130
131 static inline void sysfs_remove_link(struct kobject * k, char * name)
132 {
133         ;
134 }
135
136
137 static inline int sysfs_create_bin_file(struct kobject * k, struct bin_attribute * a)
138 {
139         return 0;
140 }
141
142 static inline int sysfs_remove_bin_file(struct kobject * k, struct bin_attribute * a)
143 {
144         return 0;
145 }
146
147 static inline int sysfs_create_group(struct kobject * k, const struct attribute_group *g)
148 {
149         return 0;
150 }
151
152 static inline void sysfs_remove_group(struct kobject * k, const struct attribute_group * g)
153 {
154         ;
155 }
156
157 #endif /* CONFIG_SYSFS */
158
159 #endif /* _SYSFS_H_ */