1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_FS_STRUCT_H
3#define _LINUX_FS_STRUCT_H
4
5#include <linux/path.h>
6#include <linux/spinlock.h>
7#include <linux/seqlock.h>
8
9struct fs_struct {
10 int users;
11 seqlock_t seq;
12 int umask;
13 int in_exec;
14 struct path root, pwd;
15} __randomize_layout;
16
17extern struct kmem_cache *fs_cachep;
18
19extern void exit_fs(struct task_struct *);
20extern void set_fs_root(struct fs_struct *, const struct path *);
21extern void set_fs_pwd(struct fs_struct *, const struct path *);
22extern struct fs_struct *copy_fs_struct(struct fs_struct *);
23extern void free_fs_struct(struct fs_struct *);
24extern int unshare_fs_struct(void);
25
26static inline void get_fs_root(struct fs_struct *fs, struct path *root)
27{
28 read_seqlock_excl(sl: &fs->seq);
29 *root = fs->root;
30 path_get(root);
31 read_sequnlock_excl(sl: &fs->seq);
32}
33
34static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd)
35{
36 read_seqlock_excl(sl: &fs->seq);
37 *pwd = fs->pwd;
38 path_get(pwd);
39 read_sequnlock_excl(sl: &fs->seq);
40}
41
42extern bool current_chrooted(void);
43
44#endif /* _LINUX_FS_STRUCT_H */
45