Commit b5fb63c1 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro

fs: add nd_jump_link

Add a helper that abstracts out the jump to an already parsed struct path
from ->follow_link operation from procfs.  Not only does this clean up
the code by moving the two sides of this game into a single helper, but
it also prepares for making struct nameidata private to namei.c
Signed-off-by: default avatarChristoph Hellwig <>
Signed-off-by: default avatarAl Viro <>
parent 408ef013
......@@ -586,6 +586,21 @@ static inline void path_to_nameidata(const struct path *path,
nd->path.dentry = path->dentry;
* Helper to directly jump to a known parsed path from ->follow_link,
* caller must have taken a reference to path beforehand.
void nd_jump_link(struct nameidata *nd, struct path *path)
nd->path = *path;
nd->inode = nd->path.dentry->d_inode;
nd->flags |= LOOKUP_JUMPED;
static inline void put_link(struct nameidata *nd, struct path *link, void *cookie)
struct inode *inode = link->dentry->d_inode;
......@@ -630,17 +645,9 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
s = nd_get_link(nd);
if (s) {
error = __vfs_follow_link(nd, s);
} else if (nd->last_type == LAST_BIND) {
nd->flags |= LOOKUP_JUMPED;
nd->inode = nd->path.dentry->d_inode;
if (nd->inode->i_op->follow_link) {
/* stepped on a _really_ weird one */
error = -ELOOP;
if (unlikely(error))
put_link(nd, link, *p);
return error;
......@@ -1438,8 +1438,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
if (error)
goto out;
nd->path = path;
nd_jump_link(nd, &path);
return NULL;
return ERR_PTR(error);
......@@ -80,6 +80,8 @@ extern int follow_up(struct path *);
extern struct dentry *lock_rename(struct dentry *, struct dentry *);
extern void unlock_rename(struct dentry *, struct dentry *);
extern void nd_jump_link(struct nameidata *nd, struct path *path);
static inline void nd_set_link(struct nameidata *nd, char *path)
nd->saved_names[nd->depth] = path;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment