--- libaitio/src/aio.c 2010/07/05 09:25:06 1.1.2.1 +++ libaitio/src/aio.c 2011/04/19 21:07:32 1.2.8.1 @@ -1,8 +1,16 @@ +/************************************************************************* +* (C) 2010 AITNET ltd - Sofia/Bulgaria - +* by Michael Pounov +* +* $Author: misho $ +* $Id: aio.c,v 1.2.8.1 2011/04/19 21:07:32 misho Exp $ +* +*************************************************************************/ #include "global.h" /* - * io_rread() Raw read function + * io_rread() Raw VFS read function * @fd = File handle * @buf = Read buffer * @nbytes = Read buffer size @@ -15,6 +23,7 @@ io_rread(int fd, void * __restrict buf, size_t nbytes, { int ret; #ifdef AIO_OPS + off_t old = 0; struct aiocb acb; #endif @@ -33,6 +42,16 @@ io_rread(int fd, void * __restrict buf, size_t nbytes, } #ifdef AIO_OPS + /* This made for generate EOF for file */ + if (!update && (old = lseek(fd, 0, SEEK_CUR)) == -1) { + LOGERR; + return -1; + } + if (offset >= lseek(fd, 0, SEEK_END)) + return 0; + if (!update) + lseek(fd, old, SEEK_SET); + memset(buf, 0, nbytes); memset(&acb, 0, sizeof acb); acb.aio_fildes = fd; @@ -67,7 +86,7 @@ io_rread(int fd, void * __restrict buf, size_t nbytes, } /* - * io_rwrite() Raw write function + * io_rwrite() Raw VFS write function * @fd = File handle * @buf = Write buffer * @nbytes = Write bytes from buffer @@ -98,7 +117,6 @@ io_rwrite(int fd, void * __restrict buf, size_t nbytes } #ifdef AIO_OPS - memset(buf, 0, nbytes); memset(&acb, 0, sizeof acb); acb.aio_fildes = fd; acb.aio_nbytes = nbytes;