Home | History | Annotate | Line # | Download | only in gen
pwcache.h revision 1.3
      1 /*	$NetBSD: pwcache.h,v 1.3 2003/08/07 16:42:55 agc Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1992, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * Keith Muller of the University of California, San Diego.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. 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  *      @(#)cache.h	8.1 (Berkeley) 5/31/93
     39  */
     40 
     41 /*-
     42  * Copyright (c) 1992 Keith Muller.
     43  *
     44  * This code is derived from software contributed to Berkeley by
     45  * Keith Muller of the University of California, San Diego.
     46  *
     47  * Redistribution and use in source and binary forms, with or without
     48  * modification, are permitted provided that the following conditions
     49  * are met:
     50  * 1. Redistributions of source code must retain the above copyright
     51  *    notice, this list of conditions and the following disclaimer.
     52  * 2. Redistributions in binary form must reproduce the above copyright
     53  *    notice, this list of conditions and the following disclaimer in the
     54  *    documentation and/or other materials provided with the distribution.
     55  * 3. All advertising materials mentioning features or use of this software
     56  *    must display the following acknowledgement:
     57  *	This product includes software developed by the University of
     58  *	California, Berkeley and its contributors.
     59  * 4. Neither the name of the University nor the names of its contributors
     60  *    may be used to endorse or promote products derived from this software
     61  *    without specific prior written permission.
     62  *
     63  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     64  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     65  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     66  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     67  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     68  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     69  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     70  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     71  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     72  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     73  * SUCH DAMAGE.
     74  *
     75  *      @(#)cache.h	8.1 (Berkeley) 5/31/93
     76  */
     77 
     78 /*
     79  * Constants and data structures used to implement group and password file
     80  * caches. Traditional passwd/group cache routines perform quite poorly with
     81  * archives. The chances of hitting a valid lookup with an archive is quite a
     82  * bit worse than with files already resident on the file system. These misses
     83  * create a MAJOR performance cost. To adress this problem, these routines
     84  * cache both hits and misses.
     85  *
     86  * NOTE:  name lengths must be as large as those stored in ANY PROTOCOL and
     87  * as stored in the passwd and group files. CACHE SIZES MUST BE PRIME
     88  */
     89 #define UNMLEN		32	/* >= user name found in any protocol */
     90 #define GNMLEN		32	/* >= group name found in any protocol */
     91 #define UID_SZ		317	/* size of uid to user_name cache */
     92 #define UNM_SZ		317	/* size of user_name to uid cache */
     93 #define GID_SZ		251	/* size of gid to group_name cache */
     94 #define GNM_SZ		251	/* size of group_name to gid cache */
     95 #define VALID		1	/* entry and name are valid */
     96 #define INVALID		2	/* entry valid, name NOT valid */
     97 
     98 /*
     99  * Node structures used in the user, group, uid, and gid caches.
    100  */
    101 
    102 typedef struct uidc {
    103 	int valid;		/* is this a valid or a miss entry */
    104 	char name[UNMLEN];	/* uid name */
    105 	uid_t uid;		/* cached uid */
    106 } UIDC;
    107 
    108 typedef struct gidc {
    109 	int valid;		/* is this a valid or a miss entry */
    110 	char name[GNMLEN];	/* gid name */
    111 	gid_t gid;		/* cached gid */
    112 } GIDC;
    113