1241233Sbrooks/* $NetBSD: pwcache.h,v 1.5 2003/11/10 08:51:51 wiz Exp $ */ 2241731Sbrooks/* $FreeBSD$ */ 3241233Sbrooks 4241233Sbrooks/*- 5241233Sbrooks * Copyright (c) 1992 Keith Muller. 6241233Sbrooks * Copyright (c) 1992, 1993 7241233Sbrooks * The Regents of the University of California. All rights reserved. 8241233Sbrooks * 9241233Sbrooks * This code is derived from software contributed to Berkeley by 10241233Sbrooks * Keith Muller of the University of California, San Diego. 11241233Sbrooks * 12241233Sbrooks * Redistribution and use in source and binary forms, with or without 13241233Sbrooks * modification, are permitted provided that the following conditions 14241233Sbrooks * are met: 15241233Sbrooks * 1. Redistributions of source code must retain the above copyright 16241233Sbrooks * notice, this list of conditions and the following disclaimer. 17241233Sbrooks * 2. Redistributions in binary form must reproduce the above copyright 18241233Sbrooks * notice, this list of conditions and the following disclaimer in the 19241233Sbrooks * documentation and/or other materials provided with the distribution. 20241233Sbrooks * 3. Neither the name of the University nor the names of its contributors 21241233Sbrooks * may be used to endorse or promote products derived from this software 22241233Sbrooks * without specific prior written permission. 23241233Sbrooks * 24241233Sbrooks * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25241233Sbrooks * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26241233Sbrooks * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27241233Sbrooks * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28241233Sbrooks * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29241233Sbrooks * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30241233Sbrooks * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31241233Sbrooks * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32241233Sbrooks * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33241233Sbrooks * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34241233Sbrooks * SUCH DAMAGE. 35241233Sbrooks * 36241233Sbrooks * @(#)cache.h 8.1 (Berkeley) 5/31/93 37241233Sbrooks */ 38241233Sbrooks 39241233Sbrooks/* 40241233Sbrooks * Constants and data structures used to implement group and password file 41241233Sbrooks * caches. Traditional passwd/group cache routines perform quite poorly with 42241233Sbrooks * archives. The chances of hitting a valid lookup with an archive is quite a 43241233Sbrooks * bit worse than with files already resident on the file system. These misses 44241233Sbrooks * create a MAJOR performance cost. To address this problem, these routines 45241233Sbrooks * cache both hits and misses. 46241233Sbrooks * 47241233Sbrooks * NOTE: name lengths must be as large as those stored in ANY PROTOCOL and 48241233Sbrooks * as stored in the passwd and group files. CACHE SIZES MUST BE PRIME 49241233Sbrooks */ 50241233Sbrooks#define UNMLEN 32 /* >= user name found in any protocol */ 51241233Sbrooks#define GNMLEN 32 /* >= group name found in any protocol */ 52241233Sbrooks#define UID_SZ 317 /* size of uid to user_name cache */ 53241233Sbrooks#define UNM_SZ 317 /* size of user_name to uid cache */ 54241233Sbrooks#define GID_SZ 251 /* size of gid to group_name cache */ 55241233Sbrooks#define GNM_SZ 251 /* size of group_name to gid cache */ 56241233Sbrooks#define VALID 1 /* entry and name are valid */ 57241233Sbrooks#define INVALID 2 /* entry valid, name NOT valid */ 58241233Sbrooks 59241233Sbrooks/* 60241233Sbrooks * Node structures used in the user, group, uid, and gid caches. 61241233Sbrooks */ 62241233Sbrooks 63241233Sbrookstypedef struct uidc { 64241233Sbrooks int valid; /* is this a valid or a miss entry */ 65241233Sbrooks char name[UNMLEN]; /* uid name */ 66241233Sbrooks uid_t uid; /* cached uid */ 67241233Sbrooks} UIDC; 68241233Sbrooks 69241233Sbrookstypedef struct gidc { 70241233Sbrooks int valid; /* is this a valid or a miss entry */ 71241233Sbrooks char name[GNMLEN]; /* gid name */ 72241233Sbrooks gid_t gid; /* cached gid */ 73241233Sbrooks} GIDC; 74