Rev 6102 | Rev 6936 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6102 | serge | 1 | /* |
2 | * sysfs.h - definitions for the device driver filesystem |
||
3 | * |
||
4 | * Copyright (c) 2001,2002 Patrick Mochel |
||
5 | * Copyright (c) 2004 Silicon Graphics, Inc. |
||
6 | * Copyright (c) 2007 SUSE Linux Products GmbH |
||
7 | * Copyright (c) 2007 Tejun Heo |
||
8 | * |
||
9 | * Please see Documentation/filesystems/sysfs.txt for more information. |
||
10 | */ |
||
11 | |||
12 | #ifndef _SYSFS_H_ |
||
13 | #define _SYSFS_H_ |
||
14 | #include |
||
15 | #include |
||
16 | #include |
||
6934 | serge | 17 | #include |
6102 | serge | 18 | #include |
19 | |||
20 | struct kobject; |
||
21 | struct module; |
||
22 | struct bin_attribute; |
||
23 | enum kobj_ns_type; |
||
24 | |||
25 | struct attribute { |
||
26 | const char *name; |
||
27 | umode_t mode; |
||
28 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
||
29 | bool ignore_lockdep:1; |
||
30 | struct lock_class_key *key; |
||
31 | struct lock_class_key skey; |
||
32 | #endif |
||
33 | }; |
||
34 | #ifdef CONFIG_SYSFS |
||
35 | |||
36 | int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns); |
||
37 | void sysfs_remove_dir(struct kobject *kobj); |
||
38 | int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name, |
||
39 | const void *new_ns); |
||
40 | int __must_check sysfs_move_dir_ns(struct kobject *kobj, |
||
41 | struct kobject *new_parent_kobj, |
||
42 | const void *new_ns); |
||
43 | int __must_check sysfs_create_mount_point(struct kobject *parent_kobj, |
||
44 | const char *name); |
||
45 | void sysfs_remove_mount_point(struct kobject *parent_kobj, |
||
46 | const char *name); |
||
47 | |||
48 | int __must_check sysfs_create_file_ns(struct kobject *kobj, |
||
49 | const struct attribute *attr, |
||
50 | const void *ns); |
||
51 | int __must_check sysfs_create_files(struct kobject *kobj, |
||
52 | const struct attribute **attr); |
||
53 | int __must_check sysfs_chmod_file(struct kobject *kobj, |
||
54 | const struct attribute *attr, umode_t mode); |
||
55 | void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr, |
||
56 | const void *ns); |
||
57 | bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr); |
||
58 | void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr); |
||
59 | |||
60 | int __must_check sysfs_create_bin_file(struct kobject *kobj, |
||
61 | const struct bin_attribute *attr); |
||
62 | void sysfs_remove_bin_file(struct kobject *kobj, |
||
63 | const struct bin_attribute *attr); |
||
64 | |||
65 | int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target, |
||
66 | const char *name); |
||
67 | int __must_check sysfs_create_link_nowarn(struct kobject *kobj, |
||
68 | struct kobject *target, |
||
69 | const char *name); |
||
70 | void sysfs_remove_link(struct kobject *kobj, const char *name); |
||
71 | |||
72 | int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target, |
||
73 | const char *old_name, const char *new_name, |
||
74 | const void *new_ns); |
||
75 | |||
76 | void sysfs_delete_link(struct kobject *dir, struct kobject *targ, |
||
77 | const char *name); |
||
78 | |||
79 | int __must_check sysfs_create_group(struct kobject *kobj, |
||
80 | const struct attribute_group *grp); |
||
81 | int __must_check sysfs_create_groups(struct kobject *kobj, |
||
82 | const struct attribute_group **groups); |
||
83 | int sysfs_update_group(struct kobject *kobj, |
||
84 | const struct attribute_group *grp); |
||
85 | void sysfs_remove_group(struct kobject *kobj, |
||
86 | const struct attribute_group *grp); |
||
87 | void sysfs_remove_groups(struct kobject *kobj, |
||
88 | const struct attribute_group **groups); |
||
89 | int sysfs_add_file_to_group(struct kobject *kobj, |
||
90 | const struct attribute *attr, const char *group); |
||
91 | void sysfs_remove_file_from_group(struct kobject *kobj, |
||
92 | const struct attribute *attr, const char *group); |
||
93 | int sysfs_merge_group(struct kobject *kobj, |
||
94 | const struct attribute_group *grp); |
||
95 | void sysfs_unmerge_group(struct kobject *kobj, |
||
96 | const struct attribute_group *grp); |
||
97 | int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name, |
||
98 | struct kobject *target, const char *link_name); |
||
99 | void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name, |
||
100 | const char *link_name); |
||
101 | int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj, |
||
102 | struct kobject *target_kobj, |
||
103 | const char *target_name); |
||
104 | |||
105 | void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); |
||
106 | |||
107 | int __must_check sysfs_init(void); |
||
108 | |||
109 | static inline void sysfs_enable_ns(struct kernfs_node *kn) |
||
110 | { |
||
111 | return kernfs_enable_ns(kn); |
||
112 | } |
||
113 | |||
114 | #else /* CONFIG_SYSFS */ |
||
115 | |||
116 | static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) |
||
117 | { |
||
118 | return 0; |
||
119 | } |
||
120 | |||
121 | static inline void sysfs_remove_dir(struct kobject *kobj) |
||
122 | { |
||
123 | } |
||
124 | |||
125 | static inline int sysfs_rename_dir_ns(struct kobject *kobj, |
||
126 | const char *new_name, const void *new_ns) |
||
127 | { |
||
128 | return 0; |
||
129 | } |
||
130 | |||
131 | static inline int sysfs_move_dir_ns(struct kobject *kobj, |
||
132 | struct kobject *new_parent_kobj, |
||
133 | const void *new_ns) |
||
134 | { |
||
135 | return 0; |
||
136 | } |
||
137 | |||
138 | static inline int sysfs_create_mount_point(struct kobject *parent_kobj, |
||
139 | const char *name) |
||
140 | { |
||
141 | return 0; |
||
142 | } |
||
143 | |||
144 | static inline void sysfs_remove_mount_point(struct kobject *parent_kobj, |
||
145 | const char *name) |
||
146 | { |
||
147 | } |
||
148 | |||
149 | static inline int sysfs_create_file_ns(struct kobject *kobj, |
||
150 | const struct attribute *attr, |
||
151 | const void *ns) |
||
152 | { |
||
153 | return 0; |
||
154 | } |
||
155 | |||
156 | static inline int sysfs_create_files(struct kobject *kobj, |
||
157 | const struct attribute **attr) |
||
158 | { |
||
159 | return 0; |
||
160 | } |
||
161 | |||
162 | static inline int sysfs_chmod_file(struct kobject *kobj, |
||
163 | const struct attribute *attr, umode_t mode) |
||
164 | { |
||
165 | return 0; |
||
166 | } |
||
167 | |||
168 | static inline void sysfs_remove_file_ns(struct kobject *kobj, |
||
169 | const struct attribute *attr, |
||
170 | const void *ns) |
||
171 | { |
||
172 | } |
||
173 | |||
174 | static inline bool sysfs_remove_file_self(struct kobject *kobj, |
||
175 | const struct attribute *attr) |
||
176 | { |
||
177 | return false; |
||
178 | } |
||
179 | |||
180 | static inline void sysfs_remove_files(struct kobject *kobj, |
||
181 | const struct attribute **attr) |
||
182 | { |
||
183 | } |
||
184 | |||
185 | static inline int sysfs_create_bin_file(struct kobject *kobj, |
||
186 | const struct bin_attribute *attr) |
||
187 | { |
||
188 | return 0; |
||
189 | } |
||
190 | |||
191 | static inline void sysfs_remove_bin_file(struct kobject *kobj, |
||
192 | const struct bin_attribute *attr) |
||
193 | { |
||
194 | } |
||
195 | |||
196 | #define sysfs_create_link(kobj,target, name) (0) |
||
197 | |||
198 | static inline int sysfs_create_link_nowarn(struct kobject *kobj, |
||
199 | struct kobject *target, |
||
200 | const char *name) |
||
201 | { |
||
202 | return 0; |
||
203 | } |
||
204 | |||
205 | #define sysfs_remove_link(kobj, name) |
||
206 | |||
207 | static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t, |
||
208 | const char *old_name, |
||
209 | const char *new_name, const void *ns) |
||
210 | { |
||
211 | return 0; |
||
212 | } |
||
213 | |||
214 | static inline void sysfs_delete_link(struct kobject *k, struct kobject *t, |
||
215 | const char *name) |
||
216 | { |
||
217 | } |
||
218 | |||
219 | |||
220 | static inline int sysfs_add_file_to_group(struct kobject *kobj, |
||
221 | const struct attribute *attr, const char *group) |
||
222 | { |
||
223 | return 0; |
||
224 | } |
||
225 | |||
226 | static inline void sysfs_remove_file_from_group(struct kobject *kobj, |
||
227 | const struct attribute *attr, const char *group) |
||
228 | { |
||
229 | } |
||
230 | |||
231 | static inline int sysfs_add_link_to_group(struct kobject *kobj, |
||
232 | const char *group_name, struct kobject *target, |
||
233 | const char *link_name) |
||
234 | { |
||
235 | return 0; |
||
236 | } |
||
237 | |||
238 | static inline void sysfs_remove_link_from_group(struct kobject *kobj, |
||
239 | const char *group_name, const char *link_name) |
||
240 | { |
||
241 | } |
||
242 | |||
243 | static inline int __compat_only_sysfs_link_entry_to_kobj( |
||
244 | struct kobject *kobj, |
||
245 | struct kobject *target_kobj, |
||
246 | const char *target_name) |
||
247 | { |
||
248 | return 0; |
||
249 | } |
||
250 | |||
251 | static inline void sysfs_notify(struct kobject *kobj, const char *dir, |
||
252 | const char *attr) |
||
253 | { |
||
254 | } |
||
255 | |||
256 | static inline int __must_check sysfs_init(void) |
||
257 | { |
||
258 | return 0; |
||
259 | } |
||
260 | |||
261 | #endif /* CONFIG_SYSFS */ |
||
262 | #endif /* _SYSFS_H_ */ |