linux/include/linux/namei.h
<<
>>
Prefs
   1#ifndef _LINUX_NAMEI_H
   2#define _LINUX_NAMEI_H
   3
   4#include <linux/dcache.h>
   5#include <linux/errno.h>
   6#include <linux/linkage.h>
   7#include <linux/path.h>
   8#include <linux/namei_lookup.h>
   9
  10struct vfsmount;
  11
  12enum { MAX_NESTED_LINKS = 8 };
  13
  14struct nameidata {
  15        struct path     path;
  16        struct qstr     last;
  17        struct path     root;
  18        struct inode    *inode; /* path.dentry.d_inode */
  19        unsigned int    flags;
  20        unsigned        seq;
  21        int             last_type;
  22        unsigned        depth;
  23        char *saved_names[MAX_NESTED_LINKS + 1];
  24        RH_KABI_EXTEND(unsigned  m_seq)
  25};
  26
  27/*
  28 * Type of the last component on LOOKUP_PARENT
  29 */
  30enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
  31
  32
  33extern int user_path_at(int, const char __user *, unsigned, struct path *);
  34extern int user_path_at_empty(int, const char __user *, unsigned, struct path *, int *empty);
  35
  36#define user_path(name, path) user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW, path)
  37#define user_lpath(name, path) user_path_at(AT_FDCWD, name, 0, path)
  38#define user_path_dir(name, path) \
  39        user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, path)
  40
  41extern int kern_path(const char *, unsigned, struct path *);
  42
  43extern struct dentry *kern_path_create(int, const char *, struct path *, unsigned int);
  44extern struct dentry *user_path_create(int, const char __user *, struct path *, unsigned int);
  45extern void done_path_create(struct path *, struct dentry *);
  46extern struct dentry *kern_path_locked(const char *, struct path *);
  47extern int kern_path_mountpoint(int, const char *, struct path *, unsigned int);
  48
  49extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
  50extern struct dentry *lookup_one_len_unlocked(const char *, struct dentry *, int);
  51
  52extern int follow_down_one(struct path *);
  53extern int follow_down(struct path *);
  54extern int follow_up(struct path *);
  55
  56extern struct dentry *lock_rename(struct dentry *, struct dentry *);
  57extern void unlock_rename(struct dentry *, struct dentry *);
  58
  59extern void nd_jump_link(struct nameidata *nd, struct path *path);
  60
  61static inline void nd_set_link(struct nameidata *nd, char *path)
  62{
  63        nd->saved_names[nd->depth] = path;
  64}
  65
  66static inline char *nd_get_link(struct nameidata *nd)
  67{
  68        return nd->saved_names[nd->depth];
  69}
  70
  71static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
  72{
  73        ((char *) name)[min(len, maxlen)] = '\0';
  74}
  75
  76/**
  77 * retry_estale - determine whether the caller should retry an operation
  78 * @error: the error that would currently be returned
  79 * @flags: flags being used for next lookup attempt
  80 *
  81 * Check to see if the error code was -ESTALE, and then determine whether
  82 * to retry the call based on whether "flags" already has LOOKUP_REVAL set.
  83 *
  84 * Returns true if the caller should try the operation again.
  85 */
  86static inline bool
  87retry_estale(const long error, const unsigned int flags)
  88{
  89        return error == -ESTALE && !(flags & LOOKUP_REVAL);
  90}
  91
  92#endif /* _LINUX_NAMEI_H */
  93