]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/linux/sysfs.h
netfilter: add helper function to set up the nfnetlink header and use it
[mirror_ubuntu-jammy-kernel.git] / include / linux / sysfs.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
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.
6d66f5cd
TH
7 * Copyright (c) 2007 SUSE Linux Products GmbH
8 * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
1da177e4 9 *
0c1bc6b8 10 * Please see Documentation/filesystems/sysfs.rst for more information.
1da177e4
LT
11 */
12
13#ifndef _SYSFS_H_
14#define _SYSFS_H_
15
b8441ed2 16#include <linux/kernfs.h>
4a7fb636 17#include <linux/compiler.h>
5851fadc 18#include <linux/errno.h>
bf0acc33 19#include <linux/list.h>
6992f533 20#include <linux/lockdep.h>
8488a38f 21#include <linux/kobject_ns.h>
3493f69f 22#include <linux/stat.h>
60063497 23#include <linux/atomic.h>
1da177e4
LT
24
25struct kobject;
26struct module;
6ab9cea1 27struct bin_attribute;
3ff195b0 28enum kobj_ns_type;
1da177e4
LT
29
30struct attribute {
59f69015 31 const char *name;
9104e427 32 umode_t mode;
6992f533 33#ifdef CONFIG_DEBUG_LOCK_ALLOC
356c05d5 34 bool ignore_lockdep:1;
6992f533
EB
35 struct lock_class_key *key;
36 struct lock_class_key skey;
37#endif
1da177e4
LT
38};
39
35960258
EB
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 */
6992f533
EB
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; \
5da5c9c8 56} while (0)
6992f533 57#else
5da5c9c8 58#define sysfs_attr_init(attr) do {} while (0)
6992f533
EB
59#endif
60
ba61af6f
GR
61/**
62 * struct attribute_group - data structure used to declare an attribute group.
63 * @name: Optional: Attribute group name
64 * If specified, the attribute group will be created in
65 * a new subdirectory with this name.
66 * @is_visible: Optional: Function to return permissions associated with an
67 * attribute of the group. Will be called repeatedly for each
7f5028cf
EL
68 * non-binary attribute in the group. Only read/write
69 * permissions as well as SYSFS_PREALLOC are accepted. Must
70 * return 0 if an attribute is not visible. The returned value
71 * will replace static permissions defined in struct attribute.
72 * @is_bin_visible:
73 * Optional: Function to return permissions associated with a
74 * binary attribute of the group. Will be called repeatedly
75 * for each binary attribute in the group. Only read/write
76 * permissions as well as SYSFS_PREALLOC are accepted. Must
77 * return 0 if a binary attribute is not visible. The returned
78 * value will replace static permissions defined in
79 * struct bin_attribute.
ba61af6f
GR
80 * @attrs: Pointer to NULL terminated list of attributes.
81 * @bin_attrs: Pointer to NULL terminated list of binary attributes.
82 * Either attrs or bin_attrs or both must be provided.
83 */
1da177e4 84struct attribute_group {
59f69015 85 const char *name;
587a1f16 86 umode_t (*is_visible)(struct kobject *,
d4acd722 87 struct attribute *, int);
7f5028cf
EL
88 umode_t (*is_bin_visible)(struct kobject *,
89 struct bin_attribute *, int);
59f69015 90 struct attribute **attrs;
6ab9cea1 91 struct bin_attribute **bin_attrs;
1da177e4
LT
92};
93
3ec78790
RD
94/*
95 * Use these macros to make defining attributes easier.
96 * See include/linux/device.h for examples..
1da177e4
LT
97 */
98
2b75869b
N
99#define SYSFS_PREALLOC 010000
100
5da5c9c8 101#define __ATTR(_name, _mode, _show, _store) { \
58f86cc8
RR
102 .attr = {.name = __stringify(_name), \
103 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
aa01aa3c
OS
104 .show = _show, \
105 .store = _store, \
1da177e4
LT
106}
107
2b75869b
N
108#define __ATTR_PREALLOC(_name, _mode, _show, _store) { \
109 .attr = {.name = __stringify(_name), \
110 .mode = SYSFS_PREALLOC | VERIFY_OCTAL_PERMISSIONS(_mode) },\
111 .show = _show, \
112 .store = _store, \
113}
114
aa01aa3c 115#define __ATTR_RO(_name) { \
353c6dda 116 .attr = { .name = __stringify(_name), .mode = 0444 }, \
aa01aa3c 117 .show = _name##_show, \
1da177e4
LT
118}
119
af97a77b
GKH
120#define __ATTR_RO_MODE(_name, _mode) { \
121 .attr = { .name = __stringify(_name), \
122 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
123 .show = _name##_show, \
124}
125
3022c6a1
DW
126#define __ATTR_RW_MODE(_name, _mode) { \
127 .attr = { .name = __stringify(_name), \
128 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
129 .show = _name##_show, \
130 .store = _name##_store, \
131}
132
a65fcce7 133#define __ATTR_WO(_name) { \
353c6dda 134 .attr = { .name = __stringify(_name), .mode = 0200 }, \
a65fcce7
GKH
135 .store = _name##_store, \
136}
137
353c6dda 138#define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store)
b9b32597 139
1da177e4 140#define __ATTR_NULL { .attr = { .name = NULL } }
356c05d5
AS
141
142#ifdef CONFIG_DEBUG_LOCK_ALLOC
143#define __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) { \
144 .attr = {.name = __stringify(_name), .mode = _mode, \
145 .ignore_lockdep = true }, \
146 .show = _show, \
147 .store = _store, \
148}
149#else
150#define __ATTR_IGNORE_LOCKDEP __ATTR
151#endif
1da177e4 152
3493f69f
OS
153#define __ATTRIBUTE_GROUPS(_name) \
154static const struct attribute_group *_name##_groups[] = { \
155 &_name##_group, \
f2f37f58
GKH
156 NULL, \
157}
158
3493f69f
OS
159#define ATTRIBUTE_GROUPS(_name) \
160static const struct attribute_group _name##_group = { \
161 .attrs = _name##_attrs, \
162}; \
163__ATTRIBUTE_GROUPS(_name)
164
2c3c8bea 165struct file;
1da177e4 166struct vm_area_struct;
74b30195 167struct address_space;
1da177e4
LT
168
169struct bin_attribute {
170 struct attribute attr;
171 size_t size;
172 void *private;
74b30195 173 struct address_space *mapping;
2c3c8bea 174 ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
91a69029 175 char *, loff_t, size_t);
5da5c9c8 176 ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *,
91a69029 177 char *, loff_t, size_t);
2c3c8bea 178 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
1da177e4
LT
179 struct vm_area_struct *vma);
180};
181
35960258
EB
182/**
183 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
184 * @attr: struct bin_attribute to initialize
185 *
186 * Initialize a dynamically allocated struct bin_attribute so we
187 * can make lockdep happy. This is a new requirement for
188 * attributes and initially this is only needed when lockdep is
189 * enabled. Lockdep gives a nice error when your attribute is
190 * added to sysfs if you don't have this.
191 */
62e877b8 192#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
6992f533 193
3493f69f
OS
194/* macros to create static binary attributes easier */
195#define __BIN_ATTR(_name, _mode, _read, _write, _size) { \
196 .attr = { .name = __stringify(_name), .mode = _mode }, \
197 .read = _read, \
198 .write = _write, \
199 .size = _size, \
200}
201
202#define __BIN_ATTR_RO(_name, _size) { \
353c6dda 203 .attr = { .name = __stringify(_name), .mode = 0444 }, \
3493f69f
OS
204 .read = _name##_read, \
205 .size = _size, \
e4b63603
GKH
206}
207
82af5b66 208#define __BIN_ATTR_WO(_name, _size) { \
7f905761 209 .attr = { .name = __stringify(_name), .mode = 0200 }, \
82af5b66 210 .write = _name##_write, \
7f905761
GKH
211 .size = _size, \
212}
213
353c6dda
JP
214#define __BIN_ATTR_RW(_name, _size) \
215 __BIN_ATTR(_name, 0644, _name##_read, _name##_write, _size)
3493f69f
OS
216
217#define __BIN_ATTR_NULL __ATTR_NULL
218
219#define BIN_ATTR(_name, _mode, _read, _write, _size) \
220struct bin_attribute bin_attr_##_name = __BIN_ATTR(_name, _mode, _read, \
221 _write, _size)
222
223#define BIN_ATTR_RO(_name, _size) \
224struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size)
225
7f905761
GKH
226#define BIN_ATTR_WO(_name, _size) \
227struct bin_attribute bin_attr_##_name = __BIN_ATTR_WO(_name, _size)
228
3493f69f
OS
229#define BIN_ATTR_RW(_name, _size) \
230struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size)
231
1da177e4 232struct sysfs_ops {
5da5c9c8
GKH
233 ssize_t (*show)(struct kobject *, struct attribute *, char *);
234 ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t);
1da177e4
LT
235};
236
1da177e4
LT
237#ifdef CONFIG_SYSFS
238
e34ff490 239int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns);
59f69015 240void sysfs_remove_dir(struct kobject *kobj);
e34ff490
TH
241int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
242 const void *new_ns);
243int __must_check sysfs_move_dir_ns(struct kobject *kobj,
244 struct kobject *new_parent_kobj,
245 const void *new_ns);
87d2846f
EB
246int __must_check sysfs_create_mount_point(struct kobject *parent_kobj,
247 const char *name);
248void sysfs_remove_mount_point(struct kobject *parent_kobj,
249 const char *name);
31e5abe9 250
58292cbe
TH
251int __must_check sysfs_create_file_ns(struct kobject *kobj,
252 const struct attribute *attr,
253 const void *ns);
1c205ae1 254int __must_check sysfs_create_files(struct kobject *kobj,
9ee4685c 255 const struct attribute * const *attr);
49c19400 256int __must_check sysfs_chmod_file(struct kobject *kobj,
48176a97 257 const struct attribute *attr, umode_t mode);
2afc9166
BVA
258struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj,
259 const struct attribute *attr);
260void sysfs_unbreak_active_protection(struct kernfs_node *kn);
58292cbe
TH
261void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
262 const void *ns);
6b0afc2a 263bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
9ee4685c 264void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);
1da177e4 265
4a7fb636 266int __must_check sysfs_create_bin_file(struct kobject *kobj,
66ecb92b
PC
267 const struct bin_attribute *attr);
268void sysfs_remove_bin_file(struct kobject *kobj,
269 const struct bin_attribute *attr);
1da177e4 270
59f69015
TH
271int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
272 const char *name);
36ce6dad
CH
273int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
274 struct kobject *target,
275 const char *name);
59f69015
TH
276void sysfs_remove_link(struct kobject *kobj, const char *name);
277
4b30ee58
TH
278int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target,
279 const char *old_name, const char *new_name,
280 const void *new_ns);
7cb32942 281
746edb7a
EB
282void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
283 const char *name);
284
59f69015
TH
285int __must_check sysfs_create_group(struct kobject *kobj,
286 const struct attribute_group *grp);
3e9b2bae
GKH
287int __must_check sysfs_create_groups(struct kobject *kobj,
288 const struct attribute_group **groups);
aac1f7f9
JO
289int __must_check sysfs_update_groups(struct kobject *kobj,
290 const struct attribute_group **groups);
0f423895
JB
291int sysfs_update_group(struct kobject *kobj,
292 const struct attribute_group *grp);
59f69015
TH
293void sysfs_remove_group(struct kobject *kobj,
294 const struct attribute_group *grp);
3e9b2bae
GKH
295void sysfs_remove_groups(struct kobject *kobj,
296 const struct attribute_group **groups);
dfa87c82 297int sysfs_add_file_to_group(struct kobject *kobj,
59f69015 298 const struct attribute *attr, const char *group);
dfa87c82 299void sysfs_remove_file_from_group(struct kobject *kobj,
59f69015 300 const struct attribute *attr, const char *group);
69d44ffb
AS
301int sysfs_merge_group(struct kobject *kobj,
302 const struct attribute_group *grp);
303void sysfs_unmerge_group(struct kobject *kobj,
304 const struct attribute_group *grp);
0bb8f3d6
RW
305int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name,
306 struct kobject *target, const char *link_name);
307void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
308 const char *link_name);
9255782f
SJ
309int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
310 struct kobject *target_kobj,
311 const char *target_name,
312 const char *symlink_name);
dfa87c82 313
8c0e3998 314void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
3ff195b0 315
f1282c84 316int __must_check sysfs_init(void);
f20a9ead 317
fa4cd451
TH
318static inline void sysfs_enable_ns(struct kernfs_node *kn)
319{
320 return kernfs_enable_ns(kn);
321}
322
f70ce185
CB
323int sysfs_file_change_owner(struct kobject *kobj, const char *name, kuid_t kuid,
324 kgid_t kgid);
2c4f9401 325int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid);
0666a3ae
CB
326int sysfs_link_change_owner(struct kobject *kobj, struct kobject *targ,
327 const char *name, kuid_t kuid, kgid_t kgid);
303a4276
CB
328int sysfs_groups_change_owner(struct kobject *kobj,
329 const struct attribute_group **groups,
330 kuid_t kuid, kgid_t kgid);
331int sysfs_group_change_owner(struct kobject *kobj,
332 const struct attribute_group *groups, kuid_t kuid,
333 kgid_t kgid);
2efc459d
JP
334__printf(2, 3)
335int sysfs_emit(char *buf, const char *fmt, ...);
336__printf(3, 4)
337int sysfs_emit_at(char *buf, int at, const char *fmt, ...);
f70ce185 338
1da177e4
LT
339#else /* CONFIG_SYSFS */
340
e34ff490 341static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
1da177e4
LT
342{
343 return 0;
344}
345
59f69015 346static inline void sysfs_remove_dir(struct kobject *kobj)
1da177e4 347{
1da177e4
LT
348}
349
e34ff490
TH
350static inline int sysfs_rename_dir_ns(struct kobject *kobj,
351 const char *new_name, const void *new_ns)
1da177e4 352{
0b4a4fea 353 return 0;
1da177e4
LT
354}
355
e34ff490
TH
356static inline int sysfs_move_dir_ns(struct kobject *kobj,
357 struct kobject *new_parent_kobj,
358 const void *new_ns)
8a82472f
CH
359{
360 return 0;
361}
362
87d2846f
EB
363static inline int sysfs_create_mount_point(struct kobject *parent_kobj,
364 const char *name)
365{
366 return 0;
367}
368
369static inline void sysfs_remove_mount_point(struct kobject *parent_kobj,
370 const char *name)
371{
372}
373
58292cbe
TH
374static inline int sysfs_create_file_ns(struct kobject *kobj,
375 const struct attribute *attr,
376 const void *ns)
1da177e4
LT
377{
378 return 0;
379}
380
1c205ae1 381static inline int sysfs_create_files(struct kobject *kobj,
9ee4685c 382 const struct attribute * const *attr)
1c205ae1
AK
383{
384 return 0;
385}
386
59f69015 387static inline int sysfs_chmod_file(struct kobject *kobj,
48176a97 388 const struct attribute *attr, umode_t mode)
31e5abe9
KS
389{
390 return 0;
391}
1da177e4 392
2afc9166
BVA
393static inline struct kernfs_node *
394sysfs_break_active_protection(struct kobject *kobj,
395 const struct attribute *attr)
396{
397 return NULL;
398}
399
400static inline void sysfs_unbreak_active_protection(struct kernfs_node *kn)
401{
402}
403
58292cbe
TH
404static inline void sysfs_remove_file_ns(struct kobject *kobj,
405 const struct attribute *attr,
406 const void *ns)
1da177e4 407{
1da177e4
LT
408}
409
6b0afc2a
TH
410static inline bool sysfs_remove_file_self(struct kobject *kobj,
411 const struct attribute *attr)
412{
413 return false;
414}
415
1c205ae1 416static inline void sysfs_remove_files(struct kobject *kobj,
9ee4685c 417 const struct attribute * const *attr)
1c205ae1
AK
418{
419}
420
59f69015 421static inline int sysfs_create_bin_file(struct kobject *kobj,
66ecb92b 422 const struct bin_attribute *attr)
1da177e4
LT
423{
424 return 0;
425}
426
3612e06b 427static inline void sysfs_remove_bin_file(struct kobject *kobj,
66ecb92b 428 const struct bin_attribute *attr)
1da177e4 429{
1da177e4
LT
430}
431
59f69015
TH
432static inline int sysfs_create_link(struct kobject *kobj,
433 struct kobject *target, const char *name)
1da177e4
LT
434{
435 return 0;
436}
437
36ce6dad
CH
438static inline int sysfs_create_link_nowarn(struct kobject *kobj,
439 struct kobject *target,
440 const char *name)
441{
442 return 0;
443}
444
59f69015 445static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
1da177e4 446{
1da177e4
LT
447}
448
4b30ee58
TH
449static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t,
450 const char *old_name,
451 const char *new_name, const void *ns)
7cb32942
EB
452{
453 return 0;
454}
455
746edb7a
EB
456static inline void sysfs_delete_link(struct kobject *k, struct kobject *t,
457 const char *name)
458{
459}
460
59f69015
TH
461static inline int sysfs_create_group(struct kobject *kobj,
462 const struct attribute_group *grp)
1da177e4
LT
463{
464 return 0;
465}
466
f7998780
GKH
467static inline int sysfs_create_groups(struct kobject *kobj,
468 const struct attribute_group **groups)
469{
574979c6 470 return 0;
f7998780
GKH
471}
472
aac1f7f9
JO
473static inline int sysfs_update_groups(struct kobject *kobj,
474 const struct attribute_group **groups)
475{
476 return 0;
477}
478
1cbfb7a5
RD
479static inline int sysfs_update_group(struct kobject *kobj,
480 const struct attribute_group *grp)
481{
482 return 0;
483}
484
59f69015
TH
485static inline void sysfs_remove_group(struct kobject *kobj,
486 const struct attribute_group *grp)
1da177e4 487{
1da177e4
LT
488}
489
f7998780
GKH
490static inline void sysfs_remove_groups(struct kobject *kobj,
491 const struct attribute_group **groups)
492{
493}
494
dfa87c82
AS
495static inline int sysfs_add_file_to_group(struct kobject *kobj,
496 const struct attribute *attr, const char *group)
497{
498 return 0;
499}
500
501static inline void sysfs_remove_file_from_group(struct kobject *kobj,
d701d8a3 502 const struct attribute *attr, const char *group)
dfa87c82 503{
dfa87c82
AS
504}
505
69d44ffb
AS
506static inline int sysfs_merge_group(struct kobject *kobj,
507 const struct attribute_group *grp)
508{
509 return 0;
510}
511
512static inline void sysfs_unmerge_group(struct kobject *kobj,
513 const struct attribute_group *grp)
514{
515}
516
0bb8f3d6
RW
517static inline int sysfs_add_link_to_group(struct kobject *kobj,
518 const char *group_name, struct kobject *target,
519 const char *link_name)
520{
521 return 0;
522}
523
524static inline void sysfs_remove_link_from_group(struct kobject *kobj,
525 const char *group_name, const char *link_name)
526{
527}
528
9255782f
SJ
529static inline int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
530 struct kobject *target_kobj,
531 const char *target_name,
532 const char *symlink_name)
533{
534 return 0;
535}
536
8c0e3998
TP
537static inline void sysfs_notify(struct kobject *kobj, const char *dir,
538 const char *attr)
4508a7a7
N
539{
540}
541
f20a9ead
AM
542static inline int __must_check sysfs_init(void)
543{
544 return 0;
545}
546
fa4cd451
TH
547static inline void sysfs_enable_ns(struct kernfs_node *kn)
548{
549}
550
f70ce185
CB
551static inline int sysfs_file_change_owner(struct kobject *kobj,
552 const char *name, kuid_t kuid,
0666a3ae
CB
553 kgid_t kgid)
554{
555 return 0;
556}
557
558static inline int sysfs_link_change_owner(struct kobject *kobj,
559 struct kobject *targ,
560 const char *name, kuid_t kuid,
f70ce185
CB
561 kgid_t kgid)
562{
563 return 0;
564}
565
2c4f9401
CB
566static inline int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid)
567{
568 return 0;
569}
570
303a4276
CB
571static inline int sysfs_groups_change_owner(struct kobject *kobj,
572 const struct attribute_group **groups,
573 kuid_t kuid, kgid_t kgid)
574{
575 return 0;
576}
577
578static inline int sysfs_group_change_owner(struct kobject *kobj,
8511d72f
CB
579 const struct attribute_group *groups,
580 kuid_t kuid, kgid_t kgid)
303a4276
CB
581{
582 return 0;
583}
584
2efc459d
JP
585__printf(2, 3)
586static inline int sysfs_emit(char *buf, const char *fmt, ...)
587{
588 return 0;
589}
590
591__printf(3, 4)
592static inline int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
593{
594 return 0;
595}
1da177e4
LT
596#endif /* CONFIG_SYSFS */
597
58292cbe
TH
598static inline int __must_check sysfs_create_file(struct kobject *kobj,
599 const struct attribute *attr)
600{
601 return sysfs_create_file_ns(kobj, attr, NULL);
602}
603
604static inline void sysfs_remove_file(struct kobject *kobj,
605 const struct attribute *attr)
606{
78e1da62 607 sysfs_remove_file_ns(kobj, attr, NULL);
58292cbe
TH
608}
609
4b30ee58
TH
610static inline int sysfs_rename_link(struct kobject *kobj, struct kobject *target,
611 const char *old_name, const char *new_name)
612{
613 return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL);
614}
615
324a56e1 616static inline void sysfs_notify_dirent(struct kernfs_node *kn)
ccf73cf3 617{
324a56e1 618 kernfs_notify(kn);
ccf73cf3
TH
619}
620
324a56e1 621static inline struct kernfs_node *sysfs_get_dirent(struct kernfs_node *parent,
89cf2a20 622 const char *name)
388975cc 623{
324a56e1 624 return kernfs_find_and_get(parent, name);
388975cc
TH
625}
626
324a56e1 627static inline struct kernfs_node *sysfs_get(struct kernfs_node *kn)
024f6471 628{
324a56e1
TH
629 kernfs_get(kn);
630 return kn;
ccf73cf3
TH
631}
632
324a56e1 633static inline void sysfs_put(struct kernfs_node *kn)
ccf73cf3 634{
324a56e1 635 kernfs_put(kn);
024f6471
TH
636}
637
1da177e4 638#endif /* _SYSFS_H_ */