4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
43 #include <sys/param.h>
44 #include <sys/uio_impl.h>
45 #include <sys/vnode.h>
46 #include <sys/zfs_znode.h>
49 zfs_uiomove(void *cp
, size_t n
, zfs_uio_rw_t dir
, zfs_uio_t
*uio
)
51 ASSERT3U(zfs_uio_rw(uio
), ==, dir
);
52 return (uiomove(cp
, (int)n
, GET_UIO_STRUCT(uio
)));
56 * same as zfs_uiomove() but doesn't modify uio structure.
57 * return in cbytes how many bytes were copied.
60 zfs_uiocopy(void *p
, size_t n
, zfs_uio_rw_t rw
, zfs_uio_t
*uio
, size_t *cbytes
)
62 struct iovec small_iovec
[1];
63 struct uio small_uio_clone
;
64 struct uio
*uio_clone
;
67 ASSERT3U(zfs_uio_rw(uio
), ==, rw
);
68 if (zfs_uio_iovcnt(uio
) == 1) {
69 small_uio_clone
= *(GET_UIO_STRUCT(uio
));
70 small_iovec
[0] = *(GET_UIO_STRUCT(uio
)->uio_iov
);
71 small_uio_clone
.uio_iov
= small_iovec
;
72 uio_clone
= &small_uio_clone
;
74 uio_clone
= cloneuio(GET_UIO_STRUCT(uio
));
77 error
= vn_io_fault_uiomove(p
, n
, uio_clone
);
78 *cbytes
= zfs_uio_resid(uio
) - uio_clone
->uio_resid
;
79 if (uio_clone
!= &small_uio_clone
)
80 free(uio_clone
, M_IOV
);
85 * Drop the next n chars out of *uiop.
88 zfs_uioskip(zfs_uio_t
*uio
, size_t n
)
92 /* For the full compatibility with illumos. */
93 if (n
> zfs_uio_resid(uio
))
96 segflg
= zfs_uio_segflg(uio
);
97 zfs_uio_segflg(uio
) = UIO_NOCOPY
;
98 zfs_uiomove(NULL
, n
, zfs_uio_rw(uio
), uio
);
99 zfs_uio_segflg(uio
) = segflg
;
103 zfs_uio_fault_move(void *p
, size_t n
, zfs_uio_rw_t dir
, zfs_uio_t
*uio
)
105 ASSERT3U(zfs_uio_rw(uio
), ==, dir
);
106 return (vn_io_fault_uiomove(p
, n
, GET_UIO_STRUCT(uio
)));