debug.c revision 215704
169800Stomsoft/* 269800Stomsoft * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz 369800Stomsoft * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. 469800Stomsoft * All rights reserved. 569800Stomsoft * 669800Stomsoft * This code is derived from software contributed to Berkeley by 769800Stomsoft * Christoph Herrmann and Thomas-Henning von Kamptz, Munich and Frankfurt. 869800Stomsoft * 969800Stomsoft * Redistribution and use in source and binary forms, with or without 1069800Stomsoft * modification, are permitted provided that the following conditions 1169800Stomsoft * are met: 1269800Stomsoft * 1. Redistributions of source code must retain the above copyright 1369800Stomsoft * notice, this list of conditions and the following disclaimer. 1469800Stomsoft * 2. Redistributions in binary form must reproduce the above copyright 1569800Stomsoft * notice, this list of conditions and the following disclaimer in the 1669800Stomsoft * documentation and/or other materials provided with the distribution. 1769800Stomsoft * 3. All advertising materials mentioning features or use of this software 1869800Stomsoft * must display the following acknowledgment: 1969800Stomsoft * This product includes software developed by the University of 2069800Stomsoft * California, Berkeley and its contributors, as well as Christoph 2169800Stomsoft * Herrmann and Thomas-Henning von Kamptz. 2269800Stomsoft * 4. Neither the name of the University nor the names of its contributors 2369800Stomsoft * may be used to endorse or promote products derived from this software 2469800Stomsoft * without specific prior written permission. 2569800Stomsoft * 2669800Stomsoft * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2769800Stomsoft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2869800Stomsoft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2969800Stomsoft * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3069800Stomsoft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3169800Stomsoft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3269800Stomsoft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3369800Stomsoft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3469800Stomsoft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3569800Stomsoft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3669800Stomsoft * SUCH DAMAGE. 3769800Stomsoft * 3869926Stomsoft * $TSHeader: src/sbin/growfs/debug.c,v 1.3 2000/12/12 19:31:00 tomsoft Exp $ 3969800Stomsoft * 4069800Stomsoft */ 4169800Stomsoft 4269800Stomsoft#ifndef lint 4369800Stomsoftstatic const char rcsid[] = 4469926Stomsoft "$FreeBSD: head/sbin/growfs/debug.c 215704 2010-11-22 20:10:48Z brucec $"; 4569800Stomsoft#endif /* not lint */ 4669800Stomsoft 4769800Stomsoft/* ********************************************************** INCLUDES ***** */ 4869800Stomsoft#include <sys/param.h> 4969800Stomsoft 50103949Smike#include <limits.h> 5169800Stomsoft#include <stdio.h> 52127798Sle#include <string.h> 5369800Stomsoft#include <ufs/ufs/dinode.h> 5469800Stomsoft#include <ufs/ffs/fs.h> 5569800Stomsoft 5669800Stomsoft#include "debug.h" 5769800Stomsoft 5869800Stomsoft#ifdef FS_DEBUG 5969800Stomsoft 6069800Stomsoft/* *********************************************************** GLOBALS ***** */ 6169800Stomsoftstatic FILE *dbg_log=NULL; 6269800Stomsoftstatic unsigned int indent=0; 6369800Stomsoft 6469800Stomsoft/* 6569800Stomsoft * prototypes not done here, as they come with debug.h 6669800Stomsoft */ 6769800Stomsoft 6869800Stomsoft/* ********************************************************** dbg_open ***** */ 6969800Stomsoft/* 7069800Stomsoft * Open the filehandle where all debug output has to go. 7169800Stomsoft */ 7269800Stomsoftvoid 7369800Stomsoftdbg_open(const char *fn) 7469800Stomsoft{ 7569800Stomsoft 7692743Srwatson if (strcmp(fn, "-") == 0) 7792743Srwatson dbg_log=fopen("/dev/stdout", "a"); 7892743Srwatson else 7992743Srwatson dbg_log=fopen(fn, "a"); 8069800Stomsoft 8169800Stomsoft return; 8269800Stomsoft} 8369800Stomsoft 8469800Stomsoft/* ********************************************************* dbg_close ***** */ 8569800Stomsoft/* 8669800Stomsoft * Close the filehandle where all debug output went to. 8769800Stomsoft */ 8869800Stomsoftvoid 8969800Stomsoftdbg_close(void) 9069800Stomsoft{ 9169800Stomsoft 9269800Stomsoft if(dbg_log) { 9369800Stomsoft fclose(dbg_log); 9469800Stomsoft dbg_log=NULL; 9569800Stomsoft } 9669800Stomsoft 9769800Stomsoft return; 9869800Stomsoft} 9969800Stomsoft 10069800Stomsoft/* ****************************************************** dbg_dump_hex ***** */ 10169800Stomsoft/* 102102231Strhodes * Dump out a full file system block in hex. 10369800Stomsoft */ 10469800Stomsoftvoid 10569800Stomsoftdbg_dump_hex(struct fs *sb, const char *comment, unsigned char *mem) 10669800Stomsoft{ 10769800Stomsoft int i, j, k; 10869800Stomsoft 10969800Stomsoft if(!dbg_log) { 11069800Stomsoft return; 11169800Stomsoft } 11269800Stomsoft fprintf(dbg_log, "===== START HEXDUMP =====\n"); 11369800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)mem, comment); 11469800Stomsoft indent++; 11569800Stomsoft for (i=0; i<sb->fs_bsize; i+=24) { 11669800Stomsoft for (j=0; j<3; j++) { 11769800Stomsoft for (k=0; k<8; k++) { 11869800Stomsoft fprintf(dbg_log, "%02x ", *mem++); 11969800Stomsoft } 12069800Stomsoft fprintf(dbg_log, " "); 12169800Stomsoft } 12269800Stomsoft fprintf(dbg_log, "\n"); 12369800Stomsoft } 12469800Stomsoft indent--; 12569800Stomsoft fprintf(dbg_log, "===== END HEXDUMP =====\n"); 12669800Stomsoft 12769800Stomsoft return; 12869800Stomsoft} 12969800Stomsoft 13069800Stomsoft/* ******************************************************* dbg_dump_fs ***** */ 13169800Stomsoft/* 13269800Stomsoft * Dump the superblock. 13369800Stomsoft */ 13469800Stomsoftvoid 13569800Stomsoftdbg_dump_fs(struct fs *sb, const char *comment) 13669800Stomsoft{ 13769800Stomsoft#ifdef FSMAXSNAP 13869800Stomsoft int j; 13969800Stomsoft#endif /* FSMAXSNAP */ 14069800Stomsoft 14169800Stomsoft if(!dbg_log) { 14269800Stomsoft return; 14369800Stomsoft } 14469800Stomsoft 14569800Stomsoft fprintf(dbg_log, "===== START SUPERBLOCK =====\n"); 14669800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)sb, comment); 14769800Stomsoft indent++; 14869800Stomsoft 149118915Srwatson fprintf(dbg_log, "sblkno int32_t 0x%08x\n", 15069800Stomsoft sb->fs_sblkno); 151118915Srwatson fprintf(dbg_log, "cblkno int32_t 0x%08x\n", 15269800Stomsoft sb->fs_cblkno); 153118915Srwatson fprintf(dbg_log, "iblkno int32_t 0x%08x\n", 15469800Stomsoft sb->fs_iblkno); 155118915Srwatson fprintf(dbg_log, "dblkno int32_t 0x%08x\n", 15669800Stomsoft sb->fs_dblkno); 15769800Stomsoft 158118915Srwatson fprintf(dbg_log, "old_cgoffset int32_t 0x%08x\n", 159118915Srwatson sb->fs_old_cgoffset); 160118915Srwatson fprintf(dbg_log, "old_cgmask int32_t 0x%08x\n", 161118915Srwatson sb->fs_old_cgmask); 162118915Srwatson fprintf(dbg_log, "old_time int32_t %10u\n", 163118915Srwatson (unsigned int)sb->fs_old_time); 164118915Srwatson fprintf(dbg_log, "old_size int32_t 0x%08x\n", 165118915Srwatson sb->fs_old_size); 166118915Srwatson fprintf(dbg_log, "old_dsize int32_t 0x%08x\n", 167118915Srwatson sb->fs_old_dsize); 168118915Srwatson fprintf(dbg_log, "ncg int32_t 0x%08x\n", 16969800Stomsoft sb->fs_ncg); 170118915Srwatson fprintf(dbg_log, "bsize int32_t 0x%08x\n", 17169800Stomsoft sb->fs_bsize); 172118915Srwatson fprintf(dbg_log, "fsize int32_t 0x%08x\n", 17369800Stomsoft sb->fs_fsize); 174118915Srwatson fprintf(dbg_log, "frag int32_t 0x%08x\n", 17569800Stomsoft sb->fs_frag); 17669800Stomsoft 177118915Srwatson fprintf(dbg_log, "minfree int32_t 0x%08x\n", 17869800Stomsoft sb->fs_minfree); 179118915Srwatson fprintf(dbg_log, "old_rotdelay int32_t 0x%08x\n", 180118915Srwatson sb->fs_old_rotdelay); 181118915Srwatson fprintf(dbg_log, "old_rps int32_t 0x%08x\n", 182118915Srwatson sb->fs_old_rps); 18369800Stomsoft 184118915Srwatson fprintf(dbg_log, "bmask int32_t 0x%08x\n", 18569800Stomsoft sb->fs_bmask); 186118915Srwatson fprintf(dbg_log, "fmask int32_t 0x%08x\n", 18769800Stomsoft sb->fs_fmask); 188118915Srwatson fprintf(dbg_log, "bshift int32_t 0x%08x\n", 18969800Stomsoft sb->fs_bshift); 190118915Srwatson fprintf(dbg_log, "fshift int32_t 0x%08x\n", 19169800Stomsoft sb->fs_fshift); 19269800Stomsoft 193118915Srwatson fprintf(dbg_log, "maxcontig int32_t 0x%08x\n", 19469800Stomsoft sb->fs_maxcontig); 195118915Srwatson fprintf(dbg_log, "maxbpg int32_t 0x%08x\n", 19669800Stomsoft sb->fs_maxbpg); 19769800Stomsoft 198118915Srwatson fprintf(dbg_log, "fragshift int32_t 0x%08x\n", 19969800Stomsoft sb->fs_fragshift); 200118915Srwatson fprintf(dbg_log, "fsbtodb int32_t 0x%08x\n", 20169800Stomsoft sb->fs_fsbtodb); 202118915Srwatson fprintf(dbg_log, "sbsize int32_t 0x%08x\n", 20369800Stomsoft sb->fs_sbsize); 204118915Srwatson fprintf(dbg_log, "spare1 int32_t[2] 0x%08x 0x%08x\n", 205118915Srwatson sb->fs_spare1[0], sb->fs_spare1[1]); 206118915Srwatson fprintf(dbg_log, "nindir int32_t 0x%08x\n", 20769800Stomsoft sb->fs_nindir); 208118915Srwatson fprintf(dbg_log, "inopb int32_t 0x%08x\n", 20969800Stomsoft sb->fs_inopb); 210118915Srwatson fprintf(dbg_log, "old_nspf int32_t 0x%08x\n", 211118915Srwatson sb->fs_old_nspf); 21269800Stomsoft 213118915Srwatson fprintf(dbg_log, "optim int32_t 0x%08x\n", 21469800Stomsoft sb->fs_optim); 21569800Stomsoft 216118915Srwatson fprintf(dbg_log, "old_npsect int32_t 0x%08x\n", 217118915Srwatson sb->fs_old_npsect); 218118915Srwatson fprintf(dbg_log, "old_interleave int32_t 0x%08x\n", 219118915Srwatson sb->fs_old_interleave); 220118915Srwatson fprintf(dbg_log, "old_trackskew int32_t 0x%08x\n", 221118915Srwatson sb->fs_old_trackskew); 22269800Stomsoft 223118915Srwatson fprintf(dbg_log, "id int32_t[2] 0x%08x 0x%08x\n", 22469800Stomsoft sb->fs_id[0], sb->fs_id[1]); 22569800Stomsoft 226118915Srwatson fprintf(dbg_log, "old_csaddr int32_t 0x%08x\n", 227118915Srwatson sb->fs_old_csaddr); 228118915Srwatson fprintf(dbg_log, "cssize int32_t 0x%08x\n", 22969800Stomsoft sb->fs_cssize); 230118915Srwatson fprintf(dbg_log, "cgsize int32_t 0x%08x\n", 23169800Stomsoft sb->fs_cgsize); 23269800Stomsoft 233118915Srwatson fprintf(dbg_log, "spare2 int32_t 0x%08x\n", 234118915Srwatson sb->fs_spare2); 235118915Srwatson fprintf(dbg_log, "old_nsect int32_t 0x%08x\n", 236118915Srwatson sb->fs_old_nsect); 237118915Srwatson fprintf(dbg_log, "old_spc int32_t 0x%08x\n", 238118915Srwatson sb->fs_old_spc); 23969800Stomsoft 240118915Srwatson fprintf(dbg_log, "old_ncyl int32_t 0x%08x\n", 241118915Srwatson sb->fs_old_ncyl); 24269800Stomsoft 243118915Srwatson fprintf(dbg_log, "old_cpg int32_t 0x%08x\n", 244118915Srwatson sb->fs_old_cpg); 245118915Srwatson fprintf(dbg_log, "ipg int32_t 0x%08x\n", 24669800Stomsoft sb->fs_ipg); 247118915Srwatson fprintf(dbg_log, "fpg int32_t 0x%08x\n", 24869800Stomsoft sb->fs_fpg); 24969800Stomsoft 250118915Srwatson dbg_dump_csum("internal old_cstotal", &sb->fs_old_cstotal); 25169800Stomsoft 252118915Srwatson fprintf(dbg_log, "fmod int8_t 0x%02x\n", 25369800Stomsoft sb->fs_fmod); 254118915Srwatson fprintf(dbg_log, "clean int8_t 0x%02x\n", 25569800Stomsoft sb->fs_clean); 256118915Srwatson fprintf(dbg_log, "ronly int8_t 0x%02x\n", 25769800Stomsoft sb->fs_ronly); 258118915Srwatson fprintf(dbg_log, "old_flags int8_t 0x%02x\n", 259118915Srwatson sb->fs_old_flags); 260118915Srwatson fprintf(dbg_log, "fsmnt u_char[MAXMNTLEN] \"%s\"\n", 26169800Stomsoft sb->fs_fsmnt); 262118915Srwatson fprintf(dbg_log, "volname u_char[MAXVOLLEN] \"%s\"\n", 263118915Srwatson sb->fs_volname); 264118915Srwatson fprintf(dbg_log, "swuid u_int64_t 0x%08x%08x\n", 265118915Srwatson ((unsigned int *)&(sb->fs_swuid))[1], 266118915Srwatson ((unsigned int *)&(sb->fs_swuid))[0]); 26769800Stomsoft 268118915Srwatson fprintf(dbg_log, "pad int32_t 0x%08x\n", 269118915Srwatson sb->fs_pad); 270118915Srwatson 271118915Srwatson fprintf(dbg_log, "cgrotor int32_t 0x%08x\n", 27269800Stomsoft sb->fs_cgrotor); 27369800Stomsoft/* 27469800Stomsoft * struct csum[MAXCSBUFS] - is only maintained in memory 27569800Stomsoft */ 27669800Stomsoft/* fprintf(dbg_log, " int32_t\n", sb->*fs_maxcluster);*/ 277118915Srwatson fprintf(dbg_log, "old_cpc int32_t 0x%08x\n", 278118915Srwatson sb->fs_old_cpc); 27969800Stomsoft/* 28069800Stomsoft * int16_t fs_opostbl[16][8] - is dumped when used in dbg_dump_sptbl 28169800Stomsoft */ 282118915Srwatson fprintf(dbg_log, "maxbsize int32_t 0x%08x\n", 283118915Srwatson sb->fs_maxbsize); 284215704Sbrucec fprintf(dbg_log, "unrefs int64_t 0x%08jx\n", 285163844Spjd sb->fs_unrefs); 286118915Srwatson fprintf(dbg_log, "sblockloc int64_t 0x%08x%08x\n", 287118915Srwatson ((unsigned int *)&(sb->fs_sblockloc))[1], 288118915Srwatson ((unsigned int *)&(sb->fs_sblockloc))[0]); 289118915Srwatson 290118915Srwatson dbg_dump_csum_total("internal cstotal", &sb->fs_cstotal); 291118915Srwatson 292118915Srwatson fprintf(dbg_log, "time ufs_time_t %10u\n", 293118915Srwatson (unsigned int)sb->fs_time); 294118915Srwatson 295118915Srwatson fprintf(dbg_log, "size int64_t 0x%08x%08x\n", 296118915Srwatson ((unsigned int *)&(sb->fs_size))[1], 297118915Srwatson ((unsigned int *)&(sb->fs_size))[0]); 298118915Srwatson fprintf(dbg_log, "dsize int64_t 0x%08x%08x\n", 299118915Srwatson ((unsigned int *)&(sb->fs_dsize))[1], 300118915Srwatson ((unsigned int *)&(sb->fs_dsize))[0]); 301118915Srwatson fprintf(dbg_log, "csaddr ufs2_daddr_t 0x%08x%08x\n", 302118915Srwatson ((unsigned int *)&(sb->fs_csaddr))[1], 303118915Srwatson ((unsigned int *)&(sb->fs_csaddr))[0]); 304118915Srwatson fprintf(dbg_log, "pendingblocks int64_t 0x%08x%08x\n", 305118915Srwatson ((unsigned int *)&(sb->fs_pendingblocks))[1], 306118915Srwatson ((unsigned int *)&(sb->fs_pendingblocks))[0]); 307118915Srwatson fprintf(dbg_log, "pendinginodes int32_t 0x%08x\n", 308118915Srwatson sb->fs_pendinginodes); 309118915Srwatson 31069800Stomsoft#ifdef FSMAXSNAP 31169800Stomsoft for(j=0; j<FSMAXSNAP; j++) { 312118915Srwatson fprintf(dbg_log, "snapinum int32_t[%2d] 0x%08x\n", 31369800Stomsoft j, sb->fs_snapinum[j]); 31469800Stomsoft if(!sb->fs_snapinum[j]) { /* list is dense */ 31569800Stomsoft break; 31669800Stomsoft } 31769800Stomsoft } 31869800Stomsoft#endif /* FSMAXSNAP */ 319118915Srwatson fprintf(dbg_log, "avgfilesize int32_t 0x%08x\n", 320118915Srwatson sb->fs_avgfilesize); 321118915Srwatson fprintf(dbg_log, "avgfpdir int32_t 0x%08x\n", 322118915Srwatson sb->fs_avgfpdir); 323118915Srwatson fprintf(dbg_log, "save_cgsize int32_t 0x%08x\n", 324118915Srwatson sb->fs_save_cgsize); 325118915Srwatson fprintf(dbg_log, "flags int32_t 0x%08x\n", 326118915Srwatson sb->fs_flags); 327118915Srwatson fprintf(dbg_log, "contigsumsize int32_t 0x%08x\n", 32869800Stomsoft sb->fs_contigsumsize); 329118915Srwatson fprintf(dbg_log, "maxsymlinklen int32_t 0x%08x\n", 33069800Stomsoft sb->fs_maxsymlinklen); 331118915Srwatson fprintf(dbg_log, "old_inodefmt int32_t 0x%08x\n", 332118915Srwatson sb->fs_old_inodefmt); 333118915Srwatson fprintf(dbg_log, "maxfilesize u_int64_t 0x%08x%08x\n", 33469800Stomsoft ((unsigned int *)&(sb->fs_maxfilesize))[1], 33569800Stomsoft ((unsigned int *)&(sb->fs_maxfilesize))[0]); 336118915Srwatson fprintf(dbg_log, "qbmask int64_t 0x%08x%08x\n", 33769800Stomsoft ((unsigned int *)&(sb->fs_qbmask))[1], 33869800Stomsoft ((unsigned int *)&(sb->fs_qbmask))[0]); 339118915Srwatson fprintf(dbg_log, "qfmask int64_t 0x%08x%08x\n", 34069800Stomsoft ((unsigned int *)&(sb->fs_qfmask))[1], 34169800Stomsoft ((unsigned int *)&(sb->fs_qfmask))[0]); 342118915Srwatson fprintf(dbg_log, "state int32_t 0x%08x\n", 34369800Stomsoft sb->fs_state); 344118915Srwatson fprintf(dbg_log, "old_postblformat int32_t 0x%08x\n", 345118915Srwatson sb->fs_old_postblformat); 346118915Srwatson fprintf(dbg_log, "old_nrpos int32_t 0x%08x\n", 347118915Srwatson sb->fs_old_nrpos); 348118915Srwatson fprintf(dbg_log, "spare5 int32_t[2] 0x%08x 0x%08x\n", 349118915Srwatson sb->fs_spare5[0], sb->fs_spare5[1]); 350118915Srwatson fprintf(dbg_log, "magic int32_t 0x%08x\n", 35169800Stomsoft sb->fs_magic); 35269800Stomsoft 35369800Stomsoft indent--; 35469800Stomsoft fprintf(dbg_log, "===== END SUPERBLOCK =====\n"); 35569800Stomsoft 35669800Stomsoft return; 35769800Stomsoft} 35869800Stomsoft 35969800Stomsoft/* ******************************************************* dbg_dump_cg ***** */ 36069800Stomsoft/* 36169800Stomsoft * Dump a cylinder group. 36269800Stomsoft */ 36369800Stomsoftvoid 36469800Stomsoftdbg_dump_cg(const char *comment, struct cg *cgr) 36569800Stomsoft{ 36669800Stomsoft int j; 36769800Stomsoft 36869800Stomsoft if(!dbg_log) { 36969800Stomsoft return; 37069800Stomsoft } 37169800Stomsoft 37269800Stomsoft fprintf(dbg_log, "===== START CYLINDER GROUP =====\n"); 37369800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 37469800Stomsoft indent++; 37569800Stomsoft 37669800Stomsoft fprintf(dbg_log, "magic int32_t 0x%08x\n", cgr->cg_magic); 377118915Srwatson fprintf(dbg_log, "old_time int32_t 0x%08x\n", cgr->cg_old_time); 37869800Stomsoft fprintf(dbg_log, "cgx int32_t 0x%08x\n", cgr->cg_cgx); 379118915Srwatson fprintf(dbg_log, "old_ncyl int16_t 0x%04x\n", cgr->cg_old_ncyl); 380118915Srwatson fprintf(dbg_log, "old_niblk int16_t 0x%04x\n", cgr->cg_old_niblk); 38169800Stomsoft fprintf(dbg_log, "ndblk int32_t 0x%08x\n", cgr->cg_ndblk); 38269800Stomsoft dbg_dump_csum("internal cs", &cgr->cg_cs); 38369800Stomsoft fprintf(dbg_log, "rotor int32_t 0x%08x\n", cgr->cg_rotor); 38469800Stomsoft fprintf(dbg_log, "frotor int32_t 0x%08x\n", cgr->cg_frotor); 38569800Stomsoft fprintf(dbg_log, "irotor int32_t 0x%08x\n", cgr->cg_irotor); 38669800Stomsoft for(j=0; j<MAXFRAG; j++) { 38769800Stomsoft fprintf(dbg_log, "frsum int32_t[%d] 0x%08x\n", j, 38869800Stomsoft cgr->cg_frsum[j]); 38969800Stomsoft } 390118915Srwatson fprintf(dbg_log, "old_btotoff int32_t 0x%08x\n", cgr->cg_old_btotoff); 391118915Srwatson fprintf(dbg_log, "old_boff int32_t 0x%08x\n", cgr->cg_old_boff); 39269800Stomsoft fprintf(dbg_log, "iusedoff int32_t 0x%08x\n", cgr->cg_iusedoff); 39369800Stomsoft fprintf(dbg_log, "freeoff int32_t 0x%08x\n", cgr->cg_freeoff); 39469800Stomsoft fprintf(dbg_log, "nextfreeoff int32_t 0x%08x\n", 39569800Stomsoft cgr->cg_nextfreeoff); 39669800Stomsoft fprintf(dbg_log, "clustersumoff int32_t 0x%08x\n", 39769800Stomsoft cgr->cg_clustersumoff); 398118915Srwatson fprintf(dbg_log, "clusteroff int32_t 0x%08x\n", 39969800Stomsoft cgr->cg_clusteroff); 40069800Stomsoft fprintf(dbg_log, "nclusterblks int32_t 0x%08x\n", 40169800Stomsoft cgr->cg_nclusterblks); 402118915Srwatson fprintf(dbg_log, "niblk int32_t 0x%08x\n", cgr->cg_niblk); 403118915Srwatson fprintf(dbg_log, "initediblk int32_t 0x%08x\n", cgr->cg_initediblk); 404163844Spjd fprintf(dbg_log, "unrefs int32_t 0x%08x\n", cgr->cg_unrefs); 405118915Srwatson fprintf(dbg_log, "time ufs_time_t %10u\n", 406118915Srwatson (unsigned int)cgr->cg_initediblk); 40769800Stomsoft 40869800Stomsoft indent--; 40969800Stomsoft fprintf(dbg_log, "===== END CYLINDER GROUP =====\n"); 41069800Stomsoft 41169800Stomsoft return; 41269800Stomsoft} 41369800Stomsoft 41469800Stomsoft/* ***************************************************** dbg_dump_csum ***** */ 41569800Stomsoft/* 41669800Stomsoft * Dump a cylinder summary. 41769800Stomsoft */ 41869800Stomsoftvoid 41969800Stomsoftdbg_dump_csum(const char *comment, struct csum *cs) 42069800Stomsoft{ 42169800Stomsoft 42269800Stomsoft if(!dbg_log) { 42369800Stomsoft return; 42469800Stomsoft } 42569800Stomsoft 42669800Stomsoft fprintf(dbg_log, "===== START CYLINDER SUMMARY =====\n"); 42769800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment); 42869800Stomsoft indent++; 42969800Stomsoft 43069800Stomsoft fprintf(dbg_log, "ndir int32_t 0x%08x\n", cs->cs_ndir); 43169800Stomsoft fprintf(dbg_log, "nbfree int32_t 0x%08x\n", cs->cs_nbfree); 43269800Stomsoft fprintf(dbg_log, "nifree int32_t 0x%08x\n", cs->cs_nifree); 43369800Stomsoft fprintf(dbg_log, "nffree int32_t 0x%08x\n", cs->cs_nffree); 43469800Stomsoft 43569800Stomsoft indent--; 43669800Stomsoft fprintf(dbg_log, "===== END CYLINDER SUMMARY =====\n"); 43769800Stomsoft 43869800Stomsoft return; 43969800Stomsoft} 44069800Stomsoft 441118915Srwatson/* ************************************************ dbg_dump_csum_total ***** */ 442118915Srwatson/* 443118915Srwatson * Dump a cylinder summary. 444118915Srwatson */ 445118915Srwatsonvoid 446118915Srwatsondbg_dump_csum_total(const char *comment, struct csum_total *cs) 447118915Srwatson{ 448118915Srwatson 449118915Srwatson if(!dbg_log) { 450118915Srwatson return; 451118915Srwatson } 452118915Srwatson 453118915Srwatson fprintf(dbg_log, "===== START CYLINDER SUMMARY TOTAL =====\n"); 454118915Srwatson fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment); 455118915Srwatson indent++; 456118915Srwatson 457118915Srwatson fprintf(dbg_log, "ndir int64_t 0x%08x%08x\n", 458118915Srwatson ((unsigned int *)&(cs->cs_ndir))[1], 459118915Srwatson ((unsigned int *)&(cs->cs_ndir))[0]); 460118915Srwatson fprintf(dbg_log, "nbfree int64_t 0x%08x%08x\n", 461118915Srwatson ((unsigned int *)&(cs->cs_nbfree))[1], 462118915Srwatson ((unsigned int *)&(cs->cs_nbfree))[0]); 463118915Srwatson fprintf(dbg_log, "nifree int64_t 0x%08x%08x\n", 464118915Srwatson ((unsigned int *)&(cs->cs_nifree))[1], 465118915Srwatson ((unsigned int *)&(cs->cs_nifree))[0]); 466118915Srwatson fprintf(dbg_log, "nffree int64_t 0x%08x%08x\n", 467118915Srwatson ((unsigned int *)&(cs->cs_nffree))[1], 468118915Srwatson ((unsigned int *)&(cs->cs_nffree))[0]); 469118915Srwatson fprintf(dbg_log, "numclusters int64_t 0x%08x%08x\n", 470118915Srwatson ((unsigned int *)&(cs->cs_numclusters))[1], 471118915Srwatson ((unsigned int *)&(cs->cs_numclusters))[0]); 472118915Srwatson 473118915Srwatson indent--; 474118915Srwatson fprintf(dbg_log, "===== END CYLINDER SUMMARY TOTAL =====\n"); 475118915Srwatson 476118915Srwatson return; 477118915Srwatson} 47869800Stomsoft/* **************************************************** dbg_dump_inmap ***** */ 47969800Stomsoft/* 48069800Stomsoft * Dump the inode allocation map in one cylinder group. 48169800Stomsoft */ 48269800Stomsoftvoid 48369800Stomsoftdbg_dump_inmap(struct fs *sb, const char *comment, struct cg *cgr) 48469800Stomsoft{ 48569800Stomsoft int j,k,l,e; 48669800Stomsoft unsigned char *cp; 48769800Stomsoft 48869800Stomsoft if(!dbg_log) { 48969800Stomsoft return; 49069800Stomsoft } 49169800Stomsoft 49269800Stomsoft fprintf(dbg_log, "===== START INODE ALLOCATION MAP =====\n"); 49369800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 49469800Stomsoft indent++; 49569800Stomsoft 49669800Stomsoft cp=(unsigned char *)cg_inosused(cgr); 49769800Stomsoft e=sb->fs_ipg/8; 49869800Stomsoft for(j=0; j<e; j+=32) { 49969800Stomsoft fprintf(dbg_log, "%08x: ", j); 50069800Stomsoft for(k=0; k<32; k+=8) { 50169800Stomsoft if(j+k+8<e) { 50269800Stomsoft fprintf(dbg_log, 50369800Stomsoft "%02x%02x%02x%02x%02x%02x%02x%02x ", 50469800Stomsoft cp[0], cp[1], cp[2], cp[3], 50569800Stomsoft cp[4], cp[5], cp[6], cp[7]); 50669800Stomsoft } else { 50769800Stomsoft for(l=0; (l<8)&&(j+k+l<e); l++) { 50869800Stomsoft fprintf(dbg_log, "%02x", cp[l]); 50969800Stomsoft } 51069800Stomsoft } 51169800Stomsoft cp+=8; 51269800Stomsoft } 51369800Stomsoft fprintf(dbg_log, "\n"); 51469800Stomsoft } 51569800Stomsoft 51669800Stomsoft indent--; 51769800Stomsoft fprintf(dbg_log, "===== END INODE ALLOCATION MAP =====\n"); 51869800Stomsoft 51969800Stomsoft return; 52069800Stomsoft} 52169800Stomsoft 52269800Stomsoft 52369800Stomsoft/* **************************************************** dbg_dump_frmap ***** */ 52469800Stomsoft/* 52569800Stomsoft * Dump the fragment allocation map in one cylinder group. 52669800Stomsoft */ 52769800Stomsoftvoid 52869800Stomsoftdbg_dump_frmap(struct fs *sb, const char *comment, struct cg *cgr) 52969800Stomsoft{ 53069800Stomsoft int j,k,l,e; 53169800Stomsoft unsigned char *cp; 53269800Stomsoft 53369800Stomsoft if(!dbg_log) { 53469800Stomsoft return; 53569800Stomsoft } 53669800Stomsoft 53769800Stomsoft fprintf(dbg_log, "===== START FRAGMENT ALLOCATION MAP =====\n"); 53869800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 53969800Stomsoft indent++; 54069800Stomsoft 54169800Stomsoft cp=(unsigned char *)cg_blksfree(cgr); 542118915Srwatson if (sb->fs_old_nspf) 543118915Srwatson e=howmany((sb->fs_old_cpg * sb->fs_old_spc / sb->fs_old_nspf), CHAR_BIT); 544118915Srwatson else 545118915Srwatson e = 0; 54669800Stomsoft for(j=0; j<e; j+=32) { 54769800Stomsoft fprintf(dbg_log, "%08x: ", j); 54869800Stomsoft for(k=0; k<32; k+=8) { 54969800Stomsoft if(j+k+8<e) { 55069800Stomsoft fprintf(dbg_log, 55169800Stomsoft "%02x%02x%02x%02x%02x%02x%02x%02x ", 55269800Stomsoft cp[0], cp[1], cp[2], cp[3], 55369800Stomsoft cp[4], cp[5], cp[6], cp[7]); 55469800Stomsoft } else { 55569800Stomsoft for(l=0; (l<8)&&(j+k+l<e); l++) { 55669800Stomsoft fprintf(dbg_log, "%02x", cp[l]); 55769800Stomsoft } 55869800Stomsoft } 55969800Stomsoft cp+=8; 56069800Stomsoft } 56169800Stomsoft fprintf(dbg_log, "\n"); 56269800Stomsoft } 56369800Stomsoft 56469800Stomsoft indent--; 56569800Stomsoft fprintf(dbg_log, "===== END FRAGMENT ALLOCATION MAP =====\n"); 56669800Stomsoft 56769800Stomsoft return; 56869800Stomsoft} 56969800Stomsoft 57069800Stomsoft/* **************************************************** dbg_dump_clmap ***** */ 57169800Stomsoft/* 57269800Stomsoft * Dump the cluster allocation map in one cylinder group. 57369800Stomsoft */ 57469800Stomsoftvoid 57569800Stomsoftdbg_dump_clmap(struct fs *sb, const char *comment, struct cg *cgr) 57669800Stomsoft{ 57769800Stomsoft int j,k,l,e; 57869800Stomsoft unsigned char *cp; 57969800Stomsoft 58069800Stomsoft if(!dbg_log) { 58169800Stomsoft return; 58269800Stomsoft } 58369800Stomsoft 58469800Stomsoft fprintf(dbg_log, "===== START CLUSTER ALLOCATION MAP =====\n"); 58569800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 58669800Stomsoft indent++; 58769800Stomsoft 58869800Stomsoft cp=(unsigned char *)cg_clustersfree(cgr); 589118915Srwatson if (sb->fs_old_nspf) 590118915Srwatson e=howmany(sb->fs_old_cpg * sb->fs_old_spc / (sb->fs_old_nspf << sb->fs_fragshift), CHAR_BIT); 591118915Srwatson else 592118915Srwatson e = 0; 59369800Stomsoft for(j=0; j<e; j+=32) { 59469800Stomsoft fprintf(dbg_log, "%08x: ", j); 59569800Stomsoft for(k=0; k<32; k+=8) { 59669800Stomsoft if(j+k+8<e) { 59769800Stomsoft fprintf(dbg_log, 59869800Stomsoft "%02x%02x%02x%02x%02x%02x%02x%02x ", 59969800Stomsoft cp[0], cp[1], cp[2], cp[3], 60069800Stomsoft cp[4], cp[5], cp[6], cp[7]); 60169800Stomsoft } else { 60269800Stomsoft for(l=0; (l<8)&&(j+k+l<e); l++) { 60369800Stomsoft fprintf(dbg_log, "%02x", cp[l]); 60469800Stomsoft } 60569800Stomsoft } 60669800Stomsoft cp+=8; 60769800Stomsoft } 60869800Stomsoft fprintf(dbg_log, "\n"); 60969800Stomsoft } 61069800Stomsoft 61169800Stomsoft indent--; 61269800Stomsoft fprintf(dbg_log, "===== END CLUSTER ALLOCATION MAP =====\n"); 61369800Stomsoft 61469800Stomsoft return; 61569800Stomsoft} 61669800Stomsoft 61769800Stomsoft/* **************************************************** dbg_dump_clsum ***** */ 61869800Stomsoft/* 61969800Stomsoft * Dump the cluster availability summary of one cylinder group. 62069800Stomsoft */ 62169800Stomsoftvoid 62269800Stomsoftdbg_dump_clsum(struct fs *sb, const char *comment, struct cg *cgr) 62369800Stomsoft{ 62469800Stomsoft int j; 62577885Stomsoft int *ip; 62669800Stomsoft 62769800Stomsoft if(!dbg_log) { 62869800Stomsoft return; 62969800Stomsoft } 63069800Stomsoft 63169800Stomsoft fprintf(dbg_log, "===== START CLUSTER SUMMARY =====\n"); 63269800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 63369800Stomsoft indent++; 63469800Stomsoft 63577885Stomsoft ip=(int *)cg_clustersum(cgr); 63669800Stomsoft for(j=0; j<=sb->fs_contigsumsize; j++) { 63777885Stomsoft fprintf(dbg_log, "%02d: %8d\n", j, *ip++); 63869800Stomsoft } 63969800Stomsoft 64069800Stomsoft indent--; 64169800Stomsoft fprintf(dbg_log, "===== END CLUSTER SUMMARY =====\n"); 64269800Stomsoft 64369800Stomsoft return; 64469800Stomsoft} 64569800Stomsoft 646118915Srwatson#ifdef NOT_CURRENTLY 647118915Srwatson/* 648118915Srwatson * This code dates from before the UFS2 integration, and doesn't compile 649118915Srwatson * post-UFS2 due to the use of cg_blks(). I'm not sure how best to update 650118915Srwatson * this for UFS2, where the rotational bits of UFS no longer apply, so 651118915Srwatson * will leave it disabled for now; it should probably be re-enabled 652118915Srwatson * specifically for UFS1. 653118915Srwatson */ 65469800Stomsoft/* **************************************************** dbg_dump_sptbl ***** */ 65569800Stomsoft/* 65669800Stomsoft * Dump the block summary, and the rotational layout table. 65769800Stomsoft */ 65869800Stomsoftvoid 65969800Stomsoftdbg_dump_sptbl(struct fs *sb, const char *comment, struct cg *cgr) 66069800Stomsoft{ 66169800Stomsoft int j,k; 66277885Stomsoft int *ip; 66369800Stomsoft 66469800Stomsoft if(!dbg_log) { 66569800Stomsoft return; 66669800Stomsoft } 66769800Stomsoft 66869800Stomsoft fprintf(dbg_log, 66969800Stomsoft "===== START BLOCK SUMMARY AND POSITION TABLE =====\n"); 67069800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 67169800Stomsoft indent++; 67269800Stomsoft 67377885Stomsoft ip=(int *)cg_blktot(cgr); 674118915Srwatson for(j=0; j<sb->fs_old_cpg; j++) { 67577885Stomsoft fprintf(dbg_log, "%2d: %5d = ", j, *ip++); 676118915Srwatson for(k=0; k<sb->fs_old_nrpos; k++) { 67769800Stomsoft fprintf(dbg_log, "%4d", cg_blks(sb, cgr, j)[k]); 678118915Srwatson if(k<sb->fs_old_nrpos-1) { 67969800Stomsoft fprintf(dbg_log, " + "); 68069800Stomsoft } 68169800Stomsoft } 68269800Stomsoft fprintf(dbg_log, "\n"); 68369800Stomsoft } 68469800Stomsoft 68569800Stomsoft indent--; 68669800Stomsoft fprintf(dbg_log, "===== END BLOCK SUMMARY AND POSITION TABLE =====\n"); 68769800Stomsoft 68869800Stomsoft return; 68969800Stomsoft} 690118915Srwatson#endif 69169800Stomsoft 692118915Srwatson/* ************************************************** dbg_dump_ufs1_ino ***** */ 69369800Stomsoft/* 694118915Srwatson * Dump a UFS1 inode structure. 69569800Stomsoft */ 69669800Stomsoftvoid 697118915Srwatsondbg_dump_ufs1_ino(struct fs *sb, const char *comment, struct ufs1_dinode *ino) 69869800Stomsoft{ 69969800Stomsoft int ictr; 70069800Stomsoft int remaining_blocks; 70169800Stomsoft 70269800Stomsoft if(!dbg_log) { 70369800Stomsoft return; 70469800Stomsoft } 70569800Stomsoft 706118915Srwatson fprintf(dbg_log, "===== START UFS1 INODE DUMP =====\n"); 70769800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment); 70869800Stomsoft indent++; 70969800Stomsoft 71069800Stomsoft fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode); 71169800Stomsoft fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink); 71269800Stomsoft fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n", 71369800Stomsoft ((unsigned int *)&(ino->di_size))[1], 71469800Stomsoft ((unsigned int *)&(ino->di_size))[0]); 71569800Stomsoft fprintf(dbg_log, "atime int32_t 0x%08x\n", ino->di_atime); 71669800Stomsoft fprintf(dbg_log, "atimensec int32_t 0x%08x\n", 71769800Stomsoft ino->di_atimensec); 71869800Stomsoft fprintf(dbg_log, "mtime int32_t 0x%08x\n", 71969800Stomsoft ino->di_mtime); 72069800Stomsoft fprintf(dbg_log, "mtimensec int32_t 0x%08x\n", 72169800Stomsoft ino->di_mtimensec); 72269800Stomsoft fprintf(dbg_log, "ctime int32_t 0x%08x\n", ino->di_ctime); 72369800Stomsoft fprintf(dbg_log, "ctimensec int32_t 0x%08x\n", 72469800Stomsoft ino->di_ctimensec); 72569800Stomsoft 72669800Stomsoft remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */ 72769800Stomsoft for(ictr=0; ictr < MIN(NDADDR, remaining_blocks); ictr++) { 72869800Stomsoft fprintf(dbg_log, "db ufs_daddr_t[%x] 0x%08x\n", ictr, 72969800Stomsoft ino->di_db[ictr]); 73069800Stomsoft } 73169800Stomsoft remaining_blocks-=NDADDR; 73269800Stomsoft if(remaining_blocks>0) { 73369800Stomsoft fprintf(dbg_log, "ib ufs_daddr_t[0] 0x%08x\n", 73469800Stomsoft ino->di_ib[0]); 73569800Stomsoft } 736118915Srwatson remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs1_daddr_t)); 73769800Stomsoft if(remaining_blocks>0) { 73869800Stomsoft fprintf(dbg_log, "ib ufs_daddr_t[1] 0x%08x\n", 73969800Stomsoft ino->di_ib[1]); 74069800Stomsoft } 74169800Stomsoft#define SQUARE(a) ((a)*(a)) 742118915Srwatson remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs1_daddr_t))); 74369800Stomsoft#undef SQUARE 74469800Stomsoft if(remaining_blocks>0) { 74569800Stomsoft fprintf(dbg_log, "ib ufs_daddr_t[2] 0x%08x\n", 74669800Stomsoft ino->di_ib[2]); 74769800Stomsoft } 74869800Stomsoft 74969800Stomsoft fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags); 75069800Stomsoft fprintf(dbg_log, "blocks int32_t 0x%08x\n", ino->di_blocks); 75169800Stomsoft fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen); 75269800Stomsoft fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid); 75369800Stomsoft fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid); 75469800Stomsoft 75569800Stomsoft indent--; 756118915Srwatson fprintf(dbg_log, "===== END UFS1 INODE DUMP =====\n"); 75769800Stomsoft 75869800Stomsoft return; 75969800Stomsoft} 76069800Stomsoft 761118915Srwatson/* ************************************************** dbg_dump_ufs2_ino ***** */ 762118915Srwatson/* 763118915Srwatson * Dump a UFS2 inode structure. 764118915Srwatson */ 765118915Srwatsonvoid 766118915Srwatsondbg_dump_ufs2_ino(struct fs *sb, const char *comment, struct ufs2_dinode *ino) 767118915Srwatson{ 768118915Srwatson int ictr; 769118915Srwatson int remaining_blocks; 770118915Srwatson 771118915Srwatson if(!dbg_log) { 772118915Srwatson return; 773118915Srwatson } 774118915Srwatson 775118915Srwatson fprintf(dbg_log, "===== START UFS2 INODE DUMP =====\n"); 776118915Srwatson fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment); 777118915Srwatson indent++; 778118915Srwatson 779118915Srwatson fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode); 780118915Srwatson fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink); 781118915Srwatson fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid); 782118915Srwatson fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid); 783118915Srwatson fprintf(dbg_log, "blksize u_int32_t 0x%08x\n", ino->di_blksize); 784118915Srwatson fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n", 785118915Srwatson ((unsigned int *)&(ino->di_size))[1], 786118915Srwatson ((unsigned int *)&(ino->di_size))[0]); 787118915Srwatson fprintf(dbg_log, "blocks u_int64_t 0x%08x%08x\n", 788118915Srwatson ((unsigned int *)&(ino->di_blocks))[1], 789118915Srwatson ((unsigned int *)&(ino->di_blocks))[0]); 790127798Sle fprintf(dbg_log, "atime ufs_time_t %10jd\n", ino->di_atime); 791127798Sle fprintf(dbg_log, "mtime ufs_time_t %10jd\n", ino->di_mtime); 792127798Sle fprintf(dbg_log, "ctime ufs_time_t %10jd\n", ino->di_ctime); 793127798Sle fprintf(dbg_log, "birthtime ufs_time_t %10jd\n", ino->di_birthtime); 794118915Srwatson fprintf(dbg_log, "mtimensec int32_t 0x%08x\n", ino->di_mtimensec); 795118915Srwatson fprintf(dbg_log, "atimensec int32_t 0x%08x\n", ino->di_atimensec); 796118915Srwatson fprintf(dbg_log, "ctimensec int32_t 0x%08x\n", ino->di_ctimensec); 797118915Srwatson fprintf(dbg_log, "birthnsec int32_t 0x%08x\n", ino->di_birthnsec); 798118915Srwatson fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen); 799118915Srwatson fprintf(dbg_log, "kernflags u_int32_t 0x%08x\n", ino->di_kernflags); 800118915Srwatson fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags); 801118915Srwatson fprintf(dbg_log, "extsize int32_t 0x%08x\n", ino->di_extsize); 802118915Srwatson 803118915Srwatson /* XXX: What do we do with di_extb[NXADDR]? */ 804118915Srwatson 805118915Srwatson remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */ 806118915Srwatson for(ictr=0; ictr < MIN(NDADDR, remaining_blocks); ictr++) { 807127798Sle fprintf(dbg_log, "db ufs2_daddr_t[%x] 0x%16jx\n", ictr, 808118915Srwatson ino->di_db[ictr]); 809118915Srwatson } 810118915Srwatson remaining_blocks-=NDADDR; 811118915Srwatson if(remaining_blocks>0) { 812127798Sle fprintf(dbg_log, "ib ufs2_daddr_t[0] 0x%16jx\n", 813118915Srwatson ino->di_ib[0]); 814118915Srwatson } 815118915Srwatson remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs2_daddr_t)); 816118915Srwatson if(remaining_blocks>0) { 817127798Sle fprintf(dbg_log, "ib ufs2_daddr_t[1] 0x%16jx\n", 818118915Srwatson ino->di_ib[1]); 819118915Srwatson } 820118915Srwatson#define SQUARE(a) ((a)*(a)) 821118915Srwatson remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs2_daddr_t))); 822118915Srwatson#undef SQUARE 823118915Srwatson if(remaining_blocks>0) { 824127798Sle fprintf(dbg_log, "ib ufs2_daddr_t[2] 0x%16jx\n", 825118915Srwatson ino->di_ib[2]); 826118915Srwatson } 827118915Srwatson 828118915Srwatson indent--; 829118915Srwatson fprintf(dbg_log, "===== END UFS2 INODE DUMP =====\n"); 830118915Srwatson 831118915Srwatson return; 832118915Srwatson} 833118915Srwatson 83469800Stomsoft/* ***************************************************** dbg_dump_iblk ***** */ 83569800Stomsoft/* 83669800Stomsoft * Dump an indirect block. The iteration to dump a full file has to be 83769800Stomsoft * written around. 83869800Stomsoft */ 83969800Stomsoftvoid 84069800Stomsoftdbg_dump_iblk(struct fs *sb, const char *comment, char *block, size_t length) 84169800Stomsoft{ 842127798Sle unsigned int *mem, i, j, size; 84369800Stomsoft 84469800Stomsoft if(!dbg_log) { 84569800Stomsoft return; 84669800Stomsoft } 84769800Stomsoft 84869800Stomsoft fprintf(dbg_log, "===== START INDIRECT BLOCK DUMP =====\n"); 84969800Stomsoft fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)block, 85069800Stomsoft comment); 85169800Stomsoft indent++; 85269800Stomsoft 853118915Srwatson if (sb->fs_magic == FS_UFS1_MAGIC) 854118915Srwatson size = sizeof(ufs1_daddr_t); 855118915Srwatson else 856118915Srwatson size = sizeof(ufs2_daddr_t); 857118915Srwatson 85869800Stomsoft mem=(unsigned int *)block; 859118915Srwatson for (i=0; (size_t)i<MIN(howmany(sb->fs_bsize, size), 86069800Stomsoft length); i+=8) { 86169800Stomsoft fprintf(dbg_log, "%04x: ", i); 86269800Stomsoft for (j=0; j<8; j++) { 86369800Stomsoft if((size_t)(i+j)<length) { 86469800Stomsoft fprintf(dbg_log, "%08X ", *mem++); 86569800Stomsoft } 86669800Stomsoft } 86769800Stomsoft fprintf(dbg_log, "\n"); 86869800Stomsoft } 86969800Stomsoft 87069800Stomsoft indent--; 87169800Stomsoft fprintf(dbg_log, "===== END INDIRECT BLOCK DUMP =====\n"); 87269800Stomsoft 87369800Stomsoft return; 87469800Stomsoft} 87569800Stomsoft 87669800Stomsoft#endif /* FS_DEBUG */ 87769800Stomsoft 878