Module Name: src
Committed By: christos
Date: Sun Oct 27 18:35:52 UTC 2024
Modified Files:
src/usr.sbin/makefs: makefs.8 makefs.c makefs.h
Log Message:
Document debugging options and allow specifying them by name.
To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/makefs/makefs.c
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/makefs/makefs.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.72 src/usr.sbin/makefs/makefs.8:1.73
--- src/usr.sbin/makefs/makefs.8:1.72 Wed May 8 11:57:56 2024
+++ src/usr.sbin/makefs/makefs.8 Sun Oct 27 14:35:52 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: makefs.8,v 1.72 2024/05/08 15:57:56 christos Exp $
+.\" $NetBSD: makefs.8,v 1.73 2024/10/27 18:35:52 christos Exp $
.\"
.\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
.\" All rights reserved.
@@ -33,7 +33,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 8, 2024
+.Dd October 27, 2024
.Dt MAKEFS 8
.Os
.Sh NAME
@@ -102,11 +102,71 @@ An optional
suffix may be provided to indicate that
.Ar free-blocks
indicates a percentage of the calculated image size.
-.It Fl d Ar debug-mask
+.It Fl d Ar debug-mask | comma-separated-debug-option
Enable various levels of debugging, depending upon which bits are
set in
.Ar debug-mask .
-XXX: document these
+The mask can also be set by specifying a comma separated list of debugging
+options.
+These are:
+.Bl -tag -width X -offset indent -compact
+.It Ar debug_time
+Print the time it takes to perform each step.
+.It Ar debug_walk_dir
+Print each directory as it gets processed.
+.It Ar debug_walk_dir_node
+Print each file as it gets processed.
+.It Ar debug_walk_dir_linkcheck
+Print file information for files that have a link count > 1.
+.It Ar debug_dump_fsnodes
+Dump information about the filesystem nodes.
+.It Ar debug_dump_fsnodes_verbose
+Enable more detail if
+.Dv debug_dump_fsnodes
+is enabled.
+.It Ar debug_fs_parse_opts
+Print debugging information about specific filesystem option parsing.
+.It Ar debug_fs_makefs
+Print nodes as they are created and enable buffer consistency checks.
+.It Ar debug_fs_validate
+Enable file-system specific validation (ffs only).
+.It Ar debug_fs_create_image
+Print image file creation stats (ffs only).
+.It Ar debug_fs_size_dir
+Print directory size information (ffs only).
+.It Ar debug_fs_size_dir_node
+Print directory size information per node (ffs only).
+.It Ar debug_fs_size_dir_add_dirent
+Print directory size information as entries are added (ffs only).
+.It Ar debug_fs_populate
+Print information at each directory population pass (ffs only).
+.It Ar debug_fs_populate_dirbuf
+Dump the directory buffer (ffs only).
+.It Ar debug_fs_populate_node
+Print information about each file during directory population (ffs only).
+.It Ar debug_fs_write_file
+Print buffer informaion when writing files (ffs only).
+.It Ar debug_fs_write_file_block
+Print block information when writing files (ffs only).
+.It Ar debug_fs_make_dirbuf
+Print directory buffer information (ffs only).
+.It Ar debug_fs_write_inode
+Print inode information (ffs only).
+.It Ar debug_buf_bread
+Print block buffer information (ffs only).
+.It Ar debug_buf_bwrite
+Print block write information (ffs only).
+.It Ar debug_buf_getblk
+Print block allocaion information (ffs only).
+.It Ar debug_apply_specfile
+Print information about each directory in the specfile.
+.It Ar debug_apply_specentry
+Print information about each entry in the specfile.
+.It Ar debug_apply_speconly
+Debug the
+.Fl x
+special file exclusion.
+.El
.It Fl F Ar mtree-specfile
Use
.Ar mtree-specfile
Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.58 src/usr.sbin/makefs/makefs.c:1.59
--- src/usr.sbin/makefs/makefs.c:1.58 Wed May 8 11:57:56 2024
+++ src/usr.sbin/makefs/makefs.c Sun Oct 27 14:35:52 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: makefs.c,v 1.58 2024/05/08 15:57:56 christos Exp $ */
+/* $NetBSD: makefs.c,v 1.59 2024/10/27 18:35:52 christos Exp $ */
/*
* Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: makefs.c,v 1.58 2024/05/08 15:57:56 christos Exp $");
+__RCSID("$NetBSD: makefs.c,v 1.59 2024/10/27 18:35:52 christos Exp $");
#endif /* !__lint */
#include <assert.h>
@@ -89,9 +89,10 @@ u_int debug;
struct timespec start_time;
struct stat stampst;
-static fstype_t *get_fstype(const char *);
+static fstype_t *get_fstype(const char *);
static int get_tstamp(const char *, struct stat *);
-static void usage(fstype_t *, fsinfo_t *) __dead;
+static void usage(fstype_t *, fsinfo_t *) __dead;
+static u_int parse_debug(char *);
int
main(int argc, char *argv[])
@@ -168,7 +169,7 @@ main(int argc, char *argv[])
break;
case 'd':
- debug = (int)strtoll(optarg, NULL, 0);
+ debug = parse_debug(optarg);
break;
case 'f':
@@ -500,6 +501,13 @@ get_tstamp(const char *b, struct stat *s
return 0;
}
+static struct {
+ const char *n;
+ u_int v;
+} nv[] = {
+ DEBUG_STRINGS
+};
+
static void
usage(fstype_t *fstype, fsinfo_t *fsoptions)
{
@@ -507,13 +515,17 @@ usage(fstype_t *fstype, fsinfo_t *fsopti
prog = getprogname();
fprintf(stderr,
-"Usage: %s [-rxZ] [-B endian] [-b free-blocks] [-d debug-mask]\n"
+"Usage: %s [-rxZ] [-B endian] [-b free-blocks] [-d debug-mask|comma-separated-option]\n"
"\t[-F mtree-specfile] [-f free-files] [-M minimum-size] [-m maximum-size]\n"
"\t[-N userdb-dir] [-O offset] [-o fs-options] [-S sector-size]\n"
"\t[-s image-size] [-T <timestamp/file>] [-t fs-type]"
" image-file directory [extra-directory ...]\n",
prog);
+ fprintf(stderr, "\nDebugging options:\n");
+ for (size_t i = 0; i < __arraycount(nv); i++)
+ fprintf(stderr, "\t0x%8.8x\t%s\n", nv[i].v, nv[i].n);
+
if (fstype) {
size_t i;
option_t *o = fsoptions->fs_options;
@@ -527,3 +539,29 @@ usage(fstype_t *fstype, fsinfo_t *fsopti
}
exit(EXIT_FAILURE);
}
+
+
+static u_int
+parse_debug(char *str)
+{
+ char *ep;
+ u_int d;
+ size_t i;
+
+ errno = 0;
+ d = (u_int)strtoul(str, &ep, 0);
+ if (str != ep && !*ep && errno == 0)
+ return d;
+ d = 0;
+ for (char *a = strtok(str, ","); a != NULL; a = strtok(NULL, ",")) {
+ for (i = 0; i < __arraycount(nv); i++)
+ if (strcmp(nv[i].n, a) == 0) {
+ d |= nv[i].v;
+ break;
+ }
+ if (i == __arraycount(nv))
+ errx(EXIT_FAILURE, "Unknown debug option `%s'", a);
+ }
+ return d;
+}
+
Index: src/usr.sbin/makefs/makefs.h
diff -u src/usr.sbin/makefs/makefs.h:1.42 src/usr.sbin/makefs/makefs.h:1.43
--- src/usr.sbin/makefs/makefs.h:1.42 Mon Jun 17 16:22:20 2024
+++ src/usr.sbin/makefs/makefs.h Sun Oct 27 14:35:52 2024
@@ -240,6 +240,33 @@ extern struct stat stampst;
#define DEBUG_APPLY_SPECENTRY 0x08000000
#define DEBUG_APPLY_SPECONLY 0x10000000
+#define DEBUG_STRINGS \
+ { "time", DEBUG_TIME }, \
+ { "walk_dir", DEBUG_WALK_DIR }, \
+ { "walk_dir_node", DEBUG_WALK_DIR_NODE }, \
+ { "walk_dir_linkcheck", DEBUG_WALK_DIR_LINKCHECK }, \
+ { "dump_fsnodes", DEBUG_DUMP_FSNODES }, \
+ { "dump_fsnodes_verbose", DEBUG_DUMP_FSNODES_VERBOSE }, \
+ { "fs_parse_opts", DEBUG_FS_PARSE_OPTS }, \
+ { "fs_makefs", DEBUG_FS_MAKEFS }, \
+ { "fs_validate", DEBUG_FS_VALIDATE }, \
+ { "fs_create_image", DEBUG_FS_CREATE_IMAGE }, \
+ { "fs_size_dir", DEBUG_FS_SIZE_DIR }, \
+ { "fs_size_dir_node", DEBUG_FS_SIZE_DIR_NODE }, \
+ { "fs_size_dir_add_dirent", DEBUG_FS_SIZE_DIR_ADD_DIRENT }, \
+ { "fs_populate", DEBUG_FS_POPULATE }, \
+ { "fs_populate_dirbuf", DEBUG_FS_POPULATE_DIRBUF }, \
+ { "fs_populate_node", DEBUG_FS_POPULATE_NODE }, \
+ { "fs_write_file", DEBUG_FS_WRITE_FILE }, \
+ { "fs_write_file_block", DEBUG_FS_WRITE_FILE_BLOCK }, \
+ { "fs_make_dirbuf", DEBUG_FS_MAKE_DIRBUF }, \
+ { "fs_write_inode", DEBUG_FS_WRITE_INODE }, \
+ { "buf_bread", DEBUG_BUF_BREAD }, \
+ { "buf_bwrite", DEBUG_BUF_BWRITE }, \
+ { "buf_getblk", DEBUG_BUF_GETBLK }, \
+ { "apply_specfile", DEBUG_APPLY_SPECFILE }, \
+ { "apply_specentry", DEBUG_APPLY_SPECENTRY }, \
+ { "apply_speconly", DEBUG_APPLY_SPECONLY },
#define TIMER_START(x) \
if (debug & DEBUG_TIME) \