1*0a6a1f1dSLionel Sambuc /* $NetBSD: lfs_debug.c,v 1.54 2015/09/01 06:12:04 dholland Exp $ */
2d65f6f70SBen Gras
3d65f6f70SBen Gras /*-
4d65f6f70SBen Gras * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
5d65f6f70SBen Gras * All rights reserved.
6d65f6f70SBen Gras *
7d65f6f70SBen Gras * This code is derived from software contributed to The NetBSD Foundation
8d65f6f70SBen Gras * by Konrad E. Schroder <perseant@hhhh.org>.
9d65f6f70SBen Gras *
10d65f6f70SBen Gras * Redistribution and use in source and binary forms, with or without
11d65f6f70SBen Gras * modification, are permitted provided that the following conditions
12d65f6f70SBen Gras * are met:
13d65f6f70SBen Gras * 1. Redistributions of source code must retain the above copyright
14d65f6f70SBen Gras * notice, this list of conditions and the following disclaimer.
15d65f6f70SBen Gras * 2. Redistributions in binary form must reproduce the above copyright
16d65f6f70SBen Gras * notice, this list of conditions and the following disclaimer in the
17d65f6f70SBen Gras * documentation and/or other materials provided with the distribution.
18d65f6f70SBen Gras *
19d65f6f70SBen Gras * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20d65f6f70SBen Gras * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21d65f6f70SBen Gras * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22d65f6f70SBen Gras * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23d65f6f70SBen Gras * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24d65f6f70SBen Gras * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25d65f6f70SBen Gras * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26d65f6f70SBen Gras * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27d65f6f70SBen Gras * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28d65f6f70SBen Gras * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29d65f6f70SBen Gras * POSSIBILITY OF SUCH DAMAGE.
30d65f6f70SBen Gras */
31d65f6f70SBen Gras /*
32d65f6f70SBen Gras * Copyright (c) 1991, 1993
33d65f6f70SBen Gras * The Regents of the University of California. All rights reserved.
34d65f6f70SBen Gras *
35d65f6f70SBen Gras * Redistribution and use in source and binary forms, with or without
36d65f6f70SBen Gras * modification, are permitted provided that the following conditions
37d65f6f70SBen Gras * are met:
38d65f6f70SBen Gras * 1. Redistributions of source code must retain the above copyright
39d65f6f70SBen Gras * notice, this list of conditions and the following disclaimer.
40d65f6f70SBen Gras * 2. Redistributions in binary form must reproduce the above copyright
41d65f6f70SBen Gras * notice, this list of conditions and the following disclaimer in the
42d65f6f70SBen Gras * documentation and/or other materials provided with the distribution.
43d65f6f70SBen Gras * 3. Neither the name of the University nor the names of its contributors
44d65f6f70SBen Gras * may be used to endorse or promote products derived from this software
45d65f6f70SBen Gras * without specific prior written permission.
46d65f6f70SBen Gras *
47d65f6f70SBen Gras * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48d65f6f70SBen Gras * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49d65f6f70SBen Gras * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50d65f6f70SBen Gras * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51d65f6f70SBen Gras * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52d65f6f70SBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53d65f6f70SBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54d65f6f70SBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55d65f6f70SBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56d65f6f70SBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57d65f6f70SBen Gras * SUCH DAMAGE.
58d65f6f70SBen Gras *
59d65f6f70SBen Gras * @(#)lfs_debug.c 8.1 (Berkeley) 6/11/93
60d65f6f70SBen Gras */
61d65f6f70SBen Gras
62d65f6f70SBen Gras #include <sys/cdefs.h>
63*0a6a1f1dSLionel Sambuc __KERNEL_RCSID(0, "$NetBSD: lfs_debug.c,v 1.54 2015/09/01 06:12:04 dholland Exp $");
64d65f6f70SBen Gras
65d65f6f70SBen Gras #ifdef DEBUG
66d65f6f70SBen Gras
67d65f6f70SBen Gras #include <sys/param.h>
68d65f6f70SBen Gras #include <sys/systm.h>
69d65f6f70SBen Gras #include <sys/namei.h>
70d65f6f70SBen Gras #include <sys/vnode.h>
71d65f6f70SBen Gras #include <sys/mount.h>
72d65f6f70SBen Gras #include <sys/buf.h>
73d65f6f70SBen Gras #include <sys/syslog.h>
74d65f6f70SBen Gras #include <sys/proc.h>
75d65f6f70SBen Gras
7684d9c625SLionel Sambuc #include <ufs/lfs/ulfs_inode.h>
77d65f6f70SBen Gras #include <ufs/lfs/lfs.h>
78*0a6a1f1dSLionel Sambuc #include <ufs/lfs/lfs_accessors.h>
79d65f6f70SBen Gras #include <ufs/lfs/lfs_extern.h>
80d65f6f70SBen Gras
81d65f6f70SBen Gras int lfs_lognum;
82d65f6f70SBen Gras struct lfs_log_entry lfs_log[LFS_LOGLENGTH];
83d65f6f70SBen Gras
84d65f6f70SBen Gras int
lfs_bwrite_log(struct buf * bp,const char * file,int line)85d65f6f70SBen Gras lfs_bwrite_log(struct buf *bp, const char *file, int line)
86d65f6f70SBen Gras {
87d65f6f70SBen Gras struct vop_bwrite_args a;
88d65f6f70SBen Gras
89d65f6f70SBen Gras a.a_desc = VDESC(vop_bwrite);
90d65f6f70SBen Gras a.a_bp = bp;
91d65f6f70SBen Gras
92d65f6f70SBen Gras if (!(bp->b_flags & B_GATHERED) && !(bp->b_oflags & BO_DELWRI)) {
93d65f6f70SBen Gras LFS_ENTER_LOG("write", file, line, bp->b_lblkno, bp->b_flags,
94d65f6f70SBen Gras curproc->p_pid);
95d65f6f70SBen Gras }
96d65f6f70SBen Gras return (VCALL(bp->b_vp, VOFFSET(vop_bwrite), &a));
97d65f6f70SBen Gras }
98d65f6f70SBen Gras
99d65f6f70SBen Gras void
lfs_dumplog(void)100d65f6f70SBen Gras lfs_dumplog(void)
101d65f6f70SBen Gras {
102d65f6f70SBen Gras int i;
103d65f6f70SBen Gras const char *cp;
104d65f6f70SBen Gras
105d65f6f70SBen Gras for (i = lfs_lognum; i != (lfs_lognum - 1) % LFS_LOGLENGTH;
106d65f6f70SBen Gras i = (i + 1) % LFS_LOGLENGTH)
107d65f6f70SBen Gras if (lfs_log[i].file) {
108d65f6f70SBen Gras /* Only print out basename, for readability */
109d65f6f70SBen Gras cp = lfs_log[i].file;
110d65f6f70SBen Gras while(*cp)
111d65f6f70SBen Gras ++cp;
112d65f6f70SBen Gras while(*cp != '/' && cp > lfs_log[i].file)
113d65f6f70SBen Gras --cp;
114d65f6f70SBen Gras
115d65f6f70SBen Gras printf("lbn %" PRId64 " %s %lx %d, %d %s\n",
116d65f6f70SBen Gras lfs_log[i].block,
117d65f6f70SBen Gras lfs_log[i].op,
118d65f6f70SBen Gras lfs_log[i].flags,
119d65f6f70SBen Gras lfs_log[i].pid,
120d65f6f70SBen Gras lfs_log[i].line,
121d65f6f70SBen Gras cp);
122d65f6f70SBen Gras }
123d65f6f70SBen Gras }
124d65f6f70SBen Gras
125d65f6f70SBen Gras void
lfs_dump_super(struct lfs * lfsp)126d65f6f70SBen Gras lfs_dump_super(struct lfs *lfsp)
127d65f6f70SBen Gras {
128d65f6f70SBen Gras int i;
129d65f6f70SBen Gras
130*0a6a1f1dSLionel Sambuc printf("%s%x\t%s%x\t%s%ju\t%s%d\n",
131*0a6a1f1dSLionel Sambuc "magic ", lfsp->lfs_is64 ?
132*0a6a1f1dSLionel Sambuc lfsp->lfs_dlfs_u.u_64.dlfs_magic :
133*0a6a1f1dSLionel Sambuc lfsp->lfs_dlfs_u.u_32.dlfs_magic,
134*0a6a1f1dSLionel Sambuc "version ", lfs_sb_getversion(lfsp),
135*0a6a1f1dSLionel Sambuc "size ", (uintmax_t)lfs_sb_getsize(lfsp),
136*0a6a1f1dSLionel Sambuc "ssize ", lfs_sb_getssize(lfsp));
137*0a6a1f1dSLionel Sambuc printf("%s%ju\t%s%d\t%s%d\t%s%d\n",
138*0a6a1f1dSLionel Sambuc "dsize ", (uintmax_t)lfs_sb_getdsize(lfsp),
139*0a6a1f1dSLionel Sambuc "bsize ", lfs_sb_getbsize(lfsp),
140*0a6a1f1dSLionel Sambuc "fsize ", lfs_sb_getfsize(lfsp),
141*0a6a1f1dSLionel Sambuc "frag ", lfs_sb_getfrag(lfsp));
142d65f6f70SBen Gras
143d65f6f70SBen Gras printf("%s%d\t%s%d\t%s%d\t%s%d\n",
144*0a6a1f1dSLionel Sambuc "minfree ", lfs_sb_getminfree(lfsp),
145*0a6a1f1dSLionel Sambuc "inopb ", lfs_sb_getinopb(lfsp),
146*0a6a1f1dSLionel Sambuc "ifpb ", lfs_sb_getifpb(lfsp),
147*0a6a1f1dSLionel Sambuc "nindir ", lfs_sb_getnindir(lfsp));
148d65f6f70SBen Gras
149d65f6f70SBen Gras printf("%s%d\t%s%d\t%s%d\t%s%d\n",
150*0a6a1f1dSLionel Sambuc "nseg ", lfs_sb_getnseg(lfsp),
151*0a6a1f1dSLionel Sambuc "nspf ", lfs_sb_getnspf(lfsp),
152*0a6a1f1dSLionel Sambuc "cleansz ", lfs_sb_getcleansz(lfsp),
153*0a6a1f1dSLionel Sambuc "segtabsz ", lfs_sb_getsegtabsz(lfsp));
154d65f6f70SBen Gras
155d65f6f70SBen Gras printf("%s%x\t%s%d\t%s%lx\t%s%d\n",
156*0a6a1f1dSLionel Sambuc "segmask ", lfs_sb_getsegmask(lfsp),
157*0a6a1f1dSLionel Sambuc "segshift ", lfs_sb_getsegshift(lfsp),
158*0a6a1f1dSLionel Sambuc "bmask ", (unsigned long)lfs_sb_getbmask(lfsp),
159*0a6a1f1dSLionel Sambuc "bshift ", lfs_sb_getbshift(lfsp));
160d65f6f70SBen Gras
161d65f6f70SBen Gras printf("%s%lu\t%s%d\t%s%lx\t%s%u\n",
162*0a6a1f1dSLionel Sambuc "ffmask ", (unsigned long)lfs_sb_getffmask(lfsp),
163*0a6a1f1dSLionel Sambuc "ffshift ", lfs_sb_getffshift(lfsp),
164*0a6a1f1dSLionel Sambuc "fbmask ", (unsigned long)lfs_sb_getfbmask(lfsp),
165*0a6a1f1dSLionel Sambuc "fbshift ", lfs_sb_getfbshift(lfsp));
166d65f6f70SBen Gras
167*0a6a1f1dSLionel Sambuc printf("%s%d\t%s%d\t%s%x\t%s%jx\n",
168*0a6a1f1dSLionel Sambuc "sushift ", lfs_sb_getsushift(lfsp),
169*0a6a1f1dSLionel Sambuc "fsbtodb ", lfs_sb_getfsbtodb(lfsp),
170*0a6a1f1dSLionel Sambuc "cksum ", lfs_sb_getcksum(lfsp),
171*0a6a1f1dSLionel Sambuc "maxfilesize ", (uintmax_t)lfs_sb_getmaxfilesize(lfsp));
172d65f6f70SBen Gras
173d65f6f70SBen Gras printf("Superblock disk addresses:");
174d65f6f70SBen Gras for (i = 0; i < LFS_MAXNUMSB; i++)
175*0a6a1f1dSLionel Sambuc printf(" %jx", (intmax_t)lfs_sb_getsboff(lfsp, i));
176d65f6f70SBen Gras printf("\n");
177d65f6f70SBen Gras
178d65f6f70SBen Gras printf("Checkpoint Info\n");
179*0a6a1f1dSLionel Sambuc printf("%s%ju\t%s%jx\n",
180*0a6a1f1dSLionel Sambuc "freehd ", (uintmax_t)lfs_sb_getfreehd(lfsp),
181*0a6a1f1dSLionel Sambuc "idaddr ", (intmax_t)lfs_sb_getidaddr(lfsp));
182*0a6a1f1dSLionel Sambuc printf("%s%jx\t%s%ju\t%s%jx\t%s%jx\t%s%jx\t%s%jx\n",
183*0a6a1f1dSLionel Sambuc "bfree ", (intmax_t)lfs_sb_getbfree(lfsp),
184*0a6a1f1dSLionel Sambuc "nfiles ", (uintmax_t)lfs_sb_getnfiles(lfsp),
185*0a6a1f1dSLionel Sambuc "lastseg ", (intmax_t)lfs_sb_getlastseg(lfsp),
186*0a6a1f1dSLionel Sambuc "nextseg ", (intmax_t)lfs_sb_getnextseg(lfsp),
187*0a6a1f1dSLionel Sambuc "curseg ", (intmax_t)lfs_sb_getcurseg(lfsp),
188*0a6a1f1dSLionel Sambuc "offset ", (intmax_t)lfs_sb_getoffset(lfsp));
189*0a6a1f1dSLionel Sambuc printf("tstamp %llx\n", (long long)lfs_sb_gettstamp(lfsp));
190*0a6a1f1dSLionel Sambuc
191*0a6a1f1dSLionel Sambuc if (!lfsp->lfs_is64) {
192*0a6a1f1dSLionel Sambuc printf("32-bit only derived or constant fields\n");
193*0a6a1f1dSLionel Sambuc printf("%s%u\n",
194*0a6a1f1dSLionel Sambuc "ifile ", lfs_sb_getifile(lfsp));
195*0a6a1f1dSLionel Sambuc }
196d65f6f70SBen Gras }
197d65f6f70SBen Gras
198d65f6f70SBen Gras void
lfs_dump_dinode(struct lfs * fs,union lfs_dinode * dip)199*0a6a1f1dSLionel Sambuc lfs_dump_dinode(struct lfs *fs, union lfs_dinode *dip)
200d65f6f70SBen Gras {
201d65f6f70SBen Gras int i;
202d65f6f70SBen Gras
203*0a6a1f1dSLionel Sambuc printf("%s%u\t%s%d\t%s%u\t%s%u\t%s%ju\t%s%ju\n",
204*0a6a1f1dSLionel Sambuc "mode ", lfs_dino_getmode(fs, dip),
205*0a6a1f1dSLionel Sambuc "nlink ", lfs_dino_getnlink(fs, dip),
206*0a6a1f1dSLionel Sambuc "uid ", lfs_dino_getuid(fs, dip),
207*0a6a1f1dSLionel Sambuc "gid ", lfs_dino_getgid(fs, dip),
208*0a6a1f1dSLionel Sambuc "size ", (uintmax_t)lfs_dino_getsize(fs, dip),
209*0a6a1f1dSLionel Sambuc "blocks ", (uintmax_t)lfs_dino_getblocks(fs, dip));
210*0a6a1f1dSLionel Sambuc printf("inum %ju\n", (uintmax_t)lfs_dino_getinumber(fs, dip));
211d65f6f70SBen Gras printf("Direct Addresses\n");
21284d9c625SLionel Sambuc for (i = 0; i < ULFS_NDADDR; i++) {
213*0a6a1f1dSLionel Sambuc printf("\t%jx", (intmax_t)lfs_dino_getdb(fs, dip, i));
214d65f6f70SBen Gras if ((i % 6) == 5)
215d65f6f70SBen Gras printf("\n");
216d65f6f70SBen Gras }
21784d9c625SLionel Sambuc for (i = 0; i < ULFS_NIADDR; i++)
218*0a6a1f1dSLionel Sambuc printf("\t%jx", (intmax_t)lfs_dino_getib(fs, dip, i));
219d65f6f70SBen Gras printf("\n");
220d65f6f70SBen Gras }
221d65f6f70SBen Gras
222d65f6f70SBen Gras void
lfs_check_segsum(struct lfs * fs,struct segment * sp,char * file,int line)223d65f6f70SBen Gras lfs_check_segsum(struct lfs *fs, struct segment *sp, char *file, int line)
224d65f6f70SBen Gras {
225d65f6f70SBen Gras int actual;
226d65f6f70SBen Gras #if 0
227d65f6f70SBen Gras static int offset;
228d65f6f70SBen Gras #endif
229d65f6f70SBen Gras
230d65f6f70SBen Gras if ((actual = 1) == 1)
231d65f6f70SBen Gras return; /* XXXX not checking this anymore, really */
232d65f6f70SBen Gras
233*0a6a1f1dSLionel Sambuc if (sp->sum_bytes_left >= FINFOSIZE(fs)
234*0a6a1f1dSLionel Sambuc && lfs_fi_getnblocks(fs, sp->fip) > 512) {
235*0a6a1f1dSLionel Sambuc printf("%s:%d: fi_nblocks = %d\n", file, line,
236*0a6a1f1dSLionel Sambuc lfs_fi_getnblocks(fs, sp->fip));
237d65f6f70SBen Gras #ifdef DDB
238d65f6f70SBen Gras Debugger();
239d65f6f70SBen Gras #endif
240d65f6f70SBen Gras }
241d65f6f70SBen Gras
242d65f6f70SBen Gras if (sp->sum_bytes_left > 484) {
243d65f6f70SBen Gras printf("%s:%d: bad value (%d = -%d) for sum_bytes_left\n",
244*0a6a1f1dSLionel Sambuc file, line, sp->sum_bytes_left, lfs_sb_getsumsize(fs)-sp->sum_bytes_left);
245d65f6f70SBen Gras panic("too many bytes");
246d65f6f70SBen Gras }
247d65f6f70SBen Gras
248*0a6a1f1dSLionel Sambuc actual = lfs_sb_getsumsize(fs)
249d65f6f70SBen Gras /* amount taken up by FINFOs */
250*0a6a1f1dSLionel Sambuc - ((char *)NEXT_FINFO(fs, sp->fip) - (char *)(sp->segsum))
251d65f6f70SBen Gras /* amount taken up by inode blocks */
252*0a6a1f1dSLionel Sambuc /* XXX should this be INUMSIZE or BLKPTRSIZE? */
253*0a6a1f1dSLionel Sambuc - LFS_INUMSIZE(fs)*((sp->ninodes+LFS_INOPB(fs)-1) / LFS_INOPB(fs));
254d65f6f70SBen Gras #if 0
255d65f6f70SBen Gras if (actual - sp->sum_bytes_left < offset)
256d65f6f70SBen Gras {
257d65f6f70SBen Gras printf("%s:%d: offset changed %d -> %d\n", file, line,
258d65f6f70SBen Gras offset, actual-sp->sum_bytes_left);
259d65f6f70SBen Gras offset = actual - sp->sum_bytes_left;
260d65f6f70SBen Gras /* panic("byte mismatch"); */
261d65f6f70SBen Gras }
262d65f6f70SBen Gras #endif
263d65f6f70SBen Gras #if 0
264d65f6f70SBen Gras if (actual != sp->sum_bytes_left)
265d65f6f70SBen Gras printf("%s:%d: warning: segsum miscalc at %d (-%d => %d)\n",
266d65f6f70SBen Gras file, line, sp->sum_bytes_left,
267*0a6a1f1dSLionel Sambuc lfs_sb_getsumsize(fs)-sp->sum_bytes_left,
268d65f6f70SBen Gras actual);
269d65f6f70SBen Gras #endif
270d65f6f70SBen Gras if (sp->sum_bytes_left > 0
271*0a6a1f1dSLionel Sambuc && ((char *)(sp->segsum))[lfs_sb_getsumsize(fs)
27284d9c625SLionel Sambuc - sizeof(int32_t) * ((sp->ninodes+LFS_INOPB(fs)-1) / LFS_INOPB(fs))
273d65f6f70SBen Gras - sp->sum_bytes_left] != '\0') {
274d65f6f70SBen Gras printf("%s:%d: warning: segsum overwrite at %d (-%d => %d)\n",
275d65f6f70SBen Gras file, line, sp->sum_bytes_left,
276*0a6a1f1dSLionel Sambuc lfs_sb_getsumsize(fs)-sp->sum_bytes_left,
277d65f6f70SBen Gras actual);
278d65f6f70SBen Gras #ifdef DDB
279d65f6f70SBen Gras Debugger();
280d65f6f70SBen Gras #endif
281d65f6f70SBen Gras }
282d65f6f70SBen Gras }
283d65f6f70SBen Gras
284d65f6f70SBen Gras void
lfs_check_bpp(struct lfs * fs,struct segment * sp,char * file,int line)285d65f6f70SBen Gras lfs_check_bpp(struct lfs *fs, struct segment *sp, char *file, int line)
286d65f6f70SBen Gras {
287d65f6f70SBen Gras daddr_t blkno;
288d65f6f70SBen Gras struct buf **bpp;
289d65f6f70SBen Gras struct vnode *devvp;
290d65f6f70SBen Gras
291d65f6f70SBen Gras devvp = VTOI(fs->lfs_ivnode)->i_devvp;
292d65f6f70SBen Gras blkno = (*(sp->bpp))->b_blkno;
293d65f6f70SBen Gras for (bpp = sp->bpp; bpp < sp->cbpp; bpp++) {
294d65f6f70SBen Gras if ((*bpp)->b_blkno != blkno) {
295d65f6f70SBen Gras if ((*bpp)->b_vp == devvp) {
296d65f6f70SBen Gras printf("Oops, would misplace raw block "
297d65f6f70SBen Gras "0x%" PRIx64 " at 0x%" PRIx64 "\n",
298d65f6f70SBen Gras (*bpp)->b_blkno,
299d65f6f70SBen Gras blkno);
300d65f6f70SBen Gras } else {
301d65f6f70SBen Gras printf("%s:%d: misplace ino %llu lbn %" PRId64
302d65f6f70SBen Gras " at 0x%" PRIx64 " instead of "
303d65f6f70SBen Gras "0x%" PRIx64 "\n",
304d65f6f70SBen Gras file, line,
305d65f6f70SBen Gras (unsigned long long)
306d65f6f70SBen Gras VTOI((*bpp)->b_vp)->i_number,
307d65f6f70SBen Gras (*bpp)->b_lblkno,
308d65f6f70SBen Gras blkno,
309d65f6f70SBen Gras (*bpp)->b_blkno);
310d65f6f70SBen Gras }
311d65f6f70SBen Gras }
31284d9c625SLionel Sambuc blkno += LFS_FSBTODB(fs, lfs_btofsb(fs, (*bpp)->b_bcount));
313d65f6f70SBen Gras }
314d65f6f70SBen Gras }
315d65f6f70SBen Gras
316d65f6f70SBen Gras int lfs_debug_log_subsys[DLOG_MAX];
317d65f6f70SBen Gras
318d65f6f70SBen Gras /*
319d65f6f70SBen Gras * Log events from various debugging areas of LFS, depending on what
320d65f6f70SBen Gras * the user has enabled.
321d65f6f70SBen Gras */
322d65f6f70SBen Gras void
lfs_debug_log(int subsys,const char * fmt,...)323d65f6f70SBen Gras lfs_debug_log(int subsys, const char *fmt, ...)
324d65f6f70SBen Gras {
325d65f6f70SBen Gras va_list ap;
326d65f6f70SBen Gras
327d65f6f70SBen Gras /* If not debugging this subsys, exit */
328d65f6f70SBen Gras if (lfs_debug_log_subsys[subsys] == 0)
329d65f6f70SBen Gras return;
330d65f6f70SBen Gras
331d65f6f70SBen Gras va_start(ap, fmt);
332d65f6f70SBen Gras vlog(LOG_DEBUG, fmt, ap);
333d65f6f70SBen Gras va_end(ap);
334d65f6f70SBen Gras }
335d65f6f70SBen Gras #endif /* DEBUG */
336