cache.h revision 3044
1885Swollman/*- 2885Swollman * Copyright (c) 1992 Keith Muller. 3885Swollman * Copyright (c) 1992, 1993 4885Swollman * The Regents of the University of California. All rights reserved. 5885Swollman * 6885Swollman * This code is derived from software contributed to Berkeley by 7885Swollman * Keith Muller of the University of California, San Diego. 8885Swollman * 9885Swollman * Redistribution and use in source and binary forms, with or without 10885Swollman * modification, are permitted provided that the following conditions 11885Swollman * are met: 12885Swollman * 1. Redistributions of source code must retain the above copyright 13885Swollman * notice, this list of conditions and the following disclaimer. 14885Swollman * 2. Redistributions in binary form must reproduce the above copyright 15885Swollman * notice, this list of conditions and the following disclaimer in the 16885Swollman * documentation and/or other materials provided with the distribution. 1710625Sdg * 3. All advertising materials mentioning features or use of this software 18885Swollman * must display the following acknowledgement: 19885Swollman * This product includes software developed by the University of 20885Swollman * California, Berkeley and its contributors. 21885Swollman * 4. Neither the name of the University nor the names of its contributors 22885Swollman * may be used to endorse or promote products derived from this software 23885Swollman * without specific prior written permission. 24885Swollman * 25885Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26885Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27116182Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28116182Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29116182Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 301549Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 311549Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 321549Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 333058Sdg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 341549Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3576166Smarkm * SUCH DAMAGE. 36103181Sbde * 3776166Smarkm * @(#)cache.h 8.1 (Berkeley) 5/31/93 3815494Sbde * $Id$ 3976166Smarkm */ 4039154Sjdp 41103181Sbde/* 422257Ssos * Constants and data structures used to implement group and password file 43103181Sbde * caches. Traditional passwd/group cache routines perform quite poorly with 4415494Sbde * archives. The chances of hitting a valid lookup with an archive is quite a 4576166Smarkm * bit worse than with files already resident on the file system. These misses 4676166Smarkm * create a MAJOR performance cost. To adress this problem, these routines 47103181Sbde * cache both hits and misses. 4839154Sjdp * 49885Swollman * NOTE: name lengths must be as large as those stored in ANY PROTOCOL and 501549Srgrimes * as stored in the passwd and group files. CACHE SIZES MUST BE PRIME 5112662Sdg */ 5212662Sdg#define UNMLEN 32 /* >= user name found in any protocol */ 5332446Sdyson#define GNMLEN 32 /* >= group name found in any protocol */ 54103181Sbde#define UID_SZ 317 /* size of user_name/uid cache */ 55885Swollman#define UNM_SZ 317 /* size of user_name/uid cache */ 5692723Salfred#define GID_SZ 251 /* size of gid cache */ 57102808Sjake#define GNM_SZ 317 /* size of group name cache */ 5812568Sbde#define VALID 1 /* entry and name are valid */ 5939154Sjdp#define INVALID 2 /* entry valid, name NOT valid */ 6039154Sjdp 6139154Sjdp/* 6239154Sjdp * Node structures used in the user, group, uid, and gid caches. 6339154Sjdp */ 64102808Sjake 6539154Sjdptypedef struct uidc { 66102808Sjake int valid; /* is this a valid or a miss entry */ 67102808Sjake char name[UNMLEN]; /* uid name */ 68102808Sjake uid_t uid; /* cached uid */ 6939154Sjdp} UIDC; 7039154Sjdp 7139154Sjdptypedef struct gidc { 72102808Sjake int valid; /* is this a valid or a miss entry */ 7339154Sjdp char name[GNMLEN]; /* gid name */ 7468520Smarcel gid_t gid; /* cached gid */ 7568520Smarcel} GIDC; 76102808Sjake