2 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifndef _OPENSOLARIS_SYS_UIO_H_
30 #define _OPENSOLARIS_SYS_UIO_H_
32 #include_next <sys/uio.h>
34 #include <sys/debug.h>
38 #define uio_loffset uio_offset
40 typedef struct uio uio_t;
41 typedef struct iovec iovec_t;
42 typedef enum uio_seg uio_seg_t;
44 typedef enum xuio_type {
52 /* Extended uio fields */
53 enum xuio_type xu_type; /* What kind of uio structure? */
62 #define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
63 #define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
66 zfs_uiomove(void *cp, size_t n, enum uio_rw dir, uio_t *uio)
69 ASSERT(uio->uio_rw == dir);
70 return (uiomove(cp, (int)n, uio));
72 #define uiomove(cp, n, dir, uio) zfs_uiomove((cp), (n), (dir), (uio))
74 int uiocopy(void *p, size_t n, enum uio_rw rw, struct uio *uio, size_t *cbytes);
75 void uioskip(uio_t *uiop, size_t n);
77 #define uio_segflg(uio) (uio)->uio_segflg
78 #define uio_offset(uio) (uio)->uio_loffset
79 #define uio_resid(uio) (uio)->uio_resid
80 #define uio_iovcnt(uio) (uio)->uio_iovcnt
81 #define uio_iovlen(uio, idx) (uio)->uio_iov[(idx)].iov_len
82 #define uio_iovbase(uio, idx) (uio)->uio_iov[(idx)].iov_base
85 uio_iov_at_index(uio_t *uio, uint_t idx, void **base, uint64_t *len)
87 *base = uio_iovbase(uio, idx);
88 *len = uio_iovlen(uio, idx);
92 uio_advance(uio_t *uio, size_t size)
94 uio->uio_resid -= size;
95 uio->uio_loffset += size;
98 static inline offset_t
99 uio_index_at_offset(uio_t *uio, offset_t off, uint_t *vec_idx)
102 while (*vec_idx < uio_iovcnt(uio) && off >= uio_iovlen(uio, *vec_idx)) {
103 off -= uio_iovlen(uio, *vec_idx);
110 #endif /* !_OPENSOLARIS_SYS_UIO_H_ */