path: root/sdcard
diff options
authorArpad Horvath <>2014-02-18 10:18:25 +0100
committerArpad Horvath <>2014-02-18 10:18:25 +0100
commit49e9344bddca3699c04f3da8c689d0f2b1a338b6 (patch)
tree57d129018d8ea5afc159033b0d58bb1502562e2e /sdcard
parentf7cf1a062ef27b6579b9afb876d635a307b3d5d3 (diff)
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
Diffstat (limited to 'sdcard')
1 files changed, 6 insertions, 0 deletions
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index 3bc8cd3f7..cb03316f4 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -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);