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