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.
109 ? (fil->f_flags & (O_RDWR | O_WRONLY))
110 : !(fil->f_flags & O_WRONLY)))
121 _sysio_validx(xtv, xtv_count,
123 #if _LARGEFILE64_SOURCE && defined(O_LARGEFILE)
124 (fil->f_flags & O_LARGEFILE) == 0
131 ioctx = _sysio_ioctx_new(ino, wr, iov, iov_count, xtv, xtv_count);
135 (err = _sysio_ioctx_cb(ioctx,
136 (void (*)(struct ioctx *,
140 (err = _sysio_ioctx_cb(ioctx,
141 (void (*)(struct ioctx *,
145 (err = _sysio_ioctx_cb(ioctx,
146 (void (*)(struct ioctx *,
149 (err = (*f)(ino, ioctx))) {
151 * Release the callback queue. Don't want it run after all.
153 while ((cb = ioctx->ioctx_cbq.tqh_first)) {
154 TAILQ_REMOVE(&ioctx->ioctx_cbq,
157 _sysio_ioctx_cb_free(cb);
159 _sysio_ioctx_complete(ioctx);
167 * Sum iovec entries, returning total found or error if range of ssize_t would
171 _sysio_sum_iovec(const struct iovec *iov, int count)
182 if (tmp && iov->iov_len && cc <= tmp)
190 * Asynch IO from/to iovec from/to current file offset.
193 _sysio_iiov(int (*f)(struct inode *, struct ioctx *),
196 const struct iovec *iov,
198 void (*iov_free)(struct ioctx *),
199 struct intnl_xtvec *xtv,
200 void (*xtv_free)(struct ioctx *),
201 struct ioctx **ioctxp)
207 cc = _sysio_sum_iovec(iov, count);
210 xtv->xtv_off = fil->f_pos;
212 off = xtv->xtv_off + xtv->xtv_len;
213 if (xtv->xtv_off && off <= xtv->xtv_off) {
215 * Ouch! The IO vector specifies more bytes than
216 * are addressable. Trim the region to limit how
217 * much of the IO vector is finally transferred.
219 xtv->xtv_len = _SYSIO_OFF_T_MAX - xtv->xtv_off;
225 iov, count, iov_free,
227 (void (*)(struct ioctx *, void *))_sysio_fcompletio,
235 free_xtv(struct ioctx *ioctx)
238 free((struct iovec *)ioctx->ioctx_xtv);
239 ioctx->ioctx_iov = NULL;
243 SYSIO_INTERFACE_NAME(ireadv)(int fd, const struct iovec *iov, int count)
246 struct intnl_xtvec *xtv;
249 SYSIO_INTERFACE_DISPLAY_BLOCK;
251 SYSIO_INTERFACE_ENTER;
252 fil = _sysio_fd_find(fd);
254 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
256 xtv = malloc(sizeof(struct intnl_xtvec));
258 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
261 _sysio_iiov(IIOXOP_READ(fil->f_ino),
268 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
270 SYSIO_INTERFACE_RETURN(ioctx, 0);
274 SYSIO_INTERFACE_NAME(readv)(int fd, const struct iovec *iov, int count)
277 struct intnl_xtvec xtvector;
281 SYSIO_INTERFACE_DISPLAY_BLOCK;
283 SYSIO_INTERFACE_ENTER;
284 fil = _sysio_fd_find(fd);
286 SYSIO_INTERFACE_RETURN(-1, -EBADF);
289 _sysio_iiov(IIOXOP_READ(fil->f_ino),
294 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
297 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
300 #if defined(__GLIBC__)
302 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(readv),
303 PREPEND(__, SYSIO_INTERFACE_NAME(readv)))
305 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(readv),
306 PREPEND(__, SYSIO_INTERFACE_NAME(libc_readv)))
310 free_iov(struct ioctx *ioctx)
313 free((struct iovec *)ioctx->ioctx_iov);
314 ioctx->ioctx_iov = NULL;
318 SYSIO_INTERFACE_NAME(iread)(int fd, void *buf, size_t count)
322 struct intnl_xtvec *xtv;
325 SYSIO_INTERFACE_DISPLAY_BLOCK;
327 SYSIO_INTERFACE_ENTER;
328 fil = _sysio_fd_find(fd);
330 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
332 iov = malloc(sizeof(struct iovec));
334 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
337 iov->iov_len = count;
338 xtv = malloc(sizeof(struct intnl_xtvec));
341 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
344 _sysio_iiov(IIOXOP_READ(fil->f_ino),
352 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
354 SYSIO_INTERFACE_RETURN(ioctx, 0);
358 SYSIO_INTERFACE_NAME(read)(int fd, void *buf, size_t count)
361 struct iovec iovector;
362 struct intnl_xtvec xtvector;
366 SYSIO_INTERFACE_DISPLAY_BLOCK;
368 SYSIO_INTERFACE_ENTER;
369 fil = _sysio_fd_find(fd);
371 SYSIO_INTERFACE_RETURN(-1, -EBADF);
373 iovector.iov_base = buf;
374 iovector.iov_len = count;
376 _sysio_iiov(IIOXOP_READ(fil->f_ino),
381 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
383 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
388 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(read),
389 PREPEND(__, SYSIO_INTERFACE_NAME(read)))
391 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(read),
392 PREPEND(__, SYSIO_INTERFACE_NAME(libc_read)))
396 * Asynch IO between iovec and data at the given offset.
399 _sysio_ipiov(int (*f)(struct inode *, struct ioctx *),
402 const struct iovec *iov,
404 void (*iov_free)(struct ioctx *),
406 struct intnl_xtvec *xtv,
407 void (*xtv_free)(struct ioctx *),
408 struct ioctx **ioctxp)
414 cc = _sysio_sum_iovec(iov, count);
425 iov, count, iov_free,
436 PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv))(int fd,
437 const struct iovec *iov,
442 struct intnl_xtvec *xtv;
445 SYSIO_INTERFACE_DISPLAY_BLOCK;
447 SYSIO_INTERFACE_ENTER;
448 fil = _sysio_fd_find(fd);
450 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
452 xtv = malloc(sizeof(struct intnl_xtvec));
454 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
457 _sysio_ipiov(IIOXOP_READ(fil->f_ino),
465 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
467 SYSIO_INTERFACE_RETURN(ioctx, 0);
470 #if _LARGEFILE64_SOURCE
472 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv)),
473 SYSIO_INTERFACE_NAME(ipread64v))
477 SYSIO_INTERFACE_NAME(ipreadv)(int fd,
478 const struct iovec *iov,
483 return PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv))(fd,
490 PREPEND(_, SYSIO_INTERFACE_NAME(preadv))(int fd,
491 const struct iovec *iov,
496 struct intnl_xtvec xtvector;
500 SYSIO_INTERFACE_DISPLAY_BLOCK;
502 SYSIO_INTERFACE_ENTER;
503 fil = _sysio_fd_find(fd);
505 SYSIO_INTERFACE_RETURN(-1, -EBADF);
508 _sysio_ipiov(IIOXOP_READ(fil->f_ino),
514 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
517 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
520 #if _LARGEFILE64_SOURCE
522 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(preadv)),
523 SYSIO_INTERFACE_NAME(pread64v))
527 SYSIO_INTERFACE_NAME(preadv)(int fd,
528 const struct iovec *iov,
533 return PREPEND(_, SYSIO_INTERFACE_NAME(preadv))(fd,
540 PREPEND(_, SYSIO_INTERFACE_NAME(ipread))(int fd,
546 struct intnl_xtvec *xtv;
550 SYSIO_INTERFACE_DISPLAY_BLOCK;
552 SYSIO_INTERFACE_ENTER;
553 fil = _sysio_fd_find(fd);
555 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
557 xtv = malloc(sizeof(struct intnl_xtvec));
558 iov = malloc(sizeof(struct iovec));
563 xtv->xtv_off = offset;
565 xtv->xtv_len = iov->iov_len = count;
567 _sysio_ipiov(IIOXOP_READ(fil->f_ino),
579 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
581 SYSIO_INTERFACE_RETURN(ioctx, 0);
584 #if _LARGEFILE64_SOURCE
586 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipread)),
587 SYSIO_INTERFACE_NAME(ipread64))
591 SYSIO_INTERFACE_NAME(ipread)(int fd,
597 return PREPEND(_, SYSIO_INTERFACE_NAME(ipread))(fd,
604 PREPEND(_, SYSIO_INTERFACE_NAME(pread))(int fd,
610 struct intnl_xtvec xtvec;
615 SYSIO_INTERFACE_DISPLAY_BLOCK;
617 SYSIO_INTERFACE_ENTER;
618 fil = _sysio_fd_find(fd);
620 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
622 xtvec.xtv_off = offset;
623 iovec.iov_base = buf;
624 xtvec.xtv_len = iovec.iov_len = count;
626 _sysio_ipiov(IIOXOP_READ(fil->f_ino),
632 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
635 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
638 #if _LARGEFILE64_SOURCE
640 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)),
641 SYSIO_INTERFACE_NAME(pread64))
644 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)),
645 PREPEND(__, SYSIO_INTERFACE_NAME(pread64)))
646 #undef __libc_pread64
647 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pread)),
648 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pread64)))
653 SYSIO_INTERFACE_NAME(pread)(int fd, void *buf, size_t count, off_t offset)
656 return PREPEND(_, SYSIO_INTERFACE_NAME(pread))(fd,
664 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pread),
665 PREPEND(__, SYSIO_INTERFACE_NAME(pread)))
667 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pread),
668 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pread)))
672 PREPEND(_, SYSIO_INTERFACE_NAME(ireadx))(int fd,
673 const struct iovec *iov,
675 const struct intnl_xtvec *xtv,
681 SYSIO_INTERFACE_DISPLAY_BLOCK;
683 SYSIO_INTERFACE_ENTER;
684 fil = _sysio_fd_find(fd);
685 if (!(fil && xtv_count))
686 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
689 _sysio_iiox(IIOXOP_READ(fil->f_ino),
691 iov, iov_count, NULL,
692 xtv, xtv_count, NULL,
696 SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err);
699 #if _LARGEFILE64_SOURCE
701 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)),
702 SYSIO_INTERFACE_NAME(iread64x))
705 #if _LARGEFILE64_SOURCE
707 SYSIO_INTERFACE_NAME(ireadx)(int fd,
708 const struct iovec *iov, size_t iov_count,
709 const struct xtvec *xtv, size_t xtv_count)
712 struct intnl_xtvec *ixtv, *ixtvent;
716 SYSIO_INTERFACE_DISPLAY_BLOCK;
718 SYSIO_INTERFACE_ENTER;
719 fil = _sysio_fd_find(fd);
720 if (!(fil && xtv_count))
721 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
723 ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec));
725 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
729 ixtvent->xtv_off = xtv->xtv_off;
730 ixtvent->xtv_len = xtv->xtv_len;
736 _sysio_iiox(IIOXOP_READ(fil->f_ino),
738 iov, iov_count, NULL,
739 ixtv, xtv_count, free_xtv,
744 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
746 SYSIO_INTERFACE_RETURN(ioctx, 0);
750 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)),
751 SYSIO_INTERFACE_NAME(ireadx))
755 SYSIO_INTERFACE_NAME(readx)(int fd,
756 const struct iovec *iov, size_t iov_count,
757 const struct xtvec *xtv, size_t xtv_count)
761 if ((ioid = SYSIO_INTERFACE_NAME(ireadx)(fd,
765 xtv_count)) == IOID_FAIL)
770 #if _LARGEFILE64_SOURCE
773 SYSIO_INTERFACE_NAME(read64x)(int fd,
774 const struct iovec *iov, size_t iov_count,
775 const struct xtvec64 *xtv, size_t xtv_count)
779 if ((ioid = SYSIO_INTERFACE_NAME(iread64x)(fd,
783 xtv_count)) == IOID_FAIL)
796 int64_t file_offsets[],
797 int32_t file_lengths[])
799 SYSIO_INTERFACE_DISPLAY_BLOCK;
801 SYSIO_INTERFACE_ENTER;
802 SYSIO_INTERFACE_RETURN(-1, -ENOSYS);
807 SYSIO_INTERFACE_NAME(iwritev)(int fd,
808 const struct iovec *iov,
812 struct intnl_xtvec *xtv;
815 SYSIO_INTERFACE_DISPLAY_BLOCK;
817 SYSIO_INTERFACE_ENTER;
818 fil = _sysio_fd_find(fd);
820 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
822 xtv = malloc(sizeof(struct intnl_xtvec));
824 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
827 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
834 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
836 SYSIO_INTERFACE_RETURN(ioctx, 0);
840 SYSIO_INTERFACE_NAME(writev)(int fd, const struct iovec *iov, int count)
843 struct intnl_xtvec xtvector;
847 SYSIO_INTERFACE_DISPLAY_BLOCK;
849 SYSIO_INTERFACE_ENTER;
850 fil = _sysio_fd_find(fd);
852 SYSIO_INTERFACE_RETURN(-1, -EBADF);
855 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
860 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
863 SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err);
868 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev),
869 PREPEND(__, SYSIO_INTERFACE_NAME(writev)))
871 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev),
872 PREPEND(__, SYSIO_INTERFACE_NAME(libc_writev)))
876 SYSIO_INTERFACE_NAME(iwrite)(int fd, const void *buf, size_t count)
880 struct intnl_xtvec *xtv;
883 SYSIO_INTERFACE_DISPLAY_BLOCK;
885 SYSIO_INTERFACE_ENTER;
886 fil = _sysio_fd_find(fd);
888 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
890 iov = malloc(sizeof(struct iovec));
892 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
894 iov->iov_base = (void *)buf;
895 iov->iov_len = count;
896 xtv = malloc(sizeof(struct intnl_xtvec));
899 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
902 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
910 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
912 SYSIO_INTERFACE_RETURN(ioctx, 0);
916 SYSIO_INTERFACE_NAME(write)(int fd, const void *buf, size_t count)
919 struct iovec iovector;
920 struct intnl_xtvec xtvector;
924 SYSIO_INTERFACE_DISPLAY_BLOCK;
926 SYSIO_INTERFACE_ENTER;
927 fil = _sysio_fd_find(fd);
929 SYSIO_INTERFACE_RETURN(-1, -EBADF);
931 iovector.iov_base = (void *)buf;
932 iovector.iov_len = count;
934 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
939 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
942 SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err);
947 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write),
948 PREPEND(__, SYSIO_INTERFACE_NAME(write)))
950 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write),
951 PREPEND(__, SYSIO_INTERFACE_NAME(libc_write)))
955 PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(int fd,
956 const struct iovec *iov,
961 struct intnl_xtvec *xtv;
964 SYSIO_INTERFACE_DISPLAY_BLOCK;
966 SYSIO_INTERFACE_ENTER;
967 fil = _sysio_fd_find(fd);
969 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
971 xtv = malloc(sizeof(struct intnl_xtvec));
973 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
976 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
984 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
986 SYSIO_INTERFACE_RETURN(ioctx, 0);
989 #if _LARGEFILE64_SOURCE
991 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev)),
992 SYSIO_INTERFACE_NAME(ipwrite64v))
996 SYSIO_INTERFACE_NAME(ipwritev)(int fd,
997 const struct iovec *iov,
1002 return PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(fd,
1009 PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(int fd,
1010 const struct iovec *iov,
1012 _SYSIO_OFF_T offset)
1015 struct intnl_xtvec xtvector;
1016 struct ioctx *ioctx;
1019 SYSIO_INTERFACE_DISPLAY_BLOCK;
1021 SYSIO_INTERFACE_ENTER;
1022 fil = _sysio_fd_find(fd);
1024 SYSIO_INTERFACE_RETURN(-1, -EBADF);
1027 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1033 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
1036 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
1039 #if _LARGEFILE64_SOURCE
1041 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwritev)),
1042 SYSIO_INTERFACE_NAME(pwrite64v))
1046 SYSIO_INTERFACE_NAME(pwritev)(int fd,
1047 const struct iovec *iov,
1052 return PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(fd,
1059 PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(int fd,
1062 _SYSIO_OFF_T offset)
1065 struct intnl_xtvec *xtv;
1067 struct ioctx *ioctx;
1069 SYSIO_INTERFACE_DISPLAY_BLOCK;
1071 SYSIO_INTERFACE_ENTER;
1072 fil = _sysio_fd_find(fd);
1074 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1076 xtv = malloc(sizeof(struct intnl_xtvec));
1077 iov = malloc(sizeof(struct iovec));
1078 if (!(xtv && iov)) {
1082 xtv->xtv_off = offset;
1083 iov->iov_base = (void *)buf;
1084 xtv->xtv_len = iov->iov_len = count;
1086 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1098 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
1100 SYSIO_INTERFACE_RETURN(ioctx, 0);
1103 #if _LARGEFILE64_SOURCE
1105 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite)),
1106 SYSIO_INTERFACE_NAME(ipwrite64))
1110 SYSIO_INTERFACE_NAME(ipwrite)(int fd,
1116 return PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(fd,
1123 PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(int fd,
1126 _SYSIO_OFF_T offset)
1129 struct intnl_xtvec xtvec;
1131 struct ioctx *ioctx;
1134 SYSIO_INTERFACE_DISPLAY_BLOCK;
1136 SYSIO_INTERFACE_ENTER;
1137 fil = _sysio_fd_find(fd);
1139 SYSIO_INTERFACE_RETURN(-1, -EBADF);
1141 xtvec.xtv_off = offset;
1142 iovec.iov_base = (void *)buf;
1143 xtvec.xtv_len = iovec.iov_len = count;
1145 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1151 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
1154 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
1157 #if _LARGEFILE64_SOURCE
1159 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1160 SYSIO_INTERFACE_NAME(pwrite64))
1163 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1164 PREPEND(__, SYSIO_INTERFACE_NAME(pwrite64)))
1165 #undef __libc_pwrite64
1166 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1167 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite64)))
1172 SYSIO_INTERFACE_NAME(pwrite)(int fd,
1178 return PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(fd,
1185 #undef __libc_pwrite
1186 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pwrite), __libc_pwrite)
1187 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite)))
1191 PREPEND(_, SYSIO_INTERFACE_NAME(iwritex))(int fd,
1192 const struct iovec *iov,
1194 const struct intnl_xtvec *xtv,
1199 struct ioctx *ioctx;
1200 SYSIO_INTERFACE_DISPLAY_BLOCK;
1202 SYSIO_INTERFACE_ENTER;
1203 fil = _sysio_fd_find(fd);
1204 if (!(fil && xtv_count))
1205 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1208 _sysio_iiox(IIOXOP_WRITE(fil->f_ino),
1210 iov, iov_count, NULL,
1211 xtv, xtv_count, NULL,
1215 SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err);
1218 #if _LARGEFILE64_SOURCE
1220 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)),
1221 SYSIO_INTERFACE_NAME(iwrite64x))
1224 #if _LARGEFILE64_SOURCE
1226 SYSIO_INTERFACE_NAME(iwritex)(int fd,
1227 const struct iovec *iov, size_t iov_count,
1228 const struct xtvec *xtv, size_t xtv_count)
1231 struct intnl_xtvec *ixtv, *ixtvent;
1234 struct ioctx *ioctx;
1235 SYSIO_INTERFACE_DISPLAY_BLOCK;
1237 SYSIO_INTERFACE_ENTER;
1238 fil = _sysio_fd_find(fd);
1239 if (!(fil && xtv_count))
1240 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1242 ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec));
1244 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
1248 ixtvent->xtv_off = xtv->xtv_off;
1249 ixtvent->xtv_len = xtv->xtv_len;
1255 _sysio_iiox(IIOXOP_WRITE(fil->f_ino),
1257 iov, iov_count, NULL,
1258 ixtv, xtv_count, free_xtv,
1263 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
1265 SYSIO_INTERFACE_RETURN(ioctx, 0);
1269 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)),
1270 SYSIO_INTERFACE_NAME(iwritex))
1275 SYSIO_INTERFACE_NAME(writex)(int fd,
1276 const struct iovec *iov, size_t iov_count,
1277 const struct xtvec *xtv, size_t xtv_count)
1282 SYSIO_INTERFACE_NAME(iwritex)(fd,
1286 xtv_count)) == IOID_FAIL)
1288 return iowait(ioid);
1291 #if _LARGEFILE64_SOURCE
1294 SYSIO_INTERFACE_NAME(write64x)(int fd,
1295 const struct iovec *iov, size_t iov_count,
1296 const struct xtvec64 *xtv, size_t xtv_count)
1300 if ((ioid = SYSIO_INTERFACE_NAME(iwrite64x)(fd,
1304 xtv_count)) == IOID_FAIL)
1306 return iowait(ioid);
1314 char *mem_offsets[],
1316 int file_list_count,
1317 int64_t file_offsets[],
1318 int32_t file_lengths[])
1320 SYSIO_INTERFACE_DISPLAY_BLOCK;
1322 SYSIO_INTERFACE_ENTER;
1323 SYSIO_INTERFACE_RETURN(-1, -ENOSYS);