From 1ca4df58c76e98d963d90c092532ca584606ccff Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 25 Jan 2012 15:30:56 -0800 Subject: Use sys_pread/sys_pwrite to cope correctly with 64-bit sizes. As in the default VFS case fall back from pread -> read and pwrite -> write on an ESPIPE error in the worker thread. Autobuild-User: Jeremy Allison Autobuild-Date: Thu Jan 26 02:11:28 CET 2012 on sn-devel-104 --- source3/modules/vfs_aio_pthread.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_aio_pthread.c b/source3/modules/vfs_aio_pthread.c index e1cc492bb5..c172ff04b2 100644 --- a/source3/modules/vfs_aio_pthread.c +++ b/source3/modules/vfs_aio_pthread.c @@ -115,15 +115,29 @@ static void aio_worker(void *private_data) (struct aio_private_data *)private_data; if (pd->write_command) { - pd->ret_size = pwrite(pd->aiocb->aio_fildes, + pd->ret_size = sys_pwrite(pd->aiocb->aio_fildes, (const void *)pd->aiocb->aio_buf, pd->aiocb->aio_nbytes, pd->aiocb->aio_offset); + if (pd->ret_size == -1 && errno == ESPIPE) { + /* Maintain the fiction that pipes can + be seeked (sought?) on. */ + pd->ret_size = sys_write(pd->aiocb->aio_fildes, + (const void *)pd->aiocb->aio_buf, + pd->aiocb->aio_nbytes); + } } else { - pd->ret_size = pread(pd->aiocb->aio_fildes, + pd->ret_size = sys_pread(pd->aiocb->aio_fildes, (void *)pd->aiocb->aio_buf, pd->aiocb->aio_nbytes, pd->aiocb->aio_offset); + if (pd->ret_size == -1 && errno == ESPIPE) { + /* Maintain the fiction that pipes can + be seeked (sought?) on. */ + pd->ret_size = sys_read(pd->aiocb->aio_fildes, + (void *)pd->aiocb->aio_buf, + pd->aiocb->aio_nbytes); + } } if (pd->ret_size == -1) { pd->ret_errno = errno; -- cgit