fs_struct.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:1k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. #ifndef _LINUX_FS_STRUCT_H
  2. #define _LINUX_FS_STRUCT_H
  3. #ifdef __KERNEL__
  4. struct fs_struct {
  5. atomic_t count;
  6. rwlock_t lock;
  7. int umask;
  8. struct dentry * root, * pwd, * altroot;
  9. struct vfsmount * rootmnt, * pwdmnt, * altrootmnt;
  10. };
  11. #define INIT_FS { 
  12. ATOMIC_INIT(1), 
  13. RW_LOCK_UNLOCKED, 
  14. 0022, 
  15. NULL, NULL, NULL, NULL, NULL, NULL 
  16. }
  17. extern void exit_fs(struct task_struct *);
  18. extern void set_fs_altroot(void);
  19. /*
  20.  * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
  21.  * It can block. Requires the big lock held.
  22.  */
  23. static inline void set_fs_root(struct fs_struct *fs,
  24. struct vfsmount *mnt,
  25. struct dentry *dentry)
  26. {
  27. struct dentry *old_root;
  28. struct vfsmount *old_rootmnt;
  29. write_lock(&fs->lock);
  30. old_root = fs->root;
  31. old_rootmnt = fs->rootmnt;
  32. fs->rootmnt = mntget(mnt);
  33. fs->root = dget(dentry);
  34. write_unlock(&fs->lock);
  35. if (old_root) {
  36. dput(old_root);
  37. mntput(old_rootmnt);
  38. }
  39. }
  40. /*
  41.  * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values.
  42.  * It can block. Requires the big lock held.
  43.  */
  44. static inline void set_fs_pwd(struct fs_struct *fs,
  45. struct vfsmount *mnt,
  46. struct dentry *dentry)
  47. {
  48. struct dentry *old_pwd;
  49. struct vfsmount *old_pwdmnt;
  50. write_lock(&fs->lock);
  51. old_pwd = fs->pwd;
  52. old_pwdmnt = fs->pwdmnt;
  53. fs->pwdmnt = mntget(mnt);
  54. fs->pwd = dget(dentry);
  55. write_unlock(&fs->lock);
  56. if (old_pwd) {
  57. dput(old_pwd);
  58. mntput(old_pwdmnt);
  59. }
  60. }
  61. struct fs_struct *copy_fs_struct(struct fs_struct *old);
  62. void put_fs_struct(struct fs_struct *fs);
  63. #endif
  64. #endif