cache.h revision 1557
1174604Sscottl/*- 2174604Sscottl * Copyright (c) 1992 Keith Muller. 3174604Sscottl * Copyright (c) 1992, 1993 4174604Sscottl * The Regents of the University of California. All rights reserved. 5174604Sscottl * 6174604Sscottl * This code is derived from software contributed to Berkeley by 7174604Sscottl * Keith Muller of the University of California, San Diego. 8174604Sscottl * 9174604Sscottl * Redistribution and use in source and binary forms, with or without 10174604Sscottl * modification, are permitted provided that the following conditions 11174604Sscottl * are met: 12174604Sscottl * 1. Redistributions of source code must retain the above copyright 13174604Sscottl * notice, this list of conditions and the following disclaimer. 14174604Sscottl * 2. Redistributions in binary form must reproduce the above copyright 15174604Sscottl * notice, this list of conditions and the following disclaimer in the 16174604Sscottl * documentation and/or other materials provided with the distribution. 17174604Sscottl * 3. All advertising materials mentioning features or use of this software 18174604Sscottl * must display the following acknowledgement: 19174604Sscottl * This product includes software developed by the University of 20174604Sscottl * California, Berkeley and its contributors. 21174604Sscottl * 4. Neither the name of the University nor the names of its contributors 22174604Sscottl * may be used to endorse or promote products derived from this software 23174604Sscottl * without specific prior written permission. 24174604Sscottl * 25174604Sscottl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26174604Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27174604Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28174604Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29174604Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30174604Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31174604Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32174604Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33174604Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34174604Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35174604Sscottl * SUCH DAMAGE. 36176018Sscottl * 37174604Sscottl * @(#)cache.h 8.1 (Berkeley) 5/31/93 38174604Sscottl */ 39174604Sscottl 40174604Sscottl/* 41174604Sscottl * Constants and data structures used to implement group and password file 42174604Sscottl * caches. Traditional passwd/group cache routines perform quite poorly with 43174604Sscottl * archives. The chances of hitting a valid lookup with an archive is quite a 44174604Sscottl * bit worse than with files already resident on the file system. These misses 45174604Sscottl * create a MAJOR performance cost. To adress this problem, these routines 46174604Sscottl * cache both hits and misses. 47174604Sscottl * 48174604Sscottl * NOTE: name lengths must be as large as those stored in ANY PROTOCOL and 49174604Sscottl * as stored in the passwd and group files. CACHE SIZES MUST BE PRIME 50174604Sscottl */ 51174604Sscottl#define UNMLEN 32 /* >= user name found in any protocol */ 52174604Sscottl#define GNMLEN 32 /* >= group name found in any protocol */ 53176018Sscottl#define UID_SZ 317 /* size of user_name/uid cache */ 54176018Sscottl#define UNM_SZ 317 /* size of user_name/uid cache */ 55174604Sscottl#define GID_SZ 251 /* size of gid cache */ 56174604Sscottl#define GNM_SZ 317 /* size of group name cache */ 57174604Sscottl#define VALID 1 /* entry and name are valid */ 58174604Sscottl#define INVALID 2 /* entry valid, name NOT valid */ 59174604Sscottl 60174604Sscottl/* 61174604Sscottl * Node structures used in the user, group, uid, and gid caches. 62174604Sscottl */ 63174604Sscottl 64174604Sscottltypedef struct uidc { 65174604Sscottl int valid; /* is this a valid or a miss entry */ 66174604Sscottl char name[UNMLEN]; /* uid name */ 67174604Sscottl uid_t uid; /* cached uid */ 68174604Sscottl} UIDC; 69174604Sscottl 70174604Sscottltypedef struct gidc { 71174604Sscottl int valid; /* is this a valid or a miss entry */ 72174604Sscottl char name[GNMLEN]; /* gid name */ 73176018Sscottl gid_t gid; /* cached gid */ 74174604Sscottl} GIDC; 75174604Sscottl