art: fix creating dalvik-cache subdirectory

The current code only ever calls mkdir if dalvik_cache_root starts
with /tmp, which is not true on the device.  Split the logic for
creating dalvik-cache from the logic for creating dalvik-cache
subdirectories, as they have different conditions.

Fixes:
05-05 21:34:04.870  1295  1295 F art     : art/runtime/utils.cc:1187] Failed to find dalvik-cache directory /data/dalvik-cache/arm64
when /data/dalvik-cache/arm64 doesn't exist.

Change-Id: Ifdf5fcc2d3a8d80f6182cf2e5b5d7b1fac3c3810
diff --git a/runtime/utils.cc b/runtime/utils.cc
index ee2cca4..c5f43e0 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -1171,14 +1171,22 @@
   CHECK(subdir != nullptr);
   const std::string dalvik_cache_root(StringPrintf("%s/dalvik-cache/", GetAndroidData()));
   const std::string dalvik_cache = dalvik_cache_root + subdir;
-  if (create_if_absent && !OS::DirectoryExists(dalvik_cache.c_str())) {
+  if (!OS::DirectoryExists(dalvik_cache_root.c_str())) {
     if (StartsWith(dalvik_cache_root, "/tmp/")) {
       int result = mkdir(dalvik_cache_root.c_str(), 0700);
-      if (result != 0 && errno != EEXIST) {
+      if (result != 0) {
         PLOG(FATAL) << "Failed to create dalvik-cache directory " << dalvik_cache_root;
         return "";
       }
-      result = mkdir(dalvik_cache.c_str(), 0700);
+    } else {
+      LOG(FATAL) << "Failed to find dalvik-cache directory " << dalvik_cache;
+      return "";
+    }
+  }
+
+  if (!OS::DirectoryExists(dalvik_cache.c_str())) {
+    if (create_if_absent) {
+      int result = mkdir(dalvik_cache.c_str(), 0700);
       if (result != 0) {
         PLOG(FATAL) << "Failed to create dalvik-cache directory " << dalvik_cache;
         return "";