diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3e89d7687..4a68aba60 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2009-11-09 Corinna Vinschen + + * path.cc (symlink_info::check_reparse_point): Always check + SubstituteName for volume string to recognize volume mount points. + Reuse subst when calling sys_wcstombs. + * syscalls.cc (rename): Set errno to EBUSY when trying to rename + volume mount points. Explain why. + 2009-11-09 Corinna Vinschen * fhandler_console.cc (fhandler_console::read): Restrict generating diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 1f95073b9..daf780e84 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -1873,18 +1873,15 @@ symlink_info::check_reparse_point (HANDLE h) (WCHAR *)((char *)rp->MountPointReparseBuffer.PathBuffer + rp->MountPointReparseBuffer.SubstituteNameOffset), rp->MountPointReparseBuffer.SubstituteNameLength); - if (rp->MountPointReparseBuffer.PrintNameLength == 0 - || RtlEqualUnicodePathPrefix (&subst, &ro_u_volume, TRUE)) + if (RtlEqualUnicodePathPrefix (&subst, &ro_u_volume, TRUE)) { /* Volume mount point. Not treated as symlink. The return value of -1 is a hint for the caller to treat this as a volume mount point. */ return -1; } - sys_wcstombs (srcbuf, SYMLINK_MAX + 1, - (WCHAR *)((char *)rp->MountPointReparseBuffer.PathBuffer - + rp->MountPointReparseBuffer.SubstituteNameOffset), - rp->MountPointReparseBuffer.SubstituteNameLength / sizeof (WCHAR)); + sys_wcstombs (srcbuf, SYMLINK_MAX + 1, subst.Buffer, + subst.Length / sizeof (WCHAR)); pflags = PATH_SYMLINK | PATH_REP; fileattr &= ~FILE_ATTRIBUTE_DIRECTORY; } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 55415b631..7a4f239b8 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1758,6 +1758,16 @@ rename (const char *oldpath, const char *newpath) set_errno (EROFS); goto out; } + if (oldpc.has_attribute (FILE_ATTRIBUTE_REPARSE_POINT) && !oldpc.issymlink ()) + { + /* Volume mount point. If we try to rename a volume mount point, NT + returns STATUS_NOT_SAME_DEVICE ==> Win32 ERROR_NOT_SAME_DEVICE ==> + errno EXDEV. That's bad since mv(1) will now perform a cross-device + move. So what we do here is to treat the volume mount point just + like Linux treats a mount point. */ + set_errno (EBUSY); + goto out; + } if (old_dir_requested && !oldpc.isdir ()) { /* Reject rename("file/","x"). */