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

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:  *
        !            33:  *     @(#)namei.h     7.15 (Berkeley) 5/15/91
        !            34:  */
        !            35: 
        !            36: #ifndef _NAMEI_H_
        !            37: #define        _NAMEI_H_
        !            38: 
        !            39: /*
        !            40:  * Encapsulation of namei parameters.
        !            41:  */
        !            42: struct nameidata {
        !            43:        /*
        !            44:         * Arguments to namei.
        !            45:         */
        !            46:        caddr_t ni_dirp;                /* pathname pointer */
        !            47:        enum    uio_seg ni_segflg;      /* location of pathname */
        !            48:        u_long  ni_nameiop;             /* see below */
        !            49:        /*
        !            50:         * Arguments to lookup.
        !            51:         */
        !            52:        struct  ucred *ni_cred;         /* credentials */
        !            53:        struct  vnode *ni_startdir;     /* starting directory */
        !            54:        struct  vnode *ni_rootdir;      /* logical root directory */
        !            55:        /*
        !            56:         * Results
        !            57:         */
        !            58:        struct  vnode *ni_vp;           /* vnode of result */
        !            59:        struct  vnode *ni_dvp;          /* vnode of intermediate directory */
        !            60:        /*
        !            61:         * Shared between namei, lookup routines, and commit routines.
        !            62:         */
        !            63:        char    *ni_pnbuf;              /* pathname buffer */
        !            64:        long    ni_pathlen;             /* remaining chars in path */
        !            65:        char    *ni_ptr;                /* current location in pathname */
        !            66:        long    ni_namelen;             /* length of current component */
        !            67:        char    *ni_next;               /* next location in pathname */
        !            68:        u_long  ni_hash;                /* hash value of current component */
        !            69:        u_char  ni_loopcnt;             /* count of symlinks encountered */
        !            70:        u_char  ni_makeentry;           /* 1 => add entry to name cache */
        !            71:        u_char  ni_isdotdot;            /* 1 => current component name is .. */
        !            72:        u_char  ni_more;                /* 1 => symlink needs interpretation */
        !            73:        /*
        !            74:         * Side effects.
        !            75:         */
        !            76:        struct ufs_specific {           /* saved info for new dir entry */
        !            77:                off_t   ufs_endoff;     /* end of useful directory contents */
        !            78:                long    ufs_offset;     /* offset of free space in directory */
        !            79:                long    ufs_count;      /* size of free slot in directory */
        !            80:                ino_t   ufs_ino;        /* inode number of found directory */
        !            81:                u_long  ufs_reclen;     /* size of found directory entry */
        !            82:        } ni_ufs;
        !            83: };
        !            84: 
        !            85: #ifdef KERNEL
        !            86: /*
        !            87:  * namei operations
        !            88:  */
        !            89: #define        LOOKUP          0       /* perform name lookup only */
        !            90: #define        CREATE          1       /* setup for file creation */
        !            91: #define        DELETE          2       /* setup for file deletion */
        !            92: #define        RENAME          3       /* setup for file renaming */
        !            93: #define        OPMASK          3       /* mask for operation */
        !            94: /*
        !            95:  * namei operational modifiers
        !            96:  */
        !            97: #define        LOCKLEAF        0x0004  /* lock inode on return */
        !            98: #define        LOCKPARENT      0x0008  /* want parent vnode returned locked */
        !            99: #define        WANTPARENT      0x0010  /* want parent vnode returned unlocked */
        !           100: #define        NOCACHE         0x0020  /* name must not be left in cache */
        !           101: #define        FOLLOW          0x0040  /* follow symbolic links */
        !           102: #define        NOFOLLOW        0x0000  /* do not follow symbolic links (pseudo) */
        !           103: #define        MODMASK         0x00fc  /* mask of operational modifiers */
        !           104: /*
        !           105:  * Namei parameter descriptors.
        !           106:  *
        !           107:  * SAVENAME may be set by either the callers of namei or by VOP_LOOKUP.
        !           108:  * If the caller of namei sets the flag (for example execve wants to
        !           109:  * know the name of the program that is being executed), then it must
        !           110:  * free the buffer. If VOP_LOOKUP sets the flag, then the buffer must
        !           111:  * be freed by either the commit routine or the VOP_ABORT routine.
        !           112:  * SAVESTART is set only by the callers of namei. It implies SAVENAME
        !           113:  * plus the addition of saving the parent directory that contains the
        !           114:  * name in ni_startdir. It allows repeated calls to lookup for the
        !           115:  * name being sought. The caller is responsible for releasing the
        !           116:  * buffer and for vrele'ing ni_startdir.
        !           117:  */
        !           118: #define        NOCROSSMOUNT    0x0100  /* do not cross mount points */
        !           119: #define        REMOTE          0x0200  /* lookup for remote filesystem servers */
        !           120: #define        HASBUF          0x0400  /* has allocated pathname buffer */
        !           121: #define        SAVENAME        0x0800  /* save pathanme buffer */
        !           122: #define        SAVESTART       0x1000  /* save starting directory */
        !           123: #define PARAMASK       0xff00  /* mask of parameter descriptors */
        !           124: #endif
        !           125: 
        !           126: /*
        !           127:  * This structure describes the elements in the cache of recent
        !           128:  * names looked up by namei. NCHNAMLEN is sized to make structure
        !           129:  * size a power of two to optimize malloc's. Minimum reasonable
        !           130:  * size is 15.
        !           131:  */
        !           132: 
        !           133: #define        NCHNAMLEN       31      /* maximum name segment length we bother with */
        !           134: 
        !           135: struct namecache {
        !           136:        struct  namecache *nc_forw;     /* hash chain, MUST BE FIRST */
        !           137:        struct  namecache *nc_back;     /* hash chain, MUST BE FIRST */
        !           138:        struct  namecache *nc_nxt;      /* LRU chain */
        !           139:        struct  namecache **nc_prev;    /* LRU chain */
        !           140:        struct  vnode *nc_dvp;          /* vnode of parent of name */
        !           141:        u_long  nc_dvpid;               /* capability number of nc_dvp */
        !           142:        struct  vnode *nc_vp;           /* vnode the name refers to */
        !           143:        u_long  nc_vpid;                /* capability number of nc_vp */
        !           144:        char    nc_nlen;                /* length of name */
        !           145:        char    nc_name[NCHNAMLEN];     /* segment name */
        !           146: };
        !           147: 
        !           148: #ifdef KERNEL
        !           149: u_long nextvnodeid;
        !           150: int    namei __P((struct nameidata *ndp, struct proc *p));
        !           151: int    lookup __P((struct nameidata *ndp, struct proc *p));
        !           152: #endif
        !           153: 
        !           154: /*
        !           155:  * Stats on usefulness of namei caches.
        !           156:  */
        !           157: struct nchstats {
        !           158:        long    ncs_goodhits;           /* hits that we can really use */
        !           159:        long    ncs_neghits;            /* negative hits that we can use */
        !           160:        long    ncs_badhits;            /* hits we must drop */
        !           161:        long    ncs_falsehits;          /* hits with id mismatch */
        !           162:        long    ncs_miss;               /* misses */
        !           163:        long    ncs_long;               /* long names that ignore cache */
        !           164:        long    ncs_pass2;              /* names found with passes == 2 */
        !           165:        long    ncs_2passes;            /* number of times we attempt it */
        !           166: };
        !           167: #endif /* !_NAMEI_H_ */

unix.superglobalmegacorp.com

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