Blob Blame History Raw
autofs-5.1.5 - log mount call arguments if mount_verbose is set

From: Lars R. Damerow <lars@pixar.com>

Override the debug log only setting if mount_verbose is set so that
mount parameter information is logged on mount.

Signed-off-by: Lars R. Damerow <lars@pixar.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG               |    1 +
 modules/mount_afs.c     |    6 +++++-
 modules/mount_bind.c    |   11 +++++++----
 modules/mount_ext2.c    |   16 ++++++++++------
 modules/mount_generic.c |   14 +++++++++-----
 modules/mount_nfs.c     |   29 +++++++++++++++++------------
 6 files changed, 49 insertions(+), 28 deletions(-)

--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -321,6 +321,7 @@
 - use malloc(3) in spawn.c.
 - add mount_verbose configuration option.
 - optionally log mount requestor process info.
+- log mount call arguments if mount_verbose is set.
 
 25/07/2012 autofs-5.0.7
 =======================
--- autofs-5.0.7.orig/modules/mount_afs.c
+++ autofs-5.0.7/modules/mount_afs.c
@@ -37,10 +37,14 @@ int mount_mount(struct autofs_point *ap,
 	char dest[PATH_MAX + 1];
 	size_t r_len = strlen(root);
 	size_t d_len = r_len + name_len + 2;
+	void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
 
 	if (ap->flags & MOUNT_FLAG_REMOUNT)
 		return 0;
 
+	if (defaults_get_mount_verbose())
+		mountlog = &log_info;
+
 	if (d_len > PATH_MAX)
 		return 1;
 
@@ -53,7 +57,7 @@ int mount_mount(struct autofs_point *ap,
 	if (dest[strlen(dest)-1] == '/')
 	    dest[strlen(dest)-1] = '\0';
 
-	debug(ap->logopt, MODPREFIX "mounting AFS %s -> %s", dest, what);
+	mountlog(ap->logopt, MODPREFIX "mounting AFS %s -> %s", dest, what);
 
 	return symlink(what, dest);	/* Try it.  If it fails, return the error. */
 }
--- autofs-5.0.7.orig/modules/mount_bind.c
+++ autofs-5.0.7/modules/mount_bind.c
@@ -81,10 +81,14 @@ int mount_mount(struct autofs_point *ap,
 	int err;
 	int i, len;
 	int symlnk = (*name != '/' && (ap->flags & MOUNT_FLAG_SYMLINK));
+	void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
 
 	if (ap->flags & MOUNT_FLAG_REMOUNT)
 		return 0;
 
+	if (defaults_get_mount_verbose())
+		mountlog = &log_info;
+
 	/* Extract "symlink" pseudo-option which forces local filesystems
 	 * to be symlinked instead of bound.
 	 */
@@ -164,10 +168,9 @@ int mount_mount(struct autofs_point *ap,
 		if (!status)
 			existed = 0;
 
-		debug(ap->logopt,
-		      MODPREFIX
-		      "calling mount --bind " SLOPPY " -o %s %s %s",
-		      options, what, fullpath);
+		mountlog(ap->logopt, MODPREFIX
+			 "calling mount --bind " SLOPPY " -o %s %s %s",
+			  options, what, fullpath);
 
 		err = spawn_bind_mount(ap->logopt,
 			     SLOPPYOPT "-o", options, what, fullpath, NULL);
--- autofs-5.0.7.orig/modules/mount_ext2.c
+++ autofs-5.0.7/modules/mount_ext2.c
@@ -47,10 +47,14 @@ int mount_mount(struct autofs_point *ap,
 	int err, ro = 0;
 	const char *fsck_prog;
 	int len, status, existed = 1;
+	void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
 
 	if (ap->flags & MOUNT_FLAG_REMOUNT)
 		return 0;
 
+	if (defaults_get_mount_verbose())
+		mountlog = &log_info;
+
 	/* Root offset of multi-mount */
 	len = strlen(root);
 	if (root[len - 1] == '/') {
@@ -121,15 +125,15 @@ int mount_mount(struct autofs_point *ap,
 	}
 
 	if (options) {
-		debug(ap->logopt,
-		      MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
-		      fstype, options, what, fullpath);
+		mountlog(ap->logopt, MODPREFIX
+			 "calling mount -t %s " SLOPPY "-o %s %s %s",
+			 fstype, options, what, fullpath);
 		err = spawn_mount(ap->logopt, "-t", fstype,
 			     SLOPPYOPT "-o", options, what, fullpath, NULL);
 	} else {
-		debug(ap->logopt,
-		      MODPREFIX "calling mount -t %s %s %s",
-		      fstype, what, fullpath);
+		mountlog(ap->logopt,
+			 MODPREFIX "calling mount -t %s %s %s",
+			 fstype, what, fullpath);
 		err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL);
 	}
 
--- autofs-5.0.7.orig/modules/mount_generic.c
+++ autofs-5.0.7/modules/mount_generic.c
@@ -46,10 +46,14 @@ int mount_mount(struct autofs_point *ap,
 	char buf[MAX_ERR_BUF];
 	int err;
 	int len, status, existed = 1;
+	void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
 
 	if (ap->flags & MOUNT_FLAG_REMOUNT)
 		return 0;
 
+	if (defaults_get_mount_verbose())
+		mountlog = &log_info;
+
 	/* Root offset of multi-mount */
 	len = strlen(root);
 	if (root[len - 1] == '/') {
@@ -80,15 +84,15 @@ int mount_mount(struct autofs_point *ap,
 		existed = 0;
 
 	if (options && options[0]) {
-		debug(ap->logopt,
-		      MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
-		      fstype, options, what, fullpath);
+		mountlog(ap->logopt,
+			 MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
+			 fstype, options, what, fullpath);
 
 		err = spawn_mount(ap->logopt, "-t", fstype,
 			     SLOPPYOPT "-o", options, what, fullpath, NULL);
 	} else {
-		debug(ap->logopt, MODPREFIX "calling mount -t %s %s %s",
-		      fstype, what, fullpath);
+		mountlog(ap->logopt, MODPREFIX "calling mount -t %s %s %s",
+			 fstype, what, fullpath);
 		err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL);
 	}
 
--- autofs-5.0.7.orig/modules/mount_nfs.c
+++ autofs-5.0.7/modules/mount_nfs.c
@@ -77,13 +77,17 @@ int mount_mount(struct autofs_point *ap,
 	int port = -1;
 	int ro = 0;            /* Set if mount bind should be read-only */
 	int rdma = 0;
+	void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
 
 	if (ap->flags & MOUNT_FLAG_REMOUNT)
 		return 0;
 
-	debug(ap->logopt,
-	      MODPREFIX "root=%s name=%s what=%s, fstype=%s, options=%s",
-	      root, name, what, fstype, options);
+	if (defaults_get_mount_verbose())
+		mountlog = &log_info;
+
+	mountlog(ap->logopt,
+		 MODPREFIX "root=%s name=%s what=%s, fstype=%s, options=%s",
+		 root, name, what, fstype, options);
 
 	mount_default_proto = defaults_get_mount_nfs_default_proto();
 	vers = NFS_VERS_MASK | NFS_PROTO_MASK;
@@ -193,9 +197,9 @@ int mount_mount(struct autofs_point *ap,
 		if ((vers & NFS_PROTO_MASK) == 0)
 			vers |= NFS_PROTO_MASK;
 
-		debug(ap->logopt, MODPREFIX
-		      "nfs options=\"%s\", nobind=%d, nosymlink=%d, ro=%d",
-		      nfsoptions, nobind, nosymlink, ro);
+		mountlog(ap->logopt, MODPREFIX
+			 "nfs options=\"%s\", nobind=%d, nosymlink=%d, ro=%d",
+			 nfsoptions, nobind, nosymlink, ro);
 	}
 
 	if (!parse_location(ap->logopt, &hosts, what, flags)) {
@@ -370,17 +374,18 @@ dont_probe:
 		}
 
 		if (nfsoptions && *nfsoptions) {
-			debug(ap->logopt,
-			      MODPREFIX "calling mount -t %s " SLOPPY 
-			      "-o %s %s %s", fstype, nfsoptions, loc, fullpath);
+			mountlog(ap->logopt,
+				 MODPREFIX "calling mount -t %s " SLOPPY
+				 "-o %s %s %s", fstype, nfsoptions, loc,
+				 fullpath);
 
 			err = spawn_mount(ap->logopt,
 					  "-t", fstype, SLOPPYOPT "-o",
 					  nfsoptions, loc, fullpath, NULL);
 		} else {
-			debug(ap->logopt,
-			      MODPREFIX "calling mount -t %s %s %s",
-			      fstype, loc, fullpath);
+			mountlog(ap->logopt,
+				 MODPREFIX "calling mount -t %s %s %s",
+				 fstype, loc, fullpath);
 			err = spawn_mount(ap->logopt,
 					  "-t", fstype, loc, fullpath, NULL);
 		}