summaryrefslogtreecommitdiff
path: root/lib/kobject.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-02-07 22:32:07 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-08 04:05:35 +0400
commit3eef34ad7dc369b7183ec383908aff3da2f6e5ec (patch)
treefac6ef1dd497adeff55fae499d953d5d51061867 /lib/kobject.c
parent0c23b2259a4850494e2c53e864ea840597c6cdd3 (diff)
downloadlinux-3eef34ad7dc369b7183ec383908aff3da2f6e5ec.tar.xz
kernfs: implement kernfs_get_parent(), kernfs_name/path() and friends
kernfs_node->parent and ->name are currently marked as "published" indicating that kernfs users may access them directly; however, those fields may get updated by kernfs_rename[_ns]() and unrestricted access may lead to erroneous values or oops. Protect ->parent and ->name updates with a irq-safe spinlock kernfs_rename_lock and implement the following accessors for these fields. * kernfs_name() - format the node's name into the specified buffer * kernfs_path() - format the node's path into the specified buffer * pr_cont_kernfs_name() - pr_cont a node's name (doesn't need buffer) * pr_cont_kernfs_path() - pr_cont a node's path (doesn't need buffer) * kernfs_get_parent() - pin and return a node's parent All can be called under any context. The recursive sysfs_pathname() in fs/sysfs/dir.c is replaced with kernfs_path() and sysfs_rename_dir_ns() is updated to use kernfs_get_parent() instead of dereferencing parent directly. v2: Dummy definition of kernfs_path() for !CONFIG_KERNFS was missing static inline making it cause a lot of build warnings. Add it. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/kobject.c')
0 files changed, 0 insertions, 0 deletions