Home | History | Annotate | Line # | Download | only in dumplfs
dumplfs.c revision 1.1
      1 /*-
      2  * Copyright (c) 1991, 1993
      3  *	The Regents of the University of California.  All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  * 3. All advertising materials mentioning features or use of this software
     14  *    must display the following acknowledgement:
     15  *	This product includes software developed by the University of
     16  *	California, Berkeley and its contributors.
     17  * 4. Neither the name of the University nor the names of its contributors
     18  *    may be used to endorse or promote products derived from this software
     19  *    without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  * SUCH DAMAGE.
     32  */
     33 
     34 #ifndef lint
     35 static char copyright[] =
     36 "@(#) Copyright (c) 1991, 1993\n\
     37 	The Regents of the University of California.  All rights reserved.\n";
     38 #endif /* not lint */
     39 
     40 #ifndef lint
     41 /*static char sccsid[] = "from: @(#)dumplfs.c	8.1 (Berkeley) 6/5/93";*/
     42 static char *rcsid = "$Id: dumplfs.c,v 1.1 1994/06/08 18:58:50 mycroft Exp $";
     43 #endif /* not lint */
     44 
     45 #include <sys/param.h>
     46 #include <sys/ucred.h>
     47 #include <sys/mount.h>
     48 #include <sys/time.h>
     49 
     50 #include <ufs/ufs/dinode.h>
     51 #include <ufs/lfs/lfs.h>
     52 
     53 #include <fcntl.h>
     54 #include <fstab.h>
     55 #include <errno.h>
     56 #include <unistd.h>
     57 #include <stdlib.h>
     58 #include <stdio.h>
     59 #include <string.h>
     60 #include "extern.h"
     61 
     62 static void	addseg __P((char *));
     63 static void	dump_cleaner_info __P((struct lfs *, void *));
     64 static void	dump_dinode __P((struct dinode *));
     65 static void	dump_ifile __P((int, struct lfs *, int));
     66 static int	dump_ipage_ifile __P((int, IFILE *, int));
     67 static int	dump_ipage_segusage __P((struct lfs *, int, IFILE *, int));
     68 static void	dump_segment __P((int, int, daddr_t, struct lfs *, int));
     69 static int	dump_sum __P((int, struct lfs *, SEGSUM *, int, daddr_t));
     70 static void	dump_super __P((struct lfs *));
     71 static void	usage __P((void));
     72 
     73 typedef struct seglist SEGLIST;
     74 struct seglist {
     75         SEGLIST *next;
     76 	int num;
     77 };
     78 SEGLIST	*seglist;
     79 
     80 int daddr_shift;
     81 char *special;
     82 
     83 /* Segment Usage formats */
     84 #define print_suheader \
     85 	(void)printf("segnum\tflags\tnbytes\tninos\tnsums\tlastmod\n")
     86 
     87 #define print_suentry(i, sp) \
     88 	(void)printf("%d\t%c%c%c\t%d\t%d\t%d\t%s", i, \
     89 	    (((sp)->su_flags & SEGUSE_ACTIVE) ? 'A' : ' '), \
     90 	    (((sp)->su_flags & SEGUSE_DIRTY) ? 'D' : 'C'), \
     91 	    (((sp)->su_flags & SEGUSE_SUPERBLOCK) ? 'S' : ' '), \
     92 	    (sp)->su_nbytes, (sp)->su_ninos, (sp)->su_nsums, \
     93 	    ctime((time_t *)&(sp)->su_lastmod))
     94 
     95 /* Ifile formats */
     96 #define print_iheader \
     97 	(void)printf("inum\tstatus\tversion\tdaddr\t\tfreeptr\n")
     98 #define print_ientry(i, ip) \
     99 	if (ip->if_daddr == LFS_UNUSED_DADDR) \
    100 		(void)printf("%d\tFREE\t%d\t \t\t%d\n", \
    101 		    i, ip->if_version, ip->if_nextfree); \
    102 	else \
    103 		(void)printf("%d\tINUSE\t%d\t%8X    \n", \
    104 		    i, ip->if_version, ip->if_daddr)
    105 int
    106 main(argc, argv)
    107 	int argc;
    108 	char *argv[];
    109 {
    110 	struct lfs lfs_sb1, lfs_sb2, *lfs_master;
    111 	daddr_t seg_addr;
    112 	int ch, do_allsb, do_ientries, fd, segnum;
    113 
    114 	do_allsb = 0;
    115 	do_ientries = 0;
    116 	while ((ch = getopt(argc, argv, "ais:")) != EOF)
    117 		switch(ch) {
    118 		case 'a':		/* Dump all superblocks */
    119 			do_allsb = 1;
    120 			break;
    121 		case 'i':		/* Dump ifile entries */
    122 			do_ientries = 1;
    123 			break;
    124 		case 's':		/* Dump out these segments */
    125 			addseg(optarg);
    126 			break;
    127 		default:
    128 			usage();
    129 		}
    130 	argc -= optind;
    131 	argv += optind;
    132 
    133 	if (argc != 1)
    134 		usage();
    135 
    136 	special = argv[0];
    137 	if ((fd = open(special, O_RDONLY, 0)) < 0)
    138 		err("%s: %s", special, strerror(errno));
    139 
    140 	/* Read the first superblock */
    141 	get(fd, LFS_LABELPAD, &lfs_sb1, sizeof(struct lfs));
    142 	daddr_shift = lfs_sb1.lfs_bshift - lfs_sb1.lfs_fsbtodb;
    143 
    144 	/*
    145 	 * Read the second superblock and figure out which check point is
    146 	 * most up to date.
    147 	 */
    148 	get(fd,
    149 	    lfs_sb1.lfs_sboffs[1] << daddr_shift, &lfs_sb2, sizeof(struct lfs));
    150 
    151 	lfs_master = &lfs_sb1;
    152 	if (lfs_sb1.lfs_tstamp < lfs_sb2.lfs_tstamp)
    153 		lfs_master = &lfs_sb2;
    154 
    155 	(void)printf("Master Superblock:\n");
    156 	dump_super(lfs_master);
    157 
    158 	dump_ifile(fd, lfs_master, do_ientries);
    159 
    160 	if (seglist != NULL)
    161 		for (; seglist != NULL; seglist = seglist->next) {
    162 			seg_addr = lfs_master->lfs_sboffs[0] + seglist->num *
    163 			    (lfs_master->lfs_ssize << lfs_master->lfs_fsbtodb);
    164 			dump_segment(fd,
    165 			    seglist->num, seg_addr, lfs_master, do_allsb);
    166 		}
    167 	else
    168 		for (segnum = 0, seg_addr = lfs_master->lfs_sboffs[0];
    169 		    segnum < lfs_master->lfs_nseg; segnum++, seg_addr +=
    170 		    lfs_master->lfs_ssize << lfs_master->lfs_fsbtodb)
    171 			dump_segment(fd,
    172 			    segnum, seg_addr, lfs_master, do_allsb);
    173 
    174 	(void)close(fd);
    175 	exit(0);
    176 }
    177 
    178 /*
    179  * We are reading all the blocks of an inode and dumping out the ifile table.
    180  * This code could be tighter, but this is a first pass at getting the stuff
    181  * printed out rather than making this code incredibly efficient.
    182  */
    183 static void
    184 dump_ifile(fd, lfsp, do_ientries)
    185 	int fd;
    186 	struct lfs *lfsp;
    187 	int do_ientries;
    188 {
    189 	IFILE *ipage;
    190 	struct dinode *dip, *dpage;
    191 	daddr_t addr, *addrp, *dindir, *iaddrp, *indir;
    192 	int block_limit, i, inum, j, nblocks, nsupb, psize;
    193 
    194 	psize = lfsp->lfs_bsize;
    195 	addr = lfsp->lfs_idaddr;
    196 
    197 	if (!(dpage = malloc(psize)))
    198 		err("%s", strerror(errno));
    199 	get(fd, addr << daddr_shift, dpage, psize);
    200 
    201 	for (dip = dpage + INOPB(lfsp) - 1; dip >= dpage; --dip)
    202 		if (dip->di_inumber == LFS_IFILE_INUM)
    203 			break;
    204 
    205 	if (dip < dpage)
    206 		err("unable to locate ifile inode");
    207 
    208 	(void)printf("\nIFILE inode\n");
    209 	dump_dinode(dip);
    210 
    211 	(void)printf("\nIFILE contents\n");
    212 	nblocks = dip->di_size >> lfsp->lfs_bshift;
    213 	block_limit = MIN(nblocks, NDADDR);
    214 
    215 	/* Get the direct block */
    216 	if ((ipage = malloc(psize)) == NULL)
    217 		err("%s", strerror(errno));
    218 	for (inum = 0, addrp = dip->di_db, i = 0; i < block_limit;
    219 	    i++, addrp++) {
    220 		get(fd, *addrp << daddr_shift, ipage, psize);
    221 		if (i < lfsp->lfs_cleansz) {
    222 			dump_cleaner_info(lfsp, ipage);
    223 			print_suheader;
    224 			continue;
    225 		}
    226 
    227 		if (i < (lfsp->lfs_segtabsz + lfsp->lfs_cleansz)) {
    228 			inum = dump_ipage_segusage(lfsp, inum, ipage,
    229 			    lfsp->lfs_sepb);
    230 			if (!inum)
    231 				if(!do_ientries)
    232 					goto e0;
    233 				else
    234 					print_iheader;
    235 		} else
    236 			inum = dump_ipage_ifile(inum, ipage, lfsp->lfs_ifpb);
    237 
    238 	}
    239 
    240 	if (nblocks <= NDADDR)
    241 		goto e0;
    242 
    243 	/* Dump out blocks off of single indirect block */
    244 	if (!(indir = malloc(psize)))
    245 		err("%s", strerror(errno));
    246 	get(fd, dip->di_ib[0] << daddr_shift, indir, psize);
    247 	block_limit = MIN(i + lfsp->lfs_nindir, nblocks);
    248 	for (addrp = indir; i < block_limit; i++, addrp++) {
    249 		if (*addrp == LFS_UNUSED_DADDR)
    250 			break;
    251 		get(fd, *addrp << daddr_shift,ipage, psize);
    252 		if (i < lfsp->lfs_cleansz) {
    253 			dump_cleaner_info(lfsp, ipage);
    254 			continue;
    255 		} else
    256 			i -= lfsp->lfs_cleansz;
    257 
    258 		if (i < lfsp->lfs_segtabsz) {
    259 			inum = dump_ipage_segusage(lfsp, inum, ipage,
    260 			    lfsp->lfs_sepb);
    261 			if (!inum)
    262 				if(!do_ientries)
    263 					goto e1;
    264 				else
    265 					print_iheader;
    266 		} else
    267 			inum = dump_ipage_ifile(inum, ipage, lfsp->lfs_ifpb);
    268 	}
    269 
    270 	if (nblocks <= lfsp->lfs_nindir * lfsp->lfs_ifpb)
    271 		goto e1;
    272 
    273 	/* Get the double indirect block */
    274 	if (!(dindir = malloc(psize)))
    275 		err("%s", strerror(errno));
    276 	get(fd, dip->di_ib[1] << daddr_shift, dindir, psize);
    277 	for (iaddrp = dindir, j = 0; j < lfsp->lfs_nindir; j++, iaddrp++) {
    278 		if (*iaddrp == LFS_UNUSED_DADDR)
    279 			break;
    280 		get(fd, *iaddrp << daddr_shift, indir, psize);
    281 		block_limit = MIN(i + lfsp->lfs_nindir, nblocks);
    282 		for (addrp = indir; i < block_limit; i++, addrp++) {
    283 			if (*addrp == LFS_UNUSED_DADDR)
    284 				break;
    285 			get(fd, *addrp << daddr_shift, ipage, psize);
    286 			if (i < lfsp->lfs_cleansz) {
    287 				dump_cleaner_info(lfsp, ipage);
    288 				continue;
    289 			} else
    290 				i -= lfsp->lfs_cleansz;
    291 
    292 			if (i < lfsp->lfs_segtabsz) {
    293 				inum = dump_ipage_segusage(lfsp,
    294 				    inum, ipage, lfsp->lfs_sepb);
    295 				if (!inum)
    296 					if(!do_ientries)
    297 						goto e2;
    298 					else
    299 						print_iheader;
    300 			} else
    301 				inum = dump_ipage_ifile(inum,
    302 				    ipage, lfsp->lfs_ifpb);
    303 		}
    304 	}
    305 e2:	free(dindir);
    306 e1:	free(indir);
    307 e0:	free(dpage);
    308 	free(ipage);
    309 }
    310 
    311 static int
    312 dump_ipage_ifile(i, pp, tot)
    313 	int i;
    314 	IFILE *pp;
    315 	int tot;
    316 {
    317 	IFILE *ip;
    318 	int cnt, max;
    319 
    320 	max = i + tot;
    321 
    322 	for (ip = pp, cnt = i; cnt < max; cnt++, ip++)
    323 		print_ientry(cnt, ip);
    324 	return (max);
    325 }
    326 
    327 static int
    328 dump_ipage_segusage(lfsp, i, pp, tot)
    329 	struct lfs *lfsp;
    330 	int i;
    331 	IFILE *pp;
    332 	int tot;
    333 {
    334 	SEGUSE *sp;
    335 	int cnt, max;
    336 
    337 	max = i + tot;
    338 	for (sp = (SEGUSE *)pp, cnt = i;
    339 	     cnt < lfsp->lfs_nseg && cnt < max; cnt++, sp++)
    340 		print_suentry(cnt, sp);
    341 	if (max >= lfsp->lfs_nseg)
    342 		return (0);
    343 	else
    344 		return (max);
    345 }
    346 
    347 static void
    348 dump_dinode(dip)
    349 	struct dinode *dip;
    350 {
    351 	int i;
    352 
    353 	(void)printf("%s%d\t%s%d\t%s%d\t%s%d\t%s%d\n",
    354 		"mode  ", dip->di_mode,
    355 		"nlink ", dip->di_nlink,
    356 		"uid   ", dip->di_uid,
    357 		"gid   ", dip->di_gid,
    358 		"size  ", dip->di_size);
    359 	(void)printf("%s%s%s%s%s%s",
    360 		"atime ", ctime(&dip->di_atime.ts_sec),
    361 		"mtime ", ctime(&dip->di_mtime.ts_sec),
    362 		"ctime ", ctime(&dip->di_ctime.ts_sec));
    363 	(void)printf("inum  %d\n", dip->di_inumber);
    364 	(void)printf("Direct Addresses\n");
    365 	for (i = 0; i < NDADDR; i++) {
    366 		(void)printf("\t0x%X", dip->di_db[i]);
    367 		if ((i % 6) == 5)
    368 			(void)printf("\n");
    369 	}
    370 	for (i = 0; i < NIADDR; i++)
    371 		(void)printf("\t0x%X", dip->di_ib[i]);
    372 	(void)printf("\n");
    373 }
    374 
    375 static int
    376 dump_sum(fd, lfsp, sp, segnum, addr)
    377 	struct lfs *lfsp;
    378 	SEGSUM *sp;
    379 	int fd, segnum;
    380 	daddr_t addr;
    381 {
    382 	FINFO *fp;
    383 	long *dp;
    384 	int i, j;
    385 	int ck;
    386 	int numblocks;
    387 	struct dinode *inop;
    388 
    389 	if (sp->ss_sumsum != (ck = cksum(&sp->ss_datasum,
    390 	    LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum)))) {
    391 		(void)printf("dumplfs: %s %d address 0x%lx\n",
    392 		    "corrupt summary block; segment", segnum, addr);
    393 		return(0);
    394 	}
    395 
    396 	(void)printf("Segment Summary Info at 0x%lx\n", addr);
    397 	(void)printf("    %s0x%X\t%s%d\t%s%d\n    %s0x%X\t%s0x%X",
    398 		"next     ", sp->ss_next,
    399 		"nfinfo   ", sp->ss_nfinfo,
    400 		"ninos    ", sp->ss_ninos,
    401 		"sumsum   ", sp->ss_sumsum,
    402 		"datasum  ", sp->ss_datasum );
    403 	(void)printf("\tcreate   %s", ctime((time_t *)&sp->ss_create));
    404 
    405 	numblocks = (sp->ss_ninos + INOPB(lfsp) - 1) / INOPB(lfsp);
    406 
    407 	/* Dump out inode disk addresses */
    408 	dp = (daddr_t *)sp;
    409 	dp += LFS_SUMMARY_SIZE / sizeof(daddr_t);
    410 	inop = malloc(1 << lfsp->lfs_bshift);
    411 	printf("    Inode addresses:");
    412 	for (dp--, i = 0; i < sp->ss_ninos; dp--) {
    413 		printf("\t0x%X {", *dp);
    414 		get(fd, *dp << (lfsp->lfs_bshift - lfsp->lfs_fsbtodb), inop,
    415 		    (1 << lfsp->lfs_bshift));
    416 		for (j = 0; i < sp->ss_ninos && j < INOPB(lfsp); j++, i++) {
    417 			if (j > 0)
    418 				(void)printf(", ");
    419 			(void)printf("%d", inop[j].di_inumber);
    420 		}
    421 		(void)printf("}");
    422 		if (((i/INOPB(lfsp)) % 4) == 3)
    423 			(void)printf("\n");
    424 	}
    425 	free(inop);
    426 
    427 	printf("\n");
    428 	for (fp = (FINFO *)(sp + 1), i = 0; i < sp->ss_nfinfo; i++) {
    429 		numblocks += fp->fi_nblocks;
    430 		(void)printf("    FINFO for inode: %d version %d nblocks %d\n",
    431 		    fp->fi_ino, fp->fi_version, fp->fi_nblocks);
    432 		dp = &(fp->fi_blocks[0]);
    433 		for (j = 0; j < fp->fi_nblocks; j++, dp++) {
    434 			(void)printf("\t%d", *dp);
    435 			if ((j % 8) == 7)
    436 				(void)printf("\n");
    437 		}
    438 		if ((j % 8) != 0)
    439 			(void)printf("\n");
    440 		fp = (FINFO *)dp;
    441 	}
    442 	return (numblocks);
    443 }
    444 
    445 static void
    446 dump_segment(fd, segnum, addr, lfsp, dump_sb)
    447 	int fd, segnum;
    448 	daddr_t addr;
    449 	struct lfs *lfsp;
    450 	int dump_sb;
    451 {
    452 	struct lfs lfs_sb, *sbp;
    453 	SEGSUM *sump;
    454 	char sumblock[LFS_SUMMARY_SIZE];
    455 	int did_one, nblocks, sb;
    456 	off_t sum_offset, super_off;
    457 
    458 	(void)printf("\nSEGMENT %d (Disk Address 0x%X)\n",
    459 	    addr >> (lfsp->lfs_segshift - daddr_shift), addr);
    460 	sum_offset = (addr << (lfsp->lfs_bshift - lfsp->lfs_fsbtodb));
    461 
    462 	sb = 0;
    463 	did_one = 0;
    464 	do {
    465 		get(fd, sum_offset, sumblock, LFS_SUMMARY_SIZE);
    466 		sump = (SEGSUM *)sumblock;
    467 		if (sump->ss_sumsum != cksum (&sump->ss_datasum,
    468 			LFS_SUMMARY_SIZE - sizeof(sump->ss_sumsum))) {
    469 			sbp = (struct lfs *)sump;
    470 			if (sb = (sbp->lfs_magic == LFS_MAGIC)) {
    471 				super_off = sum_offset;
    472 				sum_offset += LFS_SBPAD;
    473 			} else if (did_one)
    474 				break;
    475 			else {
    476 				printf("Segment at 0x%X corrupt\n", addr);
    477 				break;
    478 			}
    479 		} else {
    480 			nblocks = dump_sum(fd, lfsp, sump, segnum, sum_offset >>
    481 			     (lfsp->lfs_bshift - lfsp->lfs_fsbtodb));
    482 			if (nblocks)
    483 				sum_offset += LFS_SUMMARY_SIZE +
    484 					(nblocks << lfsp->lfs_bshift);
    485 			else
    486 				sum_offset = 0;
    487 			did_one = 1;
    488 		}
    489 	} while (sum_offset);
    490 
    491 	if (dump_sb && sb)  {
    492 		get(fd, super_off, &lfs_sb, sizeof(struct lfs));
    493 		dump_super(&lfs_sb);
    494 	}
    495 	return;
    496 }
    497 
    498 static void
    499 dump_super(lfsp)
    500 	struct lfs *lfsp;
    501 {
    502 	int i;
    503 
    504 	(void)printf("%s0x%X\t%s0x%X\t%s%d\t%s%d\n",
    505 		"magic    ", lfsp->lfs_magic,
    506 		"version  ", lfsp->lfs_version,
    507 		"size     ", lfsp->lfs_size,
    508 		"ssize    ", lfsp->lfs_ssize);
    509 	(void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n",
    510 		"dsize    ", lfsp->lfs_dsize,
    511 		"bsize    ", lfsp->lfs_bsize,
    512 		"fsize    ", lfsp->lfs_fsize,
    513 		"frag     ", lfsp->lfs_frag);
    514 
    515 	(void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n",
    516 		"minfree  ", lfsp->lfs_minfree,
    517 		"inopb    ", lfsp->lfs_inopb,
    518 		"ifpb     ", lfsp->lfs_ifpb,
    519 		"nindir   ", lfsp->lfs_nindir);
    520 
    521 	(void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n",
    522 		"nseg     ", lfsp->lfs_nseg,
    523 		"nspf     ", lfsp->lfs_nspf,
    524 		"cleansz  ", lfsp->lfs_cleansz,
    525 		"segtabsz ", lfsp->lfs_segtabsz);
    526 
    527 	(void)printf("%s0x%X\t%s%d\t%s0x%X\t%s%d\n",
    528 		"segmask  ", lfsp->lfs_segmask,
    529 		"segshift ", lfsp->lfs_segshift,
    530 		"bmask    ", lfsp->lfs_bmask,
    531 		"bshift   ", lfsp->lfs_bshift);
    532 
    533 	(void)printf("%s0x%X\t\t%s%d\t%s0x%X\t%s%d\n",
    534 		"ffmask   ", lfsp->lfs_ffmask,
    535 		"ffshift  ", lfsp->lfs_ffshift,
    536 		"fbmask   ", lfsp->lfs_fbmask,
    537 		"fbshift  ", lfsp->lfs_fbshift);
    538 
    539 	(void)printf("%s%d\t%s%d\t%s0x%X\t%s0x%qx\n",
    540 		"sushift  ", lfsp->lfs_sushift,
    541 		"fsbtodb  ", lfsp->lfs_fsbtodb,
    542 		"cksum    ", lfsp->lfs_cksum,
    543 		"maxfilesize  ", lfsp->lfs_maxfilesize);
    544 
    545 	(void)printf("Superblock disk addresses:\t");
    546 	for (i = 0; i < LFS_MAXNUMSB; i++) {
    547 		(void)printf(" 0x%X", lfsp->lfs_sboffs[i]);
    548 		if ( i == (LFS_MAXNUMSB >> 1))
    549 			(void)printf("\n\t\t\t\t");
    550 	}
    551 	(void)printf("\n");
    552 
    553 	(void)printf("Checkpoint Info\n");
    554 	(void)printf("%s%d\t%s0x%X\t%s%d\n",
    555 		"free     ", lfsp->lfs_free,
    556 		"idaddr   ", lfsp->lfs_idaddr,
    557 		"ifile    ", lfsp->lfs_ifile);
    558 	(void)printf("%s%d\t%s%d\t%s%d\n",
    559 		"bfree    ", lfsp->lfs_bfree,
    560 		"avail    ", lfsp->lfs_avail,
    561 		"uinodes  ", lfsp->lfs_uinodes);
    562 	(void)printf("%s%d\t%s0x%X\t%s0x%X\n%s0x%X\t%s0x%X\t",
    563 		"nfiles   ", lfsp->lfs_nfiles,
    564 		"lastseg  ", lfsp->lfs_lastseg,
    565 		"nextseg  ", lfsp->lfs_nextseg,
    566 		"curseg   ", lfsp->lfs_curseg,
    567 		"offset   ", lfsp->lfs_offset);
    568 	(void)printf("tstamp   %s", ctime((time_t *)&lfsp->lfs_tstamp));
    569 	(void)printf("\nIn-Memory Information\n");
    570 	(void)printf("%s%d\t%s0x%X\t%s%d%s%d\t%s%d\n",
    571 		"seglock  ", lfsp->lfs_seglock,
    572 		"iocount  ", lfsp->lfs_iocount,
    573 		"writer   ", lfsp->lfs_writer,
    574 		"dirops   ", lfsp->lfs_dirops,
    575 		"doifile  ", lfsp->lfs_doifile);
    576 	(void)printf("%s%d\t%s%d\t%s0x%X\t%s%d\n",
    577 		"nactive  ", lfsp->lfs_nactive,
    578 		"fmod     ", lfsp->lfs_fmod,
    579 		"clean    ", lfsp->lfs_clean,
    580 		"ronly    ", lfsp->lfs_ronly);
    581 }
    582 
    583 static void
    584 addseg(arg)
    585 	char *arg;
    586 {
    587 	SEGLIST *p;
    588 
    589 	if ((p = malloc(sizeof(SEGLIST))) == NULL)
    590 		err("%s", strerror(errno));
    591 	p->next = seglist;
    592 	p->num = atoi(arg);
    593 	seglist = p;
    594 }
    595 
    596 static void
    597 dump_cleaner_info(lfsp, ipage)
    598 	struct lfs *lfsp;
    599 	void *ipage;
    600 {
    601 	CLEANERINFO *cip;
    602 
    603 	cip = (CLEANERINFO *)ipage;
    604 	(void)printf("segments clean\t%d\tsegments dirty\t%d\n\n",
    605 	    cip->clean, cip->dirty);
    606 }
    607 
    608 static void
    609 usage()
    610 {
    611 	(void)fprintf(stderr, "usage: dumplfs [-ai] [-s segnum] file\n");
    612 	exit(1);
    613 }
    614