pwcache.h revision 241233
12702Swollman/*	$NetBSD: pwcache.h,v 1.5 2003/11/10 08:51:51 wiz Exp $	*/
22702Swollman
32702Swollman/*-
42702Swollman * Copyright (c) 1992 Keith Muller.
52702Swollman * Copyright (c) 1992, 1993
62702Swollman *	The Regents of the University of California.  All rights reserved.
72702Swollman *
82702Swollman * This code is derived from software contributed to Berkeley by
92702Swollman * Keith Muller of the University of California, San Diego.
102702Swollman *
112702Swollman * Redistribution and use in source and binary forms, with or without
122702Swollman * modification, are permitted provided that the following conditions
132702Swollman * are met:
142702Swollman * 1. Redistributions of source code must retain the above copyright
152702Swollman *    notice, this list of conditions and the following disclaimer.
162702Swollman * 2. Redistributions in binary form must reproduce the above copyright
172702Swollman *    notice, this list of conditions and the following disclaimer in the
182702Swollman *    documentation and/or other materials provided with the distribution.
192702Swollman * 3. Neither the name of the University nor the names of its contributors
202702Swollman *    may be used to endorse or promote products derived from this software
212702Swollman *    without specific prior written permission.
222702Swollman *
232702Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
242702Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
252702Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
262702Swollman * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
272702Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
282702Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
292702Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
302702Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
312702Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
322702Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
332702Swollman * SUCH DAMAGE.
342702Swollman *
352702Swollman *      @(#)cache.h	8.1 (Berkeley) 5/31/93
362702Swollman */
372702Swollman
382702Swollman/*
392702Swollman * Constants and data structures used to implement group and password file
402702Swollman * caches. Traditional passwd/group cache routines perform quite poorly with
412702Swollman * archives. The chances of hitting a valid lookup with an archive is quite a
422702Swollman * bit worse than with files already resident on the file system. These misses
432702Swollman * create a MAJOR performance cost. To address this problem, these routines
442702Swollman * cache both hits and misses.
452702Swollman *
462702Swollman * NOTE:  name lengths must be as large as those stored in ANY PROTOCOL and
472702Swollman * as stored in the passwd and group files. CACHE SIZES MUST BE PRIME
482702Swollman */
492702Swollman#define UNMLEN		32	/* >= user name found in any protocol */
502702Swollman#define GNMLEN		32	/* >= group name found in any protocol */
512702Swollman#define UID_SZ		317	/* size of uid to user_name cache */
522702Swollman#define UNM_SZ		317	/* size of user_name to uid cache */
532702Swollman#define GID_SZ		251	/* size of gid to group_name cache */
542702Swollman#define GNM_SZ		251	/* size of group_name to gid cache */
552702Swollman#define VALID		1	/* entry and name are valid */
562702Swollman#define INVALID		2	/* entry valid, name NOT valid */
572702Swollman
582702Swollman/*
592702Swollman * Node structures used in the user, group, uid, and gid caches.
602702Swollman */
612702Swollman
622702Swollmantypedef struct uidc {
632702Swollman	int valid;		/* is this a valid or a miss entry */
642702Swollman	char name[UNMLEN];	/* uid name */
652702Swollman	uid_t uid;		/* cached uid */
662702Swollman} UIDC;
672702Swollman
682702Swollmantypedef struct gidc {
692702Swollman	int valid;		/* is this a valid or a miss entry */
702702Swollman	char name[GNMLEN];	/* gid name */
712702Swollman	gid_t gid;		/* cached gid */
722702Swollman} GIDC;
73