blob: 0efc3e62843ae74592128dc7e34bd11fbaca4a3c [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>
Nick Pigginc28cc362011-01-07 17:49:53 +11005#include <linux/spinlock.h>
6#include <linux/seqlock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
8struct fs_struct {
Al Viro498052b2009-03-30 07:20:30 -04009 int users;
Nick Piggin2a4419b2010-08-18 04:37:33 +100010 spinlock_t lock;
Nick Pigginc28cc362011-01-07 17:49:53 +110011 seqcount_t seq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 int umask;
Al Viro498052b2009-03-30 07:20:30 -040013 int in_exec;
Al Viro7f2da1e2008-05-10 20:44:54 -040014 struct path root, pwd;
Linus Torvalds1da177e2005-04-16 15:20:36 -070015};
16
Christoph Lameteraa362a82006-12-06 20:32:54 -080017extern struct kmem_cache *fs_cachep;
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019extern void exit_fs(struct task_struct *);
Al Virodcf787f2013-03-01 23:51:07 -050020extern void set_fs_root(struct fs_struct *, const struct path *);
21extern void set_fs_pwd(struct fs_struct *, const struct path *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070022extern struct fs_struct *copy_fs_struct(struct fs_struct *);
Al Viro498052b2009-03-30 07:20:30 -040023extern void free_fs_struct(struct fs_struct *);
Al Viro3e93cd62009-03-29 19:00:13 -040024extern int unshare_fs_struct(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020026static inline void get_fs_root(struct fs_struct *fs, struct path *root)
27{
Nick Piggin2a4419b2010-08-18 04:37:33 +100028 spin_lock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020029 *root = fs->root;
30 path_get(root);
Nick Piggin2a4419b2010-08-18 04:37:33 +100031 spin_unlock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020032}
33
34static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd)
35{
Nick Piggin2a4419b2010-08-18 04:37:33 +100036 spin_lock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020037 *pwd = fs->pwd;
38 path_get(pwd);
Nick Piggin2a4419b2010-08-18 04:37:33 +100039 spin_unlock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020040}
41
Eric W. Biederman31515272013-03-15 01:45:51 -070042extern bool current_chrooted(void);
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#endif /* _LINUX_FS_STRUCT_H */