Revision: 6872
Author: [email protected]
Date: Mon Feb 21 09:17:26 2011
Log: Bug: OS::MemoryMappedFile::open() should not truncate a pre-existing file.

Patch by Mark Lam from Hewlett-Packard Development Company, LP

Review URL: http://codereview.chromium.org/6543039
http://code.google.com/p/v8/source/detail?r=6872

Modified:
 /branches/bleeding_edge/src/platform-cygwin.cc
 /branches/bleeding_edge/src/platform-freebsd.cc
 /branches/bleeding_edge/src/platform-linux.cc
 /branches/bleeding_edge/src/platform-macos.cc
 /branches/bleeding_edge/src/platform-openbsd.cc
 /branches/bleeding_edge/src/platform-solaris.cc
 /branches/bleeding_edge/src/platform-win32.cc

=======================================
--- /branches/bleeding_edge/src/platform-cygwin.cc      Thu Feb 17 08:33:10 2011
+++ /branches/bleeding_edge/src/platform-cygwin.cc      Mon Feb 21 09:17:26 2011
@@ -209,7 +209,7 @@


 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
-  FILE* file = fopen(name, "w+");
+  FILE* file = fopen(name, "r+");
   if (file == NULL) return NULL;

   fseek(file, 0, SEEK_END);
=======================================
--- /branches/bleeding_edge/src/platform-freebsd.cc     Tue Jan 25 04:59:43 2011
+++ /branches/bleeding_edge/src/platform-freebsd.cc     Mon Feb 21 09:17:26 2011
@@ -224,7 +224,7 @@


 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
-  FILE* file = fopen(name, "w+");
+  FILE* file = fopen(name, "r+");
   if (file == NULL) return NULL;

   fseek(file, 0, SEEK_END);
=======================================
--- /branches/bleeding_edge/src/platform-linux.cc       Wed Jan 19 06:28:15 2011
+++ /branches/bleeding_edge/src/platform-linux.cc       Mon Feb 21 09:17:26 2011
@@ -327,7 +327,7 @@


 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
-  FILE* file = fopen(name, "w+");
+  FILE* file = fopen(name, "r+");
   if (file == NULL) return NULL;

   fseek(file, 0, SEEK_END);
=======================================
--- /branches/bleeding_edge/src/platform-macos.cc       Wed Jan 19 06:28:15 2011
+++ /branches/bleeding_edge/src/platform-macos.cc       Mon Feb 21 09:17:26 2011
@@ -205,7 +205,7 @@


 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
-  FILE* file = fopen(name, "w+");
+  FILE* file = fopen(name, "r+");
   if (file == NULL) return NULL;

   fseek(file, 0, SEEK_END);
=======================================
--- /branches/bleeding_edge/src/platform-openbsd.cc     Wed Jan 19 06:28:15 2011
+++ /branches/bleeding_edge/src/platform-openbsd.cc     Mon Feb 21 09:17:26 2011
@@ -222,7 +222,7 @@


 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
-  FILE* file = fopen(name, "w+");
+  FILE* file = fopen(name, "r+");
   if (file == NULL) return NULL;

   fseek(file, 0, SEEK_END);
=======================================
--- /branches/bleeding_edge/src/platform-solaris.cc     Wed Jan 19 06:28:15 2011
+++ /branches/bleeding_edge/src/platform-solaris.cc     Mon Feb 21 09:17:26 2011
@@ -235,7 +235,7 @@


 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
-  FILE* file = fopen(name, "w+");
+  FILE* file = fopen(name, "r+");
   if (file == NULL) return NULL;

   fseek(file, 0, SEEK_END);
=======================================
--- /branches/bleeding_edge/src/platform-win32.cc       Thu Jan 20 00:21:40 2011
+++ /branches/bleeding_edge/src/platform-win32.cc       Mon Feb 21 09:17:26 2011
@@ -939,7 +939,7 @@
   // Open a physical file
   HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
       FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
-  if (file == NULL) return NULL;
+  if (file == INVALID_HANDLE_VALUE) return NULL;

   int size = static_cast<int>(GetFileSize(file, NULL));

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to