blob: a42b5bf02f8bcfec3ea20ecef765df3f4d690250 [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;
Nick Piggin2a4419b2010-08-18 04:37:33 +10008 spinlock_t lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 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{
Nick Piggin2a4419b2010-08-18 04:37:33 +100026 spin_lock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020027 *root = fs->root;
28 path_get(root);
Nick Piggin2a4419b2010-08-18 04:37:33 +100029 spin_unlock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020030}
31
32static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd)
33{
Nick Piggin2a4419b2010-08-18 04:37:33 +100034 spin_lock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020035 *pwd = fs->pwd;
36 path_get(pwd);
Nick Piggin2a4419b2010-08-18 04:37:33 +100037 spin_unlock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020038}
39
40static inline void get_fs_root_and_pwd(struct fs_struct *fs, struct path *root,
41 struct path *pwd)
42{
Nick Piggin2a4419b2010-08-18 04:37:33 +100043 spin_lock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020044 *root = fs->root;
45 path_get(root);
46 *pwd = fs->pwd;
47 path_get(pwd);
Nick Piggin2a4419b2010-08-18 04:37:33 +100048 spin_unlock(&fs->lock);
Miklos Szeredif7ad3c62010-08-10 11:41:36 +020049}
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#endif /* _LINUX_FS_STRUCT_H */