OSDN Git Service

Forbid JVM_O_DELETE in JVM_Open
authorPrzemyslaw Szczepaniak <pszczepaniak@google.com>
Thu, 26 May 2016 14:52:36 +0000 (15:52 +0100)
committerPrzemyslaw Szczepaniak <pszczepaniak@google.com>
Thu, 26 May 2016 16:21:12 +0000 (17:21 +0100)
Bug: 28901232
Change-Id: Icf1f9b85163f478f380c76042bcc0ff6910cc1ce

runtime/openjdkjvm/OpenjdkJvm.cc

index ca5efe5..bf4a7cb 100644 (file)
@@ -74,11 +74,15 @@ using art::FATAL;
 /* posix open() with extensions; used by e.g. ZipFile */
 JNIEXPORT jint JVM_Open(const char* fname, jint flags, jint mode) {
     /*
-     * The call is expected to handle JVM_O_DELETE, which causes the file
-     * to be removed after it is opened.  Also, some code seems to
-     * want the special return value JVM_EEXIST if the file open fails
-     * due to O_EXCL.
+     * Some code seems to want the special return value JVM_EEXIST if the
+     * file open fails due to O_EXCL.
      */
+    // Don't use JVM_O_DELETE, it's problematic with FUSE, see b/28901232.
+    if (flags & JVM_O_DELETE) {
+        LOG(FATAL) << "JVM_O_DELETE option is not supported (while opening: '"
+                   << fname << "')";
+    }
+
     int fd = TEMP_FAILURE_RETRY(open(fname, flags & ~JVM_O_DELETE, mode));
     if (fd < 0) {
         int err = errno;
@@ -89,12 +93,6 @@ JNIEXPORT jint JVM_Open(const char* fname, jint flags, jint mode) {
         }
     }
 
-    if (flags & JVM_O_DELETE) {
-        if (unlink(fname) != 0) {
-            LOG(WARNING) << "Post-open deletion of '" << fname << "' failed: " << strerror(errno);
-        }
-    }
-
     return fd;
 }