fs_struct.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef _LINUX_FS_STRUCT_H
  2. #define _LINUX_FS_STRUCT_H
  3. #include <linux/path.h>
  4. struct fs_struct {
  5. int users;
  6. rwlock_t lock;
  7. int umask;
  8. int in_exec;
  9. struct path root, pwd;
  10. };
  11. extern struct kmem_cache *fs_cachep;
  12. extern void exit_fs(struct task_struct *);
  13. extern void set_fs_root(struct fs_struct *, struct path *);
  14. extern void set_fs_pwd(struct fs_struct *, struct path *);
  15. extern struct fs_struct *copy_fs_struct(struct fs_struct *);
  16. extern void free_fs_struct(struct fs_struct *);
  17. extern void daemonize_fs_struct(void);
  18. extern int unshare_fs_struct(void);
  19. static inline void get_fs_root(struct fs_struct *fs, struct path *root)
  20. {
  21. read_lock(&fs->lock);
  22. *root = fs->root;
  23. path_get(root);
  24. read_unlock(&fs->lock);
  25. }
  26. static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd)
  27. {
  28. read_lock(&fs->lock);
  29. *pwd = fs->pwd;
  30. path_get(pwd);
  31. read_unlock(&fs->lock);
  32. }
  33. static inline void get_fs_root_and_pwd(struct fs_struct *fs, struct path *root,
  34. struct path *pwd)
  35. {
  36. read_lock(&fs->lock);
  37. *root = fs->root;
  38. path_get(root);
  39. *pwd = fs->pwd;
  40. path_get(pwd);
  41. read_unlock(&fs->lock);
  42. }
  43. #endif /* _LINUX_FS_STRUCT_H */