Merge "Fsync directories before delete key" am: 7573874d3f
am: 3a38070bbf

Change-Id: I568a6e8a39929b77ba76b021657e248a4e49e470
diff --git a/KeyStorage.cpp b/KeyStorage.cpp
index fc700c5..42890ca 100644
--- a/KeyStorage.cpp
+++ b/KeyStorage.cpp
@@ -224,6 +224,10 @@
                 PLOG(ERROR) << "Unable to move upgraded key to location: " << kmKeyPath;
                 return KeymasterOperation();
             }
+            if (!android::vold::FsyncDirectory(dir)) {
+                LOG(ERROR) << "Key dir sync failed: " << dir;
+                return KeymasterOperation();
+            }
             if (!keymaster.deleteKey(kmKey)) {
                 LOG(ERROR) << "Key deletion failed during upgrade, continuing anyway: " << dir;
             }