On Mon, 19 May 2014 14:34:40 +0200, David Guyot wrote:
> Pierre-Elliott,
> 
> Thanks for your reply. Your offer seems correct to me; nevertheless,
> regarding your second proposition, why would the warning be only
> displayed with the verbose flag? I mean, doesn't it worth the trouble to
> always display this warning, even without -v, given the relatively small
> amount of situation the current behaviour of mount will be desirable and
> the comparatively great number of situations this same current behaviour
> will be a problem?
> 
> Regarding the code, I'm afraid I can't help to this patch; my C level is
> almost at absolute zero.
> 
> Regards.
> --
> Pierre-Eliott,
> 
> Merci pour ta réponse. Ta proposition me semble correcte, si ce n'est
> que je ne comprends pas pourquoi ta seconde proposition suggère de
> n'afficher l'avertissement que si le mode verbeux est actif. Je veux
> dire par là que ça vaudrait peut-être le coup de toujours afficher cet
> avertissement, même sans mode verbeux, au vu du faible nombre de
> situations où le comportement actuel serait souhaitable, comparé au
> grand nombre de cas où ce comportement serait un problème, non ?
> 
> Concernant le code, j'ai peur de ne pas pouvoir aider à ton patch, car
> mon niveau en C avoisine le zéro absolu.
> 
> Cordialement.

Cheers,

My opinion on the subject is that my patch shouldn't modify the general
behavior of mount. This is the upstream role to decide wether mount should
alert in any case or not. I agree that this warning would be useful, but I'm
not sure to be enough good to decide the modalities of this warning.

As for the patch, I tested it with mount -v. With mount -av, it doesn't
work, probably because of the way mtab is updated. I thought I would have
the time to think about it this weekend, but I did'nt.

Btw, the patchfile I submitted is not the good one, it has a typo at strstr
call. Here is the good one.

-- 
PEB
--- util-linux-2.20.1/mount/mount.c	2014-05-19 15:27:57.000000000 +0200
+++ util-linux-2.20.1bak/mount/mount.c	2014-05-19 15:06:47.732350609 +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(mc->m.mnt_dir, node) != 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 @@
 		}
 	}
 
+    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) &&

Reply via email to