diff options
author | Zim <zezeozue@google.com> | 2020-07-03 07:05:53 +0100 |
---|---|---|
committer | Zimuzo Ezeozue <zezeozue@google.com> | 2020-07-03 08:56:39 +0000 |
commit | 1b14f2ffa1ac960b42ee87cf57b3ae4039bc7a28 (patch) | |
tree | c9cfbe419be86750a6caae841733d8c3d711f98f | |
parent | 8ea8488f78742bab100e24d5b291168aaefbd4d3 (diff) | |
download | MediaProvider-1b14f2ffa1ac960b42ee87cf57b3ae4039bc7a28.tar.gz |
Discard O_APPEND flag during FUSE open/create
With write_back_cache enabled, the kernel already handles the O_APPEND
flag. Setting it on the lower fs fd can lead to file corruption with
multiple FUSE threads writing.
Test: Whatsapp backups without corruption
Bug: 160284525
Bug: 160231482
Change-Id: Iba893e905fcbf0ef99e9ebc16d3341e692bb036d
-rw-r--r-- | jni/FuseDaemon.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/jni/FuseDaemon.cpp b/jni/FuseDaemon.cpp index 87d403f0f..bff46254d 100644 --- a/jni/FuseDaemon.cpp +++ b/jni/FuseDaemon.cpp @@ -982,6 +982,10 @@ static void pf_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { open_flags |= O_RDWR; } + if (open_flags & O_APPEND) { + open_flags &= ~O_APPEND; + } + const int fd = open(path.c_str(), open_flags); if (fd < 0) { fuse_reply_err(req, errno); @@ -1525,6 +1529,10 @@ static void pf_create(fuse_req_t req, open_flags |= O_RDWR; } + if (open_flags & O_APPEND) { + open_flags &= ~O_APPEND; + } + mode = (mode & (~0777)) | 0664; int fd = open(child_path.c_str(), open_flags, mode); if (fd < 0) { |