xref: /illumos-gate/usr/src/cmd/sendmail/db/mp/mp_pr.c (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*-
2*7c478bd9Sstevel@tonic-gate  * See the file LICENSE for redistribution information.
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1996, 1997, 1998
5*7c478bd9Sstevel@tonic-gate  *	Sleepycat Software.  All rights reserved.
6*7c478bd9Sstevel@tonic-gate  */
7*7c478bd9Sstevel@tonic-gate #include "config.h"
8*7c478bd9Sstevel@tonic-gate 
9*7c478bd9Sstevel@tonic-gate #ifndef lint
10*7c478bd9Sstevel@tonic-gate static const char sccsid[] = "@(#)mp_pr.c	10.30 (Sleepycat) 10/1/98";
11*7c478bd9Sstevel@tonic-gate #endif /* not lint */
12*7c478bd9Sstevel@tonic-gate 
13*7c478bd9Sstevel@tonic-gate #ifndef NO_SYSTEM_INCLUDES
14*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
15*7c478bd9Sstevel@tonic-gate 
16*7c478bd9Sstevel@tonic-gate #include <errno.h>
17*7c478bd9Sstevel@tonic-gate #include <stdio.h>
18*7c478bd9Sstevel@tonic-gate #include <string.h>
19*7c478bd9Sstevel@tonic-gate #include <unistd.h>
20*7c478bd9Sstevel@tonic-gate #endif
21*7c478bd9Sstevel@tonic-gate 
22*7c478bd9Sstevel@tonic-gate #include "db_int.h"
23*7c478bd9Sstevel@tonic-gate #include "db_page.h"
24*7c478bd9Sstevel@tonic-gate #include "shqueue.h"
25*7c478bd9Sstevel@tonic-gate #include "db_shash.h"
26*7c478bd9Sstevel@tonic-gate #include "mp.h"
27*7c478bd9Sstevel@tonic-gate #include "db_auto.h"
28*7c478bd9Sstevel@tonic-gate #include "db_ext.h"
29*7c478bd9Sstevel@tonic-gate #include "common_ext.h"
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate static void __memp_pbh __P((DB_MPOOL *, BH *, size_t *, FILE *));
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate /*
34*7c478bd9Sstevel@tonic-gate  * memp_stat --
35*7c478bd9Sstevel@tonic-gate  *	Display MPOOL statistics.
36*7c478bd9Sstevel@tonic-gate  */
37*7c478bd9Sstevel@tonic-gate int
memp_stat(dbmp,gspp,fspp,db_malloc)38*7c478bd9Sstevel@tonic-gate memp_stat(dbmp, gspp, fspp, db_malloc)
39*7c478bd9Sstevel@tonic-gate 	DB_MPOOL *dbmp;
40*7c478bd9Sstevel@tonic-gate 	DB_MPOOL_STAT **gspp;
41*7c478bd9Sstevel@tonic-gate 	DB_MPOOL_FSTAT ***fspp;
42*7c478bd9Sstevel@tonic-gate 	void *(*db_malloc) __P((size_t));
43*7c478bd9Sstevel@tonic-gate {
44*7c478bd9Sstevel@tonic-gate 	DB_MPOOL_FSTAT **tfsp;
45*7c478bd9Sstevel@tonic-gate 	MPOOLFILE *mfp;
46*7c478bd9Sstevel@tonic-gate 	size_t len, nlen;
47*7c478bd9Sstevel@tonic-gate 	int ret;
48*7c478bd9Sstevel@tonic-gate 	char *name;
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate 	MP_PANIC_CHECK(dbmp);
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate 	/* Allocate space for the global statistics. */
53*7c478bd9Sstevel@tonic-gate 	if (gspp != NULL) {
54*7c478bd9Sstevel@tonic-gate 		*gspp = NULL;
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate 		if ((ret = __os_malloc(sizeof(**gspp), db_malloc, gspp)) != 0)
57*7c478bd9Sstevel@tonic-gate 			return (ret);
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate 		LOCKREGION(dbmp);
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate 		/* Copy out the global statistics. */
62*7c478bd9Sstevel@tonic-gate 		**gspp = dbmp->mp->stat;
63*7c478bd9Sstevel@tonic-gate 		(*gspp)->st_hash_buckets = dbmp->mp->htab_buckets;
64*7c478bd9Sstevel@tonic-gate 		(*gspp)->st_region_wait =
65*7c478bd9Sstevel@tonic-gate 		    dbmp->mp->rlayout.lock.mutex_set_wait;
66*7c478bd9Sstevel@tonic-gate 		(*gspp)->st_region_nowait =
67*7c478bd9Sstevel@tonic-gate 		    dbmp->mp->rlayout.lock.mutex_set_nowait;
68*7c478bd9Sstevel@tonic-gate 		(*gspp)->st_refcnt = dbmp->mp->rlayout.refcnt;
69*7c478bd9Sstevel@tonic-gate 		(*gspp)->st_regsize = dbmp->mp->rlayout.size;
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate 		UNLOCKREGION(dbmp);
72*7c478bd9Sstevel@tonic-gate 	}
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate 	if (fspp != NULL) {
75*7c478bd9Sstevel@tonic-gate 		*fspp = NULL;
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate 		LOCKREGION(dbmp);
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate 		/* Count the MPOOLFILE structures. */
80*7c478bd9Sstevel@tonic-gate 		for (len = 0,
81*7c478bd9Sstevel@tonic-gate 		    mfp = SH_TAILQ_FIRST(&dbmp->mp->mpfq, __mpoolfile);
82*7c478bd9Sstevel@tonic-gate 		    mfp != NULL;
83*7c478bd9Sstevel@tonic-gate 		    ++len, mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile))
84*7c478bd9Sstevel@tonic-gate 			;
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate 		UNLOCKREGION(dbmp);
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate 		if (len == 0)
89*7c478bd9Sstevel@tonic-gate 			return (0);
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate 		/* Allocate space for the pointers. */
92*7c478bd9Sstevel@tonic-gate 		len = (len + 1) * sizeof(DB_MPOOL_FSTAT *);
93*7c478bd9Sstevel@tonic-gate 		if ((ret = __os_malloc(len, db_malloc, fspp)) != 0)
94*7c478bd9Sstevel@tonic-gate 			return (ret);
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate 		LOCKREGION(dbmp);
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 		/* Build each individual entry. */
99*7c478bd9Sstevel@tonic-gate 		for (tfsp = *fspp,
100*7c478bd9Sstevel@tonic-gate 		    mfp = SH_TAILQ_FIRST(&dbmp->mp->mpfq, __mpoolfile);
101*7c478bd9Sstevel@tonic-gate 		    mfp != NULL;
102*7c478bd9Sstevel@tonic-gate 		    ++tfsp, mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile)) {
103*7c478bd9Sstevel@tonic-gate 			name = __memp_fns(dbmp, mfp);
104*7c478bd9Sstevel@tonic-gate 			nlen = strlen(name);
105*7c478bd9Sstevel@tonic-gate 			len = sizeof(DB_MPOOL_FSTAT) + nlen + 1;
106*7c478bd9Sstevel@tonic-gate 			if ((ret = __os_malloc(len, db_malloc, tfsp)) != 0)
107*7c478bd9Sstevel@tonic-gate 				return (ret);
108*7c478bd9Sstevel@tonic-gate 			**tfsp = mfp->stat;
109*7c478bd9Sstevel@tonic-gate 			(*tfsp)->file_name = (char *)
110*7c478bd9Sstevel@tonic-gate 			    (u_int8_t *)*tfsp + sizeof(DB_MPOOL_FSTAT);
111*7c478bd9Sstevel@tonic-gate 			memcpy((*tfsp)->file_name, name, nlen + 1);
112*7c478bd9Sstevel@tonic-gate 		}
113*7c478bd9Sstevel@tonic-gate 		*tfsp = NULL;
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate 		UNLOCKREGION(dbmp);
116*7c478bd9Sstevel@tonic-gate 	}
117*7c478bd9Sstevel@tonic-gate 	return (0);
118*7c478bd9Sstevel@tonic-gate }
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate /*
121*7c478bd9Sstevel@tonic-gate  * __memp_fn --
122*7c478bd9Sstevel@tonic-gate  *	On errors we print whatever is available as the file name.
123*7c478bd9Sstevel@tonic-gate  *
124*7c478bd9Sstevel@tonic-gate  * PUBLIC: char * __memp_fn __P((DB_MPOOLFILE *));
125*7c478bd9Sstevel@tonic-gate  */
126*7c478bd9Sstevel@tonic-gate char *
__memp_fn(dbmfp)127*7c478bd9Sstevel@tonic-gate __memp_fn(dbmfp)
128*7c478bd9Sstevel@tonic-gate 	DB_MPOOLFILE *dbmfp;
129*7c478bd9Sstevel@tonic-gate {
130*7c478bd9Sstevel@tonic-gate 	return (__memp_fns(dbmfp->dbmp, dbmfp->mfp));
131*7c478bd9Sstevel@tonic-gate }
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate /*
134*7c478bd9Sstevel@tonic-gate  * __memp_fns --
135*7c478bd9Sstevel@tonic-gate  *	On errors we print whatever is available as the file name.
136*7c478bd9Sstevel@tonic-gate  *
137*7c478bd9Sstevel@tonic-gate  * PUBLIC: char * __memp_fns __P((DB_MPOOL *, MPOOLFILE *));
138*7c478bd9Sstevel@tonic-gate  *
139*7c478bd9Sstevel@tonic-gate  */
140*7c478bd9Sstevel@tonic-gate char *
__memp_fns(dbmp,mfp)141*7c478bd9Sstevel@tonic-gate __memp_fns(dbmp, mfp)
142*7c478bd9Sstevel@tonic-gate 	DB_MPOOL *dbmp;
143*7c478bd9Sstevel@tonic-gate 	MPOOLFILE *mfp;
144*7c478bd9Sstevel@tonic-gate {
145*7c478bd9Sstevel@tonic-gate 	if (mfp->path_off == 0)
146*7c478bd9Sstevel@tonic-gate 		return ((char *)"temporary");
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate 	return ((char *)R_ADDR(dbmp, mfp->path_off));
149*7c478bd9Sstevel@tonic-gate }
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate #define	FMAP_ENTRIES	200			/* Files we map. */
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate #define	MPOOL_DUMP_HASH	0x01			/* Debug hash chains. */
154*7c478bd9Sstevel@tonic-gate #define	MPOOL_DUMP_LRU	0x02			/* Debug LRU chains. */
155*7c478bd9Sstevel@tonic-gate #define	MPOOL_DUMP_MEM	0x04			/* Debug region memory. */
156*7c478bd9Sstevel@tonic-gate #define	MPOOL_DUMP_ALL	0x07			/* Debug all. */
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate /*
160*7c478bd9Sstevel@tonic-gate  * __memp_dump_region --
161*7c478bd9Sstevel@tonic-gate  *	Display MPOOL structures.
162*7c478bd9Sstevel@tonic-gate  *
163*7c478bd9Sstevel@tonic-gate  * PUBLIC: void __memp_dump_region __P((DB_MPOOL *, char *, FILE *));
164*7c478bd9Sstevel@tonic-gate  */
165*7c478bd9Sstevel@tonic-gate void
__memp_dump_region(dbmp,area,fp)166*7c478bd9Sstevel@tonic-gate __memp_dump_region(dbmp, area, fp)
167*7c478bd9Sstevel@tonic-gate 	DB_MPOOL *dbmp;
168*7c478bd9Sstevel@tonic-gate 	char *area;
169*7c478bd9Sstevel@tonic-gate 	FILE *fp;
170*7c478bd9Sstevel@tonic-gate {
171*7c478bd9Sstevel@tonic-gate 	BH *bhp;
172*7c478bd9Sstevel@tonic-gate 	DB_HASHTAB *htabp;
173*7c478bd9Sstevel@tonic-gate 	DB_MPOOLFILE *dbmfp;
174*7c478bd9Sstevel@tonic-gate 	MPOOL *mp;
175*7c478bd9Sstevel@tonic-gate 	MPOOLFILE *mfp;
176*7c478bd9Sstevel@tonic-gate 	size_t bucket, fmap[FMAP_ENTRIES + 1];
177*7c478bd9Sstevel@tonic-gate 	u_int32_t flags;
178*7c478bd9Sstevel@tonic-gate 	int cnt;
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate 	/* Make it easy to call from the debugger. */
181*7c478bd9Sstevel@tonic-gate 	if (fp == NULL)
182*7c478bd9Sstevel@tonic-gate 		fp = stderr;
183*7c478bd9Sstevel@tonic-gate 
184*7c478bd9Sstevel@tonic-gate 	for (flags = 0; *area != '\0'; ++area)
185*7c478bd9Sstevel@tonic-gate 		switch (*area) {
186*7c478bd9Sstevel@tonic-gate 		case 'A':
187*7c478bd9Sstevel@tonic-gate 			LF_SET(MPOOL_DUMP_ALL);
188*7c478bd9Sstevel@tonic-gate 			break;
189*7c478bd9Sstevel@tonic-gate 		case 'h':
190*7c478bd9Sstevel@tonic-gate 			LF_SET(MPOOL_DUMP_HASH);
191*7c478bd9Sstevel@tonic-gate 			break;
192*7c478bd9Sstevel@tonic-gate 		case 'l':
193*7c478bd9Sstevel@tonic-gate 			LF_SET(MPOOL_DUMP_LRU);
194*7c478bd9Sstevel@tonic-gate 			break;
195*7c478bd9Sstevel@tonic-gate 		case 'm':
196*7c478bd9Sstevel@tonic-gate 			LF_SET(MPOOL_DUMP_MEM);
197*7c478bd9Sstevel@tonic-gate 			break;
198*7c478bd9Sstevel@tonic-gate 		}
199*7c478bd9Sstevel@tonic-gate 
200*7c478bd9Sstevel@tonic-gate 	LOCKREGION(dbmp);
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate 	mp = dbmp->mp;
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate 	/* Display MPOOL structures. */
205*7c478bd9Sstevel@tonic-gate 	(void)fprintf(fp, "%s\nPool (region addr 0x%lx, alloc addr 0x%lx)\n",
206*7c478bd9Sstevel@tonic-gate 	    DB_LINE, (u_long)dbmp->reginfo.addr, (u_long)dbmp->addr);
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate 	/* Display the MPOOLFILE structures. */
209*7c478bd9Sstevel@tonic-gate 	cnt = 0;
210*7c478bd9Sstevel@tonic-gate 	for (mfp = SH_TAILQ_FIRST(&dbmp->mp->mpfq, __mpoolfile);
211*7c478bd9Sstevel@tonic-gate 	    mfp != NULL; mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile), ++cnt) {
212*7c478bd9Sstevel@tonic-gate 		(void)fprintf(fp, "file #%d: %s: refs %lu, type %ld, %s\n",
213*7c478bd9Sstevel@tonic-gate 		    cnt + 1, __memp_fns(dbmp, mfp), (u_long)mfp->ref,
214*7c478bd9Sstevel@tonic-gate 		    (long)mfp->ftype,
215*7c478bd9Sstevel@tonic-gate 		    F_ISSET(mfp, MP_CAN_MMAP) ? "mmap" : "read/write");
216*7c478bd9Sstevel@tonic-gate 		    if (cnt < FMAP_ENTRIES)
217*7c478bd9Sstevel@tonic-gate 			fmap[cnt] = R_OFFSET(dbmp, mfp);
218*7c478bd9Sstevel@tonic-gate 	}
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate 	for (dbmfp = TAILQ_FIRST(&dbmp->dbmfq);
221*7c478bd9Sstevel@tonic-gate 	    dbmfp != NULL; dbmfp = TAILQ_NEXT(dbmfp, q), ++cnt) {
222*7c478bd9Sstevel@tonic-gate 		(void)fprintf(fp, "file #%d: %s: fd: %d: per-process, %s\n",
223*7c478bd9Sstevel@tonic-gate 		    cnt + 1, __memp_fn(dbmfp), dbmfp->fd,
224*7c478bd9Sstevel@tonic-gate 		    F_ISSET(dbmfp, MP_READONLY) ? "readonly" : "read/write");
225*7c478bd9Sstevel@tonic-gate 		    if (cnt < FMAP_ENTRIES)
226*7c478bd9Sstevel@tonic-gate 			fmap[cnt] = R_OFFSET(dbmp, mfp);
227*7c478bd9Sstevel@tonic-gate 	}
228*7c478bd9Sstevel@tonic-gate 	if (cnt < FMAP_ENTRIES)
229*7c478bd9Sstevel@tonic-gate 		fmap[cnt] = INVALID;
230*7c478bd9Sstevel@tonic-gate 	else
231*7c478bd9Sstevel@tonic-gate 		fmap[FMAP_ENTRIES] = INVALID;
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate 	/* Display the hash table list of BH's. */
234*7c478bd9Sstevel@tonic-gate 	if (LF_ISSET(MPOOL_DUMP_HASH)) {
235*7c478bd9Sstevel@tonic-gate 		(void)fprintf(fp,
236*7c478bd9Sstevel@tonic-gate 	    "%s\nBH hash table (%lu hash slots)\npageno, file, ref, address\n",
237*7c478bd9Sstevel@tonic-gate 		    DB_LINE, (u_long)mp->htab_buckets);
238*7c478bd9Sstevel@tonic-gate 		for (htabp = dbmp->htab,
239*7c478bd9Sstevel@tonic-gate 		    bucket = 0; bucket < mp->htab_buckets; ++htabp, ++bucket) {
240*7c478bd9Sstevel@tonic-gate 			if (SH_TAILQ_FIRST(&dbmp->htab[bucket], __bh) != NULL)
241*7c478bd9Sstevel@tonic-gate 				(void)fprintf(fp, "%lu:\n", (u_long)bucket);
242*7c478bd9Sstevel@tonic-gate 			for (bhp = SH_TAILQ_FIRST(&dbmp->htab[bucket], __bh);
243*7c478bd9Sstevel@tonic-gate 			    bhp != NULL; bhp = SH_TAILQ_NEXT(bhp, hq, __bh))
244*7c478bd9Sstevel@tonic-gate 				__memp_pbh(dbmp, bhp, fmap, fp);
245*7c478bd9Sstevel@tonic-gate 		}
246*7c478bd9Sstevel@tonic-gate 	}
247*7c478bd9Sstevel@tonic-gate 
248*7c478bd9Sstevel@tonic-gate 	/* Display the LRU list of BH's. */
249*7c478bd9Sstevel@tonic-gate 	if (LF_ISSET(MPOOL_DUMP_LRU)) {
250*7c478bd9Sstevel@tonic-gate 		(void)fprintf(fp, "%s\nBH LRU list\n", DB_LINE);
251*7c478bd9Sstevel@tonic-gate 		(void)fprintf(fp, "pageno, file, ref, address\n");
252*7c478bd9Sstevel@tonic-gate 		for (bhp = SH_TAILQ_FIRST(&dbmp->mp->bhq, __bh);
253*7c478bd9Sstevel@tonic-gate 		    bhp != NULL; bhp = SH_TAILQ_NEXT(bhp, q, __bh))
254*7c478bd9Sstevel@tonic-gate 			__memp_pbh(dbmp, bhp, fmap, fp);
255*7c478bd9Sstevel@tonic-gate 	}
256*7c478bd9Sstevel@tonic-gate 
257*7c478bd9Sstevel@tonic-gate 	if (LF_ISSET(MPOOL_DUMP_MEM))
258*7c478bd9Sstevel@tonic-gate 		__db_shalloc_dump(dbmp->addr, fp);
259*7c478bd9Sstevel@tonic-gate 
260*7c478bd9Sstevel@tonic-gate 	UNLOCKREGION(dbmp);
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate 	/* Flush in case we're debugging. */
263*7c478bd9Sstevel@tonic-gate 	(void)fflush(fp);
264*7c478bd9Sstevel@tonic-gate }
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate /*
267*7c478bd9Sstevel@tonic-gate  * __memp_pbh --
268*7c478bd9Sstevel@tonic-gate  *	Display a BH structure.
269*7c478bd9Sstevel@tonic-gate  */
270*7c478bd9Sstevel@tonic-gate static void
__memp_pbh(dbmp,bhp,fmap,fp)271*7c478bd9Sstevel@tonic-gate __memp_pbh(dbmp, bhp, fmap, fp)
272*7c478bd9Sstevel@tonic-gate 	DB_MPOOL *dbmp;
273*7c478bd9Sstevel@tonic-gate 	BH *bhp;
274*7c478bd9Sstevel@tonic-gate 	size_t *fmap;
275*7c478bd9Sstevel@tonic-gate 	FILE *fp;
276*7c478bd9Sstevel@tonic-gate {
277*7c478bd9Sstevel@tonic-gate 	static const FN fn[] = {
278*7c478bd9Sstevel@tonic-gate 		{ BH_CALLPGIN,	"callpgin" },
279*7c478bd9Sstevel@tonic-gate 		{ BH_DIRTY,	"dirty" },
280*7c478bd9Sstevel@tonic-gate 		{ BH_DISCARD,	"discard" },
281*7c478bd9Sstevel@tonic-gate 		{ BH_LOCKED,	"locked" },
282*7c478bd9Sstevel@tonic-gate 		{ BH_TRASH,	"trash" },
283*7c478bd9Sstevel@tonic-gate 		{ BH_WRITE,	"write" },
284*7c478bd9Sstevel@tonic-gate 		{ 0 },
285*7c478bd9Sstevel@tonic-gate 	};
286*7c478bd9Sstevel@tonic-gate 	int i;
287*7c478bd9Sstevel@tonic-gate 
288*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < FMAP_ENTRIES; ++i)
289*7c478bd9Sstevel@tonic-gate 		if (fmap[i] == INVALID || fmap[i] == bhp->mf_offset)
290*7c478bd9Sstevel@tonic-gate 			break;
291*7c478bd9Sstevel@tonic-gate 
292*7c478bd9Sstevel@tonic-gate 	if (fmap[i] == INVALID)
293*7c478bd9Sstevel@tonic-gate 		(void)fprintf(fp, "  %4lu, %lu, %2lu, %lu",
294*7c478bd9Sstevel@tonic-gate 		    (u_long)bhp->pgno, (u_long)bhp->mf_offset,
295*7c478bd9Sstevel@tonic-gate 		    (u_long)bhp->ref, (u_long)R_OFFSET(dbmp, bhp));
296*7c478bd9Sstevel@tonic-gate 	else
297*7c478bd9Sstevel@tonic-gate 		(void)fprintf(fp, "  %4lu,   #%d,  %2lu, %lu",
298*7c478bd9Sstevel@tonic-gate 		    (u_long)bhp->pgno, i + 1,
299*7c478bd9Sstevel@tonic-gate 		    (u_long)bhp->ref, (u_long)R_OFFSET(dbmp, bhp));
300*7c478bd9Sstevel@tonic-gate 
301*7c478bd9Sstevel@tonic-gate 	__db_prflags(bhp->flags, fn, fp);
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate 	(void)fprintf(fp, "\n");
304*7c478bd9Sstevel@tonic-gate }
305