summaryrefslogtreecommitdiffstats
path: root/sdcard
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-07-08 14:38:26 -0700
committerElliott Hughes <enh@google.com>2014-07-08 14:38:26 -0700
commitf6d6737529ea164fd2ea79f02cc78a46bb9260f5 (patch)
treee5f71c7295f9e2cd224a66934eb78daf26be539c /sdcard
parent75b7171fcb1a8f898ba533011ccb813792932e4c (diff)
downloadsystem_core-f6d6737529ea164fd2ea79f02cc78a46bb9260f5.zip
system_core-f6d6737529ea164fd2ea79f02cc78a46bb9260f5.tar.gz
system_core-f6d6737529ea164fd2ea79f02cc78a46bb9260f5.tar.bz2
Fix sdcard's FUSE_FSYNCDIR handling.
For a file the FUSE fh is a struct handle containing an int fd; for a directory it's a struct dirhandle containing a DIR*. Fix handle_fsync to extract the file descriptor appropriately in both cases. Bug: 14613980 Change-Id: I45515cff6638e27a99b849e6fc639d355dbb4d27
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 566a66c..844ca65 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -1309,14 +1309,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;