mount doesn't complain about missing "mount directory" any more?

Kazuhiro Fujieda fujieda@jaist.ac.jp
Thu Jun 15 10:32:00 GMT 2000


>>> On Thu, 15 Jun 2000 12:34:19 -0400
>>> Chris Faylor <cgf@cygnus.com> said:

> Actually, UNIX can mount two devices, too.  I just tried it, and a umount
> removes the first in the mount list.  Is it possible to adapt your patch
> to do that?

On SunOS 5.7, I couldn't mount a block special device on two
different directories. Then I tried a network file system and
found it succeeded. In this case, a umount removes the last in
the list.  Anyway, I tried to tailor my patch to your request.

ChangeLog:
2000-06-15 Kazuhiro Fujieda  <fujieda@jaist.ac.jp>
	* path.cc (mount_info::add_item): Eliminate a trailing backslash 
	included in a native path starting with '//[A-Za-z]/...'.
	* path.cc (mount_info::del_item): Accept a native path as its target.

Index: path.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.cc,v
retrieving revision 1.30
diff -u -p -r1.30 path.cc
--- path.cc	2000/06/13 16:48:37	1.30
+++ path.cc	2000/06/15 17:03:16
@@ -1614,10 +1614,8 @@ mount_info::add_item (const char *native
   if (slash_drive_prefix_p (native))
     slash_drive_to_win32_path (native, nativetmp, 0);
   else
-    {
-      backslashify (native, nativetmp, 0);
-      nofinalslash (nativetmp, nativetmp);
-    }
+    backslashify (native, nativetmp, 0);
+  nofinalslash (nativetmp, nativetmp);
 
   slashify (posix, posixtmp, 0);
   nofinalslash (posixtmp, posixtmp);
@@ -1677,36 +1675,49 @@ int
 mount_info::del_item (const char *path, unsigned flags, int reg_p)
 {
   char pathtmp[MAX_PATH];
+  int posix_path_p = FALSE;
 
   /* Something's wrong if path is NULL or empty. */
-  if (path == NULL || *path == 0)
+  if (path == NULL || *path == 0 || !isabspath (path))
     {
       set_errno (EINVAL);
       return -1;
     }
 
-  slashify (path, pathtmp, 0);
+  if (slash_drive_prefix_p (path))
+      slash_drive_to_win32_path (path, pathtmp, 0);
+  else if (slash_unc_prefix_p (path) || strpbrk (path, ":\\"))
+      backslashify (path, pathtmp, 0);
+  else
+    {
+      slashify (path, pathtmp, 0);
+      posix_path_p = TRUE;
+    }
   nofinalslash (pathtmp, pathtmp);
-
-  debug_printf ("%s[%s]", path, pathtmp);
 
-  if (reg_p && del_reg_mount (pathtmp, flags)
-      && del_reg_mount (path, flags)) /* for old irregular entries */
+  if (reg_p && posix_path_p &&
+      del_reg_mount (pathtmp, flags) &&
+      del_reg_mount (path, flags)) /* for old irregular entries */
     return -1;
 
   for (int i = 0; i < nmounts; i++)
     {
-      /* Delete if paths and mount locations match. */
-      if ((strcasematch (mount[i].posix_path, pathtmp)
-	   || strcasematch (mount[i].native_path, pathtmp)) &&
-	  (mount[i].flags & MOUNT_SYSTEM) == (flags & MOUNT_SYSTEM))
+      int ent = native_sorted[i]; /* in the same order as getmntent() */
+      if (((posix_path_p)
+	   ? strcasematch (mount[ent].posix_path, pathtmp)
+	   : strcasematch (mount[ent].native_path, pathtmp)) &&
+	  (mount[ent].flags & MOUNT_SYSTEM) == (flags & MOUNT_SYSTEM))
 	{
-	  nmounts--;		/* One less mount table entry */
+	  if (!posix_path_p &&
+	      reg_p && del_reg_mount (mount[ent].posix_path, flags))
+	    return -1;
+
+	  nmounts--; /* One less mount table entry */
 	  /* Fill in the hole if not at the end of the table */
-	  if (i < nmounts)
-	    memmove (mount + i, mount + i + 1,
-		     sizeof (mount[i]) * (nmounts - i));
-	  sort ();		/* Resort the table */
+	  if (ent < nmounts)
+	    memmove (mount + ent, mount + ent + 1,
+		     sizeof (mount[ent]) * (nmounts - ent));
+	  sort (); /* Resort the table */
 	  return 0;
 	}
     }

____
  | AIST      Kazuhiro Fujieda <fujieda@jaist.ac.jp>
  | HOKURIKU  School of Information Science
o_/ 1990      Japan Advanced Institute of Science and Technology


More information about the Cygwin-developers mailing list