diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2010-08-10 05:41:36 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-08-11 00:28:20 -0400 |
commit | f7ad3c6be90809b53b7f0ae9d4eaa45ce2564a79 (patch) | |
tree | dc9b09188bab35320200f318b5e7b52f24dc43ad /include | |
parent | 542ce7a9bc6b3838832ae0f4f8de30c667af8ff3 (diff) |
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/fs_struct.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h index 78a05bfcd8eb..eca3d5202138 100644 --- a/include/linux/fs_struct.h +++ b/include/linux/fs_struct.h | |||
@@ -21,4 +21,31 @@ extern void free_fs_struct(struct fs_struct *); | |||
21 | extern void daemonize_fs_struct(void); | 21 | extern void daemonize_fs_struct(void); |
22 | extern int unshare_fs_struct(void); | 22 | extern int unshare_fs_struct(void); |
23 | 23 | ||
24 | static inline void get_fs_root(struct fs_struct *fs, struct path *root) | ||
25 | { | ||
26 | read_lock(&fs->lock); | ||
27 | *root = fs->root; | ||
28 | path_get(root); | ||
29 | read_unlock(&fs->lock); | ||
30 | } | ||
31 | |||
32 | static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd) | ||
33 | { | ||
34 | read_lock(&fs->lock); | ||
35 | *pwd = fs->pwd; | ||
36 | path_get(pwd); | ||
37 | read_unlock(&fs->lock); | ||
38 | } | ||
39 | |||
40 | static inline void get_fs_root_and_pwd(struct fs_struct *fs, struct path *root, | ||
41 | struct path *pwd) | ||
42 | { | ||
43 | read_lock(&fs->lock); | ||
44 | *root = fs->root; | ||
45 | path_get(root); | ||
46 | *pwd = fs->pwd; | ||
47 | path_get(pwd); | ||
48 | read_unlock(&fs->lock); | ||
49 | } | ||
50 | |||
24 | #endif /* _LINUX_FS_STRUCT_H */ | 51 | #endif /* _LINUX_FS_STRUCT_H */ |