summaryrefslogtreecommitdiffstats
path: root/mount/mount.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-27 23:35:56 +0100
committerKarel Zak2007-01-04 13:58:05 +0100
commit61d9d2ff1cb0e28e2b88099bbc5b919fa5004fce (patch)
tree8ea10dec4cfbfe54e2c2581c83cad6b7476fc4ec /mount/mount.c
parentbuild-sys: rename to -ng, change maintainer name (diff)
downloadkernel-qcow2-util-linux-61d9d2ff1cb0e28e2b88099bbc5b919fa5004fce.tar.gz
kernel-qcow2-util-linux-61d9d2ff1cb0e28e2b88099bbc5b919fa5004fce.tar.xz
kernel-qcow2-util-linux-61d9d2ff1cb0e28e2b88099bbc5b919fa5004fce.zip
mount: add simple (printf-like) debug routine and --debug option
The --debug=<level> command line option enables debug outputs. It's undocumented option, because it's really for debug/tests purpose only. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/mount.c')
-rw-r--r--mount/mount.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/mount/mount.c b/mount/mount.c
index a51cfe204..5dc62ef62 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -44,6 +44,13 @@
#include "setproctitle.h"
#endif
+/* Quiet mode */
+int mount_quiet = 0;
+
+/* Debug mode (level) */
+int mount_debug = 0;
+
+
/* True for fake mount (-f). */
static int fake = 0;
@@ -207,7 +214,6 @@ parse_string_opt(char *s) {
return 0;
}
-int mount_quiet=0;
/* Report on a single mount. */
static void
@@ -453,6 +459,10 @@ 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",
+ args->spec, args->node, args->type, flags, args->data ? "YES" : "NOT");
+
ret = mount (args->spec, args->node, args->type, flags, args->data);
if (ret == 0)
mountcount++;
@@ -734,7 +744,7 @@ check_special_mountprog(const char *spec, const char *node, const char *type,
res = fork();
if (res == 0) {
const char *oo, *mountargs[10];
- int i = 0;
+ int i = 0, x;
setuid(getuid());
setgid(getgid());
@@ -751,6 +761,11 @@ check_special_mountprog(const char *spec, const char *node, const char *type,
mountargs[i++] = oo;
}
mountargs[i] = NULL;
+
+ for(x = 0; x < 10 && mountargs[x]; x++)
+ mnt_debug(1, "external mount: argv[%d] = \"%s\"",
+ x, mountargs[x]);
+
execv(mountprog, (char **) mountargs);
exit(1); /* exec failed */
} else if (res != -1) {
@@ -795,6 +810,11 @@ 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);
+
spec = spec1 = xstrdup(spec0);
node = node1 = xstrdup(node0);
types = types1 = xstrdup(types0);
@@ -1382,6 +1402,7 @@ 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' },
@@ -1481,12 +1502,15 @@ main(int argc, char *argv[]) {
initproctitle(argc, argv);
#endif
- while ((c = getopt_long (argc, argv, "afFhilL:no:O:p:rsU:vVwt:",
+ while ((c = getopt_long (argc, argv, "ad:fFhilL: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;
@@ -1587,6 +1611,10 @@ 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);
+
argc -= optind;
argv += optind;