namei.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. enum { MAX_NESTED_LINKS = 8 };
  8. struct nameidata {
  9. struct path path;
  10. struct qstr last;
  11. struct path root;
  12. struct inode *inode; /* path.dentry.d_inode */
  13. unsigned int flags;
  14. unsigned seq;
  15. int last_type;
  16. unsigned depth;
  17. char *saved_names[MAX_NESTED_LINKS + 1];
  18. };
  19. /*
  20. * Type of the last component on LOOKUP_PARENT
  21. */
  22. enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
  23. /*
  24. * The bitmask for a lookup event:
  25. * - follow links at the end
  26. * - require a directory
  27. * - ending slashes ok even for nonexistent files
  28. * - internal "there are more path components" flag
  29. * - dentry cache is untrusted; force a real lookup
  30. * - suppress terminal automount
  31. */
  32. #define LOOKUP_FOLLOW 0x0001
  33. #define LOOKUP_DIRECTORY 0x0002
  34. #define LOOKUP_AUTOMOUNT 0x0004
  35. #define LOOKUP_PARENT 0x0010
  36. #define LOOKUP_REVAL 0x0020
  37. #define LOOKUP_RCU 0x0040
  38. /*
  39. * Intent data
  40. */
  41. #define LOOKUP_OPEN 0x0100
  42. #define LOOKUP_CREATE 0x0200
  43. #define LOOKUP_EXCL 0x0400
  44. #define LOOKUP_RENAME_TARGET 0x0800
  45. #define LOOKUP_JUMPED 0x1000
  46. #define LOOKUP_ROOT 0x2000
  47. #define LOOKUP_EMPTY 0x4000
  48. extern int user_path_at(int, const char __user *, unsigned, struct path *);
  49. extern int user_path_at_empty(int, const char __user *, unsigned, struct path *, int *empty);
  50. #define user_path(name, path) user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW, path)
  51. #define user_lpath(name, path) user_path_at(AT_FDCWD, name, 0, path)
  52. #define user_path_dir(name, path) \
  53. user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, path)
  54. extern int kern_path(const char *, unsigned, struct path *);
  55. extern struct dentry *kern_path_create(int, const char *, struct path *, int);
  56. extern struct dentry *user_path_create(int, const char __user *, struct path *, int);
  57. extern struct dentry *kern_path_locked(const char *, struct path *);
  58. extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
  59. const char *, unsigned int, struct path *);
  60. extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
  61. extern int follow_down_one(struct path *);
  62. extern int follow_down(struct path *);
  63. extern int follow_up(struct path *);
  64. extern struct dentry *lock_rename(struct dentry *, struct dentry *);
  65. extern void unlock_rename(struct dentry *, struct dentry *);
  66. static inline void nd_set_link(struct nameidata *nd, char *path)
  67. {
  68. nd->saved_names[nd->depth] = path;
  69. }
  70. static inline char *nd_get_link(struct nameidata *nd)
  71. {
  72. return nd->saved_names[nd->depth];
  73. }
  74. static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
  75. {
  76. ((char *) name)[min(len, maxlen)] = '\0';
  77. }
  78. #endif /* _LINUX_NAMEI_H */