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

Commit 49e9344b authored by Arpad Horvath's avatar Arpad Horvath
Browse files

sdcard: direct I/O file access write buffer alignment

It is not enough to align the read buffer only, because
consequent writes might still fail with EINVAL. The write
buffer should be also aligned according to the write(2)
manual page.

Change-Id: I7547dec5208732c56f4466c1b0c88f36dabacf5b
parent f7cf1a06
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1244,6 +1244,12 @@ static int handle_write(struct fuse* fuse, struct fuse_handler* handler,
    struct fuse_write_out out;
    struct handle *h = id_to_ptr(req->fh);
    int res;
    __u8 aligned_buffer[req->size] __attribute__((__aligned__(PAGESIZE)));
    
    if (req->flags & O_DIRECT) {
        memcpy(aligned_buffer, buffer, req->size);
        buffer = (const __u8*) aligned_buffer;
    }

    TRACE("[%d] WRITE %p(%d) %u@%llu\n", handler->token,
            h, h->fd, req->size, req->offset);