diff options
author | Tejun Heo <tj@kernel.org> | 2014-02-07 13:32:07 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-07 16:05:35 -0800 |
commit | 3eef34ad7dc369b7183ec383908aff3da2f6e5ec (patch) | |
tree | fac6ef1dd497adeff55fae499d953d5d51061867 /include/linux/sysfs.h | |
parent | 0c23b2259a4850494e2c53e864ea840597c6cdd3 (diff) | |
download | linux-stable-3eef34ad7dc369b7183ec383908aff3da2f6e5ec.tar.gz linux-stable-3eef34ad7dc369b7183ec383908aff3da2f6e5ec.tar.bz2 linux-stable-3eef34ad7dc369b7183ec383908aff3da2f6e5ec.zip |
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 'include/linux/sysfs.h')
0 files changed, 0 insertions, 0 deletions