namei.h 2.8 KB

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