blob: 003dc0fd73473a8e03cb23a163d7ae2ee547fa93 [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 void daemonize_fs_struct(void);
25extern int unshare_fs_struct(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020027static inline void get_fs_root(struct fs_struct *fs, struct path *root)
28{
Nick Piggin2a4419b2010-08-18 04:37:33 +100029 spin_lock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020030 *root = fs->root;
31 path_get(root);
Nick Piggin2a4419b2010-08-18 04:37:33 +100032 spin_unlock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020033}
34
35static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd)
36{
Nick Piggin2a4419b2010-08-18 04:37:33 +100037 spin_lock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020038 *pwd = fs->pwd;
39 path_get(pwd);
Nick Piggin2a4419b2010-08-18 04:37:33 +100040 spin_unlock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020041}
42
43static inline void get_fs_root_and_pwd(struct fs_struct *fs, struct path *root,
44 struct path *pwd)
45{
Nick Piggin2a4419b2010-08-18 04:37:33 +100046 spin_lock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020047 *root = fs->root;
48 path_get(root);
49 *pwd = fs->pwd;
50 path_get(pwd);
Nick Piggin2a4419b2010-08-18 04:37:33 +100051 spin_unlock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020052}
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#endif /* _LINUX_FS_STRUCT_H */