namei.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef _LINUX_NAMEI_H
  2. #define _LINUX_NAMEI_H
  3. #include <linux/dcache.h>
  4. #include <linux/linkage.h>
  5. #include <linux/path.h>
  6. struct vfsmount;
  7. struct open_intent {
  8. int flags;
  9. int create_mode;
  10. struct file *file;
  11. };
  12. enum { MAX_NESTED_LINKS = 8 };
  13. struct nameidata {
  14. struct path path;
  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. /*
  26. * Type of the last component on LOOKUP_PARENT
  27. */
  28. enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
  29. /*
  30. * The bitmask for a lookup event:
  31. * - follow links at the end
  32. * - require a directory
  33. * - ending slashes ok even for nonexistent files
  34. * - internal "there are more path compnents" flag
  35. * - locked when lookup done with dcache_lock held
  36. * - dentry cache is untrusted; force a real lookup
  37. */
  38. #define LOOKUP_FOLLOW 1
  39. #define LOOKUP_DIRECTORY 2
  40. #define LOOKUP_CONTINUE 4
  41. #define LOOKUP_PARENT 16
  42. #define LOOKUP_NOALT 32
  43. #define LOOKUP_REVAL 64
  44. /*
  45. * Intent data
  46. */
  47. #define LOOKUP_OPEN (0x0100)
  48. #define LOOKUP_CREATE (0x0200)
  49. #define LOOKUP_ACCESS (0x0400)
  50. extern int __user_walk(const char __user *, unsigned, struct nameidata *);
  51. extern int __user_walk_fd(int dfd, const char __user *, unsigned, struct nameidata *);
  52. #define user_path_walk(name,nd) \
  53. __user_walk_fd(AT_FDCWD, name, LOOKUP_FOLLOW, nd)
  54. #define user_path_walk_link(name,nd) \
  55. __user_walk_fd(AT_FDCWD, name, 0, nd)
  56. extern int path_lookup(const char *, unsigned, struct nameidata *);
  57. extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
  58. const char *, unsigned int, struct nameidata *);
  59. extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags);
  60. extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags);
  61. extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
  62. int (*open)(struct inode *, struct file *));
  63. extern struct file *nameidata_to_filp(struct nameidata *nd, int flags);
  64. extern void release_open_intent(struct nameidata *);
  65. extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
  66. extern struct dentry *lookup_one_noperm(const char *, struct dentry *);
  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 */