namei.h 2.2 KB

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