Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f043f061 authored by Elliott Hughes's avatar Elliott Hughes Committed by Android Git Automerger
Browse files

am 060b6ecb: am 6e141aea: Merge "Fix sdcard\'s FUSE_FSYNCDIR handling."

* commit '060b6ecb':
  Fix sdcard's FUSE_FSYNCDIR handling.
parents 94645665 060b6ecb
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -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;
    bool is_dir = (hdr->opcode == FUSE_FSYNCDIR);
    bool is_data_sync = req->fsync_flags & 1;

    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);
    int res;
      fd = h->fd;
    }

    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) {
    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;