Use sys_pread/sys_pwrite to cope correctly with 64-bit sizes. As in the default VFS...
authorJeremy Allison <jra@samba.org>
Wed, 25 Jan 2012 23:30:56 +0000 (15:30 -0800)
committerJeremy Allison <jra@samba.org>
Thu, 26 Jan 2012 01:11:28 +0000 (02:11 +0100)
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Thu Jan 26 02:11:28 CET 2012 on sn-devel-104

source3/modules/vfs_aio_pthread.c

index e1cc492..c172ff0 100644 (file)
@@ -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;