namei.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef _LINUX_NAMEI_H
  2. #define _LINUX_NAMEI_H
  3. #include <linux/dcache.h>
  4. #include <linux/linkage.h>
  5. struct vfsmount;
  6. struct open_intent {
  7. int flags;
  8. int create_mode;
  9. struct file *file;
  10. };
  11. enum { MAX_NESTED_LINKS = 8 };
  12. struct nameidata {
  13. struct dentry *dentry;
  14. struct vfsmount *mnt;
  15. struct qstr last;
  16. unsigned int flags;
  17. int last_type;
  18. unsigned depth;
  19. char *saved_names[MAX_NESTED_LINKS + 1];
  20. /* Intent data */
  21. union {
  22. struct open_intent open;
  23. } intent;
  24. };
  25. struct path {
  26. struct vfsmount *mnt;
  27. struct dentry *dentry;
  28. };
  29. /*
  30. * Type of the last component on LOOKUP_PARENT
  31. */
  32. enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
  33. /*
  34. * The bitmask for a lookup event:
  35. * - follow links at the end
  36. * - require a directory
  37. * - ending slashes ok even for nonexistent files
  38. * - internal "there are more path compnents" flag
  39. * - locked when lookup done with dcache_lock held
  40. * - dentry cache is untrusted; force a real lookup
  41. */
  42. #define LOOKUP_FOLLOW 1
  43. #define LOOKUP_DIRECTORY 2
  44. #define LOOKUP_CONTINUE 4
  45. #define LOOKUP_PARENT 16
  46. #define LOOKUP_NOALT 32
  47. #define LOOKUP_REVAL 64
  48. /*
  49. * Intent data
  50. */
  51. #define LOOKUP_OPEN (0x0100)
  52. #define LOOKUP_CREATE (0x0200)
  53. #define LOOKUP_ACCESS (0x0400)
  54. #define LOOKUP_CHDIR (0x0800)
  55. extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
  56. extern int FASTCALL(__user_walk_fd(int dfd, const char __user *, unsigned, struct nameidata *));
  57. #define user_path_walk(name,nd) \
  58. __user_walk_fd(AT_FDCWD, name, LOOKUP_FOLLOW, nd)
  59. #define user_path_walk_link(name,nd) \
  60. __user_walk_fd(AT_FDCWD, name, 0, nd)
  61. extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
  62. extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
  63. const char *, unsigned int, struct nameidata *);
  64. extern int FASTCALL(path_walk(const char *, struct nameidata *));
  65. extern void path_release(struct nameidata *);
  66. extern void path_release_on_umount(struct nameidata *);
  67. extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags);
  68. extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags);
  69. extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
  70. int (*open)(struct inode *, struct file *));
  71. extern struct file *nameidata_to_filp(struct nameidata *nd, int flags);
  72. extern void release_open_intent(struct nameidata *);
  73. extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
  74. extern struct dentry *lookup_one_len_kern(const char *, struct dentry *, int);
  75. extern int follow_down(struct vfsmount **, struct dentry **);
  76. extern int follow_up(struct vfsmount **, struct dentry **);
  77. extern struct dentry *lock_rename(struct dentry *, struct dentry *);
  78. extern void unlock_rename(struct dentry *, struct dentry *);
  79. static inline void nd_set_link(struct nameidata *nd, char *path)
  80. {
  81. nd->saved_names[nd->depth] = path;
  82. }
  83. static inline char *nd_get_link(struct nameidata *nd)
  84. {
  85. return nd->saved_names[nd->depth];
  86. }
  87. #endif /* _LINUX_NAMEI_H */