blob: eca3d5202138f68bb30dd1a308aaf4e121171663 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_FS_STRUCT_H
2#define _LINUX_FS_STRUCT_H
3
Jan Blunck6ac08c32008-02-14 19:34:38 -08004#include <linux/path.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6struct fs_struct {
Al Viro498052b2009-03-30 07:20:30 -04007 int users;
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 rwlock_t lock;
9 int umask;
Al Viro498052b2009-03-30 07:20:30 -040010 int in_exec;
Al Viro7f2da1e2008-05-10 20:44:54 -040011 struct path root, pwd;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012};
13
Christoph Lameteraa362a82006-12-06 20:32:54 -080014extern struct kmem_cache *fs_cachep;
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016extern void exit_fs(struct task_struct *);
Jan Blunckac748a02008-02-14 19:34:39 -080017extern void set_fs_root(struct fs_struct *, struct path *);
18extern void set_fs_pwd(struct fs_struct *, struct path *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070019extern struct fs_struct *copy_fs_struct(struct fs_struct *);
Al Viro498052b2009-03-30 07:20:30 -040020extern void free_fs_struct(struct fs_struct *);
Al Viro3e93cd62009-03-29 19:00:13 -040021extern void daemonize_fs_struct(void);
22extern int unshare_fs_struct(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020024static 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
32static 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
40static 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#endif /* _LINUX_FS_STRUCT_H */