fs_struct.h 1.2 KB

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