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);
686 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
688 /* Perform a check on the iov_count and xtv_count */
689 if ((iov_count == 0) || (xtv_count == 0))
690 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL);
693 _sysio_iiox(IIOXOP_READ(fil->f_ino),
695 iov, iov_count, NULL,
696 xtv, xtv_count, NULL,
700 SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err);
703 #if _LARGEFILE64_SOURCE
705 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)),
706 SYSIO_INTERFACE_NAME(iread64x))
709 #if _LARGEFILE64_SOURCE
711 SYSIO_INTERFACE_NAME(ireadx)(int fd,
712 const struct iovec *iov, size_t iov_count,
713 const struct xtvec *xtv, size_t xtv_count)
716 struct intnl_xtvec *ixtv, *ixtvent;
720 SYSIO_INTERFACE_DISPLAY_BLOCK;
722 SYSIO_INTERFACE_ENTER;
723 fil = _sysio_fd_find(fd);
725 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
728 /* Perform a check on the iov_count and xtv_count */
729 if ((iov_count == 0) || (xtv_count == 0))
730 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL);
732 ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec));
734 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
738 ixtvent->xtv_off = xtv->xtv_off;
739 ixtvent->xtv_len = xtv->xtv_len;
745 _sysio_iiox(IIOXOP_READ(fil->f_ino),
747 iov, iov_count, NULL,
748 ixtv, xtv_count, free_xtv,
753 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
755 SYSIO_INTERFACE_RETURN(ioctx, 0);
759 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)),
760 SYSIO_INTERFACE_NAME(ireadx))
764 SYSIO_INTERFACE_NAME(readx)(int fd,
765 const struct iovec *iov, size_t iov_count,
766 const struct xtvec *xtv, size_t xtv_count)
770 if ((ioid = SYSIO_INTERFACE_NAME(ireadx)(fd,
774 xtv_count)) == IOID_FAIL)
779 #if _LARGEFILE64_SOURCE
782 SYSIO_INTERFACE_NAME(read64x)(int fd,
783 const struct iovec *iov, size_t iov_count,
784 const struct xtvec64 *xtv, size_t xtv_count)
788 if ((ioid = SYSIO_INTERFACE_NAME(iread64x)(fd,
792 xtv_count)) == IOID_FAIL)
805 int64_t file_offsets[],
806 int32_t file_lengths[])
808 SYSIO_INTERFACE_DISPLAY_BLOCK;
810 SYSIO_INTERFACE_ENTER;
811 SYSIO_INTERFACE_RETURN(-1, -ENOSYS);
816 SYSIO_INTERFACE_NAME(iwritev)(int fd,
817 const struct iovec *iov,
821 struct intnl_xtvec *xtv;
824 SYSIO_INTERFACE_DISPLAY_BLOCK;
826 SYSIO_INTERFACE_ENTER;
827 fil = _sysio_fd_find(fd);
829 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
831 xtv = malloc(sizeof(struct intnl_xtvec));
833 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
836 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
843 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
845 SYSIO_INTERFACE_RETURN(ioctx, 0);
849 SYSIO_INTERFACE_NAME(writev)(int fd, const struct iovec *iov, int count)
852 struct intnl_xtvec xtvector;
856 SYSIO_INTERFACE_DISPLAY_BLOCK;
858 SYSIO_INTERFACE_ENTER;
859 fil = _sysio_fd_find(fd);
861 SYSIO_INTERFACE_RETURN(-1, -EBADF);
864 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
869 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
872 SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err);
877 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev),
878 PREPEND(__, SYSIO_INTERFACE_NAME(writev)))
880 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(writev),
881 PREPEND(__, SYSIO_INTERFACE_NAME(libc_writev)))
885 SYSIO_INTERFACE_NAME(iwrite)(int fd, const void *buf, size_t count)
889 struct intnl_xtvec *xtv;
892 SYSIO_INTERFACE_DISPLAY_BLOCK;
894 SYSIO_INTERFACE_ENTER;
895 fil = _sysio_fd_find(fd);
897 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
899 iov = malloc(sizeof(struct iovec));
901 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
903 iov->iov_base = (void *)buf;
904 iov->iov_len = count;
905 xtv = malloc(sizeof(struct intnl_xtvec));
908 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
911 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
919 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
921 SYSIO_INTERFACE_RETURN(ioctx, 0);
925 SYSIO_INTERFACE_NAME(write)(int fd, const void *buf, size_t count)
928 struct iovec iovector;
929 struct intnl_xtvec xtvector;
933 SYSIO_INTERFACE_DISPLAY_BLOCK;
935 SYSIO_INTERFACE_ENTER;
936 fil = _sysio_fd_find(fd);
938 SYSIO_INTERFACE_RETURN(-1, -EBADF);
940 iovector.iov_base = (void *)buf;
941 iovector.iov_len = count;
943 _sysio_iiov(IIOXOP_WRITE(fil->f_ino),
948 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
951 SYSIO_INTERFACE_RETURN(err < 0 ? -1 : cc, err);
956 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write),
957 PREPEND(__, SYSIO_INTERFACE_NAME(write)))
959 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(write),
960 PREPEND(__, SYSIO_INTERFACE_NAME(libc_write)))
964 PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(int fd,
965 const struct iovec *iov,
970 struct intnl_xtvec *xtv;
973 SYSIO_INTERFACE_DISPLAY_BLOCK;
975 SYSIO_INTERFACE_ENTER;
976 fil = _sysio_fd_find(fd);
978 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
980 xtv = malloc(sizeof(struct intnl_xtvec));
982 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
985 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
993 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
995 SYSIO_INTERFACE_RETURN(ioctx, 0);
998 #if _LARGEFILE64_SOURCE
1000 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev)),
1001 SYSIO_INTERFACE_NAME(ipwrite64v))
1005 SYSIO_INTERFACE_NAME(ipwritev)(int fd,
1006 const struct iovec *iov,
1011 return PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev))(fd,
1018 PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(int fd,
1019 const struct iovec *iov,
1021 _SYSIO_OFF_T offset)
1024 struct intnl_xtvec xtvector;
1025 struct ioctx *ioctx;
1028 SYSIO_INTERFACE_DISPLAY_BLOCK;
1030 SYSIO_INTERFACE_ENTER;
1031 fil = _sysio_fd_find(fd);
1033 SYSIO_INTERFACE_RETURN(-1, -EBADF);
1036 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1042 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
1045 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
1048 #if _LARGEFILE64_SOURCE
1050 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwritev)),
1051 SYSIO_INTERFACE_NAME(pwrite64v))
1055 SYSIO_INTERFACE_NAME(pwritev)(int fd,
1056 const struct iovec *iov,
1061 return PREPEND(_, SYSIO_INTERFACE_NAME(pwritev))(fd,
1068 PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(int fd,
1071 _SYSIO_OFF_T offset)
1074 struct intnl_xtvec *xtv;
1076 struct ioctx *ioctx;
1078 SYSIO_INTERFACE_DISPLAY_BLOCK;
1080 SYSIO_INTERFACE_ENTER;
1081 fil = _sysio_fd_find(fd);
1083 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1085 xtv = malloc(sizeof(struct intnl_xtvec));
1086 iov = malloc(sizeof(struct iovec));
1087 if (!(xtv && iov)) {
1091 xtv->xtv_off = offset;
1092 iov->iov_base = (void *)buf;
1093 xtv->xtv_len = iov->iov_len = count;
1095 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1107 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
1109 SYSIO_INTERFACE_RETURN(ioctx, 0);
1112 #if _LARGEFILE64_SOURCE
1114 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite)),
1115 SYSIO_INTERFACE_NAME(ipwrite64))
1119 SYSIO_INTERFACE_NAME(ipwrite)(int fd,
1125 return PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite))(fd,
1132 PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(int fd,
1135 _SYSIO_OFF_T offset)
1138 struct intnl_xtvec xtvec;
1140 struct ioctx *ioctx;
1143 SYSIO_INTERFACE_DISPLAY_BLOCK;
1145 SYSIO_INTERFACE_ENTER;
1146 fil = _sysio_fd_find(fd);
1148 SYSIO_INTERFACE_RETURN(-1, -EBADF);
1150 xtvec.xtv_off = offset;
1151 iovec.iov_base = (void *)buf;
1152 xtvec.xtv_len = iovec.iov_len = count;
1154 _sysio_ipiov(IIOXOP_WRITE(fil->f_ino),
1160 if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0)
1163 SYSIO_INTERFACE_RETURN(err ? -1 : cc, err);
1166 #if _LARGEFILE64_SOURCE
1168 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1169 SYSIO_INTERFACE_NAME(pwrite64))
1172 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1173 PREPEND(__, SYSIO_INTERFACE_NAME(pwrite64)))
1174 #undef __libc_pwrite64
1175 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)),
1176 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite64)))
1181 SYSIO_INTERFACE_NAME(pwrite)(int fd,
1187 return PREPEND(_, SYSIO_INTERFACE_NAME(pwrite))(fd,
1194 #undef __libc_pwrite
1195 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(pwrite), __libc_pwrite)
1196 PREPEND(__, SYSIO_INTERFACE_NAME(libc_pwrite)))
1200 PREPEND(_, SYSIO_INTERFACE_NAME(iwritex))(int fd,
1201 const struct iovec *iov,
1203 const struct intnl_xtvec *xtv,
1208 struct ioctx *ioctx;
1209 SYSIO_INTERFACE_DISPLAY_BLOCK;
1211 SYSIO_INTERFACE_ENTER;
1212 fil = _sysio_fd_find(fd);
1213 if (!(fil && xtv_count))
1214 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1217 _sysio_iiox(IIOXOP_WRITE(fil->f_ino),
1219 iov, iov_count, NULL,
1220 xtv, xtv_count, NULL,
1224 SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err);
1227 #if _LARGEFILE64_SOURCE
1229 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)),
1230 SYSIO_INTERFACE_NAME(iwrite64x))
1233 #if _LARGEFILE64_SOURCE
1235 SYSIO_INTERFACE_NAME(iwritex)(int fd,
1236 const struct iovec *iov, size_t iov_count,
1237 const struct xtvec *xtv, size_t xtv_count)
1240 struct intnl_xtvec *ixtv, *ixtvent;
1243 struct ioctx *ioctx;
1244 SYSIO_INTERFACE_DISPLAY_BLOCK;
1246 SYSIO_INTERFACE_ENTER;
1247 fil = _sysio_fd_find(fd);
1249 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF);
1251 /* Perform a check on the iov_count and xtv_count */
1252 if ((iov_count == 0) || (xtv_count == 0))
1253 SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL);
1255 ixtv = ixtvent = malloc(xtv_count * sizeof(struct intnl_xtvec));
1257 SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM);
1261 ixtvent->xtv_off = xtv->xtv_off;
1262 ixtvent->xtv_len = xtv->xtv_len;
1268 _sysio_iiox(IIOXOP_WRITE(fil->f_ino),
1270 iov, iov_count, NULL,
1271 ixtv, xtv_count, free_xtv,
1276 SYSIO_INTERFACE_RETURN(IOID_FAIL, err);
1278 SYSIO_INTERFACE_RETURN(ioctx, 0);
1282 sysio_sym_weak_alias(PREPEND(_, SYSIO_INTERFACE_NAME(iwritex)),
1283 SYSIO_INTERFACE_NAME(iwritex))
1288 SYSIO_INTERFACE_NAME(writex)(int fd,
1289 const struct iovec *iov, size_t iov_count,
1290 const struct xtvec *xtv, size_t xtv_count)
1295 SYSIO_INTERFACE_NAME(iwritex)(fd,
1299 xtv_count)) == IOID_FAIL)
1301 return iowait(ioid);
1304 #if _LARGEFILE64_SOURCE
1307 SYSIO_INTERFACE_NAME(write64x)(int fd,
1308 const struct iovec *iov, size_t iov_count,
1309 const struct xtvec64 *xtv, size_t xtv_count)
1313 if ((ioid = SYSIO_INTERFACE_NAME(iwrite64x)(fd,
1317 xtv_count)) == IOID_FAIL)
1319 return iowait(ioid);
1327 char *mem_offsets[],
1329 int file_list_count,
1330 int64_t file_offsets[],
1331 int32_t file_lengths[])
1333 SYSIO_INTERFACE_DISPLAY_BLOCK;
1335 SYSIO_INTERFACE_ENTER;
1336 SYSIO_INTERFACE_RETURN(-1, -ENOSYS);