Again, hello,
I have designed and tested the attached patch (based on wheezy's util-linux
package). With this patch, mount -v $from $to will raise an information if
the $to overlaps any mounted point in mtab. Trailing slashes could be a
problem, though (I'm using strstr).
Any comment is welcome, in order for me to improve, and for this patch to
fit util-linux requirements. Further tests would be a good idea.
Cheers,
--
Pierre-Elliott Bécue
--- util-linux-2.20.1/mount/mount.c 2014-05-14 17:07:01.000000000 +0200
+++ util-linux-2.20.1bak/mount/mount.c 2014-05-14 17:06:50.950190785 +0200
@@ -310,6 +310,21 @@
printf ("\n");
}
+/* Check if node overlaps another entry in mtab */
+static int
+overlap_fs(const char *spec, const char *node){
+ struct mntentchn *mc, *mc0;
+
+ mc0 = mtab_head();
+ for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
+ if(strstr(node, mc->m.mnt_dir) != NULL){
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
/* Report on everything in mtab (of the specified types if any). */
static int
print_all (char *types) {
@@ -2021,6 +2036,15 @@
}
}
+ /* XXX - PEB add */
+ if(verbose && overlap_fs(spec, node)){
+ printf(_("mount: mounting %s on %s overlaps "
+ " another already mounted fs, type "
+ " mount and search for %s for more "
+ " information.\n"),
+ spec, node, node);
+ }
+
/* Handle possible LABEL= and UUID= forms of spec */
if (types == NULL || (strncmp(types, "9p", 2) &&
strncmp(types, "nfs", 3) &&