aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/kernfs.h166
-rw-r--r--include/linux/kobject.h2
-rw-r--r--include/linux/sysfs.h20
3 files changed, 94 insertions, 94 deletions
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index d65541308419..195d1c6a8b0c 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -46,61 +46,61 @@ enum kernfs_node_flag {
46 SYSFS_FLAG_LOCKDEP = 0x0100, 46 SYSFS_FLAG_LOCKDEP = 0x0100,
47}; 47};
48 48
49/* type-specific structures for sysfs_dirent->s_* union members */ 49/* type-specific structures for kernfs_node union members */
50struct sysfs_elem_dir { 50struct kernfs_elem_dir {
51 unsigned long subdirs; 51 unsigned long subdirs;
52 /* children rbtree starts here and goes through sd->s_rb */ 52 /* children rbtree starts here and goes through kn->s_rb */
53 struct rb_root children; 53 struct rb_root children;
54 54
55 /* 55 /*
56 * The kernfs hierarchy this directory belongs to. This fits 56 * The kernfs hierarchy this directory belongs to. This fits
57 * better directly in sysfs_dirent but is here to save space. 57 * better directly in kernfs_node but is here to save space.
58 */ 58 */
59 struct kernfs_root *root; 59 struct kernfs_root *root;
60}; 60};
61 61
62struct sysfs_elem_symlink { 62struct kernfs_elem_symlink {
63 struct sysfs_dirent *target_sd; 63 struct kernfs_node *target_kn;
64}; 64};
65 65
66struct sysfs_elem_attr { 66struct kernfs_elem_attr {
67 const struct kernfs_ops *ops; 67 const struct kernfs_ops *ops;
68 struct sysfs_open_dirent *open; 68 struct sysfs_open_dirent *open;
69 loff_t size; 69 loff_t size;
70}; 70};
71 71
72/* 72/*
73 * sysfs_dirent - the building block of sysfs hierarchy. Each and every 73 * kernfs_node - the building block of kernfs hierarchy. Each and every
74 * sysfs node is represented by single sysfs_dirent. Most fields are 74 * kernfs node is represented by single kernfs_node. Most fields are
75 * private to kernfs and shouldn't be accessed directly by kernfs users. 75 * private to kernfs and shouldn't be accessed directly by kernfs users.
76 * 76 *
77 * As long as s_count reference is held, the sysfs_dirent itself is 77 * As long as s_count reference is held, the kernfs_node itself is
78 * accessible. Dereferencing s_elem or any other outer entity 78 * accessible. Dereferencing elem or any other outer entity requires
79 * requires s_active reference. 79 * active reference.
80 */ 80 */
81struct sysfs_dirent { 81struct kernfs_node {
82 atomic_t s_count; 82 atomic_t s_count;
83 atomic_t s_active; 83 atomic_t s_active;
84#ifdef CONFIG_DEBUG_LOCK_ALLOC 84#ifdef CONFIG_DEBUG_LOCK_ALLOC
85 struct lockdep_map dep_map; 85 struct lockdep_map dep_map;
86#endif 86#endif
87 /* the following two fields are published */ 87 /* the following two fields are published */
88 struct sysfs_dirent *s_parent; 88 struct kernfs_node *s_parent;
89 const char *s_name; 89 const char *s_name;
90 90
91 struct rb_node s_rb; 91 struct rb_node s_rb;
92 92
93 union { 93 union {
94 struct completion *completion; 94 struct completion *completion;
95 struct sysfs_dirent *removed_list; 95 struct kernfs_node *removed_list;
96 } u; 96 } u;
97 97
98 const void *s_ns; /* namespace tag */ 98 const void *s_ns; /* namespace tag */
99 unsigned int s_hash; /* ns + name hash */ 99 unsigned int s_hash; /* ns + name hash */
100 union { 100 union {
101 struct sysfs_elem_dir s_dir; 101 struct kernfs_elem_dir s_dir;
102 struct sysfs_elem_symlink s_symlink; 102 struct kernfs_elem_symlink s_symlink;
103 struct sysfs_elem_attr s_attr; 103 struct kernfs_elem_attr s_attr;
104 }; 104 };
105 105
106 void *priv; 106 void *priv;
@@ -113,7 +113,7 @@ struct sysfs_dirent {
113 113
114struct kernfs_root { 114struct kernfs_root {
115 /* published fields */ 115 /* published fields */
116 struct sysfs_dirent *sd; 116 struct kernfs_node *kn;
117 117
118 /* private fields, do not use outside kernfs proper */ 118 /* private fields, do not use outside kernfs proper */
119 struct ida ino_ida; 119 struct ida ino_ida;
@@ -121,7 +121,7 @@ struct kernfs_root {
121 121
122struct sysfs_open_file { 122struct sysfs_open_file {
123 /* published fields */ 123 /* published fields */
124 struct sysfs_dirent *sd; 124 struct kernfs_node *kn;
125 struct file *file; 125 struct file *file;
126 126
127 /* private fields, do not use outside kernfs proper */ 127 /* private fields, do not use outside kernfs proper */
@@ -170,64 +170,64 @@ struct kernfs_ops {
170 170
171#ifdef CONFIG_SYSFS 171#ifdef CONFIG_SYSFS
172 172
173static inline enum kernfs_node_type sysfs_type(struct sysfs_dirent *sd) 173static inline enum kernfs_node_type sysfs_type(struct kernfs_node *kn)
174{ 174{
175 return sd->s_flags & SYSFS_TYPE_MASK; 175 return kn->s_flags & SYSFS_TYPE_MASK;
176} 176}
177 177
178/** 178/**
179 * kernfs_enable_ns - enable namespace under a directory 179 * kernfs_enable_ns - enable namespace under a directory
180 * @sd: directory of interest, should be empty 180 * @kn: directory of interest, should be empty
181 * 181 *
182 * This is to be called right after @sd is created to enable namespace 182 * This is to be called right after @kn is created to enable namespace
183 * under it. All children of @sd must have non-NULL namespace tags and 183 * under it. All children of @kn must have non-NULL namespace tags and
184 * only the ones which match the super_block's tag will be visible. 184 * only the ones which match the super_block's tag will be visible.
185 */ 185 */
186static inline void kernfs_enable_ns(struct sysfs_dirent *sd) 186static inline void kernfs_enable_ns(struct kernfs_node *kn)
187{ 187{
188 WARN_ON_ONCE(sysfs_type(sd) != SYSFS_DIR); 188 WARN_ON_ONCE(sysfs_type(kn) != SYSFS_DIR);
189 WARN_ON_ONCE(!RB_EMPTY_ROOT(&sd->s_dir.children)); 189 WARN_ON_ONCE(!RB_EMPTY_ROOT(&kn->s_dir.children));
190 sd->s_flags |= SYSFS_FLAG_NS; 190 kn->s_flags |= SYSFS_FLAG_NS;
191} 191}
192 192
193/** 193/**
194 * kernfs_ns_enabled - test whether namespace is enabled 194 * kernfs_ns_enabled - test whether namespace is enabled
195 * @sd: the node to test 195 * @kn: the node to test
196 * 196 *
197 * Test whether namespace filtering is enabled for the children of @ns. 197 * Test whether namespace filtering is enabled for the children of @ns.
198 */ 198 */
199static inline bool kernfs_ns_enabled(struct sysfs_dirent *sd) 199static inline bool kernfs_ns_enabled(struct kernfs_node *kn)
200{ 200{
201 return sd->s_flags & SYSFS_FLAG_NS; 201 return kn->s_flags & SYSFS_FLAG_NS;
202} 202}
203 203
204struct sysfs_dirent *kernfs_find_and_get_ns(struct sysfs_dirent *parent, 204struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
205 const char *name, const void *ns); 205 const char *name, const void *ns);
206void kernfs_get(struct sysfs_dirent *sd); 206void kernfs_get(struct kernfs_node *kn);
207void kernfs_put(struct sysfs_dirent *sd); 207void kernfs_put(struct kernfs_node *kn);
208 208
209struct kernfs_root *kernfs_create_root(void *priv); 209struct kernfs_root *kernfs_create_root(void *priv);
210void kernfs_destroy_root(struct kernfs_root *root); 210void kernfs_destroy_root(struct kernfs_root *root);
211 211
212struct sysfs_dirent *kernfs_create_dir_ns(struct sysfs_dirent *parent, 212struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
213 const char *name, void *priv, 213 const char *name, void *priv,
214 const void *ns); 214 const void *ns);
215struct sysfs_dirent *kernfs_create_file_ns_key(struct sysfs_dirent *parent, 215struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
216 const char *name, 216 const char *name,
217 umode_t mode, loff_t size, 217 umode_t mode, loff_t size,
218 const struct kernfs_ops *ops, 218 const struct kernfs_ops *ops,
219 void *priv, const void *ns, 219 void *priv, const void *ns,
220 struct lock_class_key *key); 220 struct lock_class_key *key);
221struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent, 221struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
222 const char *name, 222 const char *name,
223 struct sysfs_dirent *target); 223 struct kernfs_node *target);
224void kernfs_remove(struct sysfs_dirent *sd); 224void kernfs_remove(struct kernfs_node *kn);
225int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, const char *name, 225int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
226 const void *ns); 226 const void *ns);
227int kernfs_rename_ns(struct sysfs_dirent *sd, struct sysfs_dirent *new_parent, 227int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
228 const char *new_name, const void *new_ns); 228 const char *new_name, const void *new_ns);
229int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr); 229int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr);
230void kernfs_notify(struct sysfs_dirent *sd); 230void kernfs_notify(struct kernfs_node *kn);
231 231
232const void *kernfs_super_ns(struct super_block *sb); 232const void *kernfs_super_ns(struct super_block *sb);
233struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, 233struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
@@ -238,60 +238,60 @@ void kernfs_init(void);
238 238
239#else /* CONFIG_SYSFS */ 239#else /* CONFIG_SYSFS */
240 240
241static inline enum kernfs_node_type sysfs_type(struct sysfs_dirent *sd) 241static inline enum kernfs_node_type sysfs_type(struct kernfs_node *kn)
242{ return 0; } /* whatever */ 242{ return 0; } /* whatever */
243 243
244static inline void kernfs_enable_ns(struct sysfs_dirent *sd) { } 244static inline void kernfs_enable_ns(struct kernfs_node *kn) { }
245 245
246static inline bool kernfs_ns_enabled(struct sysfs_dirent *sd) 246static inline bool kernfs_ns_enabled(struct kernfs_node *kn)
247{ return false; } 247{ return false; }
248 248
249static inline struct sysfs_dirent * 249static inline struct kernfs_node *
250kernfs_find_and_get_ns(struct sysfs_dirent *parent, const char *name, 250kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name,
251 const void *ns) 251 const void *ns)
252{ return NULL; } 252{ return NULL; }
253 253
254static inline void kernfs_get(struct sysfs_dirent *sd) { } 254static inline void kernfs_get(struct kernfs_node *kn) { }
255static inline void kernfs_put(struct sysfs_dirent *sd) { } 255static inline void kernfs_put(struct kernfs_node *kn) { }
256 256
257static inline struct kernfs_root *kernfs_create_root(void *priv) 257static inline struct kernfs_root *kernfs_create_root(void *priv)
258{ return ERR_PTR(-ENOSYS); } 258{ return ERR_PTR(-ENOSYS); }
259 259
260static inline void kernfs_destroy_root(struct kernfs_root *root) { } 260static inline void kernfs_destroy_root(struct kernfs_root *root) { }
261 261
262static inline struct sysfs_dirent * 262static inline struct kernfs_node *
263kernfs_create_dir_ns(struct sysfs_dirent *parent, const char *name, void *priv, 263kernfs_create_dir_ns(struct kernfs_node *parent, const char *name, void *priv,
264 const void *ns) 264 const void *ns)
265{ return ERR_PTR(-ENOSYS); } 265{ return ERR_PTR(-ENOSYS); }
266 266
267static inline struct sysfs_dirent * 267static inline struct kernfs_node *
268kernfs_create_file_ns_key(struct sysfs_dirent *parent, const char *name, 268kernfs_create_file_ns_key(struct kernfs_node *parent, const char *name,
269 umode_t mode, loff_t size, 269 umode_t mode, loff_t size,
270 const struct kernfs_ops *ops, void *priv, 270 const struct kernfs_ops *ops, void *priv,
271 const void *ns, struct lock_class_key *key) 271 const void *ns, struct lock_class_key *key)
272{ return ERR_PTR(-ENOSYS); } 272{ return ERR_PTR(-ENOSYS); }
273 273
274static inline struct sysfs_dirent * 274static inline struct kernfs_node *
275kernfs_create_link(struct sysfs_dirent *parent, const char *name, 275kernfs_create_link(struct kernfs_node *parent, const char *name,
276 struct sysfs_dirent *target) 276 struct kernfs_node *target)
277{ return ERR_PTR(-ENOSYS); } 277{ return ERR_PTR(-ENOSYS); }
278 278
279static inline void kernfs_remove(struct sysfs_dirent *sd) { } 279static inline void kernfs_remove(struct kernfs_node *kn) { }
280 280
281static inline int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, 281static inline int kernfs_remove_by_name_ns(struct kernfs_node *kn,
282 const char *name, const void *ns) 282 const char *name, const void *ns)
283{ return -ENOSYS; } 283{ return -ENOSYS; }
284 284
285static inline int kernfs_rename_ns(struct sysfs_dirent *sd, 285static inline int kernfs_rename_ns(struct kernfs_node *kn,
286 struct sysfs_dirent *new_parent, 286 struct kernfs_node *new_parent,
287 const char *new_name, const void *new_ns) 287 const char *new_name, const void *new_ns)
288{ return -ENOSYS; } 288{ return -ENOSYS; }
289 289
290static inline int kernfs_setattr(struct sysfs_dirent *sd, 290static inline int kernfs_setattr(struct kernfs_node *kn,
291 const struct iattr *iattr) 291 const struct iattr *iattr)
292{ return -ENOSYS; } 292{ return -ENOSYS; }
293 293
294static inline void kernfs_notify(struct sysfs_dirent *sd) { } 294static inline void kernfs_notify(struct kernfs_node *kn) { }
295 295
296static inline const void *kernfs_super_ns(struct super_block *sb) 296static inline const void *kernfs_super_ns(struct super_block *sb)
297{ return NULL; } 297{ return NULL; }
@@ -307,20 +307,20 @@ static inline void kernfs_init(void) { }
307 307
308#endif /* CONFIG_SYSFS */ 308#endif /* CONFIG_SYSFS */
309 309
310static inline struct sysfs_dirent * 310static inline struct kernfs_node *
311kernfs_find_and_get(struct sysfs_dirent *sd, const char *name) 311kernfs_find_and_get(struct kernfs_node *kn, const char *name)
312{ 312{
313 return kernfs_find_and_get_ns(sd, name, NULL); 313 return kernfs_find_and_get_ns(kn, name, NULL);
314} 314}
315 315
316static inline struct sysfs_dirent * 316static inline struct kernfs_node *
317kernfs_create_dir(struct sysfs_dirent *parent, const char *name, void *priv) 317kernfs_create_dir(struct kernfs_node *parent, const char *name, void *priv)
318{ 318{
319 return kernfs_create_dir_ns(parent, name, priv, NULL); 319 return kernfs_create_dir_ns(parent, name, priv, NULL);
320} 320}
321 321
322static inline struct sysfs_dirent * 322static inline struct kernfs_node *
323kernfs_create_file_ns(struct sysfs_dirent *parent, const char *name, 323kernfs_create_file_ns(struct kernfs_node *parent, const char *name,
324 umode_t mode, loff_t size, const struct kernfs_ops *ops, 324 umode_t mode, loff_t size, const struct kernfs_ops *ops,
325 void *priv, const void *ns) 325 void *priv, const void *ns)
326{ 326{
@@ -333,14 +333,14 @@ kernfs_create_file_ns(struct sysfs_dirent *parent, const char *name,
333 ns, key); 333 ns, key);
334} 334}
335 335
336static inline struct sysfs_dirent * 336static inline struct kernfs_node *
337kernfs_create_file(struct sysfs_dirent *parent, const char *name, umode_t mode, 337kernfs_create_file(struct kernfs_node *parent, const char *name, umode_t mode,
338 loff_t size, const struct kernfs_ops *ops, void *priv) 338 loff_t size, const struct kernfs_ops *ops, void *priv)
339{ 339{
340 return kernfs_create_file_ns(parent, name, mode, size, ops, priv, NULL); 340 return kernfs_create_file_ns(parent, name, mode, size, ops, priv, NULL);
341} 341}
342 342
343static inline int kernfs_remove_by_name(struct sysfs_dirent *parent, 343static inline int kernfs_remove_by_name(struct kernfs_node *parent,
344 const char *name) 344 const char *name)
345{ 345{
346 return kernfs_remove_by_name_ns(parent, name, NULL); 346 return kernfs_remove_by_name_ns(parent, name, NULL);
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index e7ba650086ce..926afb6f6b5f 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -64,7 +64,7 @@ struct kobject {
64 struct kobject *parent; 64 struct kobject *parent;
65 struct kset *kset; 65 struct kset *kset;
66 struct kobj_type *ktype; 66 struct kobj_type *ktype;
67 struct sysfs_dirent *sd; 67 struct kernfs_node *sd;
68 struct kref kref; 68 struct kref kref;
69#ifdef CONFIG_DEBUG_KOBJECT_RELEASE 69#ifdef CONFIG_DEBUG_KOBJECT_RELEASE
70 struct delayed_work release; 70 struct delayed_work release;
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index cd8f90bf51a7..30b2ebee6439 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -438,26 +438,26 @@ static inline int sysfs_rename_link(struct kobject *kobj, struct kobject *target
438 return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL); 438 return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL);
439} 439}
440 440
441static inline void sysfs_notify_dirent(struct sysfs_dirent *sd) 441static inline void sysfs_notify_dirent(struct kernfs_node *kn)
442{ 442{
443 kernfs_notify(sd); 443 kernfs_notify(kn);
444} 444}
445 445
446static inline struct sysfs_dirent * 446static inline struct kernfs_node *sysfs_get_dirent(struct kernfs_node *parent,
447sysfs_get_dirent(struct sysfs_dirent *parent_sd, const unsigned char *name) 447 const unsigned char *name)
448{ 448{
449 return kernfs_find_and_get(parent_sd, name); 449 return kernfs_find_and_get(parent, name);
450} 450}
451 451
452static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) 452static inline struct kernfs_node *sysfs_get(struct kernfs_node *kn)
453{ 453{
454 kernfs_get(sd); 454 kernfs_get(kn);
455 return sd; 455 return kn;
456} 456}
457 457
458static inline void sysfs_put(struct sysfs_dirent *sd) 458static inline void sysfs_put(struct kernfs_node *kn)
459{ 459{
460 kernfs_put(sd); 460 kernfs_put(kn);
461} 461}
462 462
463#endif /* _SYSFS_H_ */ 463#endif /* _SYSFS_H_ */