diff options
author | Tejun Heo <tj@kernel.org> | 2013-11-29 17:19:09 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-29 21:41:28 -0500 |
commit | ac9bba031001704a2339713cc12148857eccc5e5 (patch) | |
tree | c058217a47c51021d97454639ed0f7480c73fe6a /fs/kernfs | |
parent | cf9e5a73aaff0204801dd19cb4bd91d32f32026a (diff) |
sysfs, kernfs: implement kernfs_ns_enabled()
fs/sysfs/symlink.c::sysfs_delete_link() tests @sd->s_flags for
SYSFS_FLAG_NS. Let's add kernfs_ns_enabled() so that sysfs doesn't
have to test sysfs_dirent flag directly. This makes things tidier for
kernfs proper too.
This is purely cosmetic.
v2: To avoid possible NULL deref, use noop dummy implementation which
always returns false when !CONFIG_SYSFS.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/kernfs')
-rw-r--r-- | fs/kernfs/dir.c | 10 | ||||
-rw-r--r-- | fs/kernfs/symlink.c | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 7c5b51793689..f51e0625e666 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c | |||
@@ -291,7 +291,7 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags) | |||
291 | goto out_bad; | 291 | goto out_bad; |
292 | 292 | ||
293 | /* The sysfs dirent has been moved to a different namespace */ | 293 | /* The sysfs dirent has been moved to a different namespace */ |
294 | if (sd->s_parent && (sd->s_parent->s_flags & SYSFS_FLAG_NS) && | 294 | if (sd->s_parent && kernfs_ns_enabled(sd->s_parent) && |
295 | sysfs_info(dentry->d_sb)->ns != sd->s_ns) | 295 | sysfs_info(dentry->d_sb)->ns != sd->s_ns) |
296 | goto out_bad; | 296 | goto out_bad; |
297 | 297 | ||
@@ -414,7 +414,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt) | |||
414 | int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, | 414 | int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, |
415 | struct sysfs_dirent *parent_sd) | 415 | struct sysfs_dirent *parent_sd) |
416 | { | 416 | { |
417 | bool has_ns = parent_sd->s_flags & SYSFS_FLAG_NS; | 417 | bool has_ns = kernfs_ns_enabled(parent_sd); |
418 | struct sysfs_inode_attrs *ps_iattr; | 418 | struct sysfs_inode_attrs *ps_iattr; |
419 | int ret; | 419 | int ret; |
420 | 420 | ||
@@ -535,7 +535,7 @@ static struct sysfs_dirent *kernfs_find_ns(struct sysfs_dirent *parent, | |||
535 | const void *ns) | 535 | const void *ns) |
536 | { | 536 | { |
537 | struct rb_node *node = parent->s_dir.children.rb_node; | 537 | struct rb_node *node = parent->s_dir.children.rb_node; |
538 | bool has_ns = parent->s_flags & SYSFS_FLAG_NS; | 538 | bool has_ns = kernfs_ns_enabled(parent); |
539 | unsigned int hash; | 539 | unsigned int hash; |
540 | 540 | ||
541 | lockdep_assert_held(&sysfs_mutex); | 541 | lockdep_assert_held(&sysfs_mutex); |
@@ -685,7 +685,7 @@ static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry, | |||
685 | 685 | ||
686 | mutex_lock(&sysfs_mutex); | 686 | mutex_lock(&sysfs_mutex); |
687 | 687 | ||
688 | if (parent_sd->s_flags & SYSFS_FLAG_NS) | 688 | if (kernfs_ns_enabled(parent_sd)) |
689 | ns = sysfs_info(dir->i_sb)->ns; | 689 | ns = sysfs_info(dir->i_sb)->ns; |
690 | 690 | ||
691 | sd = kernfs_find_ns(parent_sd, dentry->d_name.name, ns); | 691 | sd = kernfs_find_ns(parent_sd, dentry->d_name.name, ns); |
@@ -968,7 +968,7 @@ static int sysfs_readdir(struct file *file, struct dir_context *ctx) | |||
968 | return 0; | 968 | return 0; |
969 | mutex_lock(&sysfs_mutex); | 969 | mutex_lock(&sysfs_mutex); |
970 | 970 | ||
971 | if (parent_sd->s_flags & SYSFS_FLAG_NS) | 971 | if (kernfs_ns_enabled(parent_sd)) |
972 | ns = sysfs_info(dentry->d_sb)->ns; | 972 | ns = sysfs_info(dentry->d_sb)->ns; |
973 | 973 | ||
974 | for (pos = sysfs_dir_pos(ns, parent_sd, ctx->pos, pos); | 974 | for (pos = sysfs_dir_pos(ns, parent_sd, ctx->pos, pos); |
diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c index 004c16465594..12569a738837 100644 --- a/fs/kernfs/symlink.c +++ b/fs/kernfs/symlink.c | |||
@@ -35,7 +35,7 @@ struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent, | |||
35 | if (!sd) | 35 | if (!sd) |
36 | return ERR_PTR(-ENOMEM); | 36 | return ERR_PTR(-ENOMEM); |
37 | 37 | ||
38 | if (parent->s_flags & SYSFS_FLAG_NS) | 38 | if (kernfs_ns_enabled(parent)) |
39 | sd->s_ns = target->s_ns; | 39 | sd->s_ns = target->s_ns; |
40 | sd->s_symlink.target_sd = target; | 40 | sd->s_symlink.target_sd = target; |
41 | kernfs_get(target); /* ref owned by symlink */ | 41 | kernfs_get(target); /* ref owned by symlink */ |