Commit da9cd811 authored by Stephen Lord's avatar Stephen Lord Committed by Stephen Lord

More uio changes, add code attribution

parent 36a49183
/*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
......@@ -45,30 +45,28 @@
int
uio_read(caddr_t src, size_t len, struct uio *uio)
{
struct iovec *iov;
u_int cnt;
int error;
size_t count;
if (len > 0 && uio->uio_resid) {
iov = uio->uio_iov;
cnt = (u_int)iov->iov_len;
if (cnt == 0)
return 0;
if (cnt > len)
cnt = (u_int)len;
if (uio->uio_segflg == UIO_USERSPACE) {
error = copy_to_user(iov->iov_base, src, cnt);
if (error)
return EFAULT;
} else if (uio->uio_segflg == UIO_SYSSPACE) {
memcpy(iov->iov_base, src, cnt);
} else {
ASSERT(0);
}
iov->iov_base = (void *)((char *)iov->iov_base + cnt);
iov->iov_len -= cnt;
uio->uio_resid -= cnt;
uio->uio_offset += cnt;
if (!len || !uio->uio_resid)
return 0;
count = uio->uio_iov->iov_len;
if (!count)
return 0;
if (count > len)
count = len;
if (uio->uio_segflg == UIO_USERSPACE) {
if (copy_to_user(uio->uio_iov->iov_base, src, count))
return EFAULT;
} else {
ASSERT(uio->uio_segflg == UIO_SYSSPACE);
memcpy(uio->uio_iov->iov_base, src, count);
}
uio->uio_iov->iov_base = (void*)((char*)uio->uio_iov->iov_base + count);
uio->uio_iov->iov_len -= count;
uio->uio_offset += count;
uio->uio_resid -= count;
return 0;
}
/*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
......@@ -28,32 +28,60 @@
* For further information regarding this notice, see:
*
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
*
* Portions Copyright (c) 1982, 1986, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef __XFS_SUPPORT_MOVE_H__
#define __XFS_SUPPORT_MOVE_H__
#include <linux/uio.h>
#include <asm/uaccess.h>
typedef struct iovec iovec_t;
/* Segment flag values. */
enum uio_seg {
UIO_USERSPACE, /* from user data space */
UIO_SYSSPACE, /* from system space */
};
typedef struct uio {
iovec_t *uio_iov; /* pointer to array of iovecs */
int uio_iovcnt; /* number of iovecs */
int uio_fmode; /* file mode flags */
xfs_off_t uio_offset; /* file offset */
short uio_segflg; /* address space (kernel or user) */
ssize_t uio_resid; /* residual count */
} uio_t;
struct uio {
struct iovec *uio_iov;
int uio_iovcnt;
xfs_off_t uio_offset;
int uio_resid;
enum uio_seg uio_segflg;
};
/*
* Segment flag values.
*/
typedef enum uio_seg {
UIO_USERSPACE, /* uio_iov describes user space */
UIO_SYSSPACE, /* uio_iov describes system space */
} uio_seg_t;
typedef struct uio uio_t;
typedef struct iovec iovec_t;
extern int uio_read (caddr_t, size_t, uio_t *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment