--- libaitsched/src/tasks.c 2012/08/02 09:19:31 1.10.2.6 +++ libaitsched/src/tasks.c 2012/08/02 11:37:08 1.10.2.7 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: tasks.c,v 1.10.2.6 2012/08/02 09:19:31 misho Exp $ +* $Id: tasks.c,v 1.10.2.7 2012/08/02 11:37:08 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -649,11 +649,12 @@ schedAIOWrite(sched_root_task_t * __restrict root, sch * @fd = file descriptor * @bufs = Buffer's list * @nbufs = Number of Buffers + * @offset = Offset from start of file, if =-1 from current position * return: NULL error or !=NULL new queued task */ -inline sched_task_t * +sched_task_t * schedLIORead(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, int fd, - struct iovec *bufs, size_t nbufs) + struct iovec *bufs, size_t nbufs, off_t offset) { struct sigevent sig; struct aiocb **acb; @@ -663,11 +664,14 @@ schedLIORead(sched_root_task_t * __restrict root, sche if (!root || !func || !bufs || !nbufs) return NULL; - off = lseek(fd, 0, SEEK_CUR); - if (off == -1) { - LOGERR; - return NULL; - } + if (offset == (off_t) -1) { + off = lseek(fd, 0, SEEK_CUR); + if (off == -1) { + LOGERR; + return NULL; + } + } else + off = offset; if (!(acb = calloc(sizeof(void*), nbufs))) { LOGERR; @@ -713,11 +717,12 @@ schedLIORead(sched_root_task_t * __restrict root, sche * @fd = file descriptor * @bufs = Buffer's list * @nbufs = Number of Buffers + * @offset = Offset from start of file, if =-1 from current position * return: NULL error or !=NULL new queued task */ inline sched_task_t * schedLIOWrite(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, int fd, - struct iovec *bufs, size_t nbufs) + struct iovec *bufs, size_t nbufs, off_t offset) { struct sigevent sig; struct aiocb **acb; @@ -727,11 +732,14 @@ schedLIOWrite(sched_root_task_t * __restrict root, sch if (!root || !func || !bufs || !nbufs) return NULL; - off = lseek(fd, 0, SEEK_CUR); - if (off == -1) { - LOGERR; - return NULL; - } + if (offset == (off_t) -1) { + off = lseek(fd, 0, SEEK_CUR); + if (off == -1) { + LOGERR; + return NULL; + } + } else + off = offset; if (!(acb = calloc(sizeof(void*), nbufs))) { LOGERR;