pwcache.h revision 241233
1214501Srpaulo/* $NetBSD: pwcache.h,v 1.5 2003/11/10 08:51:51 wiz Exp $ */ 2214501Srpaulo 3289549Srpaulo/*- 4214501Srpaulo * Copyright (c) 1992 Keith Muller. 5252726Srpaulo * Copyright (c) 1992, 1993 6252726Srpaulo * The Regents of the University of California. All rights reserved. 7214501Srpaulo * 8214501Srpaulo * This code is derived from software contributed to Berkeley by 9214501Srpaulo * Keith Muller of the University of California, San Diego. 10214501Srpaulo * 11214501Srpaulo * Redistribution and use in source and binary forms, with or without 12214501Srpaulo * modification, are permitted provided that the following conditions 13214501Srpaulo * are met: 14214501Srpaulo * 1. Redistributions of source code must retain the above copyright 15214501Srpaulo * notice, this list of conditions and the following disclaimer. 16214501Srpaulo * 2. Redistributions in binary form must reproduce the above copyright 17214501Srpaulo * notice, this list of conditions and the following disclaimer in the 18214501Srpaulo * documentation and/or other materials provided with the distribution. 19214501Srpaulo * 3. Neither the name of the University nor the names of its contributors 20214501Srpaulo * may be used to endorse or promote products derived from this software 21214501Srpaulo * without specific prior written permission. 22214501Srpaulo * 23214501Srpaulo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24214501Srpaulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25289549Srpaulo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26214501Srpaulo * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27214501Srpaulo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28214501Srpaulo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29214501Srpaulo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30214501Srpaulo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31214501Srpaulo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32214501Srpaulo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33214501Srpaulo * SUCH DAMAGE. 34214501Srpaulo * 35214501Srpaulo * @(#)cache.h 8.1 (Berkeley) 5/31/93 36214501Srpaulo */ 37214501Srpaulo 38214501Srpaulo/* 39214501Srpaulo * Constants and data structures used to implement group and password file 40214501Srpaulo * caches. Traditional passwd/group cache routines perform quite poorly with 41214501Srpaulo * archives. The chances of hitting a valid lookup with an archive is quite a 42214501Srpaulo * bit worse than with files already resident on the file system. These misses 43214501Srpaulo * create a MAJOR performance cost. To address this problem, these routines 44214501Srpaulo * cache both hits and misses. 45214501Srpaulo * 46281806Srpaulo * NOTE: name lengths must be as large as those stored in ANY PROTOCOL and 47214501Srpaulo * as stored in the passwd and group files. CACHE SIZES MUST BE PRIME 48214501Srpaulo */ 49214501Srpaulo#define UNMLEN 32 /* >= user name found in any protocol */ 50214501Srpaulo#define GNMLEN 32 /* >= group name found in any protocol */ 51214501Srpaulo#define UID_SZ 317 /* size of uid to user_name cache */ 52214501Srpaulo#define UNM_SZ 317 /* size of user_name to uid cache */ 53214501Srpaulo#define GID_SZ 251 /* size of gid to group_name cache */ 54214501Srpaulo#define GNM_SZ 251 /* size of group_name to gid cache */ 55214501Srpaulo#define VALID 1 /* entry and name are valid */ 56214501Srpaulo#define INVALID 2 /* entry valid, name NOT valid */ 57214501Srpaulo 58214501Srpaulo/* 59214501Srpaulo * Node structures used in the user, group, uid, and gid caches. 60214501Srpaulo */ 61214501Srpaulo 62214501Srpaulotypedef struct uidc { 63214501Srpaulo int valid; /* is this a valid or a miss entry */ 64214501Srpaulo char name[UNMLEN]; /* uid name */ 65214501Srpaulo uid_t uid; /* cached uid */ 66214501Srpaulo} UIDC; 67214501Srpaulo 68214501Srpaulotypedef struct gidc { 69214501Srpaulo int valid; /* is this a valid or a miss entry */ 70214501Srpaulo char name[GNMLEN]; /* gid name */ 71214501Srpaulo gid_t gid; /* cached gid */ 72214501Srpaulo} GIDC; 73214501Srpaulo