[前][次][番号順一覧][スレッド一覧]

ruby-changes:38209

From: usa <ko1@a...>
Date: Mon, 13 Apr 2015 17:10:38 +0900 (JST)
Subject: [ruby-changes:38209] usa:r50290 (ruby_2_1): merge revision(s) 49634, 49658, 49663: [Backport #10865]

usa	2015-04-13 17:10:10 +0900 (Mon, 13 Apr 2015)

  New Revision: 50290

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50290

  Log:
    merge revision(s) 49634,49658,49663: [Backport #10865]
    
    * win32/win32.c (wrename): return EXDEV if moving a directory to
      another drive, since MoveFileExW does not set proper error code.
      [ruby-core:68162] [Bug #10865]
    
    * win32/win32.c (different_device_p): compare by volume serial
      numbers, not by path names.
      numbers, not by path names.  [ruby-core:68162] [Bug #10865]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/version.h
    branches/ruby_2_1/win32/win32.c
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 50289)
+++ ruby_2_1/ChangeLog	(revision 50290)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Mon Apr 13 17:09:06 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/win32.c (different_device_p): compare by volume serial
+	  numbers, not by path names.  [ruby-core:68162] [Bug #10865]
+
+Mon Apr 13 17:09:06 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/win32.c (wrename): return EXDEV if moving a directory to
+	  another drive, since MoveFileExW does not set proper error code.
+	  [ruby-core:68162] [Bug #10865]
+
 Mon Apr 13 17:02:25 2015  Scott Francis  <scott.francis@s...>
 
 	* thread_pthread.c (reserve_stack): fix intermittent SIGBUS on
Index: ruby_2_1/win32/win32.c
===================================================================
--- ruby_2_1/win32/win32.c	(revision 50289)
+++ ruby_2_1/win32/win32.c	(revision 50290)
@@ -4673,6 +4673,31 @@ rb_w32_getenv(const char *name) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/win32/win32.c#L4673
     return w32_getenv(name, CP_ACP);
 }
 
+/* License: Ruby's */
+static DWORD
+get_volume_serial_number(const WCHAR *path)
+{
+    const DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+    const DWORD creation = OPEN_EXISTING;
+    const DWORD flags = FILE_FLAG_BACKUP_SEMANTICS;
+    BY_HANDLE_FILE_INFORMATION st = {0};
+    HANDLE h = CreateFileW(path, 0, share_mode, NULL, creation, flags, NULL);
+    BOOL ret;
+
+    if (h == INVALID_HANDLE_VALUE) return 0;
+    ret = GetFileInformationByHandle(h, &st);
+    CloseHandle(h);
+    if (!ret) return 0;
+    return st.dwVolumeSerialNumber;
+}
+
+/* License: Ruby's */
+static int
+different_device_p(const WCHAR *oldpath, const WCHAR *newpath)
+{
+    return get_volume_serial_number(oldpath) != get_volume_serial_number(newpath);
+}
+
 /* License: Artistic or GPL */
 static int
 wrename(const WCHAR *oldpath, const WCHAR *newpath)
@@ -4696,8 +4721,14 @@ wrename(const WCHAR *oldpath, const WCHA https://github.com/ruby/ruby/blob/trunk/ruby_2_1/win32/win32.c#L4721
 	if (!MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED))
 	    res = -1;
 
-	if (res)
-	    errno = map_errno(GetLastError());
+	if (res) {
+	    DWORD e = GetLastError();
+	    if ((e == ERROR_ACCESS_DENIED) && (oldatts & FILE_ATTRIBUTE_DIRECTORY) &&
+		different_device_p(oldpath, newpath))
+		errno = EXDEV;
+	    else
+		errno = map_errno(e);
+	}
 	else
 	    SetFileAttributesW(newpath, oldatts);
     });
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 50289)
+++ ruby_2_1/version.h	(revision 50290)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.5"
 #define RUBY_RELEASE_DATE "2015-04-13"
-#define RUBY_PATCHLEVEL 333
+#define RUBY_PATCHLEVEL 334
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 4

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49634,49658,49663


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]