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 /*      $OpenBSD: namei.h,v 1.22 2008/08/29 08:57:28 otto Exp $ */
    2 /*      $NetBSD: namei.h,v 1.11 1996/02/09 18:25:20 christos Exp $      */
    3 
    4 /*
    5  * Copyright (c) 1985, 1989, 1991, 1993
    6  *      The Regents of the University of California.  All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. Neither the name of the University nor the names of its contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  *      @(#)namei.h     8.4 (Berkeley) 8/20/94
   33  */
   34 
   35 #ifndef _SYS_NAMEI_H_
   36 #define _SYS_NAMEI_H_
   37 
   38 #include <sys/queue.h>
   39 
   40 /*
   41  * Encapsulation of namei parameters.
   42  */
   43 struct nameidata {
   44         /*
   45          * Arguments to namei/lookup.
   46          */
   47         const char *ni_dirp;            /* pathname pointer */
   48         enum    uio_seg ni_segflg;      /* location of pathname */
   49      /* u_long  ni_nameiop;                namei operation */
   50      /* u_long  ni_flags;                  flags to namei */
   51      /* struct  proc *ni_proc;             process requesting lookup */
   52         /*
   53          * Arguments to lookup.
   54          */
   55      /* struct  ucred *ni_cred;            credentials */
   56         struct  vnode *ni_startdir;     /* starting directory */
   57         struct  vnode *ni_rootdir;      /* logical root directory */
   58         /*
   59          * Results: returned from/manipulated by lookup
   60          */
   61         struct  vnode *ni_vp;           /* vnode of result */
   62         struct  vnode *ni_dvp;          /* vnode of intermediate directory */
   63         /*
   64          * Shared between namei and lookup/commit routines.
   65          */
   66         size_t  ni_pathlen;             /* remaining chars in path */
   67         char    *ni_next;               /* next location in pathname */
   68         u_long  ni_loopcnt;             /* count of symlinks encountered */
   69         /*
   70          * Lookup parameters: this structure describes the subset of
   71          * information from the nameidata structure that is passed
   72          * through the VOP interface.
   73          */
   74         struct componentname {
   75                 /*
   76                  * Arguments to lookup.
   77                  */
   78                 u_long  cn_nameiop;     /* namei operation */
   79                 u_long  cn_flags;       /* flags to namei */
   80                 struct  proc *cn_proc;  /* process requesting lookup */
   81                 struct  ucred *cn_cred; /* credentials */
   82                 /*
   83                  * Shared between lookup and commit routines.
   84                  */
   85                 char    *cn_pnbuf;      /* pathname buffer */
   86                 char    *cn_nameptr;    /* pointer to looked up name */
   87                 long    cn_namelen;     /* length of looked up component */
   88                 u_int32_t cn_hash;      /* hash value of looked up name */
   89                 long    cn_consume;     /* chars to consume in lookup() */
   90         } ni_cnd;
   91 };
   92 
   93 #ifdef _KERNEL
   94 /*
   95  * namei operations
   96  */
   97 #define LOOKUP          0       /* perform name lookup only */
   98 #define CREATE          1       /* setup for file creation */
   99 #define DELETE          2       /* setup for file deletion */
  100 #define RENAME          3       /* setup for file renaming */
  101 #define OPMASK          3       /* mask for operation */
  102 /*
  103  * namei operational modifier flags, stored in ni_cnd.flags
  104  */
  105 #define LOCKLEAF        0x0004  /* lock inode on return */
  106 #define LOCKPARENT      0x0008  /* want parent vnode returned locked */
  107 #define WANTPARENT      0x0010  /* want parent vnode returned unlocked */
  108 #define NOCACHE         0x0020  /* name must not be left in cache */
  109 #define FOLLOW          0x0040  /* follow symbolic links */
  110 #define NOFOLLOW        0x0000  /* do not follow symbolic links (pseudo) */
  111 #define MODMASK         0x00fc  /* mask of operational modifiers */
  112 /*
  113  * Namei parameter descriptors.
  114  *
  115  * SAVENAME may be set by either the callers of namei or by VOP_LOOKUP.
  116  * If the caller of namei sets the flag (for example execve wants to
  117  * know the name of the program that is being executed), then it must
  118  * free the buffer. If VOP_LOOKUP sets the flag, then the buffer must
  119  * be freed by either the commit routine or the VOP_ABORT routine.
  120  * SAVESTART is set only by the callers of namei. It implies SAVENAME
  121  * plus the addition of saving the parent directory that contains the
  122  * name in ni_startdir. It allows repeated calls to lookup for the
  123  * name being sought. The caller is responsible for releasing the
  124  * buffer and for vrele'ing ni_startdir.
  125  */
  126 #define NOCROSSMOUNT    0x000100      /* do not cross mount points */
  127 #define RDONLY          0x000200      /* lookup with read-only semantics */
  128 #define HASBUF          0x000400      /* has allocated pathname buffer */
  129 #define SAVENAME        0x000800      /* save pathanme buffer */
  130 #define SAVESTART       0x001000      /* save starting directory */
  131 #define ISDOTDOT        0x002000      /* current component name is .. */
  132 #define MAKEENTRY       0x004000      /* entry is to be added to name cache */
  133 #define ISLASTCN        0x008000      /* this is last component of pathname */
  134 #define ISSYMLINK       0x010000      /* symlink needs interpretation */
  135 #define REQUIREDIR      0x080000      /* must be a directory */
  136 #define STRIPSLASHES    0x100000      /* strip trailing slashes */
  137 #define PDIRUNLOCK      0x200000      /* vfs_lookup() unlocked parent dir */
  138 
  139 /*
  140  * Initialization of an nameidata structure.
  141  */
  142 #define NDINIT(ndp, op, flags, segflg, namep, p) { \
  143         (ndp)->ni_cnd.cn_nameiop = op; \
  144         (ndp)->ni_cnd.cn_flags = flags; \
  145         (ndp)->ni_segflg = segflg; \
  146         (ndp)->ni_dirp = namep; \
  147         (ndp)->ni_cnd.cn_proc = p; \
  148 }
  149 #endif
  150 
  151 /*
  152  * This structure describes the elements in the cache of recent
  153  * names looked up by namei.
  154  */
  155 
  156 #define NCHNAMLEN       31      /* maximum name segment length we bother with */
  157 
  158 struct  namecache {
  159         LIST_ENTRY(namecache) nc_hash;  /* hash chain */
  160         LIST_ENTRY(namecache) nc_vhash; /* (reverse) directory hash chain */
  161         TAILQ_ENTRY(namecache) nc_lru;  /* LRU chain */
  162         struct  vnode *nc_dvp;          /* vnode of parent of name */
  163         u_long  nc_dvpid;               /* capability number of nc_dvp */
  164         struct  vnode *nc_vp;           /* vnode the name refers to */
  165         u_long  nc_vpid;                /* capability number of nc_vp */
  166         char    nc_nlen;                /* length of name */
  167         char    nc_name[NCHNAMLEN];     /* segment name */
  168 };
  169 
  170 #ifdef _KERNEL
  171 int     namei(struct nameidata *ndp);
  172 int     lookup(struct nameidata *ndp);
  173 int     relookup(struct vnode *dvp, struct vnode **vpp,
  174                       struct componentname *cnp);
  175 void cache_purge(struct vnode *);
  176 int cache_lookup(struct vnode *, struct vnode **, struct componentname *);
  177 void cache_enter(struct vnode *, struct vnode *, struct componentname *);
  178 int cache_revlookup(struct vnode *, struct vnode **, char **, char *);
  179 void nchinit(void);
  180 struct mount;
  181 void cache_purgevfs(struct mount *);
  182 
  183 extern struct pool namei_pool;
  184 
  185 #endif
  186 
  187 /*
  188  * Stats on usefulness of namei caches.
  189  */
  190 struct  nchstats {
  191         u_int64_t       ncs_goodhits;   /* hits that we can really use */
  192         u_int64_t       ncs_neghits;    /* negative hits that we can use */
  193         u_int64_t       ncs_badhits;    /* hits we must drop */
  194         u_int64_t       ncs_falsehits;  /* hits with id mismatch */
  195         u_int64_t       ncs_miss;       /* misses */
  196         u_int64_t       ncs_long;       /* long names that ignore cache */
  197         u_int64_t       ncs_pass2;      /* names found with passes == 2 */
  198         u_int64_t       ncs_2passes;    /* number of times we attempt it */
  199         u_int64_t       ncs_revhits;    /* reverse-cache hits */
  200         u_int64_t       ncs_revmiss;    /* reverse-cache misses */
  201         u_int64_t       ncs_dothits;    /* hits on '.' lookups */
  202         u_int64_t       ncs_dotdothits; /* hits on '..' lookups */
  203 };
  204 
  205 /* These sysctl names are only really used by sysctl(8) */
  206 #define KERN_NCHSTATS_GOODHITS          1
  207 #define KERN_NCHSTATS_NEGHITS           2
  208 #define KERN_NCHSTATS_BADHITS           3
  209 #define KERN_NCHSTATS_FALSEHITS         4
  210 #define KERN_NCHSTATS_MISS              5
  211 #define KERN_NCHSTATS_LONG              6
  212 #define KERN_NCHSTATS_PASS2             7
  213 #define KERN_NCHSTATS_2PASSES           8
  214 #define KERN_NCHSTATS_REVHITS           9
  215 #define KERN_NCHSTATS_REVMISS           10
  216 #define KERN_NCHSTATS_DOTHITS           11
  217 #define KERN_NCHSTATS_DOTDOTHITS        12
  218 #define KERN_NCHSTATS_MAXID             13
  219 
  220 #define CTL_KERN_NCHSTATS_NAMES {               \
  221         { 0, 0 },                               \
  222         { "good_hits", CTLTYPE_QUAD },          \
  223         { "negative_hits", CTLTYPE_QUAD },      \
  224         { "bad_hits", CTLTYPE_QUAD },           \
  225         { "false_hits", CTLTYPE_QUAD },         \
  226         { "misses", CTLTYPE_QUAD },             \
  227         { "long_names", CTLTYPE_QUAD },         \
  228         { "pass2", CTLTYPE_QUAD },              \
  229         { "2passes", CTLTYPE_QUAD },            \
  230         { "ncs_revhits", CTLTYPE_QUAD },        \
  231         { "ncs_revmiss", CTLTYPE_QUAD },        \
  232         { "ncs_dothits", CTLTYPE_QUAD },        \
  233         { "nch_dotdothits", CTLTYPE_QUAD },     \
  234 }
  235 #endif /* !_SYS_NAMEI_H_ */

Cache object: edfb67a205273e7991b79bf4fbcb84fe


[ 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.