Mail Archives: cygwin-developers/2000/06/15/09:27:15
>>> On Wed, 14 Jun 2000 01:03:12 -0400
>>> Chris Faylor <cgf AT cygnus DOT com> said:
> I think you may have misunderstood me. I wanted to be able to
> type "umount c:\foo" (I got the backslash wrong above) and have
> it remove the mount point. This is what it does on UNIX.
I'm sorry. I didn't know the umount can accept a device name on
UNIX. I tried implementing this behavior in umount of Cygwin.
In my implementation, the umount invoked with a native path (or
something like it) deletes all mount entries having the same
native path. Because the mount in Cygwin unlike one in UNIX can
mount the same source path on more than two different mount
points.
By the way, I found the mount didn't eliminate a trailing
backslash in a native path starting with `//[A-Za-z]/'.
The following patch also fixes this problem.
ChangeLog:
2000-06-15 Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT 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 09:43:48
@@ -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,41 +1675,60 @@ 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++)
+ int saved_nmounts = nmounts;
+ for (int i = 0; i < nmounts;)
{
- /* Delete if paths and mount locations match. */
- if ((strcasematch (mount[i].posix_path, pathtmp)
- || strcasematch (mount[i].native_path, pathtmp)) &&
+ if (((posix_path_p)
+ ? strcasematch (mount[i].posix_path, pathtmp)
+ : strcasematch (mount[i].native_path, pathtmp)) &&
(mount[i].flags & MOUNT_SYSTEM) == (flags & MOUNT_SYSTEM))
{
- nmounts--; /* One less mount table entry */
+ if (reg_p && !posix_path_p &&
+ del_reg_mount (mount[i].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 */
- return 0;
+ sort (); /* Resort the table */
}
+ else
+ i++;
}
- set_errno (EINVAL);
- return -1;
+
+ if (saved_nmounts == nmounts)
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
+ return 0;
}
/* read_v1_mounts: Given a reg_key to an old mount table registry area,
____
| AIST Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT jp>
| HOKURIKU School of Information Science
o_/ 1990 Japan Advanced Institute of Science and Technology
- Raw text -