Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com To: cygwin-developers AT sourceware DOT cygnus DOT com Subject: Re: mount doesn't complain about missing "mount directory" any more? References: <20000613213415 DOT A20386 AT cygnus DOT com> <20000613225819 DOT A12800 AT cygnus DOT com> <20000614010312 DOT B7392 AT cygnus DOT com> Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII From: Kazuhiro Fujieda Date: 15 Jun 2000 22:26:48 +0900 In-Reply-To: Chris Faylor's message of Wed, 14 Jun 2000 01:03:12 -0400 Message-ID: Lines: 128 X-Mailer: Gnus v5.3/Emacs 19.34 >>> On Wed, 14 Jun 2000 01:03:12 -0400 >>> Chris Faylor 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 * 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 | HOKURIKU School of Information Science o_/ 1990 Japan Advanced Institute of Science and Technology