aboutsummaryrefslogtreecommitdiffstats
path: root/fs/kernfs/dir.c
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 /fs/kernfs/dir.c
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 'fs/kernfs/dir.c')
-rw-r--r--fs/kernfs/dir.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index ba5f372a226d..e1681775abd5 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -240,7 +240,7 @@ void kernfs_put(struct kernfs_node *kn)
240 240
241 if (kernfs_type(kn) == KERNFS_LINK) 241 if (kernfs_type(kn) == KERNFS_LINK)
242 kernfs_put(kn->symlink.target_kn); 242 kernfs_put(kn->symlink.target_kn);
243 if (kernfs_type(kn) & KERNFS_COPY_NAME) 243 if (!(kn->flags & KERNFS_STATIC_NAME))
244 kfree(kn->name); 244 kfree(kn->name);
245 if (kn->iattr) { 245 if (kn->iattr) {
246 if (kn->iattr->ia_secdata) 246 if (kn->iattr->ia_secdata)
@@ -336,13 +336,13 @@ const struct dentry_operations kernfs_dops = {
336}; 336};
337 337
338struct kernfs_node *kernfs_new_node(struct kernfs_root *root, const char *name, 338struct kernfs_node *kernfs_new_node(struct kernfs_root *root, const char *name,
339 umode_t mode, int type) 339 umode_t mode, unsigned flags)
340{ 340{
341 char *dup_name = NULL; 341 char *dup_name = NULL;
342 struct kernfs_node *kn; 342 struct kernfs_node *kn;
343 int ret; 343 int ret;
344 344
345 if (type & KERNFS_COPY_NAME) { 345 if (!(flags & KERNFS_STATIC_NAME)) {
346 name = dup_name = kstrdup(name, GFP_KERNEL); 346 name = dup_name = kstrdup(name, GFP_KERNEL);
347 if (!name) 347 if (!name)
348 return NULL; 348 return NULL;
@@ -362,7 +362,7 @@ struct kernfs_node *kernfs_new_node(struct kernfs_root *root, const char *name,
362 362
363 kn->name = name; 363 kn->name = name;
364 kn->mode = mode; 364 kn->mode = mode;
365 kn->flags = type | KERNFS_REMOVED; 365 kn->flags = flags | KERNFS_REMOVED;
366 366
367 return kn; 367 return kn;
368 368