Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_FS_STRUCT_H |
| 2 | #define _LINUX_FS_STRUCT_H |
| 3 | |
Jan Blunck | 6ac08c3 | 2008-02-14 19:34:38 -0800 | [diff] [blame] | 4 | #include <linux/path.h> |
Nick Piggin | c28cc36 | 2011-01-07 17:49:53 +1100 | [diff] [blame] | 5 | #include <linux/spinlock.h> |
| 6 | #include <linux/seqlock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
| 8 | struct fs_struct { |
Al Viro | 498052b | 2009-03-30 07:20:30 -0400 | [diff] [blame] | 9 | int users; |
Nick Piggin | 2a4419b | 2010-08-18 04:37:33 +1000 | [diff] [blame] | 10 | spinlock_t lock; |
Nick Piggin | c28cc36 | 2011-01-07 17:49:53 +1100 | [diff] [blame] | 11 | seqcount_t seq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | int umask; |
Al Viro | 498052b | 2009-03-30 07:20:30 -0400 | [diff] [blame] | 13 | int in_exec; |
Al Viro | 7f2da1e | 2008-05-10 20:44:54 -0400 | [diff] [blame] | 14 | struct path root, pwd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | }; |
| 16 | |
Christoph Lameter | aa362a8 | 2006-12-06 20:32:54 -0800 | [diff] [blame] | 17 | extern struct kmem_cache *fs_cachep; |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | extern void exit_fs(struct task_struct *); |
Al Viro | dcf787f | 2013-03-01 23:51:07 -0500 | [diff] [blame] | 20 | extern void set_fs_root(struct fs_struct *, const struct path *); |
| 21 | extern void set_fs_pwd(struct fs_struct *, const struct path *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | extern struct fs_struct *copy_fs_struct(struct fs_struct *); |
Al Viro | 498052b | 2009-03-30 07:20:30 -0400 | [diff] [blame] | 23 | extern void free_fs_struct(struct fs_struct *); |
Al Viro | 3e93cd6 | 2009-03-29 19:00:13 -0400 | [diff] [blame] | 24 | extern int unshare_fs_struct(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Miklos Szeredi | f7ad3c6 | 2010-08-10 11:41:36 +0200 | [diff] [blame] | 26 | static inline void get_fs_root(struct fs_struct *fs, struct path *root) |
| 27 | { |
Nick Piggin | 2a4419b | 2010-08-18 04:37:33 +1000 | [diff] [blame] | 28 | spin_lock(&fs->lock); |
Miklos Szeredi | f7ad3c6 | 2010-08-10 11:41:36 +0200 | [diff] [blame] | 29 | *root = fs->root; |
| 30 | path_get(root); |
Nick Piggin | 2a4419b | 2010-08-18 04:37:33 +1000 | [diff] [blame] | 31 | spin_unlock(&fs->lock); |
Miklos Szeredi | f7ad3c6 | 2010-08-10 11:41:36 +0200 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd) |
| 35 | { |
Nick Piggin | 2a4419b | 2010-08-18 04:37:33 +1000 | [diff] [blame] | 36 | spin_lock(&fs->lock); |
Miklos Szeredi | f7ad3c6 | 2010-08-10 11:41:36 +0200 | [diff] [blame] | 37 | *pwd = fs->pwd; |
| 38 | path_get(pwd); |
Nick Piggin | 2a4419b | 2010-08-18 04:37:33 +1000 | [diff] [blame] | 39 | spin_unlock(&fs->lock); |
Miklos Szeredi | f7ad3c6 | 2010-08-10 11:41:36 +0200 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static inline void get_fs_root_and_pwd(struct fs_struct *fs, struct path *root, |
| 43 | struct path *pwd) |
| 44 | { |
Nick Piggin | 2a4419b | 2010-08-18 04:37:33 +1000 | [diff] [blame] | 45 | spin_lock(&fs->lock); |
Miklos Szeredi | f7ad3c6 | 2010-08-10 11:41:36 +0200 | [diff] [blame] | 46 | *root = fs->root; |
| 47 | path_get(root); |
| 48 | *pwd = fs->pwd; |
| 49 | path_get(pwd); |
Nick Piggin | 2a4419b | 2010-08-18 04:37:33 +1000 | [diff] [blame] | 50 | spin_unlock(&fs->lock); |
Miklos Szeredi | f7ad3c6 | 2010-08-10 11:41:36 +0200 | [diff] [blame] | 51 | } |
| 52 | |
Eric W. Biederman | 3151527 | 2013-03-15 01:45:51 -0700 | [diff] [blame] | 53 | extern bool current_chrooted(void); |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | #endif /* _LINUX_FS_STRUCT_H */ |