X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libsysio%2Fsrc%2Frw.c;h=328f0768ed9519e5f0ad34faea15ed1cd050263d;hb=20d0187e95be6ec8c131a9bb8691e7d939875e68;hp=edc308bacc1d2150aef5d4510011fd4dae352a62;hpb=8692f4651696ff4324db3ad738d3fa62f68d7347;p=fs%2Flustre-release.git diff --git a/libsysio/src/rw.c b/libsysio/src/rw.c index edc308b..328f076 100644 --- a/libsysio/src/rw.c +++ b/libsysio/src/rw.c @@ -50,8 +50,8 @@ #include #include -#include "xtio.h" #include "sysio.h" +#include "xtio.h" #include "file.h" #include "inode.h" @@ -105,9 +105,7 @@ _sysio_iiox(int (*f)(struct inode *, struct ioctx *), /* * Check that it was opened with flags supporting the operation. */ - if (!(wr - ? (fil->f_flags & (O_RDWR | O_WRONLY)) - : !(fil->f_flags & O_WRONLY))) + if (!F_CHKRW(fil, wr ? 'w' : 'r')) return -EBADF; ino = fil->f_ino; @@ -682,9 +680,13 @@ PREPEND(_, SYSIO_INTERFACE_NAME(ireadx))(int fd, SYSIO_INTERFACE_ENTER; fil = _sysio_fd_find(fd); - if (!(fil && xtv_count)) + if (!fil) SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); + /* Perform a check on the iov_count and xtv_count */ + if ((iov_count == 0) || (xtv_count == 0)) + SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL); + err = _sysio_iiox(IIOXOP_READ(fil->f_ino), fil, @@ -717,9 +719,14 @@ SYSIO_INTERFACE_NAME(ireadx)(int fd, SYSIO_INTERFACE_ENTER; fil = _sysio_fd_find(fd); - if (!(fil && xtv_count)) + if (!fil) SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); + + /* Perform a check on the iov_count and xtv_count */ + if ((iov_count == 0) || (xtv_count == 0)) + SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL); + ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec)); if (!ixtv) SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); @@ -764,7 +771,7 @@ SYSIO_INTERFACE_NAME(readx)(int fd, xtv, xtv_count)) == IOID_FAIL) return -1; - return iowait(ioid); + return SYSIO_INTERFACE_NAME(iowait)(ioid); } #if _LARGEFILE64_SOURCE @@ -782,7 +789,7 @@ SYSIO_INTERFACE_NAME(read64x)(int fd, xtv, xtv_count)) == IOID_FAIL) return -1; - return iowait(ioid); + return SYSIO_INTERFACE_NAME(iowait)(ioid); } #endif @@ -1236,9 +1243,13 @@ SYSIO_INTERFACE_NAME(iwritex)(int fd, SYSIO_INTERFACE_ENTER; fil = _sysio_fd_find(fd); - if (!(fil && xtv_count)) + if (!fil) SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); + /* Perform a check on the iov_count and xtv_count */ + if ((iov_count == 0) || (xtv_count == 0)) + SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL); + ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec)); if (!ixtv) SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); @@ -1285,7 +1296,7 @@ SYSIO_INTERFACE_NAME(writex)(int fd, xtv, xtv_count)) == IOID_FAIL) return -1; - return iowait(ioid); + return SYSIO_INTERFACE_NAME(iowait)(ioid); } #if _LARGEFILE64_SOURCE @@ -1303,7 +1314,7 @@ SYSIO_INTERFACE_NAME(write64x)(int fd, xtv, xtv_count)) == IOID_FAIL) return -1; - return iowait(ioid); + return SYSIO_INTERFACE_NAME(iowait)(ioid); } #endif