Implement FUSE_FSYNC request.
This request is needed for application correctness, without which
data corruption may result.
Bug: 6488845
Change-Id: I3d676c2e40f6e6b37d5d270c7cb40f1bf8c1fa47
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index 4fff942..2b78482 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -853,7 +853,21 @@
return;
}
-// case FUSE_FSYNC:
+ case FUSE_FSYNC: {
+ const struct fuse_fsync_in *req = data;
+ int is_data_sync = req->fsync_flags & 1;
+ struct handle *h = id_to_ptr(req->fh);
+ int res;
+ TRACE("FSYNC %p(%d) is_data_sync=%d\n", h, h->fd, is_data_sync);
+ res = is_data_sync ? fdatasync(h->fd) : fsync(h->fd);
+ if (res < 0) {
+ fuse_status(fuse, hdr->unique, -errno);
+ return;
+ }
+ fuse_status(fuse, hdr->unique, 0);
+ return;
+ }
+
// case FUSE_SETXATTR:
// case FUSE_GETXATTR:
// case FUSE_LISTXATTR: