Introduce path_get()
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 <jblunck@suse.de> Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
09da5916ba
commit
5dd784d049
17
fs/namei.c
17
fs/namei.c
@@ -362,6 +362,19 @@ int deny_write_access(struct file * file)
|
|||||||
return 0;
|
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_put - put a reference to a path
|
||||||
* @path: path to put the reference to
|
* @path: path to put the reference to
|
||||||
@@ -1160,8 +1173,8 @@ static int do_path_lookup(int dfd, const char *name,
|
|||||||
if (retval)
|
if (retval)
|
||||||
goto fput_fail;
|
goto fput_fail;
|
||||||
|
|
||||||
nd->path.mnt = mntget(file->f_path.mnt);
|
nd->path = file->f_path;
|
||||||
nd->path.dentry = dget(dentry);
|
path_get(&file->f_path);
|
||||||
|
|
||||||
fput_light(file, fput_needed);
|
fput_light(file, fput_needed);
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@ struct path {
|
|||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern void path_get(struct path *);
|
||||||
extern void path_put(struct path *);
|
extern void path_put(struct path *);
|
||||||
|
|
||||||
#endif /* _LINUX_PATH_H */
|
#endif /* _LINUX_PATH_H */
|
||||||
|
Reference in New Issue
Block a user