[Libsysio-commit] HEAD: libsysio/drivers/yod fs_yod.c
Brought to you by:
lward
From: Ruth K. <rk...@us...> - 2004-01-12 18:09:49
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv4997 Modified Files: fs_yod.c Log Message: add native driver changes to yod driver Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- fs_yod.c 12 Nov 2003 21:51:40 -0000 1.8 +++ fs_yod.c 12 Jan 2004 18:09:44 -0000 1.9 @@ -987,7 +987,11 @@ doio(ssize_t (*f)(int, const struct iove assert(nino->ni_fd >= 0); - if (ioctx->ioctx_iovlen && (int )ioctx->ioctx_iovlen < 0) + if ((ioctx->ioctx_iovlen && (int )ioctx->ioctx_iovlen < 0) || + !(S_ISREG(ino->i_mode) || + S_ISCHR(ino->i_mode) || + S_ISSOCK(ino->i_mode) || + S_ISFIFO(ino->i_mode))) return -EINVAL; /* @@ -1002,30 +1006,29 @@ doio(ssize_t (*f)(int, const struct iove * Avoid the reposition call if we're already at the right place. * Allows us to access pipes and fifos. */ - result = nino->ni_fpos; - if (ioctx->ioctx_offset != nino->ni_fpos && - !(S_ISCHR(ino->i_mode) || - S_ISSOCK(ino->i_mode) || - S_ISFIFO(ino->i_mode)) && - (result = lseek_yod(nino->ni_fd, + result = ioctx->ioctx_offset; + if (ioctx->ioctx_offset != nino->ni_fpos) { + result = lseek_yod(nino->ni_fd, ioctx->ioctx_offset, - SEEK_SET) == -1)) { + SEEK_SET); + if (result == -1) { ioctx->ioctx_cc = -1; ioctx->ioctx_errno = errno; - } else { + goto out; + } + nino->ni_fpos = result; + } /* * Call the appropriate (read/write) IO function to * transfer the data now. */ - nino->ni_fpos = result; ioctx->ioctx_cc = (*f)(nino->ni_fd, ioctx->ioctx_iovec, ioctx->ioctx_iovlen); if (ioctx->ioctx_cc < 0) ioctx->ioctx_errno = errno; if (ioctx->ioctx_cc > 0) nino->ni_fpos += ioctx->ioctx_cc; - } - +out: ioctx->ioctx_done = 1; return 0; } |