The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/namei.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: namei.h,v 1.60.14.3 2010/02/14 13:30:04 bouyer Exp $   */
    2 
    3 /*
    4  * WARNING: GENERATED FILE.  DO NOT EDIT
    5  * (edit namei.src and run make namei)
    6  *   by:   NetBSD: gennameih.awk,v 1.2 2008/04/30 13:11:00 martin Exp 
    7  *   from: NetBSD: namei.src,v 1.8.14.2 2010/02/14 13:27:45 bouyer Exp 
    8  */
    9 
   10 /*
   11  * Copyright (c) 1985, 1989, 1991, 1993
   12  *      The Regents of the University of California.  All rights reserved.
   13  *
   14  * Redistribution and use in source and binary forms, with or without
   15  * modification, are permitted provided that the following conditions
   16  * are met:
   17  * 1. Redistributions of source code must retain the above copyright
   18  *    notice, this list of conditions and the following disclaimer.
   19  * 2. Redistributions in binary form must reproduce the above copyright
   20  *    notice, this list of conditions and the following disclaimer in the
   21  *    documentation and/or other materials provided with the distribution.
   22  * 3. Neither the name of the University nor the names of its contributors
   23  *    may be used to endorse or promote products derived from this software
   24  *    without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   36  * SUCH DAMAGE.
   37  *
   38  *      @(#)namei.h     8.5 (Berkeley) 8/20/94
   39  */
   40 
   41 #ifndef _SYS_NAMEI_H_
   42 #define _SYS_NAMEI_H_
   43 
   44 #include <sys/queue.h>
   45 #include <sys/mutex.h>
   46 
   47 #ifdef _KERNEL
   48 #include <sys/kauth.h>
   49 
   50 /*
   51  * Encapsulation of namei parameters.
   52  */
   53 struct nameidata {
   54         /*
   55          * Arguments to namei/lookup.
   56          */
   57         const char *ni_dirp;            /* pathname pointer */
   58         enum    uio_seg ni_segflg;      /* location of pathname */
   59         /*
   60          * Arguments to lookup.
   61          */
   62         struct  vnode *ni_startdir;     /* starting directory */
   63         struct  vnode *ni_rootdir;      /* logical root directory */
   64         struct  vnode *ni_erootdir;     /* emulation root directory */
   65         /*
   66          * Results: returned from/manipulated by lookup
   67          */
   68         struct  vnode *ni_vp;           /* vnode of result */
   69         struct  vnode *ni_dvp;          /* vnode of intermediate directory */
   70         /*
   71          * Shared between namei and lookup/commit routines.
   72          */
   73         size_t          ni_pathlen;     /* remaining chars in path */
   74         const char      *ni_next;       /* next location in pathname */
   75         unsigned int    ni_loopcnt;     /* count of symlinks encountered */
   76         /*
   77          * Lookup parameters: this structure describes the subset of
   78          * information from the nameidata structure that is passed
   79          * through the VOP interface.
   80          */
   81         struct componentname {
   82                 /*
   83                  * Arguments to lookup.
   84                  */
   85                 uint32_t        cn_nameiop;     /* namei operation */
   86                 uint32_t        cn_flags;       /* flags to namei */
   87                 kauth_cred_t    cn_cred;        /* credentials */
   88                 /*
   89                  * Shared between lookup and commit routines.
   90                  */
   91                 char            *cn_pnbuf;      /* pathname buffer */
   92                 const char      *cn_nameptr;    /* pointer to looked up name */
   93                 size_t          cn_namelen;     /* length of looked up comp */
   94                 u_long          cn_hash;        /* hash val of looked up name */
   95                 size_t          cn_consume;     /* chars to consume in lookup */
   96         } ni_cnd;
   97 };
   98 
   99 /*
  100  * namei operations
  101  */
  102 #define LOOKUP          0       /* perform name lookup only */
  103 #define CREATE          1       /* setup for file creation */
  104 #define DELETE          2       /* setup for file deletion */
  105 #define RENAME          3       /* setup for file renaming */
  106 #define OPMASK          3       /* mask for operation */
  107 /*
  108  * namei operational modifier flags, stored in ni_cnd.cn_flags
  109  */
  110 #define LOCKLEAF        0x0004  /* lock inode on return */
  111 #define LOCKPARENT      0x0008  /* want parent vnode returned locked */
  112 #define NOCHROOT        0x0010  /* no chroot on abs path lookups */
  113 #define NOCACHE         0x0020  /* name must not be left in cache */
  114 #define FOLLOW          0x0040  /* follow symbolic links */
  115 #define NOFOLLOW        0x0000  /* do not follow symbolic links (pseudo) */
  116 #define TRYEMULROOT     0x0010  /* try relative to emulation root first */
  117 #define EMULROOTSET     0x0080  /* emulation root already in ni_erootdir */
  118 #define MODMASK         0x00fc  /* mask of operational modifiers */
  119 /*
  120  * Namei parameter descriptors.
  121  *
  122  * SAVENAME may be set by either the callers of namei or by VOP_LOOKUP.
  123  * If the caller of namei sets the flag (for example execve wants to
  124  * know the name of the program that is being executed), then it must
  125  * free the buffer. If VOP_LOOKUP sets the flag, then the buffer must
  126  * be freed by either the commit routine or the VOP_ABORT routine.
  127  * SAVESTART is set only by the callers of namei. It implies SAVENAME
  128  * plus the addition of saving the parent directory that contains the
  129  * name in ni_startdir. It allows repeated calls to lookup for the
  130  * name being sought. The caller is responsible for releasing the
  131  * buffer and for vrele'ing ni_startdir.
  132  */
  133 #define NOCROSSMOUNT    0x0000100       /* do not cross mount points */
  134 #define RDONLY          0x0000200       /* lookup with read-only semantics */
  135 #define HASBUF          0x0000400       /* has allocated pathname buffer */
  136 #define SAVENAME        0x0000800       /* save pathname buffer */
  137 #define SAVESTART       0x0001000       /* save starting directory */
  138 #define ISDOTDOT        0x0002000       /* current component name is .. */
  139 #define MAKEENTRY       0x0004000       /* entry is to be added to name cache */
  140 #define ISLASTCN        0x0008000       /* this is last component of pathname */
  141 #define ISSYMLINK       0x0010000       /* symlink needs interpretation */
  142 #define ISWHITEOUT      0x0020000       /* found whiteout */
  143 #define DOWHITEOUT      0x0040000       /* do whiteouts */
  144 #define REQUIREDIR      0x0080000       /* must be a directory */
  145 #define CREATEDIR       0x0200000       /* trailing slashes are ok */
  146 #define INRENAME        0x0400000       /* operation is a part of ``rename'' */
  147 #define PARAMASK        0x06fff00       /* mask of parameter descriptors */
  148 
  149 /*
  150  * Initialization of an nameidata structure.
  151  */
  152 #define NDINIT(ndp, op, flags, segflg, namep) { \
  153         (ndp)->ni_cnd.cn_nameiop = op; \
  154         (ndp)->ni_cnd.cn_flags = flags; \
  155         (ndp)->ni_segflg = segflg; \
  156         (ndp)->ni_dirp = namep; \
  157         (ndp)->ni_cnd.cn_cred = kauth_cred_get(); \
  158 }
  159 #endif
  160 
  161 /*
  162  * This structure describes the elements in the cache of recent
  163  * names looked up by namei. NCHNAMLEN is sized to make structure
  164  * size a power of two to optimize malloc's. Minimum reasonable
  165  * size is 15.
  166  */
  167 
  168 #define NCHNAMLEN       31      /* maximum name segment length we bother with */
  169 
  170 /*
  171  * Namecache entry.  This structure is arranged so that frequently
  172  * accessed and mostly read-only data is toward the front, with
  173  * infrequently accessed data and the lock towards the rear.  The
  174  * lock is then more likely to be in a seperate cache line.
  175  */
  176 struct  namecache {
  177         LIST_ENTRY(namecache) nc_hash;  /* hash chain */
  178         LIST_ENTRY(namecache) nc_vhash; /* directory hash chain */
  179         struct  vnode *nc_dvp;          /* vnode of parent of name */
  180         struct  vnode *nc_vp;           /* vnode the name refers to */
  181         int     nc_flags;               /* copy of componentname's ISWHITEOUT */
  182         char    nc_nlen;                /* length of name */
  183         char    nc_name[NCHNAMLEN];     /* segment name */
  184         void    *nc_gcqueue;            /* queue for garbage collection */
  185         TAILQ_ENTRY(namecache) nc_lru;  /* psuedo-lru chain */
  186         LIST_ENTRY(namecache) nc_dvlist;
  187         LIST_ENTRY(namecache) nc_vlist;
  188         kmutex_t nc_lock;               /* lock on this entry */
  189         int     nc_hittime;             /* last time scored a hit */
  190 };
  191 
  192 #ifdef _KERNEL
  193 #include <sys/mallocvar.h>
  194 #include <sys/pool.h>
  195 
  196 struct mount;
  197 struct cpu_info;
  198 
  199 extern pool_cache_t pnbuf_cache;        /* pathname buffer cache */
  200 
  201 #define PNBUF_GET()     pool_cache_get(pnbuf_cache, PR_WAITOK)
  202 #define PNBUF_PUT(pnb)  pool_cache_put(pnbuf_cache, (pnb))
  203 
  204 int     namei(struct nameidata *);
  205 uint32_t namei_hash(const char *, const char **);
  206 int     lookup(struct nameidata *);
  207 int     relookup(struct vnode *, struct vnode **, struct componentname *);
  208 void    cache_purge1(struct vnode *, const struct componentname *, int);
  209 #define PURGE_PARENTS   1
  210 #define PURGE_CHILDREN  2
  211 #define cache_purge(vp) cache_purge1((vp), NULL, PURGE_PARENTS|PURGE_CHILDREN)
  212 int     cache_lookup(struct vnode *, struct vnode **, struct componentname *);
  213 int     cache_lookup_raw(struct vnode *, struct vnode **,
  214                          struct componentname *);
  215 int     cache_revlookup(struct vnode *, struct vnode **, char **, char *);
  216 void    cache_enter(struct vnode *, struct vnode *, struct componentname *);
  217 void    nchinit(void);
  218 void    nchreinit(void);
  219 void    cache_cpu_init(struct cpu_info *);
  220 void    cache_purgevfs(struct mount *);
  221 void    namecache_print(struct vnode *, void (*)(const char *, ...));
  222 
  223 #endif
  224 
  225 /*
  226  * Stats on usefulness of namei caches.
  227  * XXX: should be 64-bit counters.
  228  */
  229 struct  nchstats {
  230         long    ncs_goodhits;           /* hits that we can really use */
  231         long    ncs_neghits;            /* negative hits that we can use */
  232         long    ncs_badhits;            /* hits we must drop */
  233         long    ncs_falsehits;          /* hits with id mismatch */
  234         long    ncs_miss;               /* misses */
  235         long    ncs_long;               /* long names that ignore cache */
  236         long    ncs_pass2;              /* names found with passes == 2 */
  237         long    ncs_2passes;            /* number of times we attempt it */
  238         long    ncs_revhits;            /* reverse-cache hits */
  239         long    ncs_revmiss;            /* reverse-cache misses */
  240 };
  241 
  242 #ifdef _KERNEL
  243 extern struct nchstats nchstats;
  244 #endif
  245 /* #endif !_SYS_NAMEI_H_ (generated by gennameih.awk) */
  246 
  247 /* Definitions match above, but with NAMEI_ prefix */
  248 #define NAMEI_LOOKUP    0
  249 #define NAMEI_CREATE    1
  250 #define NAMEI_DELETE    2
  251 #define NAMEI_RENAME    3
  252 #define NAMEI_OPMASK    3
  253 #define NAMEI_LOCKLEAF  0x0004
  254 #define NAMEI_LOCKPARENT        0x0008
  255 #define NAMEI_NOCHROOT  0x0010
  256 #define NAMEI_NOCACHE   0x0020
  257 #define NAMEI_FOLLOW    0x0040
  258 #define NAMEI_NOFOLLOW  0x0000
  259 #define NAMEI_TRYEMULROOT       0x0010
  260 #define NAMEI_EMULROOTSET       0x0080
  261 #define NAMEI_MODMASK   0x00fc
  262 #define NAMEI_NOCROSSMOUNT      0x0000100
  263 #define NAMEI_RDONLY    0x0000200
  264 #define NAMEI_HASBUF    0x0000400
  265 #define NAMEI_SAVENAME  0x0000800
  266 #define NAMEI_SAVESTART 0x0001000
  267 #define NAMEI_ISDOTDOT  0x0002000
  268 #define NAMEI_MAKEENTRY 0x0004000
  269 #define NAMEI_ISLASTCN  0x0008000
  270 #define NAMEI_ISSYMLINK 0x0010000
  271 #define NAMEI_ISWHITEOUT        0x0020000
  272 #define NAMEI_DOWHITEOUT        0x0040000
  273 #define NAMEI_REQUIREDIR        0x0080000
  274 #define NAMEI_CREATEDIR 0x0200000
  275 #define NAMEI_INRENAME  0x0400000
  276 #define NAMEI_PARAMASK  0x06fff00
  277 
  278 #endif /* !_SYS_NAMEI_H_ */

Cache object: 80b4a6553245ccb052f257c9f53dad44


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.