Blame view

include/linux/sysfs.h 17.4 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
  /*
   * sysfs.h - definitions for the device driver filesystem
   *
   * Copyright (c) 2001,2002 Patrick Mochel
   * Copyright (c) 2004 Silicon Graphics, Inc.
6d66f5cd2   Tejun Heo   sysfs: add copyri...
7
8
   * Copyright (c) 2007 SUSE Linux Products GmbH
   * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
   *
0c1bc6b84   Mauro Carvalho Chehab   docs: filesystems...
10
   * Please see Documentation/filesystems/sysfs.rst for more information.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11
12
13
14
   */
  
  #ifndef _SYSFS_H_
  #define _SYSFS_H_
b8441ed27   Tejun Heo   sysfs, kernfs: ad...
15
  #include <linux/kernfs.h>
4a7fb6363   Andrew Morton   add __must_check ...
16
  #include <linux/compiler.h>
5851fadce   Ralf Baechle   [PATCH] Fix build...
17
  #include <linux/errno.h>
bf0acc330   Frank Haverkamp   SYSFS: Fix missin...
18
  #include <linux/list.h>
6992f5334   Eric W. Biederman   sysfs: Use one lo...
19
  #include <linux/lockdep.h>
8488a38f4   David Howells   kobject: Break th...
20
  #include <linux/kobject_ns.h>
3493f69f4   Oliver Schinagl   sysfs: add more h...
21
  #include <linux/stat.h>
60063497a   Arun Sharma   atomic: use <linu...
22
  #include <linux/atomic.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
24
25
  
  struct kobject;
  struct module;
6ab9cea16   Greg Kroah-Hartman   sysfs: add suppor...
26
  struct bin_attribute;
3ff195b01   Eric W. Biederman   sysfs: Implement ...
27
  enum kobj_ns_type;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
29
  
  struct attribute {
59f690156   Tejun Heo   sysfs: clean up h...
30
  	const char		*name;
9104e427f   Al Viro   switch sysfs attr...
31
  	umode_t			mode;
6992f5334   Eric W. Biederman   sysfs: Use one lo...
32
  #ifdef CONFIG_DEBUG_LOCK_ALLOC
356c05d58   Alan Stern   sysfs: get rid of...
33
  	bool			ignore_lockdep:1;
6992f5334   Eric W. Biederman   sysfs: Use one lo...
34
35
36
  	struct lock_class_key	*key;
  	struct lock_class_key	skey;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
  };
35960258e   Eric W. Biederman   sysfs: Document s...
38
39
40
41
42
43
44
45
46
47
  /**
   *	sysfs_attr_init - initialize a dynamically allocated sysfs attribute
   *	@attr: struct attribute to initialize
   *
   *	Initialize a dynamically allocated struct attribute so we can
   *	make lockdep happy.  This is a new requirement for attributes
   *	and initially this is only needed when lockdep is enabled.
   *	Lockdep gives a nice error when your attribute is added to
   *	sysfs if you don't have this.
   */
6992f5334   Eric W. Biederman   sysfs: Use one lo...
48
49
50
51
52
53
  #ifdef CONFIG_DEBUG_LOCK_ALLOC
  #define sysfs_attr_init(attr)				\
  do {							\
  	static struct lock_class_key __key;		\
  							\
  	(attr)->key = &__key;				\
5da5c9c89   Greg Kroah-Hartman   sysfs: fix up min...
54
  } while (0)
6992f5334   Eric W. Biederman   sysfs: Use one lo...
55
  #else
5da5c9c89   Greg Kroah-Hartman   sysfs: fix up min...
56
  #define sysfs_attr_init(attr) do {} while (0)
6992f5334   Eric W. Biederman   sysfs: Use one lo...
57
  #endif
ba61af6f3   Guenter Roeck   sysfs: Document s...
58
59
60
61
62
63
64
  /**
   * struct attribute_group - data structure used to declare an attribute group.
   * @name:	Optional: Attribute group name
   *		If specified, the attribute group will be created in
   *		a new subdirectory with this name.
   * @is_visible:	Optional: Function to return permissions associated with an
   *		attribute of the group. Will be called repeatedly for each
7f5028cf6   Emilio López   sysfs: Support is...
65
66
67
68
69
70
71
72
73
74
75
76
   *		non-binary attribute in the group. Only read/write
   *		permissions as well as SYSFS_PREALLOC are accepted. Must
   *		return 0 if an attribute is not visible. The returned value
   *		will replace static permissions defined in struct attribute.
   * @is_bin_visible:
   *		Optional: Function to return permissions associated with a
   *		binary attribute of the group. Will be called repeatedly
   *		for each binary attribute in the group. Only read/write
   *		permissions as well as SYSFS_PREALLOC are accepted. Must
   *		return 0 if a binary attribute is not visible. The returned
   *		value will replace static permissions defined in
   *		struct bin_attribute.
ba61af6f3   Guenter Roeck   sysfs: Document s...
77
78
79
80
   * @attrs:	Pointer to NULL terminated list of attributes.
   * @bin_attrs:	Pointer to NULL terminated list of binary attributes.
   *		Either attrs or bin_attrs or both must be provided.
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
  struct attribute_group {
59f690156   Tejun Heo   sysfs: clean up h...
82
  	const char		*name;
587a1f165   Al Viro   switch ->is_visib...
83
  	umode_t			(*is_visible)(struct kobject *,
d4acd722b   James Bottomley   [SCSI] sysfs: add...
84
  					      struct attribute *, int);
7f5028cf6   Emilio López   sysfs: Support is...
85
86
  	umode_t			(*is_bin_visible)(struct kobject *,
  						  struct bin_attribute *, int);
59f690156   Tejun Heo   sysfs: clean up h...
87
  	struct attribute	**attrs;
6ab9cea16   Greg Kroah-Hartman   sysfs: add suppor...
88
  	struct bin_attribute	**bin_attrs;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
89
  };
3ec78790e   Randy Dunlap   sysfs.h: fix non-...
90
91
92
  /*
   * Use these macros to make defining attributes easier.
   * See include/linux/device.h for examples..
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
93
   */
2b75869bb   NeilBrown   sysfs/kernfs: all...
94
  #define SYSFS_PREALLOC 010000
5da5c9c89   Greg Kroah-Hartman   sysfs: fix up min...
95
  #define __ATTR(_name, _mode, _show, _store) {				\
58f86cc89   Rusty Russell   VERIFY_OCTAL_PERM...
96
97
  	.attr = {.name = __stringify(_name),				\
  		 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },		\
aa01aa3ca   Oliver Schinagl   sysfs: use file m...
98
99
  	.show	= _show,						\
  	.store	= _store,						\
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
  }
2b75869bb   NeilBrown   sysfs/kernfs: all...
101
102
103
104
105
106
  #define __ATTR_PREALLOC(_name, _mode, _show, _store) {			\
  	.attr = {.name = __stringify(_name),				\
  		 .mode = SYSFS_PREALLOC | VERIFY_OCTAL_PERMISSIONS(_mode) },\
  	.show	= _show,						\
  	.store	= _store,						\
  }
aa01aa3ca   Oliver Schinagl   sysfs: use file m...
107
  #define __ATTR_RO(_name) {						\
353c6ddaa   Joe Perches   sysfs.h: Use octa...
108
  	.attr	= { .name = __stringify(_name), .mode = 0444 },		\
aa01aa3ca   Oliver Schinagl   sysfs: use file m...
109
  	.show	= _name##_show,						\
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
  }
af97a77bc   Greg Kroah-Hartman   efi: Move some sy...
111
112
113
114
115
  #define __ATTR_RO_MODE(_name, _mode) {					\
  	.attr	= { .name = __stringify(_name),				\
  		    .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },		\
  	.show	= _name##_show,						\
  }
3022c6a1b   Dan Williams   driver-core: Intr...
116
117
118
119
120
121
  #define __ATTR_RW_MODE(_name, _mode) {					\
  	.attr	= { .name = __stringify(_name),				\
  		    .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },		\
  	.show	= _name##_show,						\
  	.store	= _name##_store,					\
  }
a65fcce75   Greg Kroah-Hartman   sysfs: create __A...
122
  #define __ATTR_WO(_name) {						\
353c6ddaa   Joe Perches   sysfs.h: Use octa...
123
  	.attr	= { .name = __stringify(_name), .mode = 0200 },		\
a65fcce75   Greg Kroah-Hartman   sysfs: create __A...
124
125
  	.store	= _name##_store,					\
  }
353c6ddaa   Joe Perches   sysfs.h: Use octa...
126
  #define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store)
b9b325974   Greg Kroah-Hartman   sysfs.h: add __AT...
127

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
128
  #define __ATTR_NULL { .attr = { .name = NULL } }
356c05d58   Alan Stern   sysfs: get rid of...
129
130
131
132
133
134
135
136
137
138
139
  
  #ifdef CONFIG_DEBUG_LOCK_ALLOC
  #define __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) {	\
  	.attr = {.name = __stringify(_name), .mode = _mode,	\
  			.ignore_lockdep = true },		\
  	.show		= _show,				\
  	.store		= _store,				\
  }
  #else
  #define __ATTR_IGNORE_LOCKDEP	__ATTR
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140

3493f69f4   Oliver Schinagl   sysfs: add more h...
141
142
143
  #define __ATTRIBUTE_GROUPS(_name)				\
  static const struct attribute_group *_name##_groups[] = {	\
  	&_name##_group,						\
f2f37f58b   Greg Kroah-Hartman   sysfs.h: add ATTR...
144
145
  	NULL,							\
  }
3493f69f4   Oliver Schinagl   sysfs: add more h...
146
147
148
149
150
  #define ATTRIBUTE_GROUPS(_name)					\
  static const struct attribute_group _name##_group = {		\
  	.attrs = _name##_attrs,					\
  };								\
  __ATTRIBUTE_GROUPS(_name)
2c3c8bea6   Chris Wright   sysfs: add struct...
151
  struct file;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
152
153
154
155
156
157
  struct vm_area_struct;
  
  struct bin_attribute {
  	struct attribute	attr;
  	size_t			size;
  	void			*private;
2c3c8bea6   Chris Wright   sysfs: add struct...
158
  	ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
91a690295   Zhang Rui   sysfs: add parame...
159
  			char *, loff_t, size_t);
5da5c9c89   Greg Kroah-Hartman   sysfs: fix up min...
160
  	ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *,
91a690295   Zhang Rui   sysfs: add parame...
161
  			 char *, loff_t, size_t);
2c3c8bea6   Chris Wright   sysfs: add struct...
162
  	int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
163
164
  		    struct vm_area_struct *vma);
  };
35960258e   Eric W. Biederman   sysfs: Document s...
165
166
167
168
169
170
171
172
173
174
  /**
   *	sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
   *	@attr: struct bin_attribute to initialize
   *
   *	Initialize a dynamically allocated struct bin_attribute so we
   *	can make lockdep happy.  This is a new requirement for
   *	attributes and initially this is only needed when lockdep is
   *	enabled.  Lockdep gives a nice error when your attribute is
   *	added to sysfs if you don't have this.
   */
62e877b89   Stephen Rothwell   sysfs: fix for th...
175
  #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
6992f5334   Eric W. Biederman   sysfs: Use one lo...
176

3493f69f4   Oliver Schinagl   sysfs: add more h...
177
178
179
180
181
182
183
184
185
  /* macros to create static binary attributes easier */
  #define __BIN_ATTR(_name, _mode, _read, _write, _size) {		\
  	.attr = { .name = __stringify(_name), .mode = _mode },		\
  	.read	= _read,						\
  	.write	= _write,						\
  	.size	= _size,						\
  }
  
  #define __BIN_ATTR_RO(_name, _size) {					\
353c6ddaa   Joe Perches   sysfs.h: Use octa...
186
  	.attr	= { .name = __stringify(_name), .mode = 0444 },		\
3493f69f4   Oliver Schinagl   sysfs: add more h...
187
188
  	.read	= _name##_read,						\
  	.size	= _size,						\
e4b63603c   Greg Kroah-Hartman   sysfs.h: add BIN_...
189
  }
82af5b660   Nayna Jain   sysfs: Fixes __BI...
190
  #define __BIN_ATTR_WO(_name, _size) {					\
7f905761e   Greg Kroah-Hartman   sysfs: add BIN_AT...
191
  	.attr	= { .name = __stringify(_name), .mode = 0200 },		\
82af5b660   Nayna Jain   sysfs: Fixes __BI...
192
  	.write	= _name##_write,					\
7f905761e   Greg Kroah-Hartman   sysfs: add BIN_AT...
193
194
  	.size	= _size,						\
  }
353c6ddaa   Joe Perches   sysfs.h: Use octa...
195
196
  #define __BIN_ATTR_RW(_name, _size)					\
  	__BIN_ATTR(_name, 0644, _name##_read, _name##_write, _size)
3493f69f4   Oliver Schinagl   sysfs: add more h...
197
198
199
200
201
202
203
204
205
  
  #define __BIN_ATTR_NULL __ATTR_NULL
  
  #define BIN_ATTR(_name, _mode, _read, _write, _size)			\
  struct bin_attribute bin_attr_##_name = __BIN_ATTR(_name, _mode, _read,	\
  					_write, _size)
  
  #define BIN_ATTR_RO(_name, _size)					\
  struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size)
7f905761e   Greg Kroah-Hartman   sysfs: add BIN_AT...
206
207
  #define BIN_ATTR_WO(_name, _size)					\
  struct bin_attribute bin_attr_##_name = __BIN_ATTR_WO(_name, _size)
3493f69f4   Oliver Schinagl   sysfs: add more h...
208
209
  #define BIN_ATTR_RW(_name, _size)					\
  struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
210
  struct sysfs_ops {
5da5c9c89   Greg Kroah-Hartman   sysfs: fix up min...
211
212
  	ssize_t	(*show)(struct kobject *, struct attribute *, char *);
  	ssize_t	(*store)(struct kobject *, struct attribute *, const char *, size_t);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
213
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
214
  #ifdef CONFIG_SYSFS
e34ff4906   Tejun Heo   sysfs: remove kty...
215
  int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns);
59f690156   Tejun Heo   sysfs: clean up h...
216
  void sysfs_remove_dir(struct kobject *kobj);
e34ff4906   Tejun Heo   sysfs: remove kty...
217
218
219
220
221
  int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
  				     const void *new_ns);
  int __must_check sysfs_move_dir_ns(struct kobject *kobj,
  				   struct kobject *new_parent_kobj,
  				   const void *new_ns);
87d2846fc   Eric W. Biederman   sysfs: Add suppor...
222
223
224
225
  int __must_check sysfs_create_mount_point(struct kobject *parent_kobj,
  					  const char *name);
  void sysfs_remove_mount_point(struct kobject *parent_kobj,
  			      const char *name);
31e5abe9a   Kay Sievers   [PATCH] sysfs: ad...
226

58292cbe6   Tejun Heo   sysfs: make attr ...
227
228
229
  int __must_check sysfs_create_file_ns(struct kobject *kobj,
  				      const struct attribute *attr,
  				      const void *ns);
1c205ae18   Andi Kleen   sysfs: Add sysfs_...
230
  int __must_check sysfs_create_files(struct kobject *kobj,
9ee4685c9   Jani Nikula   sysfs: constify s...
231
  				   const struct attribute * const *attr);
49c19400f   Jean Delvare   sysfs: sysfs_chmo...
232
  int __must_check sysfs_chmod_file(struct kobject *kobj,
48176a973   Al Viro   switch sysfs_chmo...
233
  				  const struct attribute *attr, umode_t mode);
2afc9166f   Bart Van Assche   scsi: sysfs: Intr...
234
235
236
  struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj,
  						  const struct attribute *attr);
  void sysfs_unbreak_active_protection(struct kernfs_node *kn);
58292cbe6   Tejun Heo   sysfs: make attr ...
237
238
  void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
  			  const void *ns);
6b0afc2a2   Tejun Heo   kernfs, sysfs, dr...
239
  bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
9ee4685c9   Jani Nikula   sysfs: constify s...
240
  void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
241

4a7fb6363   Andrew Morton   add __must_check ...
242
  int __must_check sysfs_create_bin_file(struct kobject *kobj,
66ecb92be   Phil Carmody   Driver core: bin_...
243
244
245
  				       const struct bin_attribute *attr);
  void sysfs_remove_bin_file(struct kobject *kobj,
  			   const struct bin_attribute *attr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
246

59f690156   Tejun Heo   sysfs: clean up h...
247
248
  int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
  				   const char *name);
36ce6dad6   Cornelia Huck   driver core: Supp...
249
250
251
  int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
  					  struct kobject *target,
  					  const char *name);
59f690156   Tejun Heo   sysfs: clean up h...
252
  void sysfs_remove_link(struct kobject *kobj, const char *name);
4b30ee58e   Tejun Heo   sysfs: remove kty...
253
254
255
  int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target,
  			 const char *old_name, const char *new_name,
  			 const void *new_ns);
7cb32942d   Eric W. Biederman   sysfs: Implement ...
256

746edb7ae   Eric W. Biederman   sysfs: Implement ...
257
258
  void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
  			const char *name);
59f690156   Tejun Heo   sysfs: clean up h...
259
260
  int __must_check sysfs_create_group(struct kobject *kobj,
  				    const struct attribute_group *grp);
3e9b2bae8   Greg Kroah-Hartman   sysfs: add sysfs_...
261
262
  int __must_check sysfs_create_groups(struct kobject *kobj,
  				     const struct attribute_group **groups);
aac1f7f95   Jiri Olsa   sysfs: Add sysfs_...
263
264
  int __must_check sysfs_update_groups(struct kobject *kobj,
  				     const struct attribute_group **groups);
0f4238958   James Bottomley   [SCSI] sysfs: mak...
265
266
  int sysfs_update_group(struct kobject *kobj,
  		       const struct attribute_group *grp);
59f690156   Tejun Heo   sysfs: clean up h...
267
268
  void sysfs_remove_group(struct kobject *kobj,
  			const struct attribute_group *grp);
3e9b2bae8   Greg Kroah-Hartman   sysfs: add sysfs_...
269
270
  void sysfs_remove_groups(struct kobject *kobj,
  			 const struct attribute_group **groups);
dfa87c824   Alan Stern   sysfs: allow attr...
271
  int sysfs_add_file_to_group(struct kobject *kobj,
59f690156   Tejun Heo   sysfs: clean up h...
272
  			const struct attribute *attr, const char *group);
dfa87c824   Alan Stern   sysfs: allow attr...
273
  void sysfs_remove_file_from_group(struct kobject *kobj,
59f690156   Tejun Heo   sysfs: clean up h...
274
  			const struct attribute *attr, const char *group);
69d44ffbd   Alan Stern   sysfs: Add sysfs_...
275
276
277
278
  int sysfs_merge_group(struct kobject *kobj,
  		       const struct attribute_group *grp);
  void sysfs_unmerge_group(struct kobject *kobj,
  		       const struct attribute_group *grp);
0bb8f3d6a   Rafael J. Wysocki   sysfs: Functions ...
279
280
281
282
  int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name,
  			    struct kobject *target, const char *link_name);
  void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
  				  const char *link_name);
9255782f7   Sourabh Jain   sysfs: Wrap __com...
283
284
285
286
  int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
  					 struct kobject *target_kobj,
  					 const char *target_name,
  					 const char *symlink_name);
dfa87c824   Alan Stern   sysfs: allow attr...
287

8c0e3998f   Trent Piepho   sysfs: Make dir a...
288
  void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
3ff195b01   Eric W. Biederman   sysfs: Implement ...
289

f1282c844   Neil Brown   sysfs: Support sy...
290
  int __must_check sysfs_init(void);
f20a9ead0   Andrew Morton   sysfs: add proper...
291

fa4cd451c   Tejun Heo   sysfs, kobject: a...
292
293
294
295
  static inline void sysfs_enable_ns(struct kernfs_node *kn)
  {
  	return kernfs_enable_ns(kn);
  }
f70ce1856   Christian Brauner   sysfs: add sysfs_...
296
297
  int sysfs_file_change_owner(struct kobject *kobj, const char *name, kuid_t kuid,
  			    kgid_t kgid);
2c4f9401c   Christian Brauner   sysfs: add sysfs_...
298
  int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid);
0666a3aee   Christian Brauner   sysfs: add sysfs_...
299
300
  int sysfs_link_change_owner(struct kobject *kobj, struct kobject *targ,
  			    const char *name, kuid_t kuid, kgid_t kgid);
303a42769   Christian Brauner   sysfs: add sysfs_...
301
302
303
304
305
306
  int sysfs_groups_change_owner(struct kobject *kobj,
  			      const struct attribute_group **groups,
  			      kuid_t kuid, kgid_t kgid);
  int sysfs_group_change_owner(struct kobject *kobj,
  			     const struct attribute_group *groups, kuid_t kuid,
  			     kgid_t kgid);
2efc459d0   Joe Perches   sysfs: Add sysfs_...
307
308
309
310
  __printf(2, 3)
  int sysfs_emit(char *buf, const char *fmt, ...);
  __printf(3, 4)
  int sysfs_emit_at(char *buf, int at, const char *fmt, ...);
f70ce1856   Christian Brauner   sysfs: add sysfs_...
311

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
312
  #else /* CONFIG_SYSFS */
e34ff4906   Tejun Heo   sysfs: remove kty...
313
  static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
314
315
316
  {
  	return 0;
  }
59f690156   Tejun Heo   sysfs: clean up h...
317
  static inline void sysfs_remove_dir(struct kobject *kobj)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
318
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
319
  }
e34ff4906   Tejun Heo   sysfs: remove kty...
320
321
  static inline int sysfs_rename_dir_ns(struct kobject *kobj,
  				      const char *new_name, const void *new_ns)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
322
  {
0b4a4fea2   Eric W. Biederman   kobject: Cleanup ...
323
  	return 0;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
324
  }
e34ff4906   Tejun Heo   sysfs: remove kty...
325
326
327
  static inline int sysfs_move_dir_ns(struct kobject *kobj,
  				    struct kobject *new_parent_kobj,
  				    const void *new_ns)
8a82472f8   Cornelia Huck   driver core: Intr...
328
329
330
  {
  	return 0;
  }
87d2846fc   Eric W. Biederman   sysfs: Add suppor...
331
332
333
334
335
336
337
338
339
340
  static inline int sysfs_create_mount_point(struct kobject *parent_kobj,
  					   const char *name)
  {
  	return 0;
  }
  
  static inline void sysfs_remove_mount_point(struct kobject *parent_kobj,
  					    const char *name)
  {
  }
58292cbe6   Tejun Heo   sysfs: make attr ...
341
342
343
  static inline int sysfs_create_file_ns(struct kobject *kobj,
  				       const struct attribute *attr,
  				       const void *ns)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
344
345
346
  {
  	return 0;
  }
1c205ae18   Andi Kleen   sysfs: Add sysfs_...
347
  static inline int sysfs_create_files(struct kobject *kobj,
9ee4685c9   Jani Nikula   sysfs: constify s...
348
  				    const struct attribute * const *attr)
1c205ae18   Andi Kleen   sysfs: Add sysfs_...
349
350
351
  {
  	return 0;
  }
59f690156   Tejun Heo   sysfs: clean up h...
352
  static inline int sysfs_chmod_file(struct kobject *kobj,
48176a973   Al Viro   switch sysfs_chmo...
353
  				   const struct attribute *attr, umode_t mode)
31e5abe9a   Kay Sievers   [PATCH] sysfs: ad...
354
355
356
  {
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
357

2afc9166f   Bart Van Assche   scsi: sysfs: Intr...
358
359
360
361
362
363
364
365
366
367
  static inline struct kernfs_node *
  sysfs_break_active_protection(struct kobject *kobj,
  			      const struct attribute *attr)
  {
  	return NULL;
  }
  
  static inline void sysfs_unbreak_active_protection(struct kernfs_node *kn)
  {
  }
58292cbe6   Tejun Heo   sysfs: make attr ...
368
369
370
  static inline void sysfs_remove_file_ns(struct kobject *kobj,
  					const struct attribute *attr,
  					const void *ns)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
371
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
372
  }
6b0afc2a2   Tejun Heo   kernfs, sysfs, dr...
373
374
375
376
377
  static inline bool sysfs_remove_file_self(struct kobject *kobj,
  					  const struct attribute *attr)
  {
  	return false;
  }
1c205ae18   Andi Kleen   sysfs: Add sysfs_...
378
  static inline void sysfs_remove_files(struct kobject *kobj,
9ee4685c9   Jani Nikula   sysfs: constify s...
379
  				     const struct attribute * const *attr)
1c205ae18   Andi Kleen   sysfs: Add sysfs_...
380
381
  {
  }
59f690156   Tejun Heo   sysfs: clean up h...
382
  static inline int sysfs_create_bin_file(struct kobject *kobj,
66ecb92be   Phil Carmody   Driver core: bin_...
383
  					const struct bin_attribute *attr)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
384
385
386
  {
  	return 0;
  }
3612e06b2   David Rientjes   sysfs: small head...
387
  static inline void sysfs_remove_bin_file(struct kobject *kobj,
66ecb92be   Phil Carmody   Driver core: bin_...
388
  					 const struct bin_attribute *attr)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
389
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
390
  }
59f690156   Tejun Heo   sysfs: clean up h...
391
392
  static inline int sysfs_create_link(struct kobject *kobj,
  				    struct kobject *target, const char *name)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
393
394
395
  {
  	return 0;
  }
36ce6dad6   Cornelia Huck   driver core: Supp...
396
397
398
399
400
401
  static inline int sysfs_create_link_nowarn(struct kobject *kobj,
  					   struct kobject *target,
  					   const char *name)
  {
  	return 0;
  }
59f690156   Tejun Heo   sysfs: clean up h...
402
  static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
403
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
404
  }
4b30ee58e   Tejun Heo   sysfs: remove kty...
405
406
407
  static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t,
  				       const char *old_name,
  				       const char *new_name, const void *ns)
7cb32942d   Eric W. Biederman   sysfs: Implement ...
408
409
410
  {
  	return 0;
  }
746edb7ae   Eric W. Biederman   sysfs: Implement ...
411
412
413
414
  static inline void sysfs_delete_link(struct kobject *k, struct kobject *t,
  				     const char *name)
  {
  }
59f690156   Tejun Heo   sysfs: clean up h...
415
416
  static inline int sysfs_create_group(struct kobject *kobj,
  				     const struct attribute_group *grp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
417
418
419
  {
  	return 0;
  }
f79987800   Greg Kroah-Hartman   sysfs: add sysfs_...
420
421
422
  static inline int sysfs_create_groups(struct kobject *kobj,
  				      const struct attribute_group **groups)
  {
574979c61   Greg Kroah-Hartman   sysfs: sysfs_crea...
423
  	return 0;
f79987800   Greg Kroah-Hartman   sysfs: add sysfs_...
424
  }
aac1f7f95   Jiri Olsa   sysfs: Add sysfs_...
425
426
427
428
429
  static inline int sysfs_update_groups(struct kobject *kobj,
  				      const struct attribute_group **groups)
  {
  	return 0;
  }
1cbfb7a5a   Randy Dunlap   sysfs: sysfs_upda...
430
431
432
433
434
  static inline int sysfs_update_group(struct kobject *kobj,
  				const struct attribute_group *grp)
  {
  	return 0;
  }
59f690156   Tejun Heo   sysfs: clean up h...
435
436
  static inline void sysfs_remove_group(struct kobject *kobj,
  				      const struct attribute_group *grp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
437
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
438
  }
f79987800   Greg Kroah-Hartman   sysfs: add sysfs_...
439
440
441
442
  static inline void sysfs_remove_groups(struct kobject *kobj,
  				       const struct attribute_group **groups)
  {
  }
dfa87c824   Alan Stern   sysfs: allow attr...
443
444
445
446
447
448
449
  static inline int sysfs_add_file_to_group(struct kobject *kobj,
  		const struct attribute *attr, const char *group)
  {
  	return 0;
  }
  
  static inline void sysfs_remove_file_from_group(struct kobject *kobj,
d701d8a3b   Ralf Baechle   [PATCH] Fix sysfs...
450
  		const struct attribute *attr, const char *group)
dfa87c824   Alan Stern   sysfs: allow attr...
451
  {
dfa87c824   Alan Stern   sysfs: allow attr...
452
  }
69d44ffbd   Alan Stern   sysfs: Add sysfs_...
453
454
455
456
457
458
459
460
461
462
  static inline int sysfs_merge_group(struct kobject *kobj,
  		       const struct attribute_group *grp)
  {
  	return 0;
  }
  
  static inline void sysfs_unmerge_group(struct kobject *kobj,
  		       const struct attribute_group *grp)
  {
  }
0bb8f3d6a   Rafael J. Wysocki   sysfs: Functions ...
463
464
465
466
467
468
469
470
471
472
473
  static inline int sysfs_add_link_to_group(struct kobject *kobj,
  		const char *group_name, struct kobject *target,
  		const char *link_name)
  {
  	return 0;
  }
  
  static inline void sysfs_remove_link_from_group(struct kobject *kobj,
  		const char *group_name, const char *link_name)
  {
  }
9255782f7   Sourabh Jain   sysfs: Wrap __com...
474
475
476
477
478
479
480
  static inline int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
  						       struct kobject *target_kobj,
  						       const char *target_name,
  						       const char *symlink_name)
  {
  	return 0;
  }
8c0e3998f   Trent Piepho   sysfs: Make dir a...
481
482
  static inline void sysfs_notify(struct kobject *kobj, const char *dir,
  				const char *attr)
4508a7a73   NeilBrown   [PATCH] sysfs: Al...
483
484
  {
  }
f20a9ead0   Andrew Morton   sysfs: add proper...
485
486
487
488
  static inline int __must_check sysfs_init(void)
  {
  	return 0;
  }
fa4cd451c   Tejun Heo   sysfs, kobject: a...
489
490
491
  static inline void sysfs_enable_ns(struct kernfs_node *kn)
  {
  }
f70ce1856   Christian Brauner   sysfs: add sysfs_...
492
493
  static inline int sysfs_file_change_owner(struct kobject *kobj,
  					  const char *name, kuid_t kuid,
0666a3aee   Christian Brauner   sysfs: add sysfs_...
494
495
496
497
498
499
500
501
  					  kgid_t kgid)
  {
  	return 0;
  }
  
  static inline int sysfs_link_change_owner(struct kobject *kobj,
  					  struct kobject *targ,
  					  const char *name, kuid_t kuid,
f70ce1856   Christian Brauner   sysfs: add sysfs_...
502
503
504
505
  					  kgid_t kgid)
  {
  	return 0;
  }
2c4f9401c   Christian Brauner   sysfs: add sysfs_...
506
507
508
509
  static inline int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid)
  {
  	return 0;
  }
303a42769   Christian Brauner   sysfs: add sysfs_...
510
511
512
513
514
515
516
517
  static inline int sysfs_groups_change_owner(struct kobject *kobj,
  			  const struct attribute_group **groups,
  			  kuid_t kuid, kgid_t kgid)
  {
  	return 0;
  }
  
  static inline int sysfs_group_change_owner(struct kobject *kobj,
8511d72f1   Christian Brauner   sysfs: fix static...
518
519
  					   const struct attribute_group *groups,
  					   kuid_t kuid, kgid_t kgid)
303a42769   Christian Brauner   sysfs: add sysfs_...
520
521
522
  {
  	return 0;
  }
2efc459d0   Joe Perches   sysfs: Add sysfs_...
523
524
525
526
527
528
529
530
531
532
533
  __printf(2, 3)
  static inline int sysfs_emit(char *buf, const char *fmt, ...)
  {
  	return 0;
  }
  
  __printf(3, 4)
  static inline int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
  {
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
534
  #endif /* CONFIG_SYSFS */
58292cbe6   Tejun Heo   sysfs: make attr ...
535
536
537
538
539
540
541
542
543
  static inline int __must_check sysfs_create_file(struct kobject *kobj,
  						 const struct attribute *attr)
  {
  	return sysfs_create_file_ns(kobj, attr, NULL);
  }
  
  static inline void sysfs_remove_file(struct kobject *kobj,
  				     const struct attribute *attr)
  {
78e1da627   Simon Wunderlich   sysfs.h: don't re...
544
  	sysfs_remove_file_ns(kobj, attr, NULL);
58292cbe6   Tejun Heo   sysfs: make attr ...
545
  }
4b30ee58e   Tejun Heo   sysfs: remove kty...
546
547
548
549
550
  static inline int sysfs_rename_link(struct kobject *kobj, struct kobject *target,
  				    const char *old_name, const char *new_name)
  {
  	return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL);
  }
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
551
  static inline void sysfs_notify_dirent(struct kernfs_node *kn)
ccf73cf33   Tejun Heo   sysfs, kernfs: in...
552
  {
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
553
  	kernfs_notify(kn);
ccf73cf33   Tejun Heo   sysfs, kernfs: in...
554
  }
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
555
  static inline struct kernfs_node *sysfs_get_dirent(struct kernfs_node *parent,
89cf2a20c   Nick Desaulniers   sysfs: remove sig...
556
  						   const char *name)
388975ccc   Tejun Heo   sysfs: clean up s...
557
  {
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
558
  	return kernfs_find_and_get(parent, name);
388975ccc   Tejun Heo   sysfs: clean up s...
559
  }
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
560
  static inline struct kernfs_node *sysfs_get(struct kernfs_node *kn)
024f64711   Tejun Heo   sysfs, kernfs: in...
561
  {
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
562
563
  	kernfs_get(kn);
  	return kn;
ccf73cf33   Tejun Heo   sysfs, kernfs: in...
564
  }
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
565
  static inline void sysfs_put(struct kernfs_node *kn)
ccf73cf33   Tejun Heo   sysfs, kernfs: in...
566
  {
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
567
  	kernfs_put(kn);
024f64711   Tejun Heo   sysfs, kernfs: in...
568
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
569
  #endif /* _SYSFS_H_ */