fs_struct.h 1.0 KB

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