fs_struct.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 *, struct path *);
  17. extern void set_fs_pwd(struct fs_struct *, struct path *);
  18. extern struct fs_struct *copy_fs_struct(struct fs_struct *);
  19. extern void free_fs_struct(struct fs_struct *);
  20. extern void daemonize_fs_struct(void);
  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. static inline void get_fs_root_and_pwd(struct fs_struct *fs, struct path *root,
  37. struct path *pwd)
  38. {
  39. spin_lock(&fs->lock);
  40. *root = fs->root;
  41. path_get(root);
  42. *pwd = fs->pwd;
  43. path_get(pwd);
  44. spin_unlock(&fs->lock);
  45. }
  46. #endif /* _LINUX_FS_STRUCT_H */