Verbosity Patch for mount_hammer

Jan Lentfer Jan.Lentfer at web.de
Wed Oct 21 12:11:58 PDT 2009


Hi,

attached is a patch to increase verbosity of error messages for 
mount_hammer. Also this is preparation for actually testing each 
supplied device for mounting if it contains a valid hammer fs. Since you 
can mount numerous devices onto one mountpoint it might be helpful to 
actually know wich of the xx devices you typed on the commandline 
actually prevented a successful mount.

Kind Regards,

Jan

PS: My first C coding in years, please be gentle :-)
--- mount_hammer.c_orig	2009-10-21 11:27:24 +0200
+++ mount_hammer.c	2009-10-21 13:18:15 +0200
@@ -39,7 +39,9 @@
 #include <sys/diskmbr.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <sys/syslimits.h>
 #include <vfs/hammer/hammer_mount.h>
+#include <vfs/hammer/hammer_disk.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -81,8 +83,10 @@
 	int error;
 	int ch;
 	int init_flags = 0;
+	int ax;
 	char *mountpt;
 	char *ptr;
+	char fdevs[PATH_MAX*HAMMER_MAX_VOLUMES+PATH_MAX-1]; /* this is ugly, memory should be allocated dynamically */
 
 	bzero(&info, sizeof(info));
 	info.asof = 0;
@@ -138,7 +142,7 @@
 		}
 		mountpt = av[0];
 		if (mount(vfc.vfc_name, mountpt, mount_flags, &info))
-			err(1, NULL);
+			err(1, "mountpoint %s", mountpt);
 		exit(0);
 	}
 
@@ -167,8 +171,16 @@
 	if (error)
 		errx(1, "hammer filesystem is not available");
 
-	if (mount(vfc.vfc_name, mountpt, mount_flags, &info))
-		err(1, NULL);
+
+	if (mount(vfc.vfc_name, mountpt, mount_flags, &info)) {
+		/* Build fdevs in case of error to report failed devices */
+		for (ax = 0; ax < ac - 1; ax++) {
+			strlcat(fdevs, info.volumes[ax], sizeof(fdevs));
+			if (ax < ac - 2)
+			strlcat(fdevs, " ", sizeof(fdevs));
+		}
+		err(1,"mount %s on %s", fdevs, mountpt) ;
+	}
 	exit(0);
 }
 




More information about the Submit mailing list