xref: /netbsd-src/sys/ufs/lfs/lfs_debug.c (revision ce0bb6e8d2e560ecacbe865a848624f94498063b)
1 /*	$NetBSD: lfs_debug.c,v 1.2 1994/06/29 06:46:54 cgd 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  *	@(#)lfs_debug.c	8.1 (Berkeley) 6/11/93
36  */
37 
38 #ifdef DEBUG
39 #include <sys/param.h>
40 #include <sys/namei.h>
41 #include <sys/vnode.h>
42 #include <sys/mount.h>
43 
44 #include <ufs/ufs/quota.h>
45 #include <ufs/ufs/inode.h>
46 #include <ufs/lfs/lfs.h>
47 #include <ufs/lfs/lfs_extern.h>
48 
49 void
50 lfs_dump_super(lfsp)
51 	struct lfs *lfsp;
52 {
53 	int i;
54 
55 	(void)printf("%s%lx\t%s%lx\t%s%d\t%s%d\n",
56 		"magic    ", lfsp->lfs_magic,
57 		"version  ", lfsp->lfs_version,
58 		"size     ", lfsp->lfs_size,
59 		"ssize    ", lfsp->lfs_ssize);
60 	(void)printf("%s%d\t%s%d\t%s%d\t%s%d\n",
61 		"dsize    ", lfsp->lfs_dsize,
62 		"bsize    ", lfsp->lfs_bsize,
63 		"fsize    ", lfsp->lfs_fsize,
64 		"frag     ", lfsp->lfs_frag);
65 
66 	(void)printf("%s%d\t%s%d\t%s%d\t%s%d\n",
67 		"minfree  ", lfsp->lfs_minfree,
68 		"inopb    ", lfsp->lfs_inopb,
69 		"ifpb     ", lfsp->lfs_ifpb,
70 		"nindir   ", lfsp->lfs_nindir);
71 
72 	(void)printf("%s%d\t%s%d\t%s%d\t%s%d\n",
73 		"nseg     ", lfsp->lfs_nseg,
74 		"nspf     ", lfsp->lfs_nspf,
75 		"cleansz  ", lfsp->lfs_cleansz,
76 		"segtabsz ", lfsp->lfs_segtabsz);
77 
78 	(void)printf("%s%lx\t%s%d\t%s%lx\t%s%d\n",
79 		"segmask  ", lfsp->lfs_segmask,
80 		"segshift ", lfsp->lfs_segshift,
81 		"bmask    ", lfsp->lfs_bmask,
82 		"bshift   ", lfsp->lfs_bshift);
83 
84 	(void)printf("%s%lx\t%s%d\t%s%lx\t%s%d\n",
85 		"ffmask   ", lfsp->lfs_ffmask,
86 		"ffshift  ", lfsp->lfs_ffshift,
87 		"fbmask   ", lfsp->lfs_fbmask,
88 		"fbshift  ", lfsp->lfs_fbshift);
89 
90 	(void)printf("%s%d\t%s%d\t%s%lx\t%s%qx\n",
91 		"sushift  ", lfsp->lfs_sushift,
92 		"fsbtodb  ", lfsp->lfs_fsbtodb,
93 		"cksum    ", lfsp->lfs_cksum,
94 		"maxfilesize ", lfsp->lfs_maxfilesize);
95 
96 	(void)printf("Superblock disk addresses:");
97 	for (i = 0; i < LFS_MAXNUMSB; i++)
98 		(void)printf(" %lx", lfsp->lfs_sboffs[i]);
99 	(void)printf("\n");
100 
101 	(void)printf("Checkpoint Info\n");
102 	(void)printf("%s%d\t%s%lx\t%s%d\n",
103 		"free     ", lfsp->lfs_free,
104 		"idaddr   ", lfsp->lfs_idaddr,
105 		"ifile    ", lfsp->lfs_ifile);
106 	(void)printf("%s%lx\t%s%d\t%s%lx\t%s%lx\t%s%lx\t%s%lx\n",
107 		"bfree    ", lfsp->lfs_bfree,
108 		"nfiles   ", lfsp->lfs_nfiles,
109 		"lastseg  ", lfsp->lfs_lastseg,
110 		"nextseg  ", lfsp->lfs_nextseg,
111 		"curseg   ", lfsp->lfs_curseg,
112 		"offset   ", lfsp->lfs_offset);
113 	(void)printf("tstamp   %lx\n", lfsp->lfs_tstamp);
114 }
115 
116 void
117 lfs_dump_dinode(dip)
118 	struct dinode *dip;
119 {
120 	int i;
121 
122 	(void)printf("%s%u\t%s%d\t%s%u\t%s%u\t%s%lu\n",
123 		"mode  ", dip->di_mode,
124 		"nlink ", dip->di_nlink,
125 		"uid   ", dip->di_uid,
126 		"gid   ", dip->di_gid,
127 		"size  ", dip->di_size);
128 	(void)printf("inum  %ld\n", dip->di_inumber);
129 	(void)printf("Direct Addresses\n");
130 	for (i = 0; i < NDADDR; i++) {
131 		(void)printf("\t%lx", dip->di_db[i]);
132 		if ((i % 6) == 5)
133 			(void)printf("\n");
134 	}
135 	for (i = 0; i < NIADDR; i++)
136 		(void)printf("\t%lx", dip->di_ib[i]);
137 	(void)printf("\n");
138 }
139 #endif /* DEBUG */
140