1 /* 2 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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. 13 * 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 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 #ifndef _OPENSOLARIS_SYS_UIO_H_ 30 #define _OPENSOLARIS_SYS_UIO_H_ 31 32 #ifndef _STANDALONE 33 34 #include_next <sys/uio.h> 35 #include <sys/_uio.h> 36 #include <sys/debug.h> 37 38 typedef struct iovec iovec_t; 39 typedef enum uio_seg zfs_uio_seg_t; 40 typedef enum uio_rw zfs_uio_rw_t; 41 42 typedef struct zfs_uio { 43 struct uio *uio; 44 } zfs_uio_t; 45 46 #define GET_UIO_STRUCT(u) (u)->uio 47 #define zfs_uio_segflg(u) GET_UIO_STRUCT(u)->uio_segflg 48 #define zfs_uio_offset(u) GET_UIO_STRUCT(u)->uio_offset 49 #define zfs_uio_resid(u) GET_UIO_STRUCT(u)->uio_resid 50 #define zfs_uio_iovcnt(u) GET_UIO_STRUCT(u)->uio_iovcnt 51 #define zfs_uio_iovlen(u, idx) GET_UIO_STRUCT(u)->uio_iov[(idx)].iov_len 52 #define zfs_uio_iovbase(u, idx) GET_UIO_STRUCT(u)->uio_iov[(idx)].iov_base 53 #define zfs_uio_td(u) GET_UIO_STRUCT(u)->uio_td 54 #define zfs_uio_rw(u) GET_UIO_STRUCT(u)->uio_rw 55 #define zfs_uio_fault_disable(u, set) 56 #define zfs_uio_prefaultpages(size, u) (0) 57 58 static inline void 59 zfs_uio_setoffset(zfs_uio_t *uio, offset_t off) 60 { 61 zfs_uio_offset(uio) = off; 62 } 63 64 static inline void 65 zfs_uio_advance(zfs_uio_t *uio, size_t size) 66 { 67 zfs_uio_resid(uio) -= size; 68 zfs_uio_offset(uio) += size; 69 } 70 71 static __inline void 72 zfs_uio_init(zfs_uio_t *uio, struct uio *uio_s) 73 { 74 GET_UIO_STRUCT(uio) = uio_s; 75 } 76 77 int zfs_uio_fault_move(void *p, size_t n, zfs_uio_rw_t dir, zfs_uio_t *uio); 78 79 #endif /* !_STANDALONE */ 80 81 #endif /* !_OPENSOLARIS_SYS_UIO_H_ */ 82