1*ee1b4065Swiz /* $NetBSD: pwcache.h,v 1.5 2003/11/10 08:51:51 wiz Exp $ */ 2eb7c1594Sagc 3eb7c1594Sagc /*- 4ed6ed8e6Sagc * Copyright (c) 1992 Keith Muller. 5eb7c1594Sagc * Copyright (c) 1992, 1993 6eb7c1594Sagc * The Regents of the University of California. All rights reserved. 7eb7c1594Sagc * 8eb7c1594Sagc * This code is derived from software contributed to Berkeley by 9eb7c1594Sagc * Keith Muller of the University of California, San Diego. 10eb7c1594Sagc * 11eb7c1594Sagc * Redistribution and use in source and binary forms, with or without 12eb7c1594Sagc * modification, are permitted provided that the following conditions 13eb7c1594Sagc * are met: 14eb7c1594Sagc * 1. Redistributions of source code must retain the above copyright 15eb7c1594Sagc * notice, this list of conditions and the following disclaimer. 16eb7c1594Sagc * 2. Redistributions in binary form must reproduce the above copyright 17eb7c1594Sagc * notice, this list of conditions and the following disclaimer in the 18eb7c1594Sagc * documentation and/or other materials provided with the distribution. 19ed6ed8e6Sagc * 3. Neither the name of the University nor the names of its contributors 2076428db1Smycroft * may be used to endorse or promote products derived from this software 2176428db1Smycroft * without specific prior written permission. 2276428db1Smycroft * 2376428db1Smycroft * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2476428db1Smycroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2576428db1Smycroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2676428db1Smycroft * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2776428db1Smycroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2876428db1Smycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2976428db1Smycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3076428db1Smycroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3176428db1Smycroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3276428db1Smycroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3376428db1Smycroft * SUCH DAMAGE. 3476428db1Smycroft * 3576428db1Smycroft * @(#)cache.h 8.1 (Berkeley) 5/31/93 3676428db1Smycroft */ 3776428db1Smycroft 3876428db1Smycroft /* 3976428db1Smycroft * Constants and data structures used to implement group and password file 4076428db1Smycroft * caches. Traditional passwd/group cache routines perform quite poorly with 4176428db1Smycroft * archives. The chances of hitting a valid lookup with an archive is quite a 4276428db1Smycroft * bit worse than with files already resident on the file system. These misses 43*ee1b4065Swiz * create a MAJOR performance cost. To address this problem, these routines 4476428db1Smycroft * cache both hits and misses. 4576428db1Smycroft * 4676428db1Smycroft * NOTE: name lengths must be as large as those stored in ANY PROTOCOL and 4776428db1Smycroft * as stored in the passwd and group files. CACHE SIZES MUST BE PRIME 4876428db1Smycroft */ 4976428db1Smycroft #define UNMLEN 32 /* >= user name found in any protocol */ 5076428db1Smycroft #define GNMLEN 32 /* >= group name found in any protocol */ 51991eedcaSsimonb #define UID_SZ 317 /* size of uid to user_name cache */ 52991eedcaSsimonb #define UNM_SZ 317 /* size of user_name to uid cache */ 53991eedcaSsimonb #define GID_SZ 251 /* size of gid to group_name cache */ 54991eedcaSsimonb #define GNM_SZ 251 /* size of group_name to gid cache */ 5576428db1Smycroft #define VALID 1 /* entry and name are valid */ 5676428db1Smycroft #define INVALID 2 /* entry valid, name NOT valid */ 5776428db1Smycroft 5876428db1Smycroft /* 5976428db1Smycroft * Node structures used in the user, group, uid, and gid caches. 6076428db1Smycroft */ 6176428db1Smycroft 6276428db1Smycroft typedef struct uidc { 6376428db1Smycroft int valid; /* is this a valid or a miss entry */ 6476428db1Smycroft char name[UNMLEN]; /* uid name */ 6576428db1Smycroft uid_t uid; /* cached uid */ 6676428db1Smycroft } UIDC; 6776428db1Smycroft 6876428db1Smycroft typedef struct gidc { 6976428db1Smycroft int valid; /* is this a valid or a miss entry */ 7076428db1Smycroft char name[GNMLEN]; /* gid name */ 7176428db1Smycroft gid_t gid; /* cached gid */ 7276428db1Smycroft } GIDC; 73