fs_struct.h 1.2 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
#ifndef _LINUX_FS_STRUCT_H
#define _LINUX_FS_STRUCT_H

J
Jan Blunck 已提交
4
#include <linux/path.h>
N
Nick Piggin 已提交
5 6
#include <linux/spinlock.h>
#include <linux/seqlock.h>
L
Linus Torvalds 已提交
7 8

struct fs_struct {
A
Al Viro 已提交
9
	int users;
N
Nick Piggin 已提交
10
	spinlock_t lock;
N
Nick Piggin 已提交
11
	seqcount_t seq;
L
Linus Torvalds 已提交
12
	int umask;
A
Al Viro 已提交
13
	int in_exec;
A
Al Viro 已提交
14
	struct path root, pwd;
L
Linus Torvalds 已提交
15 16
};

17 18
extern struct kmem_cache *fs_cachep;

L
Linus Torvalds 已提交
19
extern void exit_fs(struct task_struct *);
20 21
extern void set_fs_root(struct fs_struct *, const struct path *);
extern void set_fs_pwd(struct fs_struct *, const struct path *);
L
Linus Torvalds 已提交
22
extern struct fs_struct *copy_fs_struct(struct fs_struct *);
A
Al Viro 已提交
23
extern void free_fs_struct(struct fs_struct *);
24
extern int unshare_fs_struct(void);
L
Linus Torvalds 已提交
25

26 27
static inline void get_fs_root(struct fs_struct *fs, struct path *root)
{
N
Nick Piggin 已提交
28
	spin_lock(&fs->lock);
29 30
	*root = fs->root;
	path_get(root);
N
Nick Piggin 已提交
31
	spin_unlock(&fs->lock);
32 33 34 35
}

static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd)
{
N
Nick Piggin 已提交
36
	spin_lock(&fs->lock);
37 38
	*pwd = fs->pwd;
	path_get(pwd);
N
Nick Piggin 已提交
39
	spin_unlock(&fs->lock);
40 41 42 43 44
}

static inline void get_fs_root_and_pwd(struct fs_struct *fs, struct path *root,
				       struct path *pwd)
{
N
Nick Piggin 已提交
45
	spin_lock(&fs->lock);
46 47 48 49
	*root = fs->root;
	path_get(root);
	*pwd = fs->pwd;
	path_get(pwd);
N
Nick Piggin 已提交
50
	spin_unlock(&fs->lock);
51 52
}

53 54
extern bool current_chrooted(void);

L
Linus Torvalds 已提交
55
#endif /* _LINUX_FS_STRUCT_H */