From ce9898da68856fa1fdadc48f8d9d09536180a4c4 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 18 Aug 2010 15:21:35 +0000 Subject: [PATCH] * syscalls.cc (rename): Fix renaming file-based devices. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/syscalls.cc | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c4284bdac..5bca572b7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2010-08-18 Corinna Vinschen + + * syscalls.cc (rename): Fix renaming file-based devices. + 2010-08-18 Corinna Vinschen * exceptions.cc (open_stackdumpfile): Don't try to open file if we diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index ac1fea0d2..aaa4673a1 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1804,8 +1804,9 @@ rename (const char *oldpath, const char *newpath) set_errno (ENOENT); goto out; } - if (oldpc.isspecial () && !oldpc.issocket ()) /* No renames from virtual FS */ + if (oldpc.isspecial () && !oldpc.issocket () && !oldpc.is_fs_special ()) { + /* No renames from virtual FS */ set_errno (EROFS); goto out; } @@ -1930,7 +1931,7 @@ rename (const char *oldpath, const char *newpath) goto out; } } - else if (oldpc.is_lnk_symlink () + else if (oldpc.is_lnk_special () && !RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (), &ro_u_lnk, TRUE)) rename_append_suffix (newpc, newpath, nlen, ".lnk"); @@ -1958,9 +1959,9 @@ rename (const char *oldpath, const char *newpath) goto out; } } - else if (oldpc.is_lnk_symlink ()) + else if (oldpc.is_lnk_special ()) { - if (!newpc.is_lnk_symlink () + if (!newpc.is_lnk_special () && !RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (), &ro_u_lnk, TRUE)) { @@ -1992,7 +1993,7 @@ rename (const char *oldpath, const char *newpath) { new2pc.check (newpath, PC_SYM_NOFOLLOW, stat_suffixes); newpc.get_nt_native_path ()->Length -= 4 * sizeof (WCHAR); - if (new2pc.is_binary () || new2pc.is_lnk_symlink ()) + if (new2pc.is_binary () || new2pc.is_lnk_special ()) removepc = &new2pc; } }