2 * This Cplant(TM) source code is the property of Sandia National
5 * This Cplant(TM) source code is copyrighted by Sandia National
8 * The redistribution of this Cplant(TM) source code is subject to the
9 * terms of the GNU Lesser General Public License
10 * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
12 * Cplant(TM) Copyright 1998-2004 Sandia Corporation.
13 * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
14 * license for use of this work by or on behalf of the US Government.
15 * Export of this program may require a license from the United States
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 * Questions or comments about this library should be sent to:
37 * Sandia National Laboratories, New Mexico
39 * Albuquerque, NM 87185-1110
47 #include <sys/types.h>
51 #include <sys/queue.h>
58 #include "sysio-symbols.h"
60 #define IIOXOP_READ(ino) (ino)->i_ops.inop_read, 0
61 #define IIOXOP_WRITE(ino) (ino)->i_ops.inop_write, 1
64 * Decoding the interface routine names:
66 * Much of this carries legacy from the POSIX world and the Intel ASCI
67 * Red programming environment. Routine names are composed of prefix,
68 * basic POSIX names, and postfix. The basic POSIX names are read and write.
69 * Prefixes, left-to-right:
71 * - 'i' -- asynchronous operation (from ASCI Red)
72 * - 'p' -- positional (POSIX)
74 * - 'v' -- vectored (POSIX)
75 * - 'x' -- extent-based (new for Red Storm)
77 * All valid combinations are available and symmetric.
81 * Post op using iovec with regions specified by the passed extent vector.
83 * NOTE: There are enough parameters that we should really consider
84 * passing them in a structure.
87 _sysio_iiox(int (*f)(struct inode *, struct ioctx *),
90 const struct iovec *iov,
92 void (*iov_free)(struct ioctx *),
93 const struct intnl_xtvec *xtv,
95 void (*xtv_free)(struct ioctx *),
96 void (*completio)(struct ioctx *, void *),
97 struct ioctx **ioctxp)
103 struct ioctx_callback *cb;
106 * Check that it was opened with flags supporting the operation.
108 if (!F_CHKRW(fil, wr ? 'w' : 'r'))
119 _sysio_validx(xtv, xtv_count,
121 #if defined(_LARGEFILE64_SOURCE) && defined(O_LARGEFILE)
122 (fil->f_flags & O_LARGEFILE) == 0
129 ioctx = _sysio_ioctx_new(ino, wr, iov, iov_count, xtv, xtv_count);
133 (err = _sysio_ioctx_cb(ioctx,
134 (void (*)(struct ioctx *,
138 (err = _sysio_ioctx_cb(ioctx,
139 (void (*)(struct ioctx *,
143 (err = _sysio_ioctx_cb(ioctx,
144 (void (*)(struct ioctx *,
147 (err = (*f)(ino, ioctx))) {
149 * Release the callback queue. Don't want it run after all.
151 while ((cb = ioctx->ioctx_cbq.tqh_first)) {
152 TAILQ_REMOVE(&ioctx->ioctx_cbq,
155 _sysio_ioctx_cb_free(cb);
157 _sysio_ioctx_complete(ioctx);
165 * Sum iovec entries, returning total found or error if range of ssize_t would
169 _sysio_sum_iovec(const struct iovec *iov, int count)
180 if (tmp && iov->iov_len && cc <= tmp)
188 * Asynch IO from/to iovec from/to current file offset.
191 _sysio_iiov(int (*f)(struct inode *, struct ioctx *),
194 const struct iovec *iov,
196 void (*iov_free)(struct ioctx *),
197 struct intnl_xtvec *xtv,
198 void (*xtv_free)(struct ioctx *),
199 struct ioctx **ioctxp)
205 cc = _sysio_sum_iovec(iov, count);
208 xtv->xtv_off = fil->f_pos;
210 off = xtv->xtv_off + xtv->xtv_len;
211 if (xtv->xtv_off && off <= xtv->xtv_off) {
213 * Ouch! The IO vector specifies more bytes than
214 * are addressable. Trim the region to limit how
215 * much of the IO vector is finally transferred.
217 xtv->xtv_len = _SYSIO_OFF_T_MAX - xtv->xtv_off;
223 iov, count, iov_free,
225 (void (*)(struct ioctx *, void *))_sysio_fcompletio,
233 free_xtv(struct ioctx *ioctx)
236 free((struct iovec *)ioctx->ioctx_xtv);
237 ioctx->ioctx_iov = NULL;
241 SYSIO_INTERFACE_NAME(ireadv)(int fd, const struct iovec *iov, int count)
244 struct intnl_xtvec *xtv;
247 SYSIO_INTERFACE_DISPLAY_BLOCK;
249 SYSIO_INTERFACE_ENTER;
250 fil = _sysio_fd_find(fd);
252 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
254 xtv = malloc(sizeof(struct intnl_xtvec));
256 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
259 _sysio_iiov(IIOXOP_READ(fil->f_ino),
266 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
268 SYSIO_INTERFACE_RETURN(ioctx, 0);
272 SYSIO_INTERFACE_NAME(readv)(int fd, const struct iovec *iov, int count)
275 struct intnl_xtvec xtvector;
279 SYSIO_INTERFACE_DISPLAY_BLOCK;
281 SYSIO_INTERFACE_ENTER;
282 fil = _sysio_fd_find(fd);
284 SYSIO_INTERFACE_RETURN(-1, -EBADF);
287 _sysio_iiov(IIOXOP_READ(fil->f_ino),
292 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
295 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
298 #if defined(__GLIBC__)
300 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(readv),
301 PREPEND(__, SYSIO_INTERFACE_NAME(readv)))
303 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(readv),
304 PREPEND(__, SYSIO_INTERFACE_NAME(libc_readv)))
308 free_iov(struct ioctx *ioctx)
311 free((struct iovec *)ioctx->ioctx_iov);
312 ioctx->ioctx_iov = NULL;
316 SYSIO_INTERFACE_NAME(iread)(int fd, void *buf, size_t count)
320 struct intnl_xtvec *xtv;
323 SYSIO_INTERFACE_DISPLAY_BLOCK;
325 SYSIO_INTERFACE_ENTER;
326 fil = _sysio_fd_find(fd);
328 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
330 iov = malloc(sizeof(struct iovec));
332 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
335 iov->iov_len = count;
336 xtv = malloc(sizeof(struct intnl_xtvec));
339 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
342 _sysio_iiov(IIOXOP_READ(fil->f_ino),
350 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
352 SYSIO_INTERFACE_RETURN(ioctx, 0);
356 SYSIO_INTERFACE_NAME(read)(int fd, void *buf, size_t count)
359 struct iovec iovector;
360 struct intnl_xtvec xtvector;
364 SYSIO_INTERFACE_DISPLAY_BLOCK;
366 SYSIO_INTERFACE_ENTER;
367 fil = _sysio_fd_find(fd);
369 SYSIO_INTERFACE_RETURN(-1, -EBADF);
371 iovector.iov_base = buf;
372 iovector.iov_len = count;
374 _sysio_iiov(IIOXOP_READ(fil->f_ino),
379 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
381 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
386 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(read),
387 PREPEND(__, SYSIO_INTERFACE_NAME(read)))
389 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(read),
390 PREPEND(__, SYSIO_INTERFACE_NAME(libc_read)))
394 * Asynch IO between iovec and data at the given offset.
397 _sysio_ipiov(int (*f)(struct inode *, struct ioctx *),
400 const struct iovec *iov,
402 void (*iov_free)(struct ioctx *),
404 struct intnl_xtvec *xtv,
405 void (*xtv_free)(struct ioctx *),
406 struct ioctx **ioctxp)
412 cc = _sysio_sum_iovec(iov, count);
423 iov, count, iov_free,
434 PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv))(int fd,
435 const struct iovec *iov,
440 struct intnl_xtvec *xtv;
443 SYSIO_INTERFACE_DISPLAY_BLOCK;
445 SYSIO_INTERFACE_ENTER;
446 fil = _sysio_fd_find(fd);
448 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
450 xtv = malloc(sizeof(struct intnl_xtvec));
452 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
455 _sysio_ipiov(IIOXOP_READ(fil->f_ino),
463 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
465 SYSIO_INTERFACE_RETURN(ioctx, 0);
468 #ifdef _LARGEFILE64_SOURCE
470 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv)),
471 SYSIO_INTERFACE_NAME(ipread64v))
475 SYSIO_INTERFACE_NAME(ipreadv)(int fd,
476 const struct iovec *iov,
481 return PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv))(fd,
488 PREPEND(_, SYSIO_INTERFACE_NAME(preadv))(int fd,
489 const struct iovec *iov,
490 _SYSIO_PREADV_T count,
494 struct intnl_xtvec xtvector;
498 SYSIO_INTERFACE_DISPLAY_BLOCK;
500 SYSIO_INTERFACE_ENTER;
501 fil = _sysio_fd_find(fd);
503 SYSIO_INTERFACE_RETURN(-1, -EBADF);
506 _sysio_ipiov(IIOXOP_READ(fil->f_ino),
512 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
515 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
518 #ifdef _LARGEFILE64_SOURCE
520 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(preadv)),
521 SYSIO_INTERFACE_NAME(pread64v))
525 SYSIO_INTERFACE_NAME(preadv)(int fd,
526 const struct iovec *iov,
527 _SYSIO_PREADV_T count,
531 return PREPEND(_, SYSIO_INTERFACE_NAME(preadv))(fd,
538 PREPEND(_, SYSIO_INTERFACE_NAME(ipread))(int fd,
544 struct intnl_xtvec *xtv;
548 SYSIO_INTERFACE_DISPLAY_BLOCK;
550 SYSIO_INTERFACE_ENTER;
551 fil = _sysio_fd_find(fd);
553 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
555 xtv = malloc(sizeof(struct intnl_xtvec));
556 iov = malloc(sizeof(struct iovec));
561 xtv->xtv_off = offset;
563 xtv->xtv_len = iov->iov_len = count;
565 _sysio_ipiov(IIOXOP_READ(fil->f_ino),
577 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
579 SYSIO_INTERFACE_RETURN(ioctx, 0);
582 #ifdef _LARGEFILE64_SOURCE
584 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipread)),
585 SYSIO_INTERFACE_NAME(ipread64))
589 SYSIO_INTERFACE_NAME(ipread)(int fd,
595 return PREPEND(_, SYSIO_INTERFACE_NAME(ipread))(fd,
602 PREPEND(_, SYSIO_INTERFACE_NAME(pread))(int fd,
608 struct intnl_xtvec xtvec;
613 SYSIO_INTERFACE_DISPLAY_BLOCK;
615 SYSIO_INTERFACE_ENTER;
616 fil = _sysio_fd_find(fd);
618 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
620 xtvec.xtv_off = offset;
621 iovec.iov_base = buf;
622 xtvec.xtv_len = iovec.iov_len = count;
624 _sysio_ipiov(IIOXOP_READ(fil->f_ino),
630 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
633 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
636 #ifdef _LARGEFILE64_SOURCE
638 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)),
639 SYSIO_INTERFACE_NAME(pread64))
642 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)),
643 PREPEND(__, SYSIO_INTERFACE_NAME(pread64)))
644 #undef __libc_pread64
645 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)),
646 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pread64)))
651 SYSIO_INTERFACE_NAME(pread)(int fd, void *buf, size_t count, off_t offset)
654 return PREPEND(_, SYSIO_INTERFACE_NAME(pread))(fd,
662 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pread),
663 PREPEND(__, SYSIO_INTERFACE_NAME(pread)))
665 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pread),
666 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pread)))
670 PREPEND(_, SYSIO_INTERFACE_NAME(ireadx))(int fd,
671 const struct iovec *iov,
673 const struct intnl_xtvec *xtv,
679 SYSIO_INTERFACE_DISPLAY_BLOCK;
681 SYSIO_INTERFACE_ENTER;
682 fil = _sysio_fd_find(fd);
684 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
686 /* Perform a check on the iov_count and xtv_count */
687 if ((iov_count == 0) || (xtv_count == 0))
688 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL);
691 _sysio_iiox(IIOXOP_READ(fil->f_ino),
693 iov, iov_count, NULL,
694 xtv, xtv_count, NULL,
698 SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err);
701 #ifdef _LARGEFILE64_SOURCE
703 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)),
704 SYSIO_INTERFACE_NAME(iread64x))
707 #ifdef _LARGEFILE64_SOURCE
709 SYSIO_INTERFACE_NAME(ireadx)(int fd,
710 const struct iovec *iov, size_t iov_count,
711 const struct xtvec *xtv, size_t xtv_count)
714 struct intnl_xtvec *ixtv, *ixtvent;
718 SYSIO_INTERFACE_DISPLAY_BLOCK;
720 SYSIO_INTERFACE_ENTER;
721 fil = _sysio_fd_find(fd);
723 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
726 /* Perform a check on the iov_count and xtv_count */
727 if ((iov_count == 0) || (xtv_count == 0))
728 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL);
730 ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec));
732 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
736 ixtvent->xtv_off = xtv->xtv_off;
737 ixtvent->xtv_len = xtv->xtv_len;
743 _sysio_iiox(IIOXOP_READ(fil->f_ino),
745 iov, iov_count, NULL,
746 ixtv, xtv_count, free_xtv,
751 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
753 SYSIO_INTERFACE_RETURN(ioctx, 0);
757 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)),
758 SYSIO_INTERFACE_NAME(ireadx))
762 SYSIO_INTERFACE_NAME(readx)(int fd,
763 const struct iovec *iov, size_t iov_count,
764 const struct xtvec *xtv, size_t xtv_count)
768 if ((ioid = SYSIO_INTERFACE_NAME(ireadx)(fd,
772 xtv_count)) == IOID_FAIL)
774 return SYSIO_INTERFACE_NAME(iowait)(ioid);
777 #ifdef _LARGEFILE64_SOURCE
780 SYSIO_INTERFACE_NAME(read64x)(int fd,
781 const struct iovec *iov, size_t iov_count,
782 const struct xtvec64 *xtv, size_t xtv_count)
786 if ((ioid = SYSIO_INTERFACE_NAME(iread64x)(fd,
790 xtv_count)) == IOID_FAIL)
792 return SYSIO_INTERFACE_NAME(iowait)(ioid);
803 int64_t file_offsets[],
804 int32_t file_lengths[])
806 SYSIO_INTERFACE_DISPLAY_BLOCK;
808 SYSIO_INTERFACE_ENTER;
809 SYSIO_INTERFACE_RETURN(-1, -ENOSYS);
814 SYSIO_INTERFACE_NAME(iwritev)(int fd,
815 const struct iovec *iov,
819 struct intnl_xtvec *xtv;
822 SYSIO_INTERFACE_DISPLAY_BLOCK;
824 SYSIO_INTERFACE_ENTER;
825 fil = _sysio_fd_find(fd);
827 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
829 xtv = malloc(sizeof(struct intnl_xtvec));
831 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
834 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
841 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
843 SYSIO_INTERFACE_RETURN(ioctx, 0);
847 SYSIO_INTERFACE_NAME(writev)(int fd, const struct iovec *iov,
851 struct intnl_xtvec xtvector;
855 SYSIO_INTERFACE_DISPLAY_BLOCK;
857 SYSIO_INTERFACE_ENTER;
858 fil = _sysio_fd_find(fd);
860 SYSIO_INTERFACE_RETURN(-1, -EBADF);
863 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
868 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
871 SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err);
876 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev),
877 PREPEND(__, SYSIO_INTERFACE_NAME(writev)))
879 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev),
880 PREPEND(__, SYSIO_INTERFACE_NAME(libc_writev)))
884 SYSIO_INTERFACE_NAME(iwrite)(int fd, const void *buf, size_t count)
888 struct intnl_xtvec *xtv;
891 SYSIO_INTERFACE_DISPLAY_BLOCK;
893 SYSIO_INTERFACE_ENTER;
894 fil = _sysio_fd_find(fd);
896 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
898 iov = malloc(sizeof(struct iovec));
900 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
902 iov->iov_base = (void *)buf;
903 iov->iov_len = count;
904 xtv = malloc(sizeof(struct intnl_xtvec));
907 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
910 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
918 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
920 SYSIO_INTERFACE_RETURN(ioctx, 0);
924 SYSIO_INTERFACE_NAME(write)(int fd, const void *buf, size_t count)
927 struct iovec iovector;
928 struct intnl_xtvec xtvector;
932 SYSIO_INTERFACE_DISPLAY_BLOCK;
934 SYSIO_INTERFACE_ENTER;
935 fil = _sysio_fd_find(fd);
937 SYSIO_INTERFACE_RETURN(-1, -EBADF);
939 iovector.iov_base = (void *)buf;
940 iovector.iov_len = count;
942 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
947 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
950 SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err);
955 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write),
956 PREPEND(__, SYSIO_INTERFACE_NAME(write)))
958 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write),
959 PREPEND(__, SYSIO_INTERFACE_NAME(libc_write)))
963 PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(int fd,
964 const struct iovec *iov,
969 struct intnl_xtvec *xtv;
972 SYSIO_INTERFACE_DISPLAY_BLOCK;
974 SYSIO_INTERFACE_ENTER;
975 fil = _sysio_fd_find(fd);
977 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
979 xtv = malloc(sizeof(struct intnl_xtvec));
981 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
984 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
992 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
994 SYSIO_INTERFACE_RETURN(ioctx, 0);
997 #ifdef _LARGEFILE64_SOURCE
999 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev)),
1000 SYSIO_INTERFACE_NAME(ipwrite64v))
1004 SYSIO_INTERFACE_NAME(ipwritev)(int fd,
1005 const struct iovec *iov,
1010 return PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(fd,
1017 PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(int fd,
1018 const struct iovec *iov,
1019 _SYSIO_PREADV_T count,
1020 _SYSIO_OFF_T offset)
1023 struct intnl_xtvec xtvector;
1024 struct ioctx *ioctx;
1027 SYSIO_INTERFACE_DISPLAY_BLOCK;
1029 SYSIO_INTERFACE_ENTER;
1030 fil = _sysio_fd_find(fd);
1032 SYSIO_INTERFACE_RETURN(-1, -EBADF);
1035 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1041 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
1044 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
1047 #ifdef _LARGEFILE64_SOURCE
1049 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwritev)),
1050 SYSIO_INTERFACE_NAME(pwrite64v))
1054 SYSIO_INTERFACE_NAME(pwritev)(int fd,
1055 const struct iovec *iov,
1056 _SYSIO_PREADV_T count,
1060 return PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(fd,
1067 PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(int fd,
1070 _SYSIO_OFF_T offset)
1073 struct intnl_xtvec *xtv;
1075 struct ioctx *ioctx;
1077 SYSIO_INTERFACE_DISPLAY_BLOCK;
1079 SYSIO_INTERFACE_ENTER;
1080 fil = _sysio_fd_find(fd);
1082 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1084 xtv = malloc(sizeof(struct intnl_xtvec));
1085 iov = malloc(sizeof(struct iovec));
1086 if (!(xtv && iov)) {
1090 xtv->xtv_off = offset;
1091 iov->iov_base = (void *)buf;
1092 xtv->xtv_len = iov->iov_len = count;
1094 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1106 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
1108 SYSIO_INTERFACE_RETURN(ioctx, 0);
1111 #ifdef _LARGEFILE64_SOURCE
1113 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite)),
1114 SYSIO_INTERFACE_NAME(ipwrite64))
1118 SYSIO_INTERFACE_NAME(ipwrite)(int fd,
1124 return PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(fd,
1131 PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(int fd,
1134 _SYSIO_OFF_T offset)
1137 struct intnl_xtvec xtvec;
1139 struct ioctx *ioctx;
1142 SYSIO_INTERFACE_DISPLAY_BLOCK;
1144 SYSIO_INTERFACE_ENTER;
1145 fil = _sysio_fd_find(fd);
1147 SYSIO_INTERFACE_RETURN(-1, -EBADF);
1149 xtvec.xtv_off = offset;
1150 iovec.iov_base = (void *)buf;
1151 xtvec.xtv_len = iovec.iov_len = count;
1153 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1159 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
1162 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
1165 #ifdef _LARGEFILE64_SOURCE
1167 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1168 SYSIO_INTERFACE_NAME(pwrite64))
1171 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1172 PREPEND(__, SYSIO_INTERFACE_NAME(pwrite64)))
1173 #undef __libc_pwrite64
1174 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1175 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite64)))
1180 SYSIO_INTERFACE_NAME(pwrite)(int fd,
1186 return PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(fd,
1193 #undef __libc_pwrite
1194 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pwrite), __libc_pwrite)
1195 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite)))
1199 PREPEND(_, SYSIO_INTERFACE_NAME(iwritex))(int fd,
1200 const struct iovec *iov,
1202 const struct intnl_xtvec *xtv,
1207 struct ioctx *ioctx;
1208 SYSIO_INTERFACE_DISPLAY_BLOCK;
1210 SYSIO_INTERFACE_ENTER;
1211 fil = _sysio_fd_find(fd);
1212 if (!(fil && xtv_count))
1213 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1216 _sysio_iiox(IIOXOP_WRITE(fil->f_ino),
1218 iov, iov_count, NULL,
1219 xtv, xtv_count, NULL,
1223 SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err);
1226 #ifdef _LARGEFILE64_SOURCE
1228 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)),
1229 SYSIO_INTERFACE_NAME(iwrite64x))
1232 #ifdef _LARGEFILE64_SOURCE
1234 SYSIO_INTERFACE_NAME(iwritex)(int fd,
1235 const struct iovec *iov, size_t iov_count,
1236 const struct xtvec *xtv, size_t xtv_count)
1239 struct intnl_xtvec *ixtv, *ixtvent;
1242 struct ioctx *ioctx;
1243 SYSIO_INTERFACE_DISPLAY_BLOCK;
1245 SYSIO_INTERFACE_ENTER;
1246 fil = _sysio_fd_find(fd);
1248 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1250 /* Perform a check on the iov_count and xtv_count */
1251 if ((iov_count == 0) || (xtv_count == 0))
1252 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL);
1254 ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec));
1256 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
1260 ixtvent->xtv_off = xtv->xtv_off;
1261 ixtvent->xtv_len = xtv->xtv_len;
1267 _sysio_iiox(IIOXOP_WRITE(fil->f_ino),
1269 iov, iov_count, NULL,
1270 ixtv, xtv_count, free_xtv,
1275 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
1277 SYSIO_INTERFACE_RETURN(ioctx, 0);
1281 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)),
1282 SYSIO_INTERFACE_NAME(iwritex))
1287 SYSIO_INTERFACE_NAME(writex)(int fd,
1288 const struct iovec *iov, size_t iov_count,
1289 const struct xtvec *xtv, size_t xtv_count)
1294 SYSIO_INTERFACE_NAME(iwritex)(fd,
1298 xtv_count)) == IOID_FAIL)
1300 return SYSIO_INTERFACE_NAME(iowait)(ioid);
1303 #ifdef _LARGEFILE64_SOURCE
1306 SYSIO_INTERFACE_NAME(write64x)(int fd,
1307 const struct iovec *iov, size_t iov_count,
1308 const struct xtvec64 *xtv, size_t xtv_count)
1312 if ((ioid = SYSIO_INTERFACE_NAME(iwrite64x)(fd,
1316 xtv_count)) == IOID_FAIL)
1318 return SYSIO_INTERFACE_NAME(iowait)(ioid);
1326 char *mem_offsets[],
1328 int file_list_count,
1329 int64_t file_offsets[],
1330 int32_t file_lengths[])
1332 SYSIO_INTERFACE_DISPLAY_BLOCK;
1334 SYSIO_INTERFACE_ENTER;
1335 SYSIO_INTERFACE_RETURN(-1, -ENOSYS);