Skip to content

Commit

Permalink
Introduce path_get()
Browse files Browse the repository at this point in the history
This introduces the symmetric function to path_put() for getting a reference
to the dentry and vfsmount of a struct path in the right order.

Signed-off-by: Jan Blunck <[email protected]>
Signed-off-by: Andreas Gruenbacher <[email protected]>
Acked-by: Christoph Hellwig <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jan Blunck authored and Linus Torvalds committed Feb 15, 2008
1 parent 09da591 commit 5dd784d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,19 @@ int deny_write_access(struct file * file)
return 0;
}

/**
* path_get - get a reference to a path
* @path: path to get the reference to
*
* Given a path increment the reference count to the dentry and the vfsmount.
*/
void path_get(struct path *path)
{
mntget(path->mnt);
dget(path->dentry);
}
EXPORT_SYMBOL(path_get);

/**
* path_put - put a reference to a path
* @path: path to put the reference to
Expand Down Expand Up @@ -1160,8 +1173,8 @@ static int do_path_lookup(int dfd, const char *name,
if (retval)
goto fput_fail;

nd->path.mnt = mntget(file->f_path.mnt);
nd->path.dentry = dget(dentry);
nd->path = file->f_path;
path_get(&file->f_path);

fput_light(file, fput_needed);
}
Expand Down
1 change: 1 addition & 0 deletions include/linux/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct path {
struct dentry *dentry;
};

extern void path_get(struct path *);
extern void path_put(struct path *);

#endif /* _LINUX_PATH_H */

0 comments on commit 5dd784d

Please sign in to comment.