Home | History | Annotate | Line # | Download | only in dumplfs
dumplfs.c revision 1.12
      1 /*	$NetBSD: dumplfs.c,v 1.12 1998/09/11 21:22:53 pk 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.12 1998/09/11 21:22:53 pk 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 	(void)printf("Master Superblock:\n");
    169 	dump_super(lfs_master);
    170 
    171 	dump_ifile(fd, lfs_master, do_ientries);
    172 
    173 	if (seglist != NULL)
    174 		for (; seglist != NULL; seglist = seglist->next) {
    175 			seg_addr = lfs_master->lfs_sboffs[0] + seglist->num *
    176 			    (lfs_master->lfs_ssize << lfs_master->lfs_fsbtodb);
    177 			dump_segment(fd,
    178 			    seglist->num, seg_addr, lfs_master, do_allsb);
    179 		}
    180 	else
    181 		for (segnum = 0, seg_addr = lfs_master->lfs_sboffs[0];
    182 		    segnum < lfs_master->lfs_nseg; segnum++, seg_addr +=
    183 		    lfs_master->lfs_ssize << lfs_master->lfs_fsbtodb)
    184 			dump_segment(fd,
    185 			    segnum, seg_addr, lfs_master, do_allsb);
    186 
    187 	(void)close(fd);
    188 	exit(0);
    189 }
    190 
    191 /*
    192  * We are reading all the blocks of an inode and dumping out the ifile table.
    193  * This code could be tighter, but this is a first pass at getting the stuff
    194  * printed out rather than making this code incredibly efficient.
    195  */
    196 static void
    197 dump_ifile(fd, lfsp, do_ientries)
    198 	int fd;
    199 	struct lfs *lfsp;
    200 	int do_ientries;
    201 {
    202 	IFILE *ipage;
    203 	struct dinode *dip, *dpage;
    204 	daddr_t addr, *addrp, *dindir, *iaddrp, *indir;
    205 	int block_limit, i, inum, j, nblocks, psize;
    206 
    207 	psize = lfsp->lfs_bsize;
    208 	addr = lfsp->lfs_idaddr;
    209 
    210 	if (!(dpage = malloc(psize)))
    211 		err(1, "malloc");
    212 	get(fd, addr << daddr_shift, dpage, psize);
    213 
    214 	for (dip = dpage + INOPB(lfsp) - 1; dip >= dpage; --dip)
    215 		if (dip->di_inumber == LFS_IFILE_INUM)
    216 			break;
    217 
    218 	if (dip < dpage)
    219 		errx(1, "unable to locate ifile inode");
    220 
    221 	(void)printf("\nIFILE inode\n");
    222 	dump_dinode(dip);
    223 
    224 	(void)printf("\nIFILE contents\n");
    225 	nblocks = dip->di_size >> lfsp->lfs_bshift;
    226 	block_limit = MIN(nblocks, NDADDR);
    227 
    228 	/* Get the direct block */
    229 	if ((ipage = malloc(psize)) == NULL)
    230 		err(1, "malloc");
    231 	for (inum = 0, addrp = dip->di_db, i = 0; i < block_limit;
    232 	    i++, addrp++) {
    233 		get(fd, *addrp << daddr_shift, ipage, psize);
    234 		if (i < lfsp->lfs_cleansz) {
    235 			dump_cleaner_info(lfsp, ipage);
    236 			print_suheader;
    237 			continue;
    238 		}
    239 
    240 		if (i < (lfsp->lfs_segtabsz + lfsp->lfs_cleansz)) {
    241 			inum = dump_ipage_segusage(lfsp, inum, ipage,
    242 			    lfsp->lfs_sepb);
    243 			if (!inum) {
    244 				if(!do_ientries)
    245 					goto e0;
    246 				else
    247 					print_iheader;
    248 			}
    249 		} else
    250 			inum = dump_ipage_ifile(inum, ipage, lfsp->lfs_ifpb);
    251 
    252 	}
    253 
    254 	if (nblocks <= NDADDR)
    255 		goto e0;
    256 
    257 	/* Dump out blocks off of single indirect block */
    258 	if (!(indir = malloc(psize)))
    259 		err(1, "malloc");
    260 	get(fd, dip->di_ib[0] << daddr_shift, indir, psize);
    261 	block_limit = MIN(i + lfsp->lfs_nindir, nblocks);
    262 	for (addrp = indir; i < block_limit; i++, addrp++) {
    263 		if (*addrp == LFS_UNUSED_DADDR)
    264 			break;
    265 		get(fd, *addrp << daddr_shift,ipage, psize);
    266 		if (i < lfsp->lfs_cleansz) {
    267 			dump_cleaner_info(lfsp, ipage);
    268 			continue;
    269 		} else
    270 			i -= lfsp->lfs_cleansz;
    271 
    272 		if (i < lfsp->lfs_segtabsz) {
    273 			inum = dump_ipage_segusage(lfsp, inum, ipage,
    274 			    lfsp->lfs_sepb);
    275 			if (!inum) {
    276 				if(!do_ientries)
    277 					goto e1;
    278 				else
    279 					print_iheader;
    280 			}
    281 		} else
    282 			inum = dump_ipage_ifile(inum, ipage, lfsp->lfs_ifpb);
    283 	}
    284 
    285 	if (nblocks <= lfsp->lfs_nindir * lfsp->lfs_ifpb)
    286 		goto e1;
    287 
    288 	/* Get the double indirect block */
    289 	if (!(dindir = malloc(psize)))
    290 		err(1, "malloc");
    291 	get(fd, dip->di_ib[1] << daddr_shift, dindir, psize);
    292 	for (iaddrp = dindir, j = 0; j < lfsp->lfs_nindir; j++, iaddrp++) {
    293 		if (*iaddrp == LFS_UNUSED_DADDR)
    294 			break;
    295 		get(fd, *iaddrp << daddr_shift, indir, psize);
    296 		block_limit = MIN(i + lfsp->lfs_nindir, nblocks);
    297 		for (addrp = indir; i < block_limit; i++, addrp++) {
    298 			if (*addrp == LFS_UNUSED_DADDR)
    299 				break;
    300 			get(fd, *addrp << daddr_shift, ipage, psize);
    301 			if (i < lfsp->lfs_cleansz) {
    302 				dump_cleaner_info(lfsp, ipage);
    303 				continue;
    304 			} else
    305 				i -= lfsp->lfs_cleansz;
    306 
    307 			if (i < lfsp->lfs_segtabsz) {
    308 				inum = dump_ipage_segusage(lfsp,
    309 				    inum, ipage, lfsp->lfs_sepb);
    310 				if (!inum) {
    311 					if(!do_ientries)
    312 						goto e2;
    313 					else
    314 						print_iheader;
    315 				}
    316 			} else
    317 				inum = dump_ipage_ifile(inum,
    318 				    ipage, lfsp->lfs_ifpb);
    319 		}
    320 	}
    321 e2:	free(dindir);
    322 e1:	free(indir);
    323 e0:	free(dpage);
    324 	free(ipage);
    325 }
    326 
    327 static int
    328 dump_ipage_ifile(i, pp, tot)
    329 	int i;
    330 	IFILE *pp;
    331 	int tot;
    332 {
    333 	IFILE *ip;
    334 	int cnt, max;
    335 
    336 	max = i + tot;
    337 
    338 	for (ip = pp, cnt = i; cnt < max; cnt++, ip++)
    339 		print_ientry(cnt, ip);
    340 	return (max);
    341 }
    342 
    343 static int
    344 dump_ipage_segusage(lfsp, i, pp, tot)
    345 	struct lfs *lfsp;
    346 	int i;
    347 	IFILE *pp;
    348 	int tot;
    349 {
    350 	SEGUSE *sp;
    351 	int cnt, max;
    352 
    353 	max = i + tot;
    354 	for (sp = (SEGUSE *)pp, cnt = i;
    355 	     cnt < lfsp->lfs_nseg && cnt < max; cnt++, sp++)
    356 		print_suentry(cnt, sp);
    357 	if (max >= lfsp->lfs_nseg)
    358 		return (0);
    359 	else
    360 		return (max);
    361 }
    362 
    363 static void
    364 dump_dinode(dip)
    365 	struct dinode *dip;
    366 {
    367 	int i;
    368 	time_t at, mt, ct;
    369 
    370 	at = dip->di_atime;
    371 	mt = dip->di_mtime;
    372 	ct = dip->di_ctime;
    373 
    374 	(void)printf("%s%d\t%s%d\t%s%d\t%s%d\t%s%qu\n",
    375 		"mode  ", dip->di_mode,
    376 		"nlink ", dip->di_nlink,
    377 		"uid   ", dip->di_uid,
    378 		"gid   ", dip->di_gid,
    379 		"size  ", (long long)dip->di_size);
    380 	(void)printf("%s%s%s%s%s%s",
    381 		"atime ", ctime(&at),
    382 		"mtime ", ctime(&mt),
    383 		"ctime ", ctime(&ct));
    384 	(void)printf("inum  %d\n", dip->di_inumber);
    385 	(void)printf("Direct Addresses\n");
    386 	for (i = 0; i < NDADDR; i++) {
    387 		(void)printf("\t0x%X", dip->di_db[i]);
    388 		if ((i % 6) == 5)
    389 			(void)printf("\n");
    390 	}
    391 	for (i = 0; i < NIADDR; i++)
    392 		(void)printf("\t0x%X", dip->di_ib[i]);
    393 	(void)printf("\n");
    394 }
    395 
    396 static int
    397 dump_sum(fd, lfsp, sp, segnum, addr)
    398 	struct lfs *lfsp;
    399 	SEGSUM *sp;
    400 	int fd, segnum;
    401 	daddr_t addr;
    402 {
    403 	FINFO *fp;
    404 	daddr_t *dp;
    405 	int i, j;
    406 	int ck;
    407 	int numbytes;
    408 	struct dinode *inop;
    409 
    410 	if (sp->ss_magic != SS_MAGIC ||
    411 	    sp->ss_sumsum != (ck = cksum(&sp->ss_datasum,
    412 	    LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum)))) {
    413 		(void)printf("dumplfs: %s %d address 0x%x\n",
    414 		    "corrupt summary block; segment", segnum, addr);
    415 		return(0);
    416 	}
    417 
    418 	(void)printf("Segment Summary Info at 0x%x\n", addr);
    419 	(void)printf("    %s0x%X\t%s%d\t%s%d\n    %s0x%X\t%s0x%X",
    420 		"next     ", sp->ss_next,
    421 		"nfinfo   ", sp->ss_nfinfo,
    422 		"ninos    ", sp->ss_ninos,
    423 		"sumsum   ", sp->ss_sumsum,
    424 		"datasum  ", sp->ss_datasum );
    425 	(void)printf("\tcreate   %s", ctime((time_t *)&sp->ss_create));
    426 
    427 	/* Dump out inode disk addresses */
    428 	dp = (daddr_t *)sp;
    429 	dp += LFS_SUMMARY_SIZE / sizeof(daddr_t);
    430 	inop = malloc(1 << lfsp->lfs_bshift);
    431 	printf("    Inode addresses:");
    432 	numbytes = 0;
    433 	for (dp--, i = 0; i < sp->ss_ninos; dp--) {
    434 		numbytes += lfsp->lfs_bsize;	/* add bytes for inode block */
    435 		printf("\t0x%X {", *dp);
    436 		get(fd, *dp << (lfsp->lfs_bshift - lfsp->lfs_fsbtodb), inop,
    437 		    (1 << lfsp->lfs_bshift));
    438 		for (j = 0; i < sp->ss_ninos && j < INOPB(lfsp); j++, i++) {
    439 			if (j > 0)
    440 				(void)printf(", ");
    441 			(void)printf("%d", inop[j].di_inumber);
    442 		}
    443 		(void)printf("}");
    444 		if (((i/INOPB(lfsp)) % 4) == 3)
    445 			(void)printf("\n");
    446 	}
    447 	free(inop);
    448 
    449 	printf("\n");
    450 	for (fp = (FINFO *)(sp + 1), i = 0; i < sp->ss_nfinfo; i++) {
    451 		(void)printf("    FINFO for inode: %d version %d nblocks %d lastlength %d\n",
    452 		    fp->fi_ino, fp->fi_version, fp->fi_nblocks,
    453 		    fp->fi_lastlength);
    454 		dp = &(fp->fi_blocks[0]);
    455 		for (j = 0; j < fp->fi_nblocks; j++, dp++) {
    456 			(void)printf("\t%d", *dp);
    457 			if ((j % 8) == 7)
    458 				(void)printf("\n");
    459 			if (j == fp->fi_nblocks - 1)
    460 				numbytes += fp->fi_lastlength;
    461 			else
    462 				numbytes += lfsp->lfs_bsize;
    463 		}
    464 		if ((j % 8) != 0)
    465 			(void)printf("\n");
    466 		fp = (FINFO *)dp;
    467 	}
    468 	return (numbytes);
    469 }
    470 
    471 static void
    472 dump_segment(fd, segnum, addr, lfsp, dump_sb)
    473 	int fd, segnum;
    474 	daddr_t addr;
    475 	struct lfs *lfsp;
    476 	int dump_sb;
    477 {
    478 	struct lfs lfs_sb, *sbp;
    479 	SEGSUM *sump;
    480 	char sumblock[LFS_SUMMARY_SIZE];
    481 	int did_one, nbytes, sb;
    482 	off_t sum_offset, super_off = 0;
    483 
    484 	(void)printf("\nSEGMENT %d (Disk Address 0x%X)\n",
    485 	    addr >> (lfsp->lfs_segshift - daddr_shift), addr);
    486 	sum_offset = (addr << (lfsp->lfs_bshift - lfsp->lfs_fsbtodb));
    487 
    488 	sb = 0;
    489 	did_one = 0;
    490 	do {
    491 		get(fd, sum_offset, sumblock, LFS_SUMMARY_SIZE);
    492 		sump = (SEGSUM *)sumblock;
    493 		if (sump->ss_sumsum != cksum (&sump->ss_datasum,
    494 			LFS_SUMMARY_SIZE - sizeof(sump->ss_sumsum))) {
    495 			sbp = (struct lfs *)sump;
    496 			if ((sb = (sbp->lfs_magic == LFS_MAGIC))) {
    497 				super_off = sum_offset;
    498 				sum_offset += LFS_SBPAD;
    499 			} else if (did_one)
    500 				break;
    501 			else {
    502 				printf("Segment at 0x%X corrupt\n", addr);
    503 				break;
    504 			}
    505 		} else {
    506 			nbytes = dump_sum(fd, lfsp, sump, segnum, sum_offset >>
    507 			     (lfsp->lfs_bshift - lfsp->lfs_fsbtodb));
    508 			if (nbytes)
    509 				sum_offset += LFS_SUMMARY_SIZE + nbytes;
    510 			else
    511 				sum_offset = 0;
    512 			did_one = 1;
    513 		}
    514 	} while (sum_offset);
    515 
    516 	if (dump_sb && sb)  {
    517 		get(fd, super_off, &(lfs_sb.lfs_dlfs), sizeof(struct dlfs));
    518 		dump_super(&lfs_sb);
    519 	}
    520 	return;
    521 }
    522 
    523 static void
    524 dump_super(lfsp)
    525 	struct lfs *lfsp;
    526 {
    527 	int i;
    528 
    529 	(void)printf("%s0x%X\t%s0x%X\t%s%d\t%s%d\n",
    530 		"magic    ", lfsp->lfs_magic,
    531 		"version  ", lfsp->lfs_version,
    532 		"size     ", lfsp->lfs_size,
    533 		"ssize    ", lfsp->lfs_ssize);
    534 	(void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n",
    535 		"dsize    ", lfsp->lfs_dsize,
    536 		"bsize    ", lfsp->lfs_bsize,
    537 		"fsize    ", lfsp->lfs_fsize,
    538 		"frag     ", lfsp->lfs_frag);
    539 
    540 	(void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n",
    541 		"minfree  ", lfsp->lfs_minfree,
    542 		"inopb    ", lfsp->lfs_inopb,
    543 		"ifpb     ", lfsp->lfs_ifpb,
    544 		"nindir   ", lfsp->lfs_nindir);
    545 
    546 	(void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n",
    547 		"nseg     ", lfsp->lfs_nseg,
    548 		"nspf     ", lfsp->lfs_nspf,
    549 		"cleansz  ", lfsp->lfs_cleansz,
    550 		"segtabsz ", lfsp->lfs_segtabsz);
    551 
    552 	(void)printf("%s0x%X\t%s%d\t%s0x%qX\t%s%d\n",
    553 		"segmask  ", lfsp->lfs_segmask,
    554 		"segshift ", lfsp->lfs_segshift,
    555 		"bmask    ", (long long)lfsp->lfs_bmask,
    556 		"bshift   ", lfsp->lfs_bshift);
    557 
    558 	(void)printf("%s0x%qX\t\t%s%d\t%s0x%qX\t%s%u\n",
    559 		"ffmask   ", (long long)lfsp->lfs_ffmask,
    560 		"ffshift  ", lfsp->lfs_ffshift,
    561 		"fbmask   ", (long long)lfsp->lfs_fbmask,
    562 		"fbshift  ", lfsp->lfs_fbshift);
    563 
    564 	(void)printf("%s%d\t%s%d\t%s0x%X\t%s0x%qx\n",
    565 		"sushift  ", lfsp->lfs_sushift,
    566 		"fsbtodb  ", lfsp->lfs_fsbtodb,
    567 		"cksum    ", lfsp->lfs_cksum,
    568 		"maxfilesize  ", (long long)lfsp->lfs_maxfilesize);
    569 
    570 	(void)printf("Superblock disk addresses:\t");
    571 	for (i = 0; i < LFS_MAXNUMSB; i++) {
    572 		(void)printf(" 0x%X", lfsp->lfs_sboffs[i]);
    573 		if ( i == (LFS_MAXNUMSB >> 1))
    574 			(void)printf("\n\t\t\t\t");
    575 	}
    576 	(void)printf("\n");
    577 
    578 	(void)printf("Checkpoint Info\n");
    579 	(void)printf("%s%d\t%s0x%X\t%s%d\n",
    580 		"free     ", lfsp->lfs_free,
    581 		"idaddr   ", lfsp->lfs_idaddr,
    582 		"ifile    ", lfsp->lfs_ifile);
    583 	(void)printf("%s%d\t%s%d\t%s%d\n",
    584 		"bfree    ", lfsp->lfs_bfree,
    585 		"avail    ", lfsp->lfs_avail,
    586 		"uinodes  ", lfsp->lfs_uinodes);
    587 	(void)printf("%s%d\t%s0x%X\t%s0x%X\n%s0x%X\t%s0x%X\t",
    588 		"nfiles   ", lfsp->lfs_nfiles,
    589 		"lastseg  ", lfsp->lfs_lastseg,
    590 		"nextseg  ", lfsp->lfs_nextseg,
    591 		"curseg   ", lfsp->lfs_curseg,
    592 		"offset   ", lfsp->lfs_offset);
    593 	(void)printf("tstamp   %s", ctime((time_t *)&lfsp->lfs_tstamp));
    594 #if 0  /* This is no longer stored on disk! --ks */
    595 	(void)printf("\nIn-Memory Information\n");
    596 	(void)printf("%s%d\t%s0x%X\t%s%d%s%d\t%s%d\n",
    597 		"seglock  ", lfsp->lfs_seglock,
    598 		"iocount  ", lfsp->lfs_iocount,
    599 		"writer   ", lfsp->lfs_writer,
    600 		"dirops   ", lfsp->lfs_dirops,
    601 		"doifile  ", lfsp->lfs_doifile);
    602 	(void)printf("%s%d\t%s%d\t%s0x%X\t%s%d\n",
    603 		"nactive  ", lfsp->lfs_nactive,
    604 		"fmod     ", lfsp->lfs_fmod,
    605 		"clean    ", lfsp->lfs_clean,
    606 		"ronly    ", lfsp->lfs_ronly);
    607 #endif
    608 }
    609 
    610 static void
    611 addseg(arg)
    612 	char *arg;
    613 {
    614 	SEGLIST *p;
    615 
    616 	if ((p = malloc(sizeof(SEGLIST))) == NULL)
    617 		err(1, "malloc");
    618 	p->next = seglist;
    619 	p->num = atoi(arg);
    620 	seglist = p;
    621 }
    622 
    623 static void
    624 dump_cleaner_info(lfsp, ipage)
    625 	struct lfs *lfsp;
    626 	void *ipage;
    627 {
    628 	CLEANERINFO *cip;
    629 
    630 	cip = (CLEANERINFO *)ipage;
    631 	(void)printf("segments clean\t%d\tsegments dirty\t%d\n\n",
    632 	    cip->clean, cip->dirty);
    633 }
    634 
    635 static void
    636 usage()
    637 {
    638 	(void)fprintf(stderr, "usage: dumplfs [-ai] [-s segnum] file\n");
    639 	exit(1);
    640 }
    641