kernfs: implement kernfs_walk_and_get()
Implement kernfs_walk_and_get() which is similar to
kernfs_find_and_get() but can walk a path instead of just a name.
v2: Use strlcpy() instead of strlen() + memcpy() as suggested by
David.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: David Miller <davem@davemloft.net>
This commit is contained in:
@@ -274,6 +274,8 @@ void pr_cont_kernfs_path(struct kernfs_node *kn);
|
||||
struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn);
|
||||
struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
|
||||
const char *name, const void *ns);
|
||||
struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent,
|
||||
const char *path, const void *ns);
|
||||
void kernfs_get(struct kernfs_node *kn);
|
||||
void kernfs_put(struct kernfs_node *kn);
|
||||
|
||||
@@ -350,6 +352,10 @@ static inline struct kernfs_node *
|
||||
kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name,
|
||||
const void *ns)
|
||||
{ return NULL; }
|
||||
static inline struct kernfs_node *
|
||||
kernfs_walk_and_get_ns(struct kernfs_node *parent, const char *path,
|
||||
const void *ns)
|
||||
{ return NULL; }
|
||||
|
||||
static inline void kernfs_get(struct kernfs_node *kn) { }
|
||||
static inline void kernfs_put(struct kernfs_node *kn) { }
|
||||
@@ -430,6 +436,12 @@ kernfs_find_and_get(struct kernfs_node *kn, const char *name)
|
||||
return kernfs_find_and_get_ns(kn, name, NULL);
|
||||
}
|
||||
|
||||
static inline struct kernfs_node *
|
||||
kernfs_walk_and_get(struct kernfs_node *kn, const char *path)
|
||||
{
|
||||
return kernfs_walk_and_get_ns(kn, path, NULL);
|
||||
}
|
||||
|
||||
static inline struct kernfs_node *
|
||||
kernfs_create_dir(struct kernfs_node *parent, const char *name, umode_t mode,
|
||||
void *priv)
|
||||
|
||||
Reference in New Issue
Block a user