aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernfs.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-12-11 16:02:57 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-17 11:59:15 -0500
commit2063d608f5110d120db60e896ec2c70c95bb7978 (patch)
tree45b02932c241cf2fe6a54ee4013a94221b2c2b8d /include/linux/kernfs.h
parentd0ae3d4347ee025cf23b850d484fe8593f7dd0f2 (diff)
kernfs: mark static names with KERNFS_STATIC_NAME
Because sysfs used struct attribute which are supposed to stay constant, sysfs didn't copy names when creating regular files. The specified string for name was supposed to stay constant. Such distinction isn't inherent for kernfs. kernfs_create_file[_ns]() should be able to take the same @name as kernfs_create_dir[_ns]() As there can be huge number of sysfs attributes, we still want to be able to use static names for sysfs attributes. This patch renames kernfs_create_file_ns_key() to __kernfs_create_file() and adds @name_is_static parameter so that the caller can explicitly indicate that @name can be used without copying. kernfs is updated to use KERNFS_STATIC_NAME to distinguish static and copied names. This patch doesn't introduce any behavior changes. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/kernfs.h')
-rw-r--r--include/linux/kernfs.h27
1 files changed, 14 insertions, 13 deletions
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index 0ca2aedfd31b..321ed84ad4ce 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -34,7 +34,6 @@ enum kernfs_node_type {
34}; 34};
35 35
36#define KERNFS_TYPE_MASK 0x000f 36#define KERNFS_TYPE_MASK 0x000f
37#define KERNFS_COPY_NAME (KERNFS_DIR | KERNFS_LINK)
38#define KERNFS_ACTIVE_REF KERNFS_FILE 37#define KERNFS_ACTIVE_REF KERNFS_FILE
39#define KERNFS_FLAG_MASK ~KERNFS_TYPE_MASK 38#define KERNFS_FLAG_MASK ~KERNFS_TYPE_MASK
40 39
@@ -44,6 +43,7 @@ enum kernfs_node_flag {
44 KERNFS_HAS_SEQ_SHOW = 0x0040, 43 KERNFS_HAS_SEQ_SHOW = 0x0040,
45 KERNFS_HAS_MMAP = 0x0080, 44 KERNFS_HAS_MMAP = 0x0080,
46 KERNFS_LOCKDEP = 0x0100, 45 KERNFS_LOCKDEP = 0x0100,
46 KERNFS_STATIC_NAME = 0x0200,
47}; 47};
48 48
49/* type-specific structures for kernfs_node union members */ 49/* type-specific structures for kernfs_node union members */
@@ -212,12 +212,13 @@ void kernfs_destroy_root(struct kernfs_root *root);
212struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent, 212struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
213 const char *name, umode_t mode, 213 const char *name, umode_t mode,
214 void *priv, const void *ns); 214 void *priv, const void *ns);
215struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent, 215struct kernfs_node *__kernfs_create_file(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 bool name_is_static,
221 struct lock_class_key *key);
221struct kernfs_node *kernfs_create_link(struct kernfs_node *parent, 222struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
222 const char *name, 223 const char *name,
223 struct kernfs_node *target); 224 struct kernfs_node *target);
@@ -265,10 +266,10 @@ kernfs_create_dir_ns(struct kernfs_node *parent, const char *name,
265{ return ERR_PTR(-ENOSYS); } 266{ return ERR_PTR(-ENOSYS); }
266 267
267static inline struct kernfs_node * 268static inline struct kernfs_node *
268kernfs_create_file_ns_key(struct kernfs_node *parent, const char *name, 269__kernfs_create_file(struct kernfs_node *parent, const char *name,
269 umode_t mode, loff_t size, 270 umode_t mode, loff_t size, const struct kernfs_ops *ops,
270 const struct kernfs_ops *ops, void *priv, 271 void *priv, const void *ns, bool name_is_static,
271 const void *ns, struct lock_class_key *key) 272 struct lock_class_key *key)
272{ return ERR_PTR(-ENOSYS); } 273{ return ERR_PTR(-ENOSYS); }
273 274
274static inline struct kernfs_node * 275static inline struct kernfs_node *
@@ -330,8 +331,8 @@ kernfs_create_file_ns(struct kernfs_node *parent, const char *name,
330#ifdef CONFIG_DEBUG_LOCK_ALLOC 331#ifdef CONFIG_DEBUG_LOCK_ALLOC
331 key = (struct lock_class_key *)&ops->lockdep_key; 332 key = (struct lock_class_key *)&ops->lockdep_key;
332#endif 333#endif
333 return kernfs_create_file_ns_key(parent, name, mode, size, ops, priv, 334 return __kernfs_create_file(parent, name, mode, size, ops, priv, ns,
334 ns, key); 335 false, key);
335} 336}
336 337
337static inline struct kernfs_node * 338static inline struct kernfs_node *