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,
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,
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, int count)
850 struct intnl_xtvec xtvector;
854 SYSIO_INTERFACE_DISPLAY_BLOCK;
856 SYSIO_INTERFACE_ENTER;
857 fil = _sysio_fd_find(fd);
859 SYSIO_INTERFACE_RETURN(-1, -EBADF);
862 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
867 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
870 SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err);
875 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev),
876 PREPEND(__, SYSIO_INTERFACE_NAME(writev)))
878 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev),
879 PREPEND(__, SYSIO_INTERFACE_NAME(libc_writev)))
883 SYSIO_INTERFACE_NAME(iwrite)(int fd, const void *buf, size_t count)
887 struct intnl_xtvec *xtv;
890 SYSIO_INTERFACE_DISPLAY_BLOCK;
892 SYSIO_INTERFACE_ENTER;
893 fil = _sysio_fd_find(fd);
895 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
897 iov = malloc(sizeof(struct iovec));
899 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
901 iov->iov_base = (void *)buf;
902 iov->iov_len = count;
903 xtv = malloc(sizeof(struct intnl_xtvec));
906 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
909 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
917 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
919 SYSIO_INTERFACE_RETURN(ioctx, 0);
923 SYSIO_INTERFACE_NAME(write)(int fd, const void *buf, size_t count)
926 struct iovec iovector;
927 struct intnl_xtvec xtvector;
931 SYSIO_INTERFACE_DISPLAY_BLOCK;
933 SYSIO_INTERFACE_ENTER;
934 fil = _sysio_fd_find(fd);
936 SYSIO_INTERFACE_RETURN(-1, -EBADF);
938 iovector.iov_base = (void *)buf;
939 iovector.iov_len = count;
941 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
946 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
949 SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err);
954 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write),
955 PREPEND(__, SYSIO_INTERFACE_NAME(write)))
957 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write),
958 PREPEND(__, SYSIO_INTERFACE_NAME(libc_write)))
962 PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(int fd,
963 const struct iovec *iov,
968 struct intnl_xtvec *xtv;
971 SYSIO_INTERFACE_DISPLAY_BLOCK;
973 SYSIO_INTERFACE_ENTER;
974 fil = _sysio_fd_find(fd);
976 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
978 xtv = malloc(sizeof(struct intnl_xtvec));
980 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
983 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
991 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
993 SYSIO_INTERFACE_RETURN(ioctx, 0);
996 #ifdef _LARGEFILE64_SOURCE
998 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev)),
999 SYSIO_INTERFACE_NAME(ipwrite64v))
1003 SYSIO_INTERFACE_NAME(ipwritev)(int fd,
1004 const struct iovec *iov,
1009 return PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(fd,
1016 PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(int fd,
1017 const struct iovec *iov,
1019 _SYSIO_OFF_T offset)
1022 struct intnl_xtvec xtvector;
1023 struct ioctx *ioctx;
1026 SYSIO_INTERFACE_DISPLAY_BLOCK;
1028 SYSIO_INTERFACE_ENTER;
1029 fil = _sysio_fd_find(fd);
1031 SYSIO_INTERFACE_RETURN(-1, -EBADF);
1034 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1040 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
1043 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
1046 #ifdef _LARGEFILE64_SOURCE
1048 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwritev)),
1049 SYSIO_INTERFACE_NAME(pwrite64v))
1053 SYSIO_INTERFACE_NAME(pwritev)(int fd,
1054 const struct iovec *iov,
1059 return PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(fd,
1066 PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(int fd,
1069 _SYSIO_OFF_T offset)
1072 struct intnl_xtvec *xtv;
1074 struct ioctx *ioctx;
1076 SYSIO_INTERFACE_DISPLAY_BLOCK;
1078 SYSIO_INTERFACE_ENTER;
1079 fil = _sysio_fd_find(fd);
1081 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1083 xtv = malloc(sizeof(struct intnl_xtvec));
1084 iov = malloc(sizeof(struct iovec));
1085 if (!(xtv && iov)) {
1089 xtv->xtv_off = offset;
1090 iov->iov_base = (void *)buf;
1091 xtv->xtv_len = iov->iov_len = count;
1093 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1105 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
1107 SYSIO_INTERFACE_RETURN(ioctx, 0);
1110 #ifdef _LARGEFILE64_SOURCE
1112 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite)),
1113 SYSIO_INTERFACE_NAME(ipwrite64))
1117 SYSIO_INTERFACE_NAME(ipwrite)(int fd,
1123 return PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(fd,
1130 PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(int fd,
1133 _SYSIO_OFF_T offset)
1136 struct intnl_xtvec xtvec;
1138 struct ioctx *ioctx;
1141 SYSIO_INTERFACE_DISPLAY_BLOCK;
1143 SYSIO_INTERFACE_ENTER;
1144 fil = _sysio_fd_find(fd);
1146 SYSIO_INTERFACE_RETURN(-1, -EBADF);
1148 xtvec.xtv_off = offset;
1149 iovec.iov_base = (void *)buf;
1150 xtvec.xtv_len = iovec.iov_len = count;
1152 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1158 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
1161 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
1164 #ifdef _LARGEFILE64_SOURCE
1166 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1167 SYSIO_INTERFACE_NAME(pwrite64))
1170 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1171 PREPEND(__, SYSIO_INTERFACE_NAME(pwrite64)))
1172 #undef __libc_pwrite64
1173 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1174 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite64)))
1179 SYSIO_INTERFACE_NAME(pwrite)(int fd,
1185 return PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(fd,
1192 #undef __libc_pwrite
1193 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pwrite), __libc_pwrite)
1194 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite)))
1198 PREPEND(_, SYSIO_INTERFACE_NAME(iwritex))(int fd,
1199 const struct iovec *iov,
1201 const struct intnl_xtvec *xtv,
1206 struct ioctx *ioctx;
1207 SYSIO_INTERFACE_DISPLAY_BLOCK;
1209 SYSIO_INTERFACE_ENTER;
1210 fil = _sysio_fd_find(fd);
1211 if (!(fil && xtv_count))
1212 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1215 _sysio_iiox(IIOXOP_WRITE(fil->f_ino),
1217 iov, iov_count, NULL,
1218 xtv, xtv_count, NULL,
1222 SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err);
1225 #ifdef _LARGEFILE64_SOURCE
1227 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)),
1228 SYSIO_INTERFACE_NAME(iwrite64x))
1231 #ifdef _LARGEFILE64_SOURCE
1233 SYSIO_INTERFACE_NAME(iwritex)(int fd,
1234 const struct iovec *iov, size_t iov_count,
1235 const struct xtvec *xtv, size_t xtv_count)
1238 struct intnl_xtvec *ixtv, *ixtvent;
1241 struct ioctx *ioctx;
1242 SYSIO_INTERFACE_DISPLAY_BLOCK;
1244 SYSIO_INTERFACE_ENTER;
1245 fil = _sysio_fd_find(fd);
1247 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1249 /* Perform a check on the iov_count and xtv_count */
1250 if ((iov_count == 0) || (xtv_count == 0))
1251 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL);
1253 ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec));
1255 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
1259 ixtvent->xtv_off = xtv->xtv_off;
1260 ixtvent->xtv_len = xtv->xtv_len;
1266 _sysio_iiox(IIOXOP_WRITE(fil->f_ino),
1268 iov, iov_count, NULL,
1269 ixtv, xtv_count, free_xtv,
1274 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
1276 SYSIO_INTERFACE_RETURN(ioctx, 0);
1280 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)),
1281 SYSIO_INTERFACE_NAME(iwritex))
1286 SYSIO_INTERFACE_NAME(writex)(int fd,
1287 const struct iovec *iov, size_t iov_count,
1288 const struct xtvec *xtv, size_t xtv_count)
1293 SYSIO_INTERFACE_NAME(iwritex)(fd,
1297 xtv_count)) == IOID_FAIL)
1299 return SYSIO_INTERFACE_NAME(iowait)(ioid);
1302 #ifdef _LARGEFILE64_SOURCE
1305 SYSIO_INTERFACE_NAME(write64x)(int fd,
1306 const struct iovec *iov, size_t iov_count,
1307 const struct xtvec64 *xtv, size_t xtv_count)
1311 if ((ioid = SYSIO_INTERFACE_NAME(iwrite64x)(fd,
1315 xtv_count)) == IOID_FAIL)
1317 return SYSIO_INTERFACE_NAME(iowait)(ioid);
1325 char *mem_offsets[],
1327 int file_list_count,
1328 int64_t file_offsets[],
1329 int32_t file_lengths[])
1331 SYSIO_INTERFACE_DISPLAY_BLOCK;
1333 SYSIO_INTERFACE_ENTER;
1334 SYSIO_INTERFACE_RETURN(-1, -ENOSYS);