Path: blob/main/sys/cddl/compat/opensolaris/kern/opensolaris_uio.c
48383 views
/*1* CDDL HEADER START2*3* The contents of this file are subject to the terms of the4* Common Development and Distribution License (the "License").5* You may not use this file except in compliance with the License.6*7* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE8* or http://www.opensolaris.org/os/licensing.9* See the License for the specific language governing permissions10* and limitations under the License.11*12* When distributing Covered Code, include this CDDL HEADER in each13* file and include the License file at usr/src/OPENSOLARIS.LICENSE.14* If applicable, add the following below this CDDL HEADER, with the15* fields enclosed by brackets "[]" replaced with your own identifying16* information: Portions Copyright [yyyy] [name of copyright owner]17*18* CDDL HEADER END19*/20/*21* Copyright 2009 Sun Microsystems, Inc. All rights reserved.22* Use is subject to license terms.23*/2425/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */26/* All Rights Reserved */2728/*29* University Copyright- Copyright (c) 1982, 1986, 198830* The Regents of the University of California31* All Rights Reserved32*33* University Acknowledgment- Portions of this document are derived from34* software developed by the University of California, Berkeley, and its35* contributors.36*/3738/*39*/4041#include <sys/types.h>42#include <sys/uio.h>43#include <sys/vnode.h>4445/*46* same as uiomove() but doesn't modify uio structure.47* return in cbytes how many bytes were copied.48*/49int50uiocopy(void *p, size_t n, enum uio_rw rw, struct uio *uio, size_t *cbytes)51{52struct iovec small_iovec[1];53struct uio small_uio_clone;54struct uio *uio_clone;55int error;5657ASSERT3U(uio->uio_rw, ==, rw);58if (uio->uio_iovcnt == 1) {59small_uio_clone = *uio;60small_iovec[0] = *uio->uio_iov;61small_uio_clone.uio_iov = small_iovec;62uio_clone = &small_uio_clone;63} else {64uio_clone = cloneuio(uio);65}6667error = vn_io_fault_uiomove(p, n, uio_clone);68*cbytes = uio->uio_resid - uio_clone->uio_resid;69if (uio_clone != &small_uio_clone)70freeuio(uio_clone);71return (error);72}7374/*75* Drop the next n chars out of *uiop.76*/77void78uioskip(uio_t *uio, size_t n)79{80enum uio_seg segflg;8182/* For the full compatibility with illumos. */83if (n > uio->uio_resid)84return;8586segflg = uio->uio_segflg;87uio->uio_segflg = UIO_NOCOPY;88uiomove(NULL, n, uio->uio_rw, uio);89uio->uio_segflg = segflg;90}919293