summaryrefslogtreecommitdiff
path: root/sdcard
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-07-09 12:16:46 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-07-09 12:16:46 +0000
commit6ebab06dc4e7149b4deb5032518c64b881801259 (patch)
tree41ca1d5a8d26c2571bc03c1b6bf1aa58469a659e /sdcard
parent40372e5b4ed1027418485a66d80e48748eedc07f (diff)
parentf043f061295a787aca42186fe9ab87c24d393b92 (diff)
am f043f061: am 060b6ecb: am 6e141aea: Merge "Fix sdcard\'s FUSE_FSYNCDIR handling."
* commit 'f043f061295a787aca42186fe9ab87c24d393b92': Fix sdcard's FUSE_FSYNCDIR handling.
Diffstat (limited to 'sdcard')
-rw-r--r--sdcard/sdcard.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index 2f02f65ed..d3afcb1c5 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -1316,14 +1316,23 @@ static int handle_release(struct fuse* fuse, struct fuse_handler* handler,
static int handle_fsync(struct fuse* fuse, struct fuse_handler* handler,
const struct fuse_in_header* hdr, const struct fuse_fsync_in* req)
{
- int is_data_sync = req->fsync_flags & 1;
- struct handle *h = id_to_ptr(req->fh);
- int res;
+ bool is_dir = (hdr->opcode == FUSE_FSYNCDIR);
+ bool is_data_sync = req->fsync_flags & 1;
- TRACE("[%d] FSYNC %p(%d) is_data_sync=%d\n", handler->token,
- h, h->fd, is_data_sync);
- res = is_data_sync ? fdatasync(h->fd) : fsync(h->fd);
- if (res < 0) {
+ int fd = -1;
+ if (is_dir) {
+ struct dirhandle *dh = id_to_ptr(req->fh);
+ fd = dirfd(dh->d);
+ } else {
+ struct handle *h = id_to_ptr(req->fh);
+ fd = h->fd;
+ }
+
+ TRACE("[%d] %s %p(%d) is_data_sync=%d\n", handler->token,
+ is_dir ? "FSYNCDIR" : "FSYNC",
+ id_to_ptr(req->fh), fd, is_data_sync);
+ int res = is_data_sync ? fdatasync(fd) : fsync(fd);
+ if (res == -1) {
return -errno;
}
return 0;