Annotation of Net2/sys/namei.h, revision 1.1.1.2

1.1       root        1: /*
                      2:  * Copyright (c) 1985, 1989, 1991 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  * 1. Redistributions of source code must retain the above copyright
                      9:  *    notice, this list of conditions and the following disclaimer.
                     10:  * 2. Redistributions in binary form must reproduce the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer in the
                     12:  *    documentation and/or other materials provided with the distribution.
                     13:  * 3. All advertising materials mentioning features or use of this software
                     14:  *    must display the following acknowledgement:
                     15:  *     This product includes software developed by the University of
                     16:  *     California, Berkeley and its contributors.
                     17:  * 4. Neither the name of the University nor the names of its contributors
                     18:  *    may be used to endorse or promote products derived from this software
                     19:  *    without specific prior written permission.
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     31:  * SUCH DAMAGE.
                     32:  *
1.1.1.2 ! root       33:  *     from: @(#)namei.h       7.15 (Berkeley) 5/15/91
        !            34:  *     namei.h,v 1.3 1993/05/20 16:22:47 cgd Exp
1.1       root       35:  */
                     36: 
1.1.1.2 ! root       37: #ifndef _SYS_NAMEI_H_
        !            38: #define _SYS_NAMEI_H_
1.1       root       39: 
                     40: /*
                     41:  * Encapsulation of namei parameters.
                     42:  */
                     43: struct nameidata {
                     44:        /*
                     45:         * Arguments to namei.
                     46:         */
                     47:        caddr_t ni_dirp;                /* pathname pointer */
                     48:        enum    uio_seg ni_segflg;      /* location of pathname */
                     49:        u_long  ni_nameiop;             /* see below */
                     50:        /*
                     51:         * Arguments to lookup.
                     52:         */
                     53:        struct  ucred *ni_cred;         /* credentials */
                     54:        struct  vnode *ni_startdir;     /* starting directory */
                     55:        struct  vnode *ni_rootdir;      /* logical root directory */
                     56:        /*
                     57:         * Results
                     58:         */
                     59:        struct  vnode *ni_vp;           /* vnode of result */
                     60:        struct  vnode *ni_dvp;          /* vnode of intermediate directory */
                     61:        /*
                     62:         * Shared between namei, lookup routines, and commit routines.
                     63:         */
                     64:        char    *ni_pnbuf;              /* pathname buffer */
                     65:        long    ni_pathlen;             /* remaining chars in path */
                     66:        char    *ni_ptr;                /* current location in pathname */
                     67:        long    ni_namelen;             /* length of current component */
                     68:        char    *ni_next;               /* next location in pathname */
                     69:        u_long  ni_hash;                /* hash value of current component */
                     70:        u_char  ni_loopcnt;             /* count of symlinks encountered */
                     71:        u_char  ni_makeentry;           /* 1 => add entry to name cache */
                     72:        u_char  ni_isdotdot;            /* 1 => current component name is .. */
                     73:        u_char  ni_more;                /* 1 => symlink needs interpretation */
                     74:        /*
                     75:         * Side effects.
                     76:         */
                     77:        struct ufs_specific {           /* saved info for new dir entry */
                     78:                off_t   ufs_endoff;     /* end of useful directory contents */
                     79:                long    ufs_offset;     /* offset of free space in directory */
                     80:                long    ufs_count;      /* size of free slot in directory */
                     81:                ino_t   ufs_ino;        /* inode number of found directory */
                     82:                u_long  ufs_reclen;     /* size of found directory entry */
                     83:        } ni_ufs;
                     84: };
                     85: 
                     86: #ifdef KERNEL
                     87: /*
                     88:  * namei operations
                     89:  */
                     90: #define        LOOKUP          0       /* perform name lookup only */
                     91: #define        CREATE          1       /* setup for file creation */
                     92: #define        DELETE          2       /* setup for file deletion */
                     93: #define        RENAME          3       /* setup for file renaming */
                     94: #define        OPMASK          3       /* mask for operation */
                     95: /*
                     96:  * namei operational modifiers
                     97:  */
                     98: #define        LOCKLEAF        0x0004  /* lock inode on return */
                     99: #define        LOCKPARENT      0x0008  /* want parent vnode returned locked */
                    100: #define        WANTPARENT      0x0010  /* want parent vnode returned unlocked */
                    101: #define        NOCACHE         0x0020  /* name must not be left in cache */
                    102: #define        FOLLOW          0x0040  /* follow symbolic links */
                    103: #define        NOFOLLOW        0x0000  /* do not follow symbolic links (pseudo) */
                    104: #define        MODMASK         0x00fc  /* mask of operational modifiers */
                    105: /*
                    106:  * Namei parameter descriptors.
                    107:  *
                    108:  * SAVENAME may be set by either the callers of namei or by VOP_LOOKUP.
                    109:  * If the caller of namei sets the flag (for example execve wants to
                    110:  * know the name of the program that is being executed), then it must
                    111:  * free the buffer. If VOP_LOOKUP sets the flag, then the buffer must
                    112:  * be freed by either the commit routine or the VOP_ABORT routine.
                    113:  * SAVESTART is set only by the callers of namei. It implies SAVENAME
                    114:  * plus the addition of saving the parent directory that contains the
                    115:  * name in ni_startdir. It allows repeated calls to lookup for the
                    116:  * name being sought. The caller is responsible for releasing the
                    117:  * buffer and for vrele'ing ni_startdir.
                    118:  */
                    119: #define        NOCROSSMOUNT    0x0100  /* do not cross mount points */
                    120: #define        REMOTE          0x0200  /* lookup for remote filesystem servers */
                    121: #define        HASBUF          0x0400  /* has allocated pathname buffer */
                    122: #define        SAVENAME        0x0800  /* save pathanme buffer */
                    123: #define        SAVESTART       0x1000  /* save starting directory */
                    124: #define PARAMASK       0xff00  /* mask of parameter descriptors */
                    125: #endif
                    126: 
                    127: /*
                    128:  * This structure describes the elements in the cache of recent
                    129:  * names looked up by namei. NCHNAMLEN is sized to make structure
                    130:  * size a power of two to optimize malloc's. Minimum reasonable
                    131:  * size is 15.
                    132:  */
                    133: 
                    134: #define        NCHNAMLEN       31      /* maximum name segment length we bother with */
                    135: 
                    136: struct namecache {
                    137:        struct  namecache *nc_forw;     /* hash chain, MUST BE FIRST */
                    138:        struct  namecache *nc_back;     /* hash chain, MUST BE FIRST */
                    139:        struct  namecache *nc_nxt;      /* LRU chain */
                    140:        struct  namecache **nc_prev;    /* LRU chain */
                    141:        struct  vnode *nc_dvp;          /* vnode of parent of name */
                    142:        u_long  nc_dvpid;               /* capability number of nc_dvp */
                    143:        struct  vnode *nc_vp;           /* vnode the name refers to */
                    144:        u_long  nc_vpid;                /* capability number of nc_vp */
                    145:        char    nc_nlen;                /* length of name */
                    146:        char    nc_name[NCHNAMLEN];     /* segment name */
                    147: };
                    148: 
                    149: #ifdef KERNEL
                    150: u_long nextvnodeid;
                    151: int    namei __P((struct nameidata *ndp, struct proc *p));
                    152: int    lookup __P((struct nameidata *ndp, struct proc *p));
                    153: #endif
                    154: 
                    155: /*
                    156:  * Stats on usefulness of namei caches.
                    157:  */
                    158: struct nchstats {
                    159:        long    ncs_goodhits;           /* hits that we can really use */
                    160:        long    ncs_neghits;            /* negative hits that we can use */
                    161:        long    ncs_badhits;            /* hits we must drop */
                    162:        long    ncs_falsehits;          /* hits with id mismatch */
                    163:        long    ncs_miss;               /* misses */
                    164:        long    ncs_long;               /* long names that ignore cache */
                    165:        long    ncs_pass2;              /* names found with passes == 2 */
                    166:        long    ncs_2passes;            /* number of times we attempt it */
                    167: };
1.1.1.2 ! root      168: 
        !           169: #endif /* !_SYS_NAMEI_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.