summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mount/mount.c34
-rw-r--r--mount/sundries.h24
2 files changed, 55 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;
diff --git a/mount/sundries.h b/mount/sundries.h
index 6def95b1c..00959be7a 100644
--- a/mount/sundries.h
+++ b/mount/sundries.h
@@ -2,7 +2,10 @@
* sundries.h
* Support function prototypes. Functions are in sundries.c.
*/
+#ifndef SUNDRIES_H
+#define SUNDRIES_H
+#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <limits.h>
@@ -14,6 +17,7 @@
#endif
extern int mount_quiet;
+extern int mount_debug;
extern int verbose;
extern int sloppy;
@@ -47,3 +51,23 @@ int nfsmount (const char *spec, const char *node, int *flags,
#define EX_SOMEOK 64 /* some mount succeeded */
#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 */
+