blob: d0ae3a84bcfb1e65b25a064bf17818ea2cf5d8aa [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 *);
Jan Blunckac748a02008-02-14 19:34:39 -080020extern void set_fs_root(struct fs_struct *, struct path *);
21extern void set_fs_pwd(struct fs_struct *, 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
42static inline void get_fs_root_and_pwd(struct fs_struct *fs, struct path *root,
43 struct path *pwd)
44{
Nick Piggin2a4419b2010-08-18 04:37:33 +100045 spin_lock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020046 *root = fs->root;
47 path_get(root);
48 *pwd = fs->pwd;
49 path_get(pwd);
Nick Piggin2a4419b2010-08-18 04:37:33 +100050 spin_unlock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020051}
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#endif /* _LINUX_FS_STRUCT_H */