1df57947fSPedro F. Giffuni /*- 2df57947fSPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 3df57947fSPedro F. Giffuni * 43d500078SThomas-Henning von Kamptz * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz 53d500078SThomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. 63d500078SThomas-Henning von Kamptz * All rights reserved. 73d500078SThomas-Henning von Kamptz * 83d500078SThomas-Henning von Kamptz * This code is derived from software contributed to Berkeley by 93d500078SThomas-Henning von Kamptz * Christoph Herrmann and Thomas-Henning von Kamptz, Munich and Frankfurt. 103d500078SThomas-Henning von Kamptz * 113d500078SThomas-Henning von Kamptz * Redistribution and use in source and binary forms, with or without 123d500078SThomas-Henning von Kamptz * modification, are permitted provided that the following conditions 133d500078SThomas-Henning von Kamptz * are met: 143d500078SThomas-Henning von Kamptz * 1. Redistributions of source code must retain the above copyright 153d500078SThomas-Henning von Kamptz * notice, this list of conditions and the following disclaimer. 163d500078SThomas-Henning von Kamptz * 2. Redistributions in binary form must reproduce the above copyright 173d500078SThomas-Henning von Kamptz * notice, this list of conditions and the following disclaimer in the 183d500078SThomas-Henning von Kamptz * documentation and/or other materials provided with the distribution. 193d500078SThomas-Henning von Kamptz * 3. All advertising materials mentioning features or use of this software 203d500078SThomas-Henning von Kamptz * must display the following acknowledgment: 213d500078SThomas-Henning von Kamptz * This product includes software developed by the University of 223d500078SThomas-Henning von Kamptz * California, Berkeley and its contributors, as well as Christoph 233d500078SThomas-Henning von Kamptz * Herrmann and Thomas-Henning von Kamptz. 243d500078SThomas-Henning von Kamptz * 4. Neither the name of the University nor the names of its contributors 253d500078SThomas-Henning von Kamptz * may be used to endorse or promote products derived from this software 263d500078SThomas-Henning von Kamptz * without specific prior written permission. 273d500078SThomas-Henning von Kamptz * 283d500078SThomas-Henning von Kamptz * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 293d500078SThomas-Henning von Kamptz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 303d500078SThomas-Henning von Kamptz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 313d500078SThomas-Henning von Kamptz * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 323d500078SThomas-Henning von Kamptz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 333d500078SThomas-Henning von Kamptz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 343d500078SThomas-Henning von Kamptz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 353d500078SThomas-Henning von Kamptz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 363d500078SThomas-Henning von Kamptz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 373d500078SThomas-Henning von Kamptz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 383d500078SThomas-Henning von Kamptz * SUCH DAMAGE. 393d500078SThomas-Henning von Kamptz * 404020c5bcSThomas-Henning von Kamptz * $TSHeader: src/sbin/growfs/debug.c,v 1.3 2000/12/12 19:31:00 tomsoft Exp $ 413d500078SThomas-Henning von Kamptz * 423d500078SThomas-Henning von Kamptz */ 433d500078SThomas-Henning von Kamptz 443d500078SThomas-Henning von Kamptz #include <sys/param.h> 453d500078SThomas-Henning von Kamptz 4689fdc4e1SMike Barcroft #include <limits.h> 473d500078SThomas-Henning von Kamptz #include <stdio.h> 4875d1ec91SLukas Ertl #include <string.h> 493d500078SThomas-Henning von Kamptz #include <ufs/ufs/dinode.h> 503d500078SThomas-Henning von Kamptz #include <ufs/ffs/fs.h> 513d500078SThomas-Henning von Kamptz 523d500078SThomas-Henning von Kamptz #include "debug.h" 533d500078SThomas-Henning von Kamptz 543d500078SThomas-Henning von Kamptz #ifdef FS_DEBUG 553d500078SThomas-Henning von Kamptz 563d500078SThomas-Henning von Kamptz static FILE *dbg_log = NULL; 573d500078SThomas-Henning von Kamptz static unsigned int indent = 0; 583d500078SThomas-Henning von Kamptz 593d500078SThomas-Henning von Kamptz /* 60*b00271ceSHUANG,YU-JIA * prototypes are not done here, as they come with debug.h 613d500078SThomas-Henning von Kamptz */ 623d500078SThomas-Henning von Kamptz 633d500078SThomas-Henning von Kamptz /* 643d500078SThomas-Henning von Kamptz * Open the filehandle where all debug output has to go. 653d500078SThomas-Henning von Kamptz */ 663d500078SThomas-Henning von Kamptz void 673d500078SThomas-Henning von Kamptz dbg_open(const char *fn) 683d500078SThomas-Henning von Kamptz { 693d500078SThomas-Henning von Kamptz 70b819704fSRobert Watson if (strcmp(fn, "-") == 0) 71b819704fSRobert Watson dbg_log = fopen("/dev/stdout", "a"); 72b819704fSRobert Watson else 733d500078SThomas-Henning von Kamptz dbg_log = fopen(fn, "a"); 743d500078SThomas-Henning von Kamptz 753d500078SThomas-Henning von Kamptz return; 763d500078SThomas-Henning von Kamptz } 773d500078SThomas-Henning von Kamptz 783d500078SThomas-Henning von Kamptz /* 793d500078SThomas-Henning von Kamptz * Close the filehandle where all debug output went to. 803d500078SThomas-Henning von Kamptz */ 813d500078SThomas-Henning von Kamptz void 823d500078SThomas-Henning von Kamptz dbg_close(void) 833d500078SThomas-Henning von Kamptz { 843d500078SThomas-Henning von Kamptz 853d500078SThomas-Henning von Kamptz if (dbg_log) { 863d500078SThomas-Henning von Kamptz fclose(dbg_log); 873d500078SThomas-Henning von Kamptz dbg_log = NULL; 883d500078SThomas-Henning von Kamptz } 893d500078SThomas-Henning von Kamptz 903d500078SThomas-Henning von Kamptz return; 913d500078SThomas-Henning von Kamptz } 923d500078SThomas-Henning von Kamptz 933d500078SThomas-Henning von Kamptz /* 943d500078SThomas-Henning von Kamptz * Dump out a full file system block in hex. 953d500078SThomas-Henning von Kamptz */ 963d500078SThomas-Henning von Kamptz void 973d500078SThomas-Henning von Kamptz dbg_dump_hex(struct fs *sb, const char *comment, unsigned char *mem) 983d500078SThomas-Henning von Kamptz { 993d500078SThomas-Henning von Kamptz int i, j, k; 1003d500078SThomas-Henning von Kamptz 101a1da0740SEdward Tomasz Napierala if (!dbg_log) 1023d500078SThomas-Henning von Kamptz return; 103a1da0740SEdward Tomasz Napierala 1043d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== START HEXDUMP =====\n"); 1053d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)mem, comment); 1063d500078SThomas-Henning von Kamptz indent++; 1073d500078SThomas-Henning von Kamptz for (i = 0; i < sb->fs_bsize; i += 24) { 1083d500078SThomas-Henning von Kamptz for (j = 0; j < 3; j++) { 109a1da0740SEdward Tomasz Napierala for (k = 0; k < 8; k++) 1103d500078SThomas-Henning von Kamptz fprintf(dbg_log, "%02x ", *mem++); 1113d500078SThomas-Henning von Kamptz fprintf(dbg_log, " "); 1123d500078SThomas-Henning von Kamptz } 1133d500078SThomas-Henning von Kamptz fprintf(dbg_log, "\n"); 1143d500078SThomas-Henning von Kamptz } 1153d500078SThomas-Henning von Kamptz indent--; 1163d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== END HEXDUMP =====\n"); 1173d500078SThomas-Henning von Kamptz 1183d500078SThomas-Henning von Kamptz return; 1193d500078SThomas-Henning von Kamptz } 1203d500078SThomas-Henning von Kamptz 1213d500078SThomas-Henning von Kamptz /* 1223d500078SThomas-Henning von Kamptz * Dump the superblock. 1233d500078SThomas-Henning von Kamptz */ 1243d500078SThomas-Henning von Kamptz void 1253d500078SThomas-Henning von Kamptz dbg_dump_fs(struct fs *sb, const char *comment) 1263d500078SThomas-Henning von Kamptz { 1273d500078SThomas-Henning von Kamptz int j; 1283d500078SThomas-Henning von Kamptz 129a1da0740SEdward Tomasz Napierala if (!dbg_log) 1303d500078SThomas-Henning von Kamptz return; 1313d500078SThomas-Henning von Kamptz 1323d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== START SUPERBLOCK =====\n"); 1333d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)sb, comment); 1343d500078SThomas-Henning von Kamptz indent++; 1353d500078SThomas-Henning von Kamptz 1360b22953bSRobert Watson fprintf(dbg_log, "sblkno int32_t 0x%08x\n", 1373d500078SThomas-Henning von Kamptz sb->fs_sblkno); 1380b22953bSRobert Watson fprintf(dbg_log, "cblkno int32_t 0x%08x\n", 1393d500078SThomas-Henning von Kamptz sb->fs_cblkno); 1400b22953bSRobert Watson fprintf(dbg_log, "iblkno int32_t 0x%08x\n", 1413d500078SThomas-Henning von Kamptz sb->fs_iblkno); 1420b22953bSRobert Watson fprintf(dbg_log, "dblkno int32_t 0x%08x\n", 1433d500078SThomas-Henning von Kamptz sb->fs_dblkno); 1443d500078SThomas-Henning von Kamptz 1450b22953bSRobert Watson fprintf(dbg_log, "old_cgoffset int32_t 0x%08x\n", 1460b22953bSRobert Watson sb->fs_old_cgoffset); 1470b22953bSRobert Watson fprintf(dbg_log, "old_cgmask int32_t 0x%08x\n", 1480b22953bSRobert Watson sb->fs_old_cgmask); 1490b22953bSRobert Watson fprintf(dbg_log, "old_time int32_t %10u\n", 1500b22953bSRobert Watson (unsigned int)sb->fs_old_time); 1510b22953bSRobert Watson fprintf(dbg_log, "old_size int32_t 0x%08x\n", 1520b22953bSRobert Watson sb->fs_old_size); 1530b22953bSRobert Watson fprintf(dbg_log, "old_dsize int32_t 0x%08x\n", 1540b22953bSRobert Watson sb->fs_old_dsize); 1553d500078SThomas-Henning von Kamptz fprintf(dbg_log, "ncg int32_t 0x%08x\n", 1563d500078SThomas-Henning von Kamptz sb->fs_ncg); 1573d500078SThomas-Henning von Kamptz fprintf(dbg_log, "bsize int32_t 0x%08x\n", 1583d500078SThomas-Henning von Kamptz sb->fs_bsize); 1593d500078SThomas-Henning von Kamptz fprintf(dbg_log, "fsize int32_t 0x%08x\n", 1603d500078SThomas-Henning von Kamptz sb->fs_fsize); 1613d500078SThomas-Henning von Kamptz fprintf(dbg_log, "frag int32_t 0x%08x\n", 1623d500078SThomas-Henning von Kamptz sb->fs_frag); 1633d500078SThomas-Henning von Kamptz 1643d500078SThomas-Henning von Kamptz fprintf(dbg_log, "minfree int32_t 0x%08x\n", 1653d500078SThomas-Henning von Kamptz sb->fs_minfree); 1660b22953bSRobert Watson fprintf(dbg_log, "old_rotdelay int32_t 0x%08x\n", 1670b22953bSRobert Watson sb->fs_old_rotdelay); 1680b22953bSRobert Watson fprintf(dbg_log, "old_rps int32_t 0x%08x\n", 1690b22953bSRobert Watson sb->fs_old_rps); 1703d500078SThomas-Henning von Kamptz 1713d500078SThomas-Henning von Kamptz fprintf(dbg_log, "bmask int32_t 0x%08x\n", 1723d500078SThomas-Henning von Kamptz sb->fs_bmask); 1733d500078SThomas-Henning von Kamptz fprintf(dbg_log, "fmask int32_t 0x%08x\n", 1743d500078SThomas-Henning von Kamptz sb->fs_fmask); 1753d500078SThomas-Henning von Kamptz fprintf(dbg_log, "bshift int32_t 0x%08x\n", 1763d500078SThomas-Henning von Kamptz sb->fs_bshift); 1773d500078SThomas-Henning von Kamptz fprintf(dbg_log, "fshift int32_t 0x%08x\n", 1783d500078SThomas-Henning von Kamptz sb->fs_fshift); 1793d500078SThomas-Henning von Kamptz 1803d500078SThomas-Henning von Kamptz fprintf(dbg_log, "maxcontig int32_t 0x%08x\n", 1813d500078SThomas-Henning von Kamptz sb->fs_maxcontig); 1823d500078SThomas-Henning von Kamptz fprintf(dbg_log, "maxbpg int32_t 0x%08x\n", 1833d500078SThomas-Henning von Kamptz sb->fs_maxbpg); 1843d500078SThomas-Henning von Kamptz 1853d500078SThomas-Henning von Kamptz fprintf(dbg_log, "fragshift int32_t 0x%08x\n", 1863d500078SThomas-Henning von Kamptz sb->fs_fragshift); 1873d500078SThomas-Henning von Kamptz fprintf(dbg_log, "fsbtodb int32_t 0x%08x\n", 1883d500078SThomas-Henning von Kamptz sb->fs_fsbtodb); 1893d500078SThomas-Henning von Kamptz fprintf(dbg_log, "sbsize int32_t 0x%08x\n", 1903d500078SThomas-Henning von Kamptz sb->fs_sbsize); 1910b22953bSRobert Watson fprintf(dbg_log, "spare1 int32_t[2] 0x%08x 0x%08x\n", 1920b22953bSRobert Watson sb->fs_spare1[0], sb->fs_spare1[1]); 1933d500078SThomas-Henning von Kamptz fprintf(dbg_log, "nindir int32_t 0x%08x\n", 1943d500078SThomas-Henning von Kamptz sb->fs_nindir); 1953d500078SThomas-Henning von Kamptz fprintf(dbg_log, "inopb int32_t 0x%08x\n", 1963d500078SThomas-Henning von Kamptz sb->fs_inopb); 1970b22953bSRobert Watson fprintf(dbg_log, "old_nspf int32_t 0x%08x\n", 1980b22953bSRobert Watson sb->fs_old_nspf); 1993d500078SThomas-Henning von Kamptz 2003d500078SThomas-Henning von Kamptz fprintf(dbg_log, "optim int32_t 0x%08x\n", 2013d500078SThomas-Henning von Kamptz sb->fs_optim); 2023d500078SThomas-Henning von Kamptz 2030b22953bSRobert Watson fprintf(dbg_log, "old_npsect int32_t 0x%08x\n", 2040b22953bSRobert Watson sb->fs_old_npsect); 2050b22953bSRobert Watson fprintf(dbg_log, "old_interleave int32_t 0x%08x\n", 2060b22953bSRobert Watson sb->fs_old_interleave); 2070b22953bSRobert Watson fprintf(dbg_log, "old_trackskew int32_t 0x%08x\n", 2080b22953bSRobert Watson sb->fs_old_trackskew); 2093d500078SThomas-Henning von Kamptz 2100b22953bSRobert Watson fprintf(dbg_log, "id int32_t[2] 0x%08x 0x%08x\n", 2113d500078SThomas-Henning von Kamptz sb->fs_id[0], sb->fs_id[1]); 2123d500078SThomas-Henning von Kamptz 2130b22953bSRobert Watson fprintf(dbg_log, "old_csaddr int32_t 0x%08x\n", 2140b22953bSRobert Watson sb->fs_old_csaddr); 2153d500078SThomas-Henning von Kamptz fprintf(dbg_log, "cssize int32_t 0x%08x\n", 2163d500078SThomas-Henning von Kamptz sb->fs_cssize); 2173d500078SThomas-Henning von Kamptz fprintf(dbg_log, "cgsize int32_t 0x%08x\n", 2183d500078SThomas-Henning von Kamptz sb->fs_cgsize); 2193d500078SThomas-Henning von Kamptz 2200b22953bSRobert Watson fprintf(dbg_log, "spare2 int32_t 0x%08x\n", 2210b22953bSRobert Watson sb->fs_spare2); 2220b22953bSRobert Watson fprintf(dbg_log, "old_nsect int32_t 0x%08x\n", 2230b22953bSRobert Watson sb->fs_old_nsect); 2240b22953bSRobert Watson fprintf(dbg_log, "old_spc int32_t 0x%08x\n", 2250b22953bSRobert Watson sb->fs_old_spc); 2263d500078SThomas-Henning von Kamptz 2270b22953bSRobert Watson fprintf(dbg_log, "old_ncyl int32_t 0x%08x\n", 2280b22953bSRobert Watson sb->fs_old_ncyl); 2293d500078SThomas-Henning von Kamptz 2300b22953bSRobert Watson fprintf(dbg_log, "old_cpg int32_t 0x%08x\n", 2310b22953bSRobert Watson sb->fs_old_cpg); 2323d500078SThomas-Henning von Kamptz fprintf(dbg_log, "ipg int32_t 0x%08x\n", 2333d500078SThomas-Henning von Kamptz sb->fs_ipg); 2343d500078SThomas-Henning von Kamptz fprintf(dbg_log, "fpg int32_t 0x%08x\n", 2353d500078SThomas-Henning von Kamptz sb->fs_fpg); 2363d500078SThomas-Henning von Kamptz 2370b22953bSRobert Watson dbg_dump_csum("internal old_cstotal", &sb->fs_old_cstotal); 2383d500078SThomas-Henning von Kamptz 2393d500078SThomas-Henning von Kamptz fprintf(dbg_log, "fmod int8_t 0x%02x\n", 2403d500078SThomas-Henning von Kamptz sb->fs_fmod); 2413d500078SThomas-Henning von Kamptz fprintf(dbg_log, "clean int8_t 0x%02x\n", 2423d500078SThomas-Henning von Kamptz sb->fs_clean); 2433d500078SThomas-Henning von Kamptz fprintf(dbg_log, "ronly int8_t 0x%02x\n", 2443d500078SThomas-Henning von Kamptz sb->fs_ronly); 2450b22953bSRobert Watson fprintf(dbg_log, "old_flags int8_t 0x%02x\n", 2460b22953bSRobert Watson sb->fs_old_flags); 2473d500078SThomas-Henning von Kamptz fprintf(dbg_log, "fsmnt u_char[MAXMNTLEN] \"%s\"\n", 2483d500078SThomas-Henning von Kamptz sb->fs_fsmnt); 2490b22953bSRobert Watson fprintf(dbg_log, "volname u_char[MAXVOLLEN] \"%s\"\n", 2500b22953bSRobert Watson sb->fs_volname); 2510b22953bSRobert Watson fprintf(dbg_log, "swuid u_int64_t 0x%08x%08x\n", 2520b22953bSRobert Watson ((unsigned int *)&(sb->fs_swuid))[1], 2530b22953bSRobert Watson ((unsigned int *)&(sb->fs_swuid))[0]); 2540b22953bSRobert Watson 2550b22953bSRobert Watson fprintf(dbg_log, "pad int32_t 0x%08x\n", 2560b22953bSRobert Watson sb->fs_pad); 2573d500078SThomas-Henning von Kamptz 2583d500078SThomas-Henning von Kamptz fprintf(dbg_log, "cgrotor int32_t 0x%08x\n", 2593d500078SThomas-Henning von Kamptz sb->fs_cgrotor); 2603d500078SThomas-Henning von Kamptz /* 2613d500078SThomas-Henning von Kamptz * struct csum[MAXCSBUFS] - is only maintained in memory 2623d500078SThomas-Henning von Kamptz */ 2633d500078SThomas-Henning von Kamptz /* fprintf(dbg_log, " int32_t\n", sb->*fs_maxcluster);*/ 2640b22953bSRobert Watson fprintf(dbg_log, "old_cpc int32_t 0x%08x\n", 2650b22953bSRobert Watson sb->fs_old_cpc); 2663d500078SThomas-Henning von Kamptz /* 2673d500078SThomas-Henning von Kamptz * int16_t fs_opostbl[16][8] - is dumped when used in dbg_dump_sptbl 2683d500078SThomas-Henning von Kamptz */ 2690b22953bSRobert Watson fprintf(dbg_log, "maxbsize int32_t 0x%08x\n", 2700b22953bSRobert Watson sb->fs_maxbsize); 2711161d420SRebecca Cran fprintf(dbg_log, "unrefs int64_t 0x%08jx\n", 2725a9dc069SPawel Jakub Dawidek sb->fs_unrefs); 2730b22953bSRobert Watson fprintf(dbg_log, "sblockloc int64_t 0x%08x%08x\n", 2740b22953bSRobert Watson ((unsigned int *)&(sb->fs_sblockloc))[1], 2750b22953bSRobert Watson ((unsigned int *)&(sb->fs_sblockloc))[0]); 2760b22953bSRobert Watson 2770b22953bSRobert Watson dbg_dump_csum_total("internal cstotal", &sb->fs_cstotal); 2780b22953bSRobert Watson 2790b22953bSRobert Watson fprintf(dbg_log, "time ufs_time_t %10u\n", 2800b22953bSRobert Watson (unsigned int)sb->fs_time); 2810b22953bSRobert Watson 2820b22953bSRobert Watson fprintf(dbg_log, "size int64_t 0x%08x%08x\n", 2830b22953bSRobert Watson ((unsigned int *)&(sb->fs_size))[1], 2840b22953bSRobert Watson ((unsigned int *)&(sb->fs_size))[0]); 2850b22953bSRobert Watson fprintf(dbg_log, "dsize int64_t 0x%08x%08x\n", 2860b22953bSRobert Watson ((unsigned int *)&(sb->fs_dsize))[1], 2870b22953bSRobert Watson ((unsigned int *)&(sb->fs_dsize))[0]); 2880b22953bSRobert Watson fprintf(dbg_log, "csaddr ufs2_daddr_t 0x%08x%08x\n", 2890b22953bSRobert Watson ((unsigned int *)&(sb->fs_csaddr))[1], 2900b22953bSRobert Watson ((unsigned int *)&(sb->fs_csaddr))[0]); 2910b22953bSRobert Watson fprintf(dbg_log, "pendingblocks int64_t 0x%08x%08x\n", 2920b22953bSRobert Watson ((unsigned int *)&(sb->fs_pendingblocks))[1], 2930b22953bSRobert Watson ((unsigned int *)&(sb->fs_pendingblocks))[0]); 2940b22953bSRobert Watson fprintf(dbg_log, "pendinginodes int32_t 0x%08x\n", 2950b22953bSRobert Watson sb->fs_pendinginodes); 2960b22953bSRobert Watson 2973d500078SThomas-Henning von Kamptz for (j = 0; j < FSMAXSNAP; j++) { 2983d500078SThomas-Henning von Kamptz fprintf(dbg_log, "snapinum int32_t[%2d] 0x%08x\n", 2993d500078SThomas-Henning von Kamptz j, sb->fs_snapinum[j]); 3003d500078SThomas-Henning von Kamptz if (!sb->fs_snapinum[j]) { /* list is dense */ 3013d500078SThomas-Henning von Kamptz break; 3023d500078SThomas-Henning von Kamptz } 3033d500078SThomas-Henning von Kamptz } 3040b22953bSRobert Watson fprintf(dbg_log, "avgfilesize int32_t 0x%08x\n", 3050b22953bSRobert Watson sb->fs_avgfilesize); 3060b22953bSRobert Watson fprintf(dbg_log, "avgfpdir int32_t 0x%08x\n", 3070b22953bSRobert Watson sb->fs_avgfpdir); 3080b22953bSRobert Watson fprintf(dbg_log, "flags int32_t 0x%08x\n", 3090b22953bSRobert Watson sb->fs_flags); 3103d500078SThomas-Henning von Kamptz fprintf(dbg_log, "contigsumsize int32_t 0x%08x\n", 3113d500078SThomas-Henning von Kamptz sb->fs_contigsumsize); 3123d500078SThomas-Henning von Kamptz fprintf(dbg_log, "maxsymlinklen int32_t 0x%08x\n", 3133d500078SThomas-Henning von Kamptz sb->fs_maxsymlinklen); 3140b22953bSRobert Watson fprintf(dbg_log, "old_inodefmt int32_t 0x%08x\n", 3150b22953bSRobert Watson sb->fs_old_inodefmt); 3163d500078SThomas-Henning von Kamptz fprintf(dbg_log, "maxfilesize u_int64_t 0x%08x%08x\n", 3173d500078SThomas-Henning von Kamptz ((unsigned int *)&(sb->fs_maxfilesize))[1], 3183d500078SThomas-Henning von Kamptz ((unsigned int *)&(sb->fs_maxfilesize))[0]); 3193d500078SThomas-Henning von Kamptz fprintf(dbg_log, "qbmask int64_t 0x%08x%08x\n", 3203d500078SThomas-Henning von Kamptz ((unsigned int *)&(sb->fs_qbmask))[1], 3213d500078SThomas-Henning von Kamptz ((unsigned int *)&(sb->fs_qbmask))[0]); 3223d500078SThomas-Henning von Kamptz fprintf(dbg_log, "qfmask int64_t 0x%08x%08x\n", 3233d500078SThomas-Henning von Kamptz ((unsigned int *)&(sb->fs_qfmask))[1], 3243d500078SThomas-Henning von Kamptz ((unsigned int *)&(sb->fs_qfmask))[0]); 3253d500078SThomas-Henning von Kamptz fprintf(dbg_log, "state int32_t 0x%08x\n", 3263d500078SThomas-Henning von Kamptz sb->fs_state); 3270b22953bSRobert Watson fprintf(dbg_log, "old_postblformat int32_t 0x%08x\n", 3280b22953bSRobert Watson sb->fs_old_postblformat); 3290b22953bSRobert Watson fprintf(dbg_log, "old_nrpos int32_t 0x%08x\n", 3300b22953bSRobert Watson sb->fs_old_nrpos); 3310b22953bSRobert Watson fprintf(dbg_log, "spare5 int32_t[2] 0x%08x 0x%08x\n", 3320b22953bSRobert Watson sb->fs_spare5[0], sb->fs_spare5[1]); 3333d500078SThomas-Henning von Kamptz fprintf(dbg_log, "magic int32_t 0x%08x\n", 3343d500078SThomas-Henning von Kamptz sb->fs_magic); 3353d500078SThomas-Henning von Kamptz 3363d500078SThomas-Henning von Kamptz indent--; 3373d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== END SUPERBLOCK =====\n"); 3383d500078SThomas-Henning von Kamptz 3393d500078SThomas-Henning von Kamptz return; 3403d500078SThomas-Henning von Kamptz } 3413d500078SThomas-Henning von Kamptz 3423d500078SThomas-Henning von Kamptz /* 3433d500078SThomas-Henning von Kamptz * Dump a cylinder group. 3443d500078SThomas-Henning von Kamptz */ 3453d500078SThomas-Henning von Kamptz void 3463d500078SThomas-Henning von Kamptz dbg_dump_cg(const char *comment, struct cg *cgr) 3473d500078SThomas-Henning von Kamptz { 3483d500078SThomas-Henning von Kamptz int j; 3493d500078SThomas-Henning von Kamptz 350a1da0740SEdward Tomasz Napierala if (!dbg_log) 3513d500078SThomas-Henning von Kamptz return; 3523d500078SThomas-Henning von Kamptz 3533d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== START CYLINDER GROUP =====\n"); 3543d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 3553d500078SThomas-Henning von Kamptz indent++; 3563d500078SThomas-Henning von Kamptz 3573d500078SThomas-Henning von Kamptz fprintf(dbg_log, "magic int32_t 0x%08x\n", cgr->cg_magic); 3580b22953bSRobert Watson fprintf(dbg_log, "old_time int32_t 0x%08x\n", cgr->cg_old_time); 3593d500078SThomas-Henning von Kamptz fprintf(dbg_log, "cgx int32_t 0x%08x\n", cgr->cg_cgx); 3600b22953bSRobert Watson fprintf(dbg_log, "old_ncyl int16_t 0x%04x\n", cgr->cg_old_ncyl); 3610b22953bSRobert Watson fprintf(dbg_log, "old_niblk int16_t 0x%04x\n", cgr->cg_old_niblk); 3623d500078SThomas-Henning von Kamptz fprintf(dbg_log, "ndblk int32_t 0x%08x\n", cgr->cg_ndblk); 3633d500078SThomas-Henning von Kamptz dbg_dump_csum("internal cs", &cgr->cg_cs); 3643d500078SThomas-Henning von Kamptz fprintf(dbg_log, "rotor int32_t 0x%08x\n", cgr->cg_rotor); 3653d500078SThomas-Henning von Kamptz fprintf(dbg_log, "frotor int32_t 0x%08x\n", cgr->cg_frotor); 3663d500078SThomas-Henning von Kamptz fprintf(dbg_log, "irotor int32_t 0x%08x\n", cgr->cg_irotor); 3673d500078SThomas-Henning von Kamptz for (j = 0; j < MAXFRAG; j++) { 3683d500078SThomas-Henning von Kamptz fprintf(dbg_log, "frsum int32_t[%d] 0x%08x\n", j, 3693d500078SThomas-Henning von Kamptz cgr->cg_frsum[j]); 3703d500078SThomas-Henning von Kamptz } 3710b22953bSRobert Watson fprintf(dbg_log, "old_btotoff int32_t 0x%08x\n", cgr->cg_old_btotoff); 3720b22953bSRobert Watson fprintf(dbg_log, "old_boff int32_t 0x%08x\n", cgr->cg_old_boff); 3733d500078SThomas-Henning von Kamptz fprintf(dbg_log, "iusedoff int32_t 0x%08x\n", cgr->cg_iusedoff); 3743d500078SThomas-Henning von Kamptz fprintf(dbg_log, "freeoff int32_t 0x%08x\n", cgr->cg_freeoff); 3753d500078SThomas-Henning von Kamptz fprintf(dbg_log, "nextfreeoff int32_t 0x%08x\n", 3763d500078SThomas-Henning von Kamptz cgr->cg_nextfreeoff); 3773d500078SThomas-Henning von Kamptz fprintf(dbg_log, "clustersumoff int32_t 0x%08x\n", 3783d500078SThomas-Henning von Kamptz cgr->cg_clustersumoff); 3790b22953bSRobert Watson fprintf(dbg_log, "clusteroff int32_t 0x%08x\n", 3803d500078SThomas-Henning von Kamptz cgr->cg_clusteroff); 3813d500078SThomas-Henning von Kamptz fprintf(dbg_log, "nclusterblks int32_t 0x%08x\n", 3823d500078SThomas-Henning von Kamptz cgr->cg_nclusterblks); 3830b22953bSRobert Watson fprintf(dbg_log, "niblk int32_t 0x%08x\n", cgr->cg_niblk); 3840b22953bSRobert Watson fprintf(dbg_log, "initediblk int32_t 0x%08x\n", cgr->cg_initediblk); 3855a9dc069SPawel Jakub Dawidek fprintf(dbg_log, "unrefs int32_t 0x%08x\n", cgr->cg_unrefs); 3860b22953bSRobert Watson fprintf(dbg_log, "time ufs_time_t %10u\n", 3870b22953bSRobert Watson (unsigned int)cgr->cg_initediblk); 3883d500078SThomas-Henning von Kamptz 3893d500078SThomas-Henning von Kamptz indent--; 3903d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== END CYLINDER GROUP =====\n"); 3913d500078SThomas-Henning von Kamptz 3923d500078SThomas-Henning von Kamptz return; 3933d500078SThomas-Henning von Kamptz } 3943d500078SThomas-Henning von Kamptz 3953d500078SThomas-Henning von Kamptz /* 3963d500078SThomas-Henning von Kamptz * Dump a cylinder summary. 3973d500078SThomas-Henning von Kamptz */ 3983d500078SThomas-Henning von Kamptz void 3993d500078SThomas-Henning von Kamptz dbg_dump_csum(const char *comment, struct csum *cs) 4003d500078SThomas-Henning von Kamptz { 4013d500078SThomas-Henning von Kamptz 402a1da0740SEdward Tomasz Napierala if (!dbg_log) 4033d500078SThomas-Henning von Kamptz return; 4043d500078SThomas-Henning von Kamptz 4053d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== START CYLINDER SUMMARY =====\n"); 4063d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment); 4073d500078SThomas-Henning von Kamptz indent++; 4083d500078SThomas-Henning von Kamptz 4093d500078SThomas-Henning von Kamptz fprintf(dbg_log, "ndir int32_t 0x%08x\n", cs->cs_ndir); 4103d500078SThomas-Henning von Kamptz fprintf(dbg_log, "nbfree int32_t 0x%08x\n", cs->cs_nbfree); 4113d500078SThomas-Henning von Kamptz fprintf(dbg_log, "nifree int32_t 0x%08x\n", cs->cs_nifree); 4123d500078SThomas-Henning von Kamptz fprintf(dbg_log, "nffree int32_t 0x%08x\n", cs->cs_nffree); 4133d500078SThomas-Henning von Kamptz 4143d500078SThomas-Henning von Kamptz indent--; 4153d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== END CYLINDER SUMMARY =====\n"); 4163d500078SThomas-Henning von Kamptz 4173d500078SThomas-Henning von Kamptz return; 4183d500078SThomas-Henning von Kamptz } 4193d500078SThomas-Henning von Kamptz 4200b22953bSRobert Watson /* 4210b22953bSRobert Watson * Dump a cylinder summary. 4220b22953bSRobert Watson */ 4230b22953bSRobert Watson void 4240b22953bSRobert Watson dbg_dump_csum_total(const char *comment, struct csum_total *cs) 4250b22953bSRobert Watson { 4260b22953bSRobert Watson 427a1da0740SEdward Tomasz Napierala if (!dbg_log) 4280b22953bSRobert Watson return; 4290b22953bSRobert Watson 4300b22953bSRobert Watson fprintf(dbg_log, "===== START CYLINDER SUMMARY TOTAL =====\n"); 4310b22953bSRobert Watson fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment); 4320b22953bSRobert Watson indent++; 4330b22953bSRobert Watson 4340b22953bSRobert Watson fprintf(dbg_log, "ndir int64_t 0x%08x%08x\n", 4350b22953bSRobert Watson ((unsigned int *)&(cs->cs_ndir))[1], 4360b22953bSRobert Watson ((unsigned int *)&(cs->cs_ndir))[0]); 4370b22953bSRobert Watson fprintf(dbg_log, "nbfree int64_t 0x%08x%08x\n", 4380b22953bSRobert Watson ((unsigned int *)&(cs->cs_nbfree))[1], 4390b22953bSRobert Watson ((unsigned int *)&(cs->cs_nbfree))[0]); 4400b22953bSRobert Watson fprintf(dbg_log, "nifree int64_t 0x%08x%08x\n", 4410b22953bSRobert Watson ((unsigned int *)&(cs->cs_nifree))[1], 4420b22953bSRobert Watson ((unsigned int *)&(cs->cs_nifree))[0]); 4430b22953bSRobert Watson fprintf(dbg_log, "nffree int64_t 0x%08x%08x\n", 4440b22953bSRobert Watson ((unsigned int *)&(cs->cs_nffree))[1], 4450b22953bSRobert Watson ((unsigned int *)&(cs->cs_nffree))[0]); 4460b22953bSRobert Watson fprintf(dbg_log, "numclusters int64_t 0x%08x%08x\n", 4470b22953bSRobert Watson ((unsigned int *)&(cs->cs_numclusters))[1], 4480b22953bSRobert Watson ((unsigned int *)&(cs->cs_numclusters))[0]); 4490b22953bSRobert Watson 4500b22953bSRobert Watson indent--; 4510b22953bSRobert Watson fprintf(dbg_log, "===== END CYLINDER SUMMARY TOTAL =====\n"); 4520b22953bSRobert Watson 4530b22953bSRobert Watson return; 4540b22953bSRobert Watson } 4553d500078SThomas-Henning von Kamptz /* 4563d500078SThomas-Henning von Kamptz * Dump the inode allocation map in one cylinder group. 4573d500078SThomas-Henning von Kamptz */ 4583d500078SThomas-Henning von Kamptz void 4593d500078SThomas-Henning von Kamptz dbg_dump_inmap(struct fs *sb, const char *comment, struct cg *cgr) 4603d500078SThomas-Henning von Kamptz { 4613d500078SThomas-Henning von Kamptz int j,k,l,e; 4623d500078SThomas-Henning von Kamptz unsigned char *cp; 4633d500078SThomas-Henning von Kamptz 464a1da0740SEdward Tomasz Napierala if (!dbg_log) 4653d500078SThomas-Henning von Kamptz return; 4663d500078SThomas-Henning von Kamptz 4673d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== START INODE ALLOCATION MAP =====\n"); 4683d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 4693d500078SThomas-Henning von Kamptz indent++; 4703d500078SThomas-Henning von Kamptz 4713d500078SThomas-Henning von Kamptz cp = (unsigned char *)cg_inosused(cgr); 4723d500078SThomas-Henning von Kamptz e = sb->fs_ipg / 8; 4733d500078SThomas-Henning von Kamptz for (j = 0; j < e; j += 32) { 4743d500078SThomas-Henning von Kamptz fprintf(dbg_log, "%08x: ", j); 4753d500078SThomas-Henning von Kamptz for (k = 0; k < 32; k += 8) { 4763d500078SThomas-Henning von Kamptz if (j + k + 8 < e) { 4773d500078SThomas-Henning von Kamptz fprintf(dbg_log, 4783d500078SThomas-Henning von Kamptz "%02x%02x%02x%02x%02x%02x%02x%02x ", 4793d500078SThomas-Henning von Kamptz cp[0], cp[1], cp[2], cp[3], 4803d500078SThomas-Henning von Kamptz cp[4], cp[5], cp[6], cp[7]); 4813d500078SThomas-Henning von Kamptz } else { 4823d500078SThomas-Henning von Kamptz for (l = 0; (l < 8) && (j + k + l < e); l++) { 4833d500078SThomas-Henning von Kamptz fprintf(dbg_log, "%02x", cp[l]); 4843d500078SThomas-Henning von Kamptz } 4853d500078SThomas-Henning von Kamptz } 4863d500078SThomas-Henning von Kamptz cp += 8; 4873d500078SThomas-Henning von Kamptz } 4883d500078SThomas-Henning von Kamptz fprintf(dbg_log, "\n"); 4893d500078SThomas-Henning von Kamptz } 4903d500078SThomas-Henning von Kamptz 4913d500078SThomas-Henning von Kamptz indent--; 4923d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== END INODE ALLOCATION MAP =====\n"); 4933d500078SThomas-Henning von Kamptz 4943d500078SThomas-Henning von Kamptz return; 4953d500078SThomas-Henning von Kamptz } 4963d500078SThomas-Henning von Kamptz 4973d500078SThomas-Henning von Kamptz 4983d500078SThomas-Henning von Kamptz /* 4993d500078SThomas-Henning von Kamptz * Dump the fragment allocation map in one cylinder group. 5003d500078SThomas-Henning von Kamptz */ 5013d500078SThomas-Henning von Kamptz void 5023d500078SThomas-Henning von Kamptz dbg_dump_frmap(struct fs *sb, const char *comment, struct cg *cgr) 5033d500078SThomas-Henning von Kamptz { 5043d500078SThomas-Henning von Kamptz int j,k,l,e; 5053d500078SThomas-Henning von Kamptz unsigned char *cp; 5063d500078SThomas-Henning von Kamptz 507a1da0740SEdward Tomasz Napierala if (!dbg_log) 5083d500078SThomas-Henning von Kamptz return; 5093d500078SThomas-Henning von Kamptz 5103d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== START FRAGMENT ALLOCATION MAP =====\n"); 5113d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 5123d500078SThomas-Henning von Kamptz indent++; 5133d500078SThomas-Henning von Kamptz 5143d500078SThomas-Henning von Kamptz cp = (unsigned char *)cg_blksfree(cgr); 5150b22953bSRobert Watson if (sb->fs_old_nspf) 51631271717SPedro F. Giffuni e = howmany(sb->fs_old_cpg * sb->fs_old_spc / sb->fs_old_nspf, 51731271717SPedro F. Giffuni CHAR_BIT); 5180b22953bSRobert Watson else 5190b22953bSRobert Watson e = 0; 5203d500078SThomas-Henning von Kamptz for (j = 0; j < e; j += 32) { 5213d500078SThomas-Henning von Kamptz fprintf(dbg_log, "%08x: ", j); 5223d500078SThomas-Henning von Kamptz for (k = 0; k < 32; k += 8) { 5233d500078SThomas-Henning von Kamptz if (j + k + 8 <e) { 5243d500078SThomas-Henning von Kamptz fprintf(dbg_log, 5253d500078SThomas-Henning von Kamptz "%02x%02x%02x%02x%02x%02x%02x%02x ", 5263d500078SThomas-Henning von Kamptz cp[0], cp[1], cp[2], cp[3], 5273d500078SThomas-Henning von Kamptz cp[4], cp[5], cp[6], cp[7]); 5283d500078SThomas-Henning von Kamptz } else { 5293d500078SThomas-Henning von Kamptz for (l = 0; (l < 8) && (j + k + l < e); l++) { 5303d500078SThomas-Henning von Kamptz fprintf(dbg_log, "%02x", cp[l]); 5313d500078SThomas-Henning von Kamptz } 5323d500078SThomas-Henning von Kamptz } 5333d500078SThomas-Henning von Kamptz cp += 8; 5343d500078SThomas-Henning von Kamptz } 5353d500078SThomas-Henning von Kamptz fprintf(dbg_log, "\n"); 5363d500078SThomas-Henning von Kamptz } 5373d500078SThomas-Henning von Kamptz 5383d500078SThomas-Henning von Kamptz indent--; 5393d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== END FRAGMENT ALLOCATION MAP =====\n"); 5403d500078SThomas-Henning von Kamptz 5413d500078SThomas-Henning von Kamptz return; 5423d500078SThomas-Henning von Kamptz } 5433d500078SThomas-Henning von Kamptz 5443d500078SThomas-Henning von Kamptz /* 5453d500078SThomas-Henning von Kamptz * Dump the cluster allocation map in one cylinder group. 5463d500078SThomas-Henning von Kamptz */ 5473d500078SThomas-Henning von Kamptz void 5483d500078SThomas-Henning von Kamptz dbg_dump_clmap(struct fs *sb, const char *comment, struct cg *cgr) 5493d500078SThomas-Henning von Kamptz { 5503d500078SThomas-Henning von Kamptz int j,k,l,e; 5513d500078SThomas-Henning von Kamptz unsigned char *cp; 5523d500078SThomas-Henning von Kamptz 553a1da0740SEdward Tomasz Napierala if (!dbg_log) 5543d500078SThomas-Henning von Kamptz return; 5553d500078SThomas-Henning von Kamptz 5563d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== START CLUSTER ALLOCATION MAP =====\n"); 5573d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 5583d500078SThomas-Henning von Kamptz indent++; 5593d500078SThomas-Henning von Kamptz 5603d500078SThomas-Henning von Kamptz cp = (unsigned char *)cg_clustersfree(cgr); 5610b22953bSRobert Watson if (sb->fs_old_nspf) 5620b22953bSRobert Watson e = howmany(sb->fs_old_cpg * sb->fs_old_spc / (sb->fs_old_nspf << sb->fs_fragshift), CHAR_BIT); 5630b22953bSRobert Watson else 5640b22953bSRobert Watson e = 0; 5653d500078SThomas-Henning von Kamptz for (j = 0; j < e; j += 32) { 5663d500078SThomas-Henning von Kamptz fprintf(dbg_log, "%08x: ", j); 5673d500078SThomas-Henning von Kamptz for (k = 0; k < 32; k += 8) { 5683d500078SThomas-Henning von Kamptz if (j + k + 8 < e) { 5693d500078SThomas-Henning von Kamptz fprintf(dbg_log, 5703d500078SThomas-Henning von Kamptz "%02x%02x%02x%02x%02x%02x%02x%02x ", 5713d500078SThomas-Henning von Kamptz cp[0], cp[1], cp[2], cp[3], 5723d500078SThomas-Henning von Kamptz cp[4], cp[5], cp[6], cp[7]); 5733d500078SThomas-Henning von Kamptz } else { 5743d500078SThomas-Henning von Kamptz for (l = 0; (l < 8) && (j + k + l <e); l++) { 5753d500078SThomas-Henning von Kamptz fprintf(dbg_log, "%02x", cp[l]); 5763d500078SThomas-Henning von Kamptz } 5773d500078SThomas-Henning von Kamptz } 5783d500078SThomas-Henning von Kamptz cp += 8; 5793d500078SThomas-Henning von Kamptz } 5803d500078SThomas-Henning von Kamptz fprintf(dbg_log, "\n"); 5813d500078SThomas-Henning von Kamptz } 5823d500078SThomas-Henning von Kamptz 5833d500078SThomas-Henning von Kamptz indent--; 5843d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== END CLUSTER ALLOCATION MAP =====\n"); 5853d500078SThomas-Henning von Kamptz 5863d500078SThomas-Henning von Kamptz return; 5873d500078SThomas-Henning von Kamptz } 5883d500078SThomas-Henning von Kamptz 5893d500078SThomas-Henning von Kamptz /* 5903d500078SThomas-Henning von Kamptz * Dump the cluster availability summary of one cylinder group. 5913d500078SThomas-Henning von Kamptz */ 5923d500078SThomas-Henning von Kamptz void 5933d500078SThomas-Henning von Kamptz dbg_dump_clsum(struct fs *sb, const char *comment, struct cg *cgr) 5943d500078SThomas-Henning von Kamptz { 5953d500078SThomas-Henning von Kamptz int j; 596adcaff07SThomas-Henning von Kamptz int *ip; 5973d500078SThomas-Henning von Kamptz 598a1da0740SEdward Tomasz Napierala if (!dbg_log) 5993d500078SThomas-Henning von Kamptz return; 6003d500078SThomas-Henning von Kamptz 6013d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== START CLUSTER SUMMARY =====\n"); 6023d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 6033d500078SThomas-Henning von Kamptz indent++; 6043d500078SThomas-Henning von Kamptz 605adcaff07SThomas-Henning von Kamptz ip = (int *)cg_clustersum(cgr); 6063d500078SThomas-Henning von Kamptz for (j = 0; j <= sb->fs_contigsumsize; j++) { 607adcaff07SThomas-Henning von Kamptz fprintf(dbg_log, "%02d: %8d\n", j, *ip++); 6083d500078SThomas-Henning von Kamptz } 6093d500078SThomas-Henning von Kamptz 6103d500078SThomas-Henning von Kamptz indent--; 6113d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== END CLUSTER SUMMARY =====\n"); 6123d500078SThomas-Henning von Kamptz 6133d500078SThomas-Henning von Kamptz return; 6143d500078SThomas-Henning von Kamptz } 6153d500078SThomas-Henning von Kamptz 6160b22953bSRobert Watson #ifdef NOT_CURRENTLY 6170b22953bSRobert Watson /* 6180b22953bSRobert Watson * This code dates from before the UFS2 integration, and doesn't compile 6190b22953bSRobert Watson * post-UFS2 due to the use of cg_blks(). I'm not sure how best to update 6200b22953bSRobert Watson * this for UFS2, where the rotational bits of UFS no longer apply, so 6210b22953bSRobert Watson * will leave it disabled for now; it should probably be re-enabled 6220b22953bSRobert Watson * specifically for UFS1. 6230b22953bSRobert Watson */ 6243d500078SThomas-Henning von Kamptz /* 6253d500078SThomas-Henning von Kamptz * Dump the block summary, and the rotational layout table. 6263d500078SThomas-Henning von Kamptz */ 6273d500078SThomas-Henning von Kamptz void 6283d500078SThomas-Henning von Kamptz dbg_dump_sptbl(struct fs *sb, const char *comment, struct cg *cgr) 6293d500078SThomas-Henning von Kamptz { 6303d500078SThomas-Henning von Kamptz int j,k; 631adcaff07SThomas-Henning von Kamptz int *ip; 6323d500078SThomas-Henning von Kamptz 633a1da0740SEdward Tomasz Napierala if (!dbg_log) 6343d500078SThomas-Henning von Kamptz return; 6353d500078SThomas-Henning von Kamptz 6363d500078SThomas-Henning von Kamptz fprintf(dbg_log, 6373d500078SThomas-Henning von Kamptz "===== START BLOCK SUMMARY AND POSITION TABLE =====\n"); 6383d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 6393d500078SThomas-Henning von Kamptz indent++; 6403d500078SThomas-Henning von Kamptz 641adcaff07SThomas-Henning von Kamptz ip = (int *)cg_blktot(cgr); 6420b22953bSRobert Watson for (j = 0; j < sb->fs_old_cpg; j++) { 643adcaff07SThomas-Henning von Kamptz fprintf(dbg_log, "%2d: %5d = ", j, *ip++); 6440b22953bSRobert Watson for (k = 0; k < sb->fs_old_nrpos; k++) { 6453d500078SThomas-Henning von Kamptz fprintf(dbg_log, "%4d", cg_blks(sb, cgr, j)[k]); 646a1da0740SEdward Tomasz Napierala if (k < sb->fs_old_nrpos - 1) 6473d500078SThomas-Henning von Kamptz fprintf(dbg_log, " + "); 6483d500078SThomas-Henning von Kamptz } 6493d500078SThomas-Henning von Kamptz fprintf(dbg_log, "\n"); 6503d500078SThomas-Henning von Kamptz } 6513d500078SThomas-Henning von Kamptz 6523d500078SThomas-Henning von Kamptz indent--; 6533d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== END BLOCK SUMMARY AND POSITION TABLE =====\n"); 6543d500078SThomas-Henning von Kamptz 6553d500078SThomas-Henning von Kamptz return; 6563d500078SThomas-Henning von Kamptz } 6570b22953bSRobert Watson #endif 6583d500078SThomas-Henning von Kamptz 6593d500078SThomas-Henning von Kamptz /* 6600b22953bSRobert Watson * Dump a UFS1 inode structure. 6613d500078SThomas-Henning von Kamptz */ 6623d500078SThomas-Henning von Kamptz void 6630b22953bSRobert Watson dbg_dump_ufs1_ino(struct fs *sb, const char *comment, struct ufs1_dinode *ino) 6643d500078SThomas-Henning von Kamptz { 6653d500078SThomas-Henning von Kamptz int ictr; 6663d500078SThomas-Henning von Kamptz int remaining_blocks; 6673d500078SThomas-Henning von Kamptz 668a1da0740SEdward Tomasz Napierala if (!dbg_log) 6693d500078SThomas-Henning von Kamptz return; 6703d500078SThomas-Henning von Kamptz 6710b22953bSRobert Watson fprintf(dbg_log, "===== START UFS1 INODE DUMP =====\n"); 6723d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment); 6733d500078SThomas-Henning von Kamptz indent++; 6743d500078SThomas-Henning von Kamptz 6753d500078SThomas-Henning von Kamptz fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode); 6763d500078SThomas-Henning von Kamptz fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink); 6773d500078SThomas-Henning von Kamptz fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n", 6783d500078SThomas-Henning von Kamptz ((unsigned int *)&(ino->di_size))[1], 6793d500078SThomas-Henning von Kamptz ((unsigned int *)&(ino->di_size))[0]); 6803d500078SThomas-Henning von Kamptz fprintf(dbg_log, "atime int32_t 0x%08x\n", ino->di_atime); 6813d500078SThomas-Henning von Kamptz fprintf(dbg_log, "atimensec int32_t 0x%08x\n", 6823d500078SThomas-Henning von Kamptz ino->di_atimensec); 6833d500078SThomas-Henning von Kamptz fprintf(dbg_log, "mtime int32_t 0x%08x\n", 6843d500078SThomas-Henning von Kamptz ino->di_mtime); 6853d500078SThomas-Henning von Kamptz fprintf(dbg_log, "mtimensec int32_t 0x%08x\n", 6863d500078SThomas-Henning von Kamptz ino->di_mtimensec); 6873d500078SThomas-Henning von Kamptz fprintf(dbg_log, "ctime int32_t 0x%08x\n", ino->di_ctime); 6883d500078SThomas-Henning von Kamptz fprintf(dbg_log, "ctimensec int32_t 0x%08x\n", 6893d500078SThomas-Henning von Kamptz ino->di_ctimensec); 6903d500078SThomas-Henning von Kamptz 6913d500078SThomas-Henning von Kamptz remaining_blocks = howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */ 6921dc349abSEd Maste for (ictr = 0; ictr < MIN(UFS_NDADDR, remaining_blocks); ictr++) { 6933d500078SThomas-Henning von Kamptz fprintf(dbg_log, "db ufs_daddr_t[%x] 0x%08x\n", ictr, 6943d500078SThomas-Henning von Kamptz ino->di_db[ictr]); 6953d500078SThomas-Henning von Kamptz } 6961dc349abSEd Maste remaining_blocks -= UFS_NDADDR; 6973d500078SThomas-Henning von Kamptz if (remaining_blocks > 0) { 6983d500078SThomas-Henning von Kamptz fprintf(dbg_log, "ib ufs_daddr_t[0] 0x%08x\n", 6993d500078SThomas-Henning von Kamptz ino->di_ib[0]); 7003d500078SThomas-Henning von Kamptz } 7010b22953bSRobert Watson remaining_blocks -= howmany(sb->fs_bsize, sizeof(ufs1_daddr_t)); 7023d500078SThomas-Henning von Kamptz if (remaining_blocks > 0) { 7033d500078SThomas-Henning von Kamptz fprintf(dbg_log, "ib ufs_daddr_t[1] 0x%08x\n", 7043d500078SThomas-Henning von Kamptz ino->di_ib[1]); 7053d500078SThomas-Henning von Kamptz } 7063d500078SThomas-Henning von Kamptz #define SQUARE(a) ((a) * (a)) 7070b22953bSRobert Watson remaining_blocks -= SQUARE(howmany(sb->fs_bsize, sizeof(ufs1_daddr_t))); 7083d500078SThomas-Henning von Kamptz #undef SQUARE 7093d500078SThomas-Henning von Kamptz if (remaining_blocks > 0) { 7103d500078SThomas-Henning von Kamptz fprintf(dbg_log, "ib ufs_daddr_t[2] 0x%08x\n", 7113d500078SThomas-Henning von Kamptz ino->di_ib[2]); 7123d500078SThomas-Henning von Kamptz } 7133d500078SThomas-Henning von Kamptz 7143d500078SThomas-Henning von Kamptz fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags); 7153d500078SThomas-Henning von Kamptz fprintf(dbg_log, "blocks int32_t 0x%08x\n", ino->di_blocks); 7163d500078SThomas-Henning von Kamptz fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen); 7173d500078SThomas-Henning von Kamptz fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid); 7183d500078SThomas-Henning von Kamptz fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid); 7193d500078SThomas-Henning von Kamptz 7203d500078SThomas-Henning von Kamptz indent--; 7210b22953bSRobert Watson fprintf(dbg_log, "===== END UFS1 INODE DUMP =====\n"); 7220b22953bSRobert Watson 7230b22953bSRobert Watson return; 7240b22953bSRobert Watson } 7250b22953bSRobert Watson 7260b22953bSRobert Watson /* 7270b22953bSRobert Watson * Dump a UFS2 inode structure. 7280b22953bSRobert Watson */ 7290b22953bSRobert Watson void 7300b22953bSRobert Watson dbg_dump_ufs2_ino(struct fs *sb, const char *comment, struct ufs2_dinode *ino) 7310b22953bSRobert Watson { 7320b22953bSRobert Watson int ictr; 7330b22953bSRobert Watson int remaining_blocks; 7340b22953bSRobert Watson 735a1da0740SEdward Tomasz Napierala if (!dbg_log) 7360b22953bSRobert Watson return; 7370b22953bSRobert Watson 7380b22953bSRobert Watson fprintf(dbg_log, "===== START UFS2 INODE DUMP =====\n"); 7390b22953bSRobert Watson fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment); 7400b22953bSRobert Watson indent++; 7410b22953bSRobert Watson 7420b22953bSRobert Watson fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode); 7430b22953bSRobert Watson fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink); 7440b22953bSRobert Watson fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid); 7450b22953bSRobert Watson fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid); 7460b22953bSRobert Watson fprintf(dbg_log, "blksize u_int32_t 0x%08x\n", ino->di_blksize); 7470b22953bSRobert Watson fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n", 7480b22953bSRobert Watson ((unsigned int *)&(ino->di_size))[1], 7490b22953bSRobert Watson ((unsigned int *)&(ino->di_size))[0]); 7500b22953bSRobert Watson fprintf(dbg_log, "blocks u_int64_t 0x%08x%08x\n", 7510b22953bSRobert Watson ((unsigned int *)&(ino->di_blocks))[1], 7520b22953bSRobert Watson ((unsigned int *)&(ino->di_blocks))[0]); 75375d1ec91SLukas Ertl fprintf(dbg_log, "atime ufs_time_t %10jd\n", ino->di_atime); 75475d1ec91SLukas Ertl fprintf(dbg_log, "mtime ufs_time_t %10jd\n", ino->di_mtime); 75575d1ec91SLukas Ertl fprintf(dbg_log, "ctime ufs_time_t %10jd\n", ino->di_ctime); 75675d1ec91SLukas Ertl fprintf(dbg_log, "birthtime ufs_time_t %10jd\n", ino->di_birthtime); 7570b22953bSRobert Watson fprintf(dbg_log, "mtimensec int32_t 0x%08x\n", ino->di_mtimensec); 7580b22953bSRobert Watson fprintf(dbg_log, "atimensec int32_t 0x%08x\n", ino->di_atimensec); 7590b22953bSRobert Watson fprintf(dbg_log, "ctimensec int32_t 0x%08x\n", ino->di_ctimensec); 7600b22953bSRobert Watson fprintf(dbg_log, "birthnsec int32_t 0x%08x\n", ino->di_birthnsec); 7610b22953bSRobert Watson fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen); 7620b22953bSRobert Watson fprintf(dbg_log, "kernflags u_int32_t 0x%08x\n", ino->di_kernflags); 7630b22953bSRobert Watson fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags); 7644b367145SPedro F. Giffuni fprintf(dbg_log, "extsize u_int32_t 0x%08x\n", ino->di_extsize); 7650b22953bSRobert Watson 7661dc349abSEd Maste /* XXX: What do we do with di_extb[UFS_NXADDR]? */ 7670b22953bSRobert Watson 7680b22953bSRobert Watson remaining_blocks = howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */ 7691dc349abSEd Maste for (ictr = 0; ictr < MIN(UFS_NDADDR, remaining_blocks); ictr++) { 77075d1ec91SLukas Ertl fprintf(dbg_log, "db ufs2_daddr_t[%x] 0x%16jx\n", ictr, 7710b22953bSRobert Watson ino->di_db[ictr]); 7720b22953bSRobert Watson } 7731dc349abSEd Maste remaining_blocks -= UFS_NDADDR; 7740b22953bSRobert Watson if (remaining_blocks > 0) { 77575d1ec91SLukas Ertl fprintf(dbg_log, "ib ufs2_daddr_t[0] 0x%16jx\n", 7760b22953bSRobert Watson ino->di_ib[0]); 7770b22953bSRobert Watson } 7780b22953bSRobert Watson remaining_blocks -= howmany(sb->fs_bsize, sizeof(ufs2_daddr_t)); 7790b22953bSRobert Watson if (remaining_blocks > 0) { 78075d1ec91SLukas Ertl fprintf(dbg_log, "ib ufs2_daddr_t[1] 0x%16jx\n", 7810b22953bSRobert Watson ino->di_ib[1]); 7820b22953bSRobert Watson } 7830b22953bSRobert Watson #define SQUARE(a) ((a) * (a)) 7840b22953bSRobert Watson remaining_blocks -= SQUARE(howmany(sb->fs_bsize, sizeof(ufs2_daddr_t))); 7850b22953bSRobert Watson #undef SQUARE 7860b22953bSRobert Watson if (remaining_blocks > 0) { 78775d1ec91SLukas Ertl fprintf(dbg_log, "ib ufs2_daddr_t[2] 0x%16jx\n", 7880b22953bSRobert Watson ino->di_ib[2]); 7890b22953bSRobert Watson } 7900b22953bSRobert Watson 7910b22953bSRobert Watson indent--; 7920b22953bSRobert Watson fprintf(dbg_log, "===== END UFS2 INODE DUMP =====\n"); 7933d500078SThomas-Henning von Kamptz 7943d500078SThomas-Henning von Kamptz return; 7953d500078SThomas-Henning von Kamptz } 7963d500078SThomas-Henning von Kamptz 7973d500078SThomas-Henning von Kamptz /* 7983d500078SThomas-Henning von Kamptz * Dump an indirect block. The iteration to dump a full file has to be 7993d500078SThomas-Henning von Kamptz * written around. 8003d500078SThomas-Henning von Kamptz */ 8013d500078SThomas-Henning von Kamptz void 8023d500078SThomas-Henning von Kamptz dbg_dump_iblk(struct fs *sb, const char *comment, char *block, size_t length) 8033d500078SThomas-Henning von Kamptz { 80475d1ec91SLukas Ertl unsigned int *mem, i, j, size; 8053d500078SThomas-Henning von Kamptz 806a1da0740SEdward Tomasz Napierala if (!dbg_log) 8073d500078SThomas-Henning von Kamptz return; 8083d500078SThomas-Henning von Kamptz 8093d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== START INDIRECT BLOCK DUMP =====\n"); 8103d500078SThomas-Henning von Kamptz fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)block, 8113d500078SThomas-Henning von Kamptz comment); 8123d500078SThomas-Henning von Kamptz indent++; 8133d500078SThomas-Henning von Kamptz 8140b22953bSRobert Watson if (sb->fs_magic == FS_UFS1_MAGIC) 8150b22953bSRobert Watson size = sizeof(ufs1_daddr_t); 8160b22953bSRobert Watson else 8170b22953bSRobert Watson size = sizeof(ufs2_daddr_t); 8180b22953bSRobert Watson 8193d500078SThomas-Henning von Kamptz mem = (unsigned int *)block; 820a1da0740SEdward Tomasz Napierala for (i = 0; (size_t)i < MIN(howmany(sb->fs_bsize, size), length); 821a1da0740SEdward Tomasz Napierala i += 8) { 8223d500078SThomas-Henning von Kamptz fprintf(dbg_log, "%04x: ", i); 8233d500078SThomas-Henning von Kamptz for (j = 0; j < 8; j++) { 824a1da0740SEdward Tomasz Napierala if ((size_t)(i + j) < length) 8253d500078SThomas-Henning von Kamptz fprintf(dbg_log, "%08X ", *mem++); 8263d500078SThomas-Henning von Kamptz } 8273d500078SThomas-Henning von Kamptz fprintf(dbg_log, "\n"); 8283d500078SThomas-Henning von Kamptz } 8293d500078SThomas-Henning von Kamptz 8303d500078SThomas-Henning von Kamptz indent--; 8313d500078SThomas-Henning von Kamptz fprintf(dbg_log, "===== END INDIRECT BLOCK DUMP =====\n"); 8323d500078SThomas-Henning von Kamptz 8333d500078SThomas-Henning von Kamptz return; 8343d500078SThomas-Henning von Kamptz } 8353d500078SThomas-Henning von Kamptz 8363d500078SThomas-Henning von Kamptz #endif /* FS_DEBUG */ 8373d500078SThomas-Henning von Kamptz 838