Fsync directories after creating files
Bug: 112145641
Bug: 124279741
Bug: 120248692
Test: adb shell locksettings set-pin 1111 && \
adb shell "echo b > /proc/sysrq-trigger"
Change-Id: I53d252942c21365983b4f8b6e0948b1864f195c1
Merged-In: I53d252942c21365983b4f8b6e0948b1864f195c1
(cherry picked from commit 2e58acb4123e559fddfd4013af3ead6c055bd71c)
diff --git a/KeyStorage.cpp b/KeyStorage.cpp
index 0518930..84dd8ec 100644
--- a/KeyStorage.cpp
+++ b/KeyStorage.cpp
@@ -480,6 +480,7 @@
if (!encryptWithoutKeymaster(appId, key, &encryptedKey)) return false;
}
if (!writeStringToFile(encryptedKey, dir + "/" + kFn_encrypted_key)) return false;
+ if (!FsyncDirectory(dir)) return false;
return true;
}