ffsinfo.c revision 166725
1/*
2 * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
3 * Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Christoph Herrmann and Thomas-Henning von Kamptz, Munich and Frankfurt.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 *    must display the following acknowledgment:
19 *      This product includes software developed by the University of
20 *      California, Berkeley and its contributors, as well as Christoph
21 *      Herrmann and Thomas-Henning von Kamptz.
22 * 4. Neither the name of the University nor the names of its contributors
23 *    may be used to endorse or promote products derived from this software
24 *    without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * $TSHeader: src/sbin/ffsinfo/ffsinfo.c,v 1.4 2000/12/12 19:30:55 tomsoft Exp $
39 *
40 */
41
42#ifndef lint
43static const char copyright[] =
44"@(#) Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz\n\
45Copyright (c) 1980, 1989, 1993 The Regents of the University of California.\n\
46All rights reserved.\n";
47#endif /* not lint */
48
49#ifndef lint
50static const char rcsid[] =
51  "$FreeBSD: head/sbin/ffsinfo/ffsinfo.c 166725 2007-02-14 23:20:30Z brian $";
52#endif /* not lint */
53
54/* ********************************************************** INCLUDES ***** */
55#include <sys/param.h>
56#include <sys/disklabel.h>
57#include <sys/mount.h>
58#include <sys/stat.h>
59
60#include <ufs/ufs/ufsmount.h>
61#include <ufs/ufs/dinode.h>
62#include <ufs/ffs/fs.h>
63
64#include <ctype.h>
65#include <err.h>
66#include <errno.h>
67#include <fcntl.h>
68#include <libufs.h>
69#include <paths.h>
70#include <stdio.h>
71#include <stdlib.h>
72#include <string.h>
73#include <unistd.h>
74
75#include "debug.h"
76
77/* *********************************************************** GLOBALS ***** */
78#ifdef FS_DEBUG
79int	_dbg_lvl_ = (DL_INFO); /* DL_TRC */
80#endif /* FS_DEBUG */
81
82struct uufsd disk;
83
84#define sblock disk.d_fs
85#define acg    disk.d_cg
86
87static union {
88	struct fs fs;
89	char pad[SBLOCKSIZE];
90} fsun;
91
92#define osblock fsun.fs
93
94static char	i1blk[MAXBSIZE];
95static char	i2blk[MAXBSIZE];
96static char	i3blk[MAXBSIZE];
97
98static struct csum	*fscs;
99
100/* ******************************************************** PROTOTYPES ***** */
101static void	usage(void);
102static void	dump_whole_ufs1_inode(ino_t, int);
103static void	dump_whole_ufs2_inode(ino_t, int);
104
105#define DUMP_WHOLE_INODE(A,B) \
106	( disk.d_ufs == 1 \
107		? dump_whole_ufs1_inode((A),(B)) : dump_whole_ufs2_inode((A),(B)) )
108
109/* ************************************************************** main ***** */
110/*
111 * ffsinfo(8) is a tool to dump all metadata of a file system. It helps to find
112 * errors is the file system much easier. You can run ffsinfo before and  after
113 * an  fsck(8),  and compare the two ascii dumps easy with diff, and  you  see
114 * directly where the problem is. You can control how much detail you want  to
115 * see  with some command line arguments. You can also easy check  the  status
116 * of  a file system, like is there is enough space for growing  a  file system,
117 * or  how  many active snapshots do we have. It provides much  more  detailed
118 * information  then dumpfs. Snapshots, as they are very new, are  not  really
119 * supported.  They  are just mentioned currently, but it is  planned  to  run
120 * also over active snapshots, to even get that output.
121 */
122int
123main(int argc, char **argv)
124{
125	DBG_FUNC("main")
126	char	*device, *special;
127	int	ch;
128	size_t	len;
129	struct stat	st;
130	struct csum	*dbg_csp;
131	int	dbg_csc;
132	char	dbg_line[80];
133	int	cylno,i;
134	int	cfg_cg, cfg_in, cfg_lv;
135	int	cg_start, cg_stop;
136	ino_t	in;
137	char	*out_file;
138
139	DBG_ENTER;
140
141	cfg_lv = 0xff;
142	cfg_in = -2;
143	cfg_cg = -2;
144	out_file = NULL;
145
146	while ((ch = getopt(argc, argv, "g:i:l:o:")) != -1) {
147		switch (ch) {
148		case 'g':
149			cfg_cg = strtol(optarg, NULL, 0);
150			if (errno == EINVAL || errno == ERANGE)
151				err(1, "%s", optarg);
152			if (cfg_cg < -1)
153				usage();
154			break;
155		case 'i':
156			cfg_in = strtol(optarg, NULL, 0);
157			if (errno == EINVAL || errno == ERANGE)
158				err(1, "%s", optarg);
159			if (cfg_in < 0)
160				usage();
161			break;
162		case 'l':
163			cfg_lv = strtol(optarg, NULL, 0);
164			if (errno == EINVAL||errno == ERANGE)
165				err(1, "%s", optarg);
166			if (cfg_lv < 0x1 || cfg_lv > 0x3ff)
167				usage();
168			break;
169		case 'o':
170			free(out_file);
171			out_file = strdup(optarg);
172			if (out_file == NULL)
173				errx(1, "strdup failed");
174			break;
175		case '?':
176			/* FALLTHROUGH */
177		default:
178			usage();
179		}
180	}
181	argc -= optind;
182	argv += optind;
183
184	if (argc != 1)
185		usage();
186	device = *argv;
187	if (out_file == NULL)
188		errx(1, "out_file not specified");
189
190	/*
191	 * Now we try to guess the (raw)device name.
192	 */
193	if (0 == strrchr(device, '/') && stat(device, &st) == -1) {
194		/*-
195		 * No path prefix was given, so try in this order:
196		 *     /dev/r%s
197		 *     /dev/%s
198		 *     /dev/vinum/r%s
199		 *     /dev/vinum/%s.
200		 *
201		 * FreeBSD now doesn't distinguish between raw and  block
202		 * devices any longer, but it should still work this way.
203		 */
204		len = strlen(device) + strlen(_PATH_DEV) + 2 + strlen("vinum/");
205		special = (char *)malloc(len);
206		if (special == NULL)
207			errx(1, "malloc failed");
208		snprintf(special, len, "%sr%s", _PATH_DEV, device);
209		if (stat(special, &st) == -1) {
210			snprintf(special, len, "%s%s", _PATH_DEV, device);
211			if (stat(special, &st) == -1) {
212				snprintf(special, len, "%svinum/r%s",
213				    _PATH_DEV, device);
214				if (stat(special, &st) == -1)
215					/* For now this is the 'last resort' */
216					snprintf(special, len, "%svinum/%s",
217					    _PATH_DEV, device);
218			}
219		}
220		device = special;
221	}
222
223	if (ufs_disk_fillout(&disk, device) == -1)
224		err(1, "ufs_disk_fillout(%s) failed: %s", device, disk.d_error);
225
226	DBG_OPEN(out_file);	/* already here we need a superblock */
227
228	if (cfg_lv & 0x001)
229		DBG_DUMP_FS(&sblock, "primary sblock");
230
231	/* Determine here what cylinder groups to dump */
232	if (cfg_cg==-2) {
233		cg_start = 0;
234		cg_stop = sblock.fs_ncg;
235	} else if (cfg_cg == -1) {
236		cg_start = sblock.fs_ncg - 1;
237		cg_stop = sblock.fs_ncg;
238	} else if (cfg_cg < sblock.fs_ncg) {
239		cg_start = cfg_cg;
240		cg_stop = cfg_cg + 1;
241	} else {
242		cg_start = sblock.fs_ncg;
243		cg_stop = sblock.fs_ncg;
244	}
245
246	if (cfg_lv & 0x004) {
247		fscs = (struct csum *)calloc((size_t)1,
248		    (size_t)sblock.fs_cssize);
249		if (fscs == NULL)
250			errx(1, "calloc failed");
251
252		/* get the cylinder summary into the memory ... */
253		for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize) {
254			if (bread(&disk, fsbtodb(&sblock,
255			    sblock.fs_csaddr + numfrags(&sblock, i)),
256			    (void *)(((char *)fscs)+i),
257			    (size_t)(sblock.fs_cssize-i < sblock.fs_bsize ?
258			    sblock.fs_cssize - i : sblock.fs_bsize)) == -1)
259				err(1, "bread: %s", disk.d_error);
260		}
261
262		dbg_csp = fscs;
263		/* ... and dump it */
264		for(dbg_csc=0; dbg_csc<sblock.fs_ncg; dbg_csc++) {
265			snprintf(dbg_line, sizeof(dbg_line),
266			    "%d. csum in fscs", dbg_csc);
267			DBG_DUMP_CSUM(&sblock,
268			    dbg_line,
269			    dbg_csp++);
270		}
271	}
272
273	if (cfg_lv & 0xf8) {
274		/* for each requested cylinder group ... */
275		for (cylno = cg_start; cylno < cg_stop; cylno++) {
276			snprintf(dbg_line, sizeof(dbg_line), "cgr %d", cylno);
277			if (cfg_lv & 0x002) {
278				/* dump the superblock copies */
279				if (bread(&disk, fsbtodb(&sblock,
280				    cgsblock(&sblock, cylno)),
281				    (void *)&osblock, SBLOCKSIZE) == -1)
282					err(1, "bread: %s", disk.d_error);
283				DBG_DUMP_FS(&osblock, dbg_line);
284			}
285
286			/*
287			 * Read the cylinder group and dump whatever was
288			 * requested.
289			 */
290			if (bread(&disk, fsbtodb(&sblock,
291			    cgtod(&sblock, cylno)), (void *)&acg,
292			    (size_t)sblock.fs_cgsize) == -1)
293				err(1, "bread: %s", disk.d_error);
294
295			if (cfg_lv & 0x008)
296				DBG_DUMP_CG(&sblock, dbg_line, &acg);
297			if (cfg_lv & 0x010)
298				DBG_DUMP_INMAP(&sblock, dbg_line, &acg);
299			if (cfg_lv & 0x020)
300				DBG_DUMP_FRMAP(&sblock, dbg_line, &acg);
301			if (cfg_lv & 0x040) {
302				DBG_DUMP_CLMAP(&sblock, dbg_line, &acg);
303				DBG_DUMP_CLSUM(&sblock, dbg_line, &acg);
304			}
305	#ifdef NOT_CURRENTLY
306			/*
307			 * See the comment in sbin/growfs/debug.c for why this
308			 * is currently disabled, and what needs to be done to
309			 * re-enable it.
310			 */
311			if (disk.d_ufs == 1 && cfg_lv & 0x080)
312				DBG_DUMP_SPTBL(&sblock, dbg_line, &acg);
313	#endif
314		}
315	}
316
317	if (cfg_lv & 0x300) {
318		/* Dump the requested inode(s) */
319		if (cfg_in != -2)
320			DUMP_WHOLE_INODE((ino_t)cfg_in, cfg_lv);
321		else {
322			for (in = cg_start * sblock.fs_ipg;
323			    in < (ino_t)cg_stop * sblock.fs_ipg;
324			    in++)
325				DUMP_WHOLE_INODE(in, cfg_lv);
326		}
327	}
328
329	DBG_CLOSE;
330	DBG_LEAVE;
331
332	return 0;
333}
334
335/* ********************************************** dump_whole_ufs1_inode ***** */
336/*
337 * Here we dump a list of all blocks allocated by this inode. We follow
338 * all indirect blocks.
339 */
340void
341dump_whole_ufs1_inode(ino_t inode, int level)
342{
343	DBG_FUNC("dump_whole_ufs1_inode")
344	struct ufs1_dinode	*ino;
345	int	rb, mode;
346	unsigned int	ind2ctr, ind3ctr;
347	ufs1_daddr_t	*ind2ptr, *ind3ptr;
348	char	comment[80];
349
350	DBG_ENTER;
351
352	/*
353	 * Read the inode from disk/cache.
354	 */
355	if (getino(&disk, (void **)&ino, inode, &mode) == -1)
356		err(1, "getino: %s", disk.d_error);
357
358	if(ino->di_nlink==0) {
359		DBG_LEAVE;
360		return;	/* inode not in use */
361	}
362
363	/*
364	 * Dump the main inode structure.
365	 */
366	snprintf(comment, sizeof(comment), "Inode 0x%08x", inode);
367	if (level & 0x100) {
368		DBG_DUMP_INO(&sblock,
369		    comment,
370		    ino);
371	}
372
373	if (!(level & 0x200)) {
374		DBG_LEAVE;
375		return;
376	}
377
378	/*
379	 * Ok, now prepare for dumping all direct and indirect pointers.
380	 */
381	rb=howmany(ino->di_size, sblock.fs_bsize)-NDADDR;
382	if(rb>0) {
383		/*
384		 * Dump single indirect block.
385		 */
386		if (bread(&disk, fsbtodb(&sblock, ino->di_ib[0]), (void *)&i1blk,
387			(size_t)sblock.fs_bsize) == -1) {
388			err(1, "bread: %s", disk.d_error);
389		}
390		snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 0",
391		    inode);
392		DBG_DUMP_IBLK(&sblock,
393		    comment,
394		    i1blk,
395		    (size_t)rb);
396		rb-=howmany(sblock.fs_bsize, sizeof(ufs1_daddr_t));
397	}
398	if(rb>0) {
399		/*
400		 * Dump double indirect blocks.
401		 */
402		if (bread(&disk, fsbtodb(&sblock, ino->di_ib[1]), (void *)&i2blk,
403			(size_t)sblock.fs_bsize) == -1) {
404			err(1, "bread: %s", disk.d_error);
405		}
406		snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 1",
407		    inode);
408		DBG_DUMP_IBLK(&sblock,
409		    comment,
410		    i2blk,
411		    howmany(rb, howmany(sblock.fs_bsize, sizeof(ufs1_daddr_t))));
412		for(ind2ctr=0; ((ind2ctr < howmany(sblock.fs_bsize,
413			sizeof(ufs1_daddr_t))) && (rb>0)); ind2ctr++) {
414			ind2ptr=&((ufs1_daddr_t *)(void *)&i2blk)[ind2ctr];
415
416			if (bread(&disk, fsbtodb(&sblock, *ind2ptr), (void *)&i1blk,
417				(size_t)sblock.fs_bsize) == -1) {
418				err(1, "bread: %s", disk.d_error);
419			}
420			snprintf(comment, sizeof(comment),
421			    "Inode 0x%08x: indirect 1->%d", inode, ind2ctr);
422			DBG_DUMP_IBLK(&sblock,
423			    comment,
424			    i1blk,
425			    (size_t)rb);
426			rb-=howmany(sblock.fs_bsize, sizeof(ufs1_daddr_t));
427		}
428	}
429	if(rb>0) {
430		/*
431		 * Dump triple indirect blocks.
432		 */
433		if (bread(&disk, fsbtodb(&sblock, ino->di_ib[2]), (void *)&i3blk,
434			(size_t)sblock.fs_bsize) == -1) {
435			err(1, "bread: %s", disk.d_error);
436		}
437		snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 2",
438		    inode);
439#define SQUARE(a) ((a)*(a))
440		DBG_DUMP_IBLK(&sblock,
441		    comment,
442		    i3blk,
443		    howmany(rb,
444		      SQUARE(howmany(sblock.fs_bsize, sizeof(ufs1_daddr_t)))));
445#undef SQUARE
446		for(ind3ctr=0; ((ind3ctr<howmany(sblock.fs_bsize,
447			sizeof(ufs1_daddr_t)))&&(rb>0)); ind3ctr++) {
448			ind3ptr=&((ufs1_daddr_t *)(void *)&i3blk)[ind3ctr];
449
450			if (bread(&disk, fsbtodb(&sblock, *ind3ptr), (void *)&i2blk,
451				(size_t)sblock.fs_bsize) == -1) {
452				err(1, "bread: %s", disk.d_error);
453			}
454			snprintf(comment, sizeof(comment),
455			    "Inode 0x%08x: indirect 2->%d", inode, ind3ctr);
456			DBG_DUMP_IBLK(&sblock,
457			    comment,
458			    i2blk,
459			    howmany(rb,
460			      howmany(sblock.fs_bsize, sizeof(ufs1_daddr_t))));
461			for(ind2ctr=0; ((ind2ctr < howmany(sblock.fs_bsize,
462			    sizeof(ufs1_daddr_t)))&&(rb>0)); ind2ctr++) {
463				ind2ptr=&((ufs1_daddr_t *)(void *)&i2blk)
464				    [ind2ctr];
465				if (bread(&disk, fsbtodb(&sblock, *ind2ptr),
466				    (void *)&i1blk, (size_t)sblock.fs_bsize)
467				    == -1) {
468					err(1, "bread: %s", disk.d_error);
469				}
470				snprintf(comment, sizeof(comment),
471				    "Inode 0x%08x: indirect 2->%d->%d", inode,
472				    ind3ctr, ind3ctr);
473				DBG_DUMP_IBLK(&sblock,
474				    comment,
475				    i1blk,
476				    (size_t)rb);
477				rb-=howmany(sblock.fs_bsize,
478				    sizeof(ufs1_daddr_t));
479			}
480		}
481	}
482
483	DBG_LEAVE;
484	return;
485}
486
487/* ********************************************** dump_whole_ufs2_inode ***** */
488/*
489 * Here we dump a list of all blocks allocated by this inode. We follow
490 * all indirect blocks.
491 */
492void
493dump_whole_ufs2_inode(ino_t inode, int level)
494{
495	DBG_FUNC("dump_whole_ufs2_inode")
496	struct ufs2_dinode	*ino;
497	int	rb, mode;
498	unsigned int	ind2ctr, ind3ctr;
499	ufs2_daddr_t	*ind2ptr, *ind3ptr;
500	char	comment[80];
501
502	DBG_ENTER;
503
504	/*
505	 * Read the inode from disk/cache.
506	 */
507	if (getino(&disk, (void **)&ino, inode, &mode) == -1)
508		err(1, "getino: %s", disk.d_error);
509
510	if (ino->di_nlink == 0) {
511		DBG_LEAVE;
512		return;	/* inode not in use */
513	}
514
515	/*
516	 * Dump the main inode structure.
517	 */
518	snprintf(comment, sizeof(comment), "Inode 0x%08x", inode);
519	if (level & 0x100) {
520		DBG_DUMP_INO(&sblock, comment, ino);
521	}
522
523	if (!(level & 0x200)) {
524		DBG_LEAVE;
525		return;
526	}
527
528	/*
529	 * Ok, now prepare for dumping all direct and indirect pointers.
530	 */
531	rb = howmany(ino->di_size, sblock.fs_bsize) - NDADDR;
532	if (rb > 0) {
533		/*
534		 * Dump single indirect block.
535		 */
536		if (bread(&disk, fsbtodb(&sblock, ino->di_ib[0]), (void *)&i1blk,
537			(size_t)sblock.fs_bsize) == -1) {
538			err(1, "bread: %s", disk.d_error);
539		}
540		snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 0", inode);
541		DBG_DUMP_IBLK(&sblock, comment, i1blk, (size_t)rb);
542		rb -= howmany(sblock.fs_bsize, sizeof(ufs2_daddr_t));
543	}
544	if (rb > 0) {
545		/*
546		 * Dump double indirect blocks.
547		 */
548		if (bread(&disk, fsbtodb(&sblock, ino->di_ib[1]), (void *)&i2blk,
549			(size_t)sblock.fs_bsize) == -1) {
550			err(1, "bread: %s", disk.d_error);
551		}
552		snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 1", inode);
553		DBG_DUMP_IBLK(&sblock,
554			comment,
555			i2blk,
556			howmany(rb, howmany(sblock.fs_bsize, sizeof(ufs2_daddr_t))));
557		for (ind2ctr = 0; ((ind2ctr < howmany(sblock.fs_bsize,
558			sizeof(ufs2_daddr_t))) && (rb>0)); ind2ctr++) {
559			ind2ptr = &((ufs2_daddr_t *)(void *)&i2blk)[ind2ctr];
560
561			if (bread(&disk, fsbtodb(&sblock, *ind2ptr), (void *)&i1blk,
562				(size_t)sblock.fs_bsize) == -1) {
563				err(1, "bread: %s", disk.d_error);
564			}
565			snprintf(comment, sizeof(comment),
566				"Inode 0x%08x: indirect 1->%d", inode, ind2ctr);
567			DBG_DUMP_IBLK(&sblock, comment, i1blk, (size_t)rb);
568			rb -= howmany(sblock.fs_bsize, sizeof(ufs2_daddr_t));
569		}
570	}
571	if (rb > 0) {
572		/*
573		 * Dump triple indirect blocks.
574		 */
575		if (bread(&disk, fsbtodb(&sblock, ino->di_ib[2]), (void *)&i3blk,
576			(size_t)sblock.fs_bsize) == -1) {
577			err(1, "bread: %s", disk.d_error);
578		}
579		snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 2", inode);
580#define SQUARE(a) ((a)*(a))
581		DBG_DUMP_IBLK(&sblock,
582			comment,
583			i3blk,
584			howmany(rb,
585				SQUARE(howmany(sblock.fs_bsize, sizeof(ufs2_daddr_t)))));
586#undef SQUARE
587		for (ind3ctr = 0; ((ind3ctr < howmany(sblock.fs_bsize,
588			sizeof(ufs2_daddr_t))) && (rb > 0)); ind3ctr++) {
589			ind3ptr = &((ufs2_daddr_t *)(void *)&i3blk)[ind3ctr];
590
591			if (bread(&disk, fsbtodb(&sblock, *ind3ptr), (void *)&i2blk,
592				(size_t)sblock.fs_bsize) == -1) {
593				err(1, "bread: %s", disk.d_error);
594			}
595			snprintf(comment, sizeof(comment),
596				"Inode 0x%08x: indirect 2->%d", inode, ind3ctr);
597			DBG_DUMP_IBLK(&sblock,
598				comment,
599				i2blk,
600				howmany(rb,
601					howmany(sblock.fs_bsize, sizeof(ufs2_daddr_t))));
602			for (ind2ctr = 0; ((ind2ctr < howmany(sblock.fs_bsize,
603				sizeof(ufs2_daddr_t))) && (rb > 0)); ind2ctr++) {
604				ind2ptr = &((ufs2_daddr_t *)(void *)&i2blk) [ind2ctr];
605				if (bread(&disk, fsbtodb(&sblock, *ind2ptr), (void *)&i1blk,
606					(size_t)sblock.fs_bsize) == -1) {
607					err(1, "bread: %s", disk.d_error);
608				}
609				snprintf(comment, sizeof(comment),
610					"Inode 0x%08x: indirect 2->%d->%d", inode,
611					ind3ctr, ind3ctr);
612				DBG_DUMP_IBLK(&sblock, comment, i1blk, (size_t)rb);
613				rb -= howmany(sblock.fs_bsize, sizeof(ufs2_daddr_t));
614			}
615		}
616	}
617
618	DBG_LEAVE;
619	return;
620}
621
622/* ************************************************************* usage ***** */
623/*
624 * Dump a line of usage.
625 */
626void
627usage(void)
628{
629	DBG_FUNC("usage")
630
631	DBG_ENTER;
632
633	fprintf(stderr,
634	    "usage: ffsinfo [-g cylinder_group] [-i inode] [-l level] "
635	    "[-o outfile]\n"
636	    "               special | file\n");
637
638	DBG_LEAVE;
639	exit(1);
640}
641