Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * sysfs.h - definitions for the device driver filesystem
4 *
5 * Copyright (c) 2001,2002 Patrick Mochel
6 * Copyright (c) 2004 Silicon Graphics, Inc.
7 * Copyright (c) 2007 SUSE Linux Products GmbH
8 * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
9 *
10 * Please see Documentation/filesystems/sysfs.rst for more information.
11 */
12
13#ifndef _SYSFS_H_
14#define _SYSFS_H_
15
16#include <linux/kernfs.h>
17#include <linux/compiler.h>
18#include <linux/errno.h>
19#include <linux/list.h>
20#include <linux/lockdep.h>
21#include <linux/kobject_ns.h>
22#include <linux/stat.h>
23#include <linux/atomic.h>
24
25struct kobject;
26struct module;
27struct bin_attribute;
28enum kobj_ns_type;
29
30struct attribute {
31 const char *name;
32 umode_t mode;
33#ifdef CONFIG_DEBUG_LOCK_ALLOC
34 bool ignore_lockdep:1;
35 struct lock_class_key *key;
36 struct lock_class_key skey;
37#endif
38};
39
40/**
41 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
42 * @attr: struct attribute to initialize
43 *
44 * Initialize a dynamically allocated struct attribute so we can
45 * make lockdep happy. This is a new requirement for attributes
46 * and initially this is only needed when lockdep is enabled.
47 * Lockdep gives a nice error when your attribute is added to
48 * sysfs if you don't have this.
49 */
50#ifdef CONFIG_DEBUG_LOCK_ALLOC
51#define sysfs_attr_init(attr) \
52do { \
53 static struct lock_class_key __key; \
54 \
55 (attr)->key = &__key; \
56} while (0)
57#else
58#define sysfs_attr_init(attr) do {} while (0)
59#endif
60
61#ifdef CONFIG_CFI
62#define __SYSFS_FUNCTION_ALTERNATIVE(MEMBERS...) struct { MEMBERS }
63#else
64#define __SYSFS_FUNCTION_ALTERNATIVE(MEMBERS...) union { MEMBERS }
65#endif
66
67/**
68 * struct attribute_group - data structure used to declare an attribute group.
69 * @name: Optional: Attribute group name
70 * If specified, the attribute group will be created in a
71 * new subdirectory with this name. Additionally when a
72 * group is named, @is_visible and @is_bin_visible may
73 * return SYSFS_GROUP_INVISIBLE to control visibility of
74 * the directory itself.
75 * @is_visible: Optional: Function to return permissions associated with an
76 * attribute of the group. Will be called repeatedly for
77 * each non-binary attribute in the group. Only read/write
78 * permissions as well as SYSFS_PREALLOC are accepted. Must
79 * return 0 if an attribute is not visible. The returned
80 * value will replace static permissions defined in struct
81 * attribute. Use SYSFS_GROUP_VISIBLE() when assigning this
82 * callback to specify separate _group_visible() and
83 * _attr_visible() handlers.
84 * @is_bin_visible:
85 * Optional: Function to return permissions associated with a
86 * binary attribute of the group. Will be called repeatedly
87 * for each binary attribute in the group. Only read/write
88 * permissions as well as SYSFS_PREALLOC (and the
89 * visibility flags for named groups) are accepted. Must
90 * return 0 if a binary attribute is not visible. The
91 * returned value will replace static permissions defined
92 * in struct bin_attribute. If @is_visible is not set, Use
93 * SYSFS_GROUP_VISIBLE() when assigning this callback to
94 * specify separate _group_visible() and _attr_visible()
95 * handlers.
96 * @bin_size:
97 * Optional: Function to return the size of a binary attribute
98 * of the group. Will be called repeatedly for each binary
99 * attribute in the group. Overwrites the size field embedded
100 * inside the attribute itself.
101 * @attrs: Pointer to NULL terminated list of attributes.
102 * @bin_attrs: Pointer to NULL terminated list of binary attributes.
103 * Either attrs or bin_attrs or both must be provided.
104 */
105struct attribute_group {
106 const char *name;
107 __SYSFS_FUNCTION_ALTERNATIVE(
108 umode_t (*is_visible)(struct kobject *,
109 struct attribute *, int);
110 umode_t (*is_visible_const)(struct kobject *,
111 const struct attribute *, int);
112 );
113 umode_t (*is_bin_visible)(struct kobject *,
114 const struct bin_attribute *, int);
115 size_t (*bin_size)(struct kobject *,
116 const struct bin_attribute *,
117 int);
118 union {
119 struct attribute **attrs;
120 const struct attribute *const *attrs_const;
121 };
122 const struct bin_attribute *const *bin_attrs;
123};
124
125#define SYSFS_PREALLOC 010000
126#define SYSFS_GROUP_INVISIBLE 020000
127
128/*
129 * DEFINE_SYSFS_GROUP_VISIBLE(name):
130 * A helper macro to pair with the assignment of ".is_visible =
131 * SYSFS_GROUP_VISIBLE(name)", that arranges for the directory
132 * associated with a named attribute_group to optionally be hidden.
133 * This allows for static declaration of attribute_groups, and the
134 * simplification of attribute visibility lifetime that implies,
135 * without polluting sysfs with empty attribute directories.
136 * Ex.
137 *
138 * static umode_t example_attr_visible(struct kobject *kobj,
139 * struct attribute *attr, int n)
140 * {
141 * if (example_attr_condition)
142 * return 0;
143 * else if (ro_attr_condition)
144 * return 0444;
145 * return a->mode;
146 * }
147 *
148 * static bool example_group_visible(struct kobject *kobj)
149 * {
150 * if (example_group_condition)
151 * return false;
152 * return true;
153 * }
154 *
155 * DEFINE_SYSFS_GROUP_VISIBLE(example);
156 *
157 * static struct attribute_group example_group = {
158 * .name = "example",
159 * .is_visible = SYSFS_GROUP_VISIBLE(example),
160 * .attrs = &example_attrs,
161 * };
162 *
163 * Note that it expects <name>_attr_visible and <name>_group_visible to
164 * be defined. For cases where individual attributes do not need
165 * separate visibility consideration, only entire group visibility at
166 * once, see DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE().
167 */
168#define DEFINE_SYSFS_GROUP_VISIBLE(name) \
169 static inline umode_t sysfs_group_visible_##name( \
170 struct kobject *kobj, struct attribute *attr, int n) \
171 { \
172 if (n == 0 && !name##_group_visible(kobj)) \
173 return SYSFS_GROUP_INVISIBLE; \
174 return name##_attr_visible(kobj, attr, n); \
175 }
176
177/*
178 * DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name):
179 * A helper macro to pair with SYSFS_GROUP_VISIBLE() that like
180 * DEFINE_SYSFS_GROUP_VISIBLE() controls group visibility, but does
181 * not require the implementation of a per-attribute visibility
182 * callback.
183 * Ex.
184 *
185 * static bool example_group_visible(struct kobject *kobj)
186 * {
187 * if (example_group_condition)
188 * return false;
189 * return true;
190 * }
191 *
192 * DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(example);
193 *
194 * static struct attribute_group example_group = {
195 * .name = "example",
196 * .is_visible = SYSFS_GROUP_VISIBLE(example),
197 * .attrs = &example_attrs,
198 * };
199 */
200#define DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name) \
201 static inline umode_t sysfs_group_visible_##name( \
202 struct kobject *kobj, struct attribute *a, int n) \
203 { \
204 if (n == 0 && !name##_group_visible(kobj)) \
205 return SYSFS_GROUP_INVISIBLE; \
206 return a->mode; \
207 }
208
209/*
210 * Same as DEFINE_SYSFS_GROUP_VISIBLE, but for groups with only binary
211 * attributes. If an attribute_group defines both text and binary
212 * attributes, the group visibility is determined by the function
213 * specified to is_visible() not is_bin_visible()
214 */
215#define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) \
216 static inline umode_t sysfs_group_visible_##name( \
217 struct kobject *kobj, const struct bin_attribute *attr, int n) \
218 { \
219 if (n == 0 && !name##_group_visible(kobj)) \
220 return SYSFS_GROUP_INVISIBLE; \
221 return name##_attr_visible(kobj, attr, n); \
222 }
223
224#define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) \
225 static inline umode_t sysfs_group_visible_##name( \
226 struct kobject *kobj, const struct bin_attribute *a, int n) \
227 { \
228 if (n == 0 && !name##_group_visible(kobj)) \
229 return SYSFS_GROUP_INVISIBLE; \
230 return a->mode; \
231 }
232
233#define SYSFS_GROUP_VISIBLE(fn) sysfs_group_visible_##fn
234
235/*
236 * Use these macros to make defining attributes easier.
237 * See include/linux/device.h for examples..
238 */
239
240#define __ATTR(_name, _mode, _show, _store) { \
241 .attr = {.name = __stringify(_name), \
242 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
243 .show = _show, \
244 .store = _store, \
245}
246
247#define __ATTR_PREALLOC(_name, _mode, _show, _store) { \
248 .attr = {.name = __stringify(_name), \
249 .mode = SYSFS_PREALLOC | VERIFY_OCTAL_PERMISSIONS(_mode) },\
250 .show = _show, \
251 .store = _store, \
252}
253
254#define __ATTR_RO_MODE(_name, _mode) { \
255 .attr = { .name = __stringify(_name), \
256 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
257 .show = _name##_show, \
258}
259
260#define __ATTR_RO(_name) \
261 __ATTR_RO_MODE(_name, 0444)
262
263#define __ATTR_RW_MODE(_name, _mode) \
264 __ATTR(_name, _mode, _name##_show, _name##_store)
265
266#define __ATTR_WO(_name) \
267 __ATTR(_name, 0200, NULL, _name##_store)
268
269#define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store)
270
271#define __ATTR_NULL { .attr = { .name = NULL } }
272
273#ifdef CONFIG_DEBUG_LOCK_ALLOC
274#define __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) { \
275 .attr = {.name = __stringify(_name), .mode = _mode, \
276 .ignore_lockdep = true }, \
277 .show = _show, \
278 .store = _store, \
279}
280#else
281#define __ATTR_IGNORE_LOCKDEP __ATTR
282#endif
283
284#define __ATTRIBUTE_GROUPS(_name) \
285static const struct attribute_group *_name##_groups[] = { \
286 &_name##_group, \
287 NULL, \
288}
289
290#define ATTRIBUTE_GROUPS(_name) \
291static const struct attribute_group _name##_group = { \
292 .attrs = _Generic(_name##_attrs, \
293 struct attribute **: \
294 _name##_attrs, \
295 const struct attribute *const *: \
296 (void *)_name##_attrs \
297 ), \
298}; \
299__ATTRIBUTE_GROUPS(_name)
300
301#define BIN_ATTRIBUTE_GROUPS(_name) \
302static const struct attribute_group _name##_group = { \
303 .bin_attrs = _name##_attrs, \
304}; \
305__ATTRIBUTE_GROUPS(_name)
306
307struct file;
308struct vm_area_struct;
309struct address_space;
310
311struct bin_attribute {
312 struct attribute attr;
313 size_t size;
314 void *private;
315 struct address_space *(*f_mapping)(void);
316 ssize_t (*read)(struct file *, struct kobject *, const struct bin_attribute *,
317 char *, loff_t, size_t);
318 ssize_t (*write)(struct file *, struct kobject *, const struct bin_attribute *,
319 char *, loff_t, size_t);
320 loff_t (*llseek)(struct file *, struct kobject *, const struct bin_attribute *,
321 loff_t, int);
322 int (*mmap)(struct file *, struct kobject *, const struct bin_attribute *attr,
323 struct vm_area_struct *vma);
324};
325
326/**
327 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
328 * @attr: struct bin_attribute to initialize
329 *
330 * Initialize a dynamically allocated struct bin_attribute so we
331 * can make lockdep happy. This is a new requirement for
332 * attributes and initially this is only needed when lockdep is
333 * enabled. Lockdep gives a nice error when your attribute is
334 * added to sysfs if you don't have this.
335 */
336#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
337
338/* macros to create static binary attributes easier */
339#define __BIN_ATTR(_name, _mode, _read, _write, _size) { \
340 .attr = { .name = __stringify(_name), .mode = _mode }, \
341 .read = _read, \
342 .write = _write, \
343 .size = _size, \
344}
345
346#define __BIN_ATTR_RO(_name, _size) \
347 __BIN_ATTR(_name, 0444, _name##_read, NULL, _size)
348
349#define __BIN_ATTR_WO(_name, _size) \
350 __BIN_ATTR(_name, 0200, NULL, _name##_write, _size)
351
352#define __BIN_ATTR_RW(_name, _size) \
353 __BIN_ATTR(_name, 0644, _name##_read, _name##_write, _size)
354
355#define __BIN_ATTR_NULL __ATTR_NULL
356
357#define BIN_ATTR(_name, _mode, _read, _write, _size) \
358struct bin_attribute bin_attr_##_name = __BIN_ATTR(_name, _mode, _read, \
359 _write, _size)
360
361#define BIN_ATTR_RO(_name, _size) \
362struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size)
363
364#define BIN_ATTR_WO(_name, _size) \
365struct bin_attribute bin_attr_##_name = __BIN_ATTR_WO(_name, _size)
366
367#define BIN_ATTR_RW(_name, _size) \
368struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size)
369
370
371#define __BIN_ATTR_ADMIN_RO(_name, _size) \
372 __BIN_ATTR(_name, 0400, _name##_read, NULL, _size)
373
374#define __BIN_ATTR_ADMIN_RW(_name, _size) \
375 __BIN_ATTR(_name, 0600, _name##_read, _name##_write, _size)
376
377#define BIN_ATTR_ADMIN_RO(_name, _size) \
378struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RO(_name, _size)
379
380#define BIN_ATTR_ADMIN_RW(_name, _size) \
381struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RW(_name, _size)
382
383#define __BIN_ATTR_SIMPLE_RO(_name, _mode) \
384 __BIN_ATTR(_name, _mode, sysfs_bin_attr_simple_read, NULL, 0)
385
386#define BIN_ATTR_SIMPLE_RO(_name) \
387struct bin_attribute bin_attr_##_name = __BIN_ATTR_SIMPLE_RO(_name, 0444)
388
389#define BIN_ATTR_SIMPLE_ADMIN_RO(_name) \
390struct bin_attribute bin_attr_##_name = __BIN_ATTR_SIMPLE_RO(_name, 0400)
391
392struct sysfs_ops {
393 ssize_t (*show)(struct kobject *, struct attribute *, char *);
394 ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t);
395};
396
397#ifdef CONFIG_SYSFS
398
399int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns);
400void sysfs_remove_dir(struct kobject *kobj);
401int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
402 const void *new_ns);
403int __must_check sysfs_move_dir_ns(struct kobject *kobj,
404 struct kobject *new_parent_kobj,
405 const void *new_ns);
406int __must_check sysfs_create_mount_point(struct kobject *parent_kobj,
407 const char *name);
408void sysfs_remove_mount_point(struct kobject *parent_kobj,
409 const char *name);
410
411int __must_check sysfs_create_file_ns(struct kobject *kobj,
412 const struct attribute *attr,
413 const void *ns);
414int __must_check sysfs_create_files(struct kobject *kobj,
415 const struct attribute * const *attr);
416int __must_check sysfs_chmod_file(struct kobject *kobj,
417 const struct attribute *attr, umode_t mode);
418struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj,
419 const struct attribute *attr);
420void sysfs_unbreak_active_protection(struct kernfs_node *kn);
421void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
422 const void *ns);
423bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
424void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);
425
426int __must_check sysfs_create_bin_file(struct kobject *kobj,
427 const struct bin_attribute *attr);
428void sysfs_remove_bin_file(struct kobject *kobj,
429 const struct bin_attribute *attr);
430
431int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
432 const char *name);
433int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
434 struct kobject *target,
435 const char *name);
436void sysfs_remove_link(struct kobject *kobj, const char *name);
437
438int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target,
439 const char *old_name, const char *new_name,
440 const void *new_ns);
441
442void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
443 const char *name);
444
445int __must_check sysfs_create_group(struct kobject *kobj,
446 const struct attribute_group *grp);
447int __must_check sysfs_create_groups(struct kobject *kobj,
448 const struct attribute_group **groups);
449int __must_check sysfs_update_groups(struct kobject *kobj,
450 const struct attribute_group **groups);
451int sysfs_update_group(struct kobject *kobj,
452 const struct attribute_group *grp);
453void sysfs_remove_group(struct kobject *kobj,
454 const struct attribute_group *grp);
455void sysfs_remove_groups(struct kobject *kobj,
456 const struct attribute_group **groups);
457int sysfs_add_file_to_group(struct kobject *kobj,
458 const struct attribute *attr, const char *group);
459void sysfs_remove_file_from_group(struct kobject *kobj,
460 const struct attribute *attr, const char *group);
461int sysfs_merge_group(struct kobject *kobj,
462 const struct attribute_group *grp);
463void sysfs_unmerge_group(struct kobject *kobj,
464 const struct attribute_group *grp);
465int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name,
466 struct kobject *target, const char *link_name);
467void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
468 const char *link_name);
469int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
470 struct kobject *target_kobj,
471 const char *target_name,
472 const char *symlink_name);
473
474void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
475
476int __must_check sysfs_init(void);
477
478static inline void sysfs_enable_ns(struct kernfs_node *kn)
479{
480 return kernfs_enable_ns(kn);
481}
482
483int sysfs_file_change_owner(struct kobject *kobj, const char *name, kuid_t kuid,
484 kgid_t kgid);
485int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid);
486int sysfs_link_change_owner(struct kobject *kobj, struct kobject *targ,
487 const char *name, kuid_t kuid, kgid_t kgid);
488int sysfs_groups_change_owner(struct kobject *kobj,
489 const struct attribute_group **groups,
490 kuid_t kuid, kgid_t kgid);
491int sysfs_group_change_owner(struct kobject *kobj,
492 const struct attribute_group *groups, kuid_t kuid,
493 kgid_t kgid);
494__printf(2, 3)
495int sysfs_emit(char *buf, const char *fmt, ...);
496__printf(3, 4)
497int sysfs_emit_at(char *buf, int at, const char *fmt, ...);
498
499ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj,
500 const struct bin_attribute *attr, char *buf,
501 loff_t off, size_t count);
502
503#else /* CONFIG_SYSFS */
504
505static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
506{
507 return 0;
508}
509
510static inline void sysfs_remove_dir(struct kobject *kobj)
511{
512}
513
514static inline int sysfs_rename_dir_ns(struct kobject *kobj,
515 const char *new_name, const void *new_ns)
516{
517 return 0;
518}
519
520static inline int sysfs_move_dir_ns(struct kobject *kobj,
521 struct kobject *new_parent_kobj,
522 const void *new_ns)
523{
524 return 0;
525}
526
527static inline int sysfs_create_mount_point(struct kobject *parent_kobj,
528 const char *name)
529{
530 return 0;
531}
532
533static inline void sysfs_remove_mount_point(struct kobject *parent_kobj,
534 const char *name)
535{
536}
537
538static inline int sysfs_create_file_ns(struct kobject *kobj,
539 const struct attribute *attr,
540 const void *ns)
541{
542 return 0;
543}
544
545static inline int sysfs_create_files(struct kobject *kobj,
546 const struct attribute * const *attr)
547{
548 return 0;
549}
550
551static inline int sysfs_chmod_file(struct kobject *kobj,
552 const struct attribute *attr, umode_t mode)
553{
554 return 0;
555}
556
557static inline struct kernfs_node *
558sysfs_break_active_protection(struct kobject *kobj,
559 const struct attribute *attr)
560{
561 return NULL;
562}
563
564static inline void sysfs_unbreak_active_protection(struct kernfs_node *kn)
565{
566}
567
568static inline void sysfs_remove_file_ns(struct kobject *kobj,
569 const struct attribute *attr,
570 const void *ns)
571{
572}
573
574static inline bool sysfs_remove_file_self(struct kobject *kobj,
575 const struct attribute *attr)
576{
577 return false;
578}
579
580static inline void sysfs_remove_files(struct kobject *kobj,
581 const struct attribute * const *attr)
582{
583}
584
585static inline int sysfs_create_bin_file(struct kobject *kobj,
586 const struct bin_attribute *attr)
587{
588 return 0;
589}
590
591static inline void sysfs_remove_bin_file(struct kobject *kobj,
592 const struct bin_attribute *attr)
593{
594}
595
596static inline int sysfs_create_link(struct kobject *kobj,
597 struct kobject *target, const char *name)
598{
599 return 0;
600}
601
602static inline int sysfs_create_link_nowarn(struct kobject *kobj,
603 struct kobject *target,
604 const char *name)
605{
606 return 0;
607}
608
609static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
610{
611}
612
613static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t,
614 const char *old_name,
615 const char *new_name, const void *ns)
616{
617 return 0;
618}
619
620static inline void sysfs_delete_link(struct kobject *k, struct kobject *t,
621 const char *name)
622{
623}
624
625static inline int sysfs_create_group(struct kobject *kobj,
626 const struct attribute_group *grp)
627{
628 return 0;
629}
630
631static inline int sysfs_create_groups(struct kobject *kobj,
632 const struct attribute_group **groups)
633{
634 return 0;
635}
636
637static inline int sysfs_update_groups(struct kobject *kobj,
638 const struct attribute_group **groups)
639{
640 return 0;
641}
642
643static inline int sysfs_update_group(struct kobject *kobj,
644 const struct attribute_group *grp)
645{
646 return 0;
647}
648
649static inline void sysfs_remove_group(struct kobject *kobj,
650 const struct attribute_group *grp)
651{
652}
653
654static inline void sysfs_remove_groups(struct kobject *kobj,
655 const struct attribute_group **groups)
656{
657}
658
659static inline int sysfs_add_file_to_group(struct kobject *kobj,
660 const struct attribute *attr, const char *group)
661{
662 return 0;
663}
664
665static inline void sysfs_remove_file_from_group(struct kobject *kobj,
666 const struct attribute *attr, const char *group)
667{
668}
669
670static inline int sysfs_merge_group(struct kobject *kobj,
671 const struct attribute_group *grp)
672{
673 return 0;
674}
675
676static inline void sysfs_unmerge_group(struct kobject *kobj,
677 const struct attribute_group *grp)
678{
679}
680
681static inline int sysfs_add_link_to_group(struct kobject *kobj,
682 const char *group_name, struct kobject *target,
683 const char *link_name)
684{
685 return 0;
686}
687
688static inline void sysfs_remove_link_from_group(struct kobject *kobj,
689 const char *group_name, const char *link_name)
690{
691}
692
693static inline int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
694 struct kobject *target_kobj,
695 const char *target_name,
696 const char *symlink_name)
697{
698 return 0;
699}
700
701static inline void sysfs_notify(struct kobject *kobj, const char *dir,
702 const char *attr)
703{
704}
705
706static inline int __must_check sysfs_init(void)
707{
708 return 0;
709}
710
711static inline void sysfs_enable_ns(struct kernfs_node *kn)
712{
713}
714
715static inline int sysfs_file_change_owner(struct kobject *kobj,
716 const char *name, kuid_t kuid,
717 kgid_t kgid)
718{
719 return 0;
720}
721
722static inline int sysfs_link_change_owner(struct kobject *kobj,
723 struct kobject *targ,
724 const char *name, kuid_t kuid,
725 kgid_t kgid)
726{
727 return 0;
728}
729
730static inline int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid)
731{
732 return 0;
733}
734
735static inline int sysfs_groups_change_owner(struct kobject *kobj,
736 const struct attribute_group **groups,
737 kuid_t kuid, kgid_t kgid)
738{
739 return 0;
740}
741
742static inline int sysfs_group_change_owner(struct kobject *kobj,
743 const struct attribute_group *groups,
744 kuid_t kuid, kgid_t kgid)
745{
746 return 0;
747}
748
749__printf(2, 3)
750static inline int sysfs_emit(char *buf, const char *fmt, ...)
751{
752 return 0;
753}
754
755__printf(3, 4)
756static inline int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
757{
758 return 0;
759}
760
761static inline ssize_t sysfs_bin_attr_simple_read(struct file *file,
762 struct kobject *kobj,
763 const struct bin_attribute *attr,
764 char *buf, loff_t off,
765 size_t count)
766{
767 return 0;
768}
769#endif /* CONFIG_SYSFS */
770
771static inline int __must_check sysfs_create_file(struct kobject *kobj,
772 const struct attribute *attr)
773{
774 return sysfs_create_file_ns(kobj, attr, NULL);
775}
776
777static inline void sysfs_remove_file(struct kobject *kobj,
778 const struct attribute *attr)
779{
780 sysfs_remove_file_ns(kobj, attr, NULL);
781}
782
783static inline int sysfs_rename_link(struct kobject *kobj, struct kobject *target,
784 const char *old_name, const char *new_name)
785{
786 return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL);
787}
788
789static inline void sysfs_notify_dirent(struct kernfs_node *kn)
790{
791 kernfs_notify(kn);
792}
793
794static inline struct kernfs_node *sysfs_get_dirent(struct kernfs_node *parent,
795 const char *name)
796{
797 return kernfs_find_and_get(parent, name);
798}
799
800static inline struct kernfs_node *sysfs_get(struct kernfs_node *kn)
801{
802 kernfs_get(kn);
803 return kn;
804}
805
806static inline void sysfs_put(struct kernfs_node *kn)
807{
808 kernfs_put(kn);
809}
810
811#endif /* _SYSFS_H_ */