From 10e7d5c15fa8e8618bdc117d498276e78d9a570d Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 25 May 2007 13:33:22 +0200 Subject: [PATCH] mount: use verbose mode instead debug mode The patch: commit 61d9d2ff1cb0e28e2b88099bbc5b919fa5004fce Date: Wed Dec 27 23:35:56 2006 +0100 added debug mode to the mount command. It was mistake. It's better to use old verbose mode instead a new debug mode. This patch transform all staff from debug mode to to verbose mode. Signed-off-by: Karel Zak --- mount/mount.c | 48 +++++++++++++++++---------------- mount/sundries.h | 18 ------------- tests/expected/ts-mount-paths | 16 ++++++----- tests/expected/ts-mount-special | 28 ++++++++++--------- tests/ts-mount-paths | 2 +- tests/ts-mount-special | 2 +- 6 files changed, 51 insertions(+), 63 deletions(-) diff --git a/mount/mount.c b/mount/mount.c index 50576ee2..3ebf4db7 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -52,10 +52,6 @@ /* Quiet mode */ int mount_quiet = 0; -/* Debug mode (level) */ -int mount_debug = 0; - - /* True for fake mount (-f). */ static int fake = 0; @@ -583,8 +579,9 @@ do_mount_syscall (struct mountargs *args) { if ((flags & MS_MGC_MSK) == 0) flags |= MS_MGC_VAL; - mnt_debug(1, "mount(2) syscall: source: \"%s\", target: \"%s\", " - "filesystemtype: \"%s\", mountflags: %lu, data: %s", + if (verbose > 2) + printf("mount: mount(2) syscall: source: \"%s\", target: \"%s\", " + "filesystemtype: \"%s\", mountflags: %d, data: %s\n", args->spec, args->node, args->type, flags, (char *) args->data); ret = mount (args->spec, args->node, args->type, flags, args->data); @@ -612,6 +609,8 @@ check_special_mountprog(const char *spec, const char *node, const char *type, in if (type && strlen(type) < 100) { sprintf(mountprog, "/sbin/mount.%s", type); if (stat(mountprog, &statbuf) == 0) { + if (verbose) + fflush(stdout); res = fork(); if (res == 0) { char *oo, *mountargs[10]; @@ -637,11 +636,14 @@ check_special_mountprog(const char *spec, const char *node, const char *type, in } mountargs[i] = NULL; /* 10 */ - i = 0; - while(mount_debug && mountargs[i]) { - mnt_debug(1, "external mount: argv[%d] = \"%s\"", - i, mountargs[i]); - i++; + if (verbose > 2) { + i = 0; + while(verbose > 2 && mountargs[i]) { + printf("mount: external mount: argv[%d] = \"%s\"\n", + i, mountargs[i]); + i++; + } + fflush(stdout); } execv(mountprog, mountargs); @@ -968,10 +970,12 @@ try_mount_one (const char *spec0, const char *node0, const char *types0, /* copies for freeing on exit */ const char *opts1, *spec1, *node1, *types1, *extra_opts1; - mnt_debug(1, "spec: \"%s\"", spec0); - mnt_debug(1, "node: \"%s\"", node0); - mnt_debug(1, "types: \"%s\"", types0); - mnt_debug(1, "opts: \"%s\"", opts0); + if (verbose > 2) { + printf("mount: spec: \"%s\"\n", spec0); + printf("mount: node: \"%s\"\n", node0); + printf("mount: types: \"%s\"\n", types0); + printf("mount: opts: \"%s\"\n", opts0); + } spec = spec1 = xstrdup(spec0); node = node1 = xstrdup(node0); @@ -1561,7 +1565,6 @@ do_mount_all (char *types, char *options, char *test_opts) { static struct option longopts[] = { { "all", 0, 0, 'a' }, - { "debug", 1, 0, 'd' }, { "fake", 0, 0, 'f' }, { "fork", 0, 0, 'F' }, { "help", 0, 0, 'h' }, @@ -1680,15 +1683,12 @@ main(int argc, char *argv[]) { initproctitle(argc, argv); #endif - while ((c = getopt_long (argc, argv, "ad:fFhilL:no:O:p:rsU:vVwt:", + while ((c = getopt_long (argc, argv, "afFhilL:no:O:p:rsU:vVwt:", longopts, NULL)) != -1) { switch (c) { case 'a': /* mount everything in fstab */ ++mount_all; break; - case 'd': - mount_debug = atoi(optarg); - break; case 'f': /* fake: don't actually call mount(2) */ ++fake; break; @@ -1816,9 +1816,11 @@ main(int argc, char *argv[]) { } } - mnt_debug(2, "fstab path: \"%s\"", _PATH_FSTAB); - mnt_debug(2, "lock path: \"%s\"", MOUNTED_LOCK); - mnt_debug(2, "temp path: \"%s\"", MOUNTED_TEMP); + if (verbose > 2) { + printf("mount: fstab path: \"%s\"\n", _PATH_FSTAB); + printf("mount: lock path: \"%s\"\n", MOUNTED_LOCK); + printf("mount: temp path: \"%s\"\n", MOUNTED_TEMP); + } argc -= optind; argv += optind; diff --git a/mount/sundries.h b/mount/sundries.h index 85ccd85f..95d4bea7 100644 --- a/mount/sundries.h +++ b/mount/sundries.h @@ -17,7 +17,6 @@ #endif extern int mount_quiet; -extern int mount_debug; extern int verbose; extern int sloppy; @@ -50,22 +49,5 @@ void die (int errcode, const char *fmt, ...); #define EX_BG 256 /* retry in background (internal only) */ -static inline void -mnt_debug(int lev, const char *fmt, ...) -{ - va_list ap; - - if (lev > mount_debug) - return; - - fputs("DEBUG: ", stderr); - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - - fputc('\n', stderr); -} - #endif /* SUNDRIES_H */ diff --git a/tests/expected/ts-mount-paths b/tests/expected/ts-mount-paths index d6f798ae..6de4ece3 100644 --- a/tests/expected/ts-mount-paths +++ b/tests/expected/ts-mount-paths @@ -1,7 +1,9 @@ -DEBUG: fstab path: "/etc/fstab" -DEBUG: lock path: "/etc/mtab~" -DEBUG: temp path: "/etc/mtab.tmp" -DEBUG: spec: "/dev/dummy" -DEBUG: node: "/mnt" -DEBUG: types: "(null)" -DEBUG: opts: "(null)" +mount: fstab path: "/etc/fstab" +mount: lock path: "/etc/mtab~" +mount: temp path: "/etc/mtab.tmp" +mount: no LABEL=, no UUID=, going to mount /dev/dummy by path +mount: spec: "/dev/dummy" +mount: node: "/mnt" +mount: types: "(null)" +mount: opts: "(null)" +/dev/dummy on /mnt type unknown (rw) diff --git a/tests/expected/ts-mount-special b/tests/expected/ts-mount-special index fb472079..0e97aa01 100644 --- a/tests/expected/ts-mount-special +++ b/tests/expected/ts-mount-special @@ -1,13 +1,15 @@ -DEBUG: fstab path: "/etc/fstab" -DEBUG: lock path: "/etc/mtab~" -DEBUG: temp path: "/etc/mtab.tmp" -DEBUG: spec: "/foo" -DEBUG: node: "/bar" -DEBUG: types: "mytest" -DEBUG: opts: "(null)" -DEBUG: external mount: argv[0] = "/sbin/mount.mytest" -DEBUG: external mount: argv[1] = "/foo" -DEBUG: external mount: argv[2] = "/bar" -DEBUG: external mount: argv[3] = "-o" -DEBUG: external mount: argv[4] = "rw" -/sbin/mount.mytest called with "/foo /bar -o rw" +mount: fstab path: "/etc/fstab" +mount: lock path: "/etc/mtab~" +mount: temp path: "/etc/mtab.tmp" +mount: no LABEL=, no UUID=, going to mount /foo by path +mount: spec: "/foo" +mount: node: "/bar" +mount: types: "mytest" +mount: opts: "(null)" +mount: external mount: argv[0] = "/sbin/mount.mytest" +mount: external mount: argv[1] = "/foo" +mount: external mount: argv[2] = "/bar" +mount: external mount: argv[3] = "-v" +mount: external mount: argv[4] = "-o" +mount: external mount: argv[5] = "rw" +/sbin/mount.mytest called with "/foo /bar -v -o rw" diff --git a/tests/ts-mount-paths b/tests/ts-mount-paths index 32198c41..fe3ef920 100755 --- a/tests/ts-mount-paths +++ b/tests/ts-mount-paths @@ -8,7 +8,7 @@ TS_DESC="basic paths" ts_init "$1" -$TS_CMD_MOUNT -n -f --debug=2 /dev/dummy /mnt &> $TS_OUTPUT +$TS_CMD_MOUNT -n -f -v -v -v /dev/dummy /mnt &> $TS_OUTPUT ts_finalize diff --git a/tests/ts-mount-special b/tests/ts-mount-special index e0d3f997..bcdec248 100755 --- a/tests/ts-mount-special +++ b/tests/ts-mount-special @@ -24,7 +24,7 @@ echo "\$0 called with \"\$*\"" EOF chmod +x $MOUNTER -$TS_CMD_MOUNT --debug=2 -t mytest /foo /bar &> $TS_OUTPUT +$TS_CMD_MOUNT -v -v -v -t mytest /foo /bar &> $TS_OUTPUT rm -f $MOUNTER -- 2.39.5