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 http://www.opensolaris.org/os/licensing.
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>
45 #include <sys/vnode.h>
48 * same as uiomove() but doesn't modify uio structure.
49 * return in cbytes how many bytes were copied.
52 uiocopy(void *p, size_t n, enum uio_rw rw, struct uio *uio, size_t *cbytes)
54 struct iovec small_iovec[1];
55 struct uio small_uio_clone;
56 struct uio *uio_clone;
59 ASSERT3U(uio->uio_rw, ==, rw);
60 if (uio->uio_iovcnt == 1) {
61 small_uio_clone = *uio;
62 small_iovec[0] = *uio->uio_iov;
63 small_uio_clone.uio_iov = small_iovec;
64 uio_clone = &small_uio_clone;
66 uio_clone = cloneuio(uio);
69 error = vn_io_fault_uiomove(p, n, uio_clone);
70 *cbytes = uio->uio_resid - uio_clone->uio_resid;
71 if (uio_clone != &small_uio_clone)
72 free(uio_clone, M_IOV);
77 * Drop the next n chars out of *uiop.
80 uioskip(uio_t *uio, size_t n)
84 /* For the full compatibility with illumos. */
85 if (n > uio->uio_resid)
88 segflg = uio->uio_segflg;
89 uio->uio_segflg = UIO_NOCOPY;
90 uiomove(NULL, n, uio->uio_rw, uio);
91 uio->uio_segflg = segflg;