summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-08-04 20:49:36 +0200
committerAndroid Git Automerger <android-git-automerger@android.com>2015-08-04 20:49:36 +0200
commit2ecdc8948d60a99b14ceef5cf290f22e65cf635e (patch)
treee9370f13fe557460523708ca41015aec7755e7ad
parentam 414c576c: am 2e979ef6: am 302779e7: Merge "recovery: Allow "Mount /system" for system_root_image." (diff)
parentam 393d1e73: am 27c1ab20: Merge "udpater: Call fsync() after rename()." (diff)
downloadandroid_bootable_recovery-2ecdc8948d60a99b14ceef5cf290f22e65cf635e.tar
android_bootable_recovery-2ecdc8948d60a99b14ceef5cf290f22e65cf635e.tar.gz
android_bootable_recovery-2ecdc8948d60a99b14ceef5cf290f22e65cf635e.tar.bz2
android_bootable_recovery-2ecdc8948d60a99b14ceef5cf290f22e65cf635e.tar.lz
android_bootable_recovery-2ecdc8948d60a99b14ceef5cf290f22e65cf635e.tar.xz
android_bootable_recovery-2ecdc8948d60a99b14ceef5cf290f22e65cf635e.tar.zst
android_bootable_recovery-2ecdc8948d60a99b14ceef5cf290f22e65cf635e.zip
Diffstat (limited to '')
-rw-r--r--updater/blockimg.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp
index 77117db05..a7821f362 100644
--- a/updater/blockimg.cpp
+++ b/updater/blockimg.cpp
@@ -19,6 +19,7 @@
#include <dirent.h>
#include <fcntl.h>
#include <inttypes.h>
+#include <libgen.h>
#include <linux/fs.h>
#include <pthread.h>
#include <stdarg.h>
@@ -686,6 +687,7 @@ static int WriteStash(const char* base, const char* id, int blocks, uint8_t* buf
char *cn = NULL;
int fd = -1;
int rc = -1;
+ int dfd = -1;
int res;
struct stat st;
@@ -744,6 +746,20 @@ static int WriteStash(const char* base, const char* id, int blocks, uint8_t* buf
goto wsout;
}
+ const char* dname;
+ dname = dirname(cn);
+ dfd = TEMP_FAILURE_RETRY(open(dname, O_RDONLY | O_DIRECTORY));
+
+ if (dfd == -1) {
+ fprintf(stderr, "failed to open \"%s\" failed: %s\n", dname, strerror(errno));
+ goto wsout;
+ }
+
+ if (fsync(dfd) == -1) {
+ fprintf(stderr, "fsync \"%s\" failed: %s\n", dname, strerror(errno));
+ goto wsout;
+ }
+
rc = 0;
wsout:
@@ -751,6 +767,10 @@ wsout:
close(fd);
}
+ if (dfd != -1) {
+ close(dfd);
+ }
+
if (fn) {
free(fn);
}