vfs: add helpers to get root and pwd
Add three helpers that retrieve a refcounted copy of the root and cwd from the supplied fs_struct. get_fs_root() get_fs_pwd() get_fs_root_and_pwd() Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
15
fs/namei.c
15
fs/namei.c
@@ -483,13 +483,8 @@ ok:
|
||||
|
||||
static __always_inline void set_root(struct nameidata *nd)
|
||||
{
|
||||
if (!nd->root.mnt) {
|
||||
struct fs_struct *fs = current->fs;
|
||||
read_lock(&fs->lock);
|
||||
nd->root = fs->root;
|
||||
path_get(&nd->root);
|
||||
read_unlock(&fs->lock);
|
||||
}
|
||||
if (!nd->root.mnt)
|
||||
get_fs_root(current->fs, &nd->root);
|
||||
}
|
||||
|
||||
static int link_path_walk(const char *, struct nameidata *);
|
||||
@@ -1015,11 +1010,7 @@ static int path_init(int dfd, const char *name, unsigned int flags, struct namei
|
||||
nd->path = nd->root;
|
||||
path_get(&nd->root);
|
||||
} else if (dfd == AT_FDCWD) {
|
||||
struct fs_struct *fs = current->fs;
|
||||
read_lock(&fs->lock);
|
||||
nd->path = fs->pwd;
|
||||
path_get(&fs->pwd);
|
||||
read_unlock(&fs->lock);
|
||||
get_fs_pwd(current->fs, &nd->path);
|
||||
} else {
|
||||
struct dentry *dentry;
|
||||
|
||||
|
Reference in New Issue
Block a user