summaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/netbsd/files.netbsd3
-rw-r--r--sys/compat/netbsd/netbsd_pos_io.c219
-rw-r--r--sys/compat/netbsd/netbsd_stat.c10
-rw-r--r--sys/compat/netbsd/netbsd_stat.h4
-rw-r--r--sys/compat/netbsd/netbsd_types.h3
-rw-r--r--sys/compat/netbsd/syscalls.master26
6 files changed, 241 insertions, 24 deletions
diff --git a/sys/compat/netbsd/files.netbsd b/sys/compat/netbsd/files.netbsd
index 145b6fd8dc7..ad35c72c41b 100644
--- a/sys/compat/netbsd/files.netbsd
+++ b/sys/compat/netbsd/files.netbsd
@@ -1,4 +1,4 @@
-# $OpenBSD: files.netbsd,v 1.4 1999/09/15 20:41:16 kstailey Exp $
+# $OpenBSD: files.netbsd,v 1.5 1999/09/17 12:13:47 kstailey Exp $
#
# Config.new file description for machine-independent NetBSD compat code.
# Included by ports that need it.
@@ -10,6 +10,7 @@ file compat/netbsd/netbsd_exec.c compat_netbsd
file compat/netbsd/netbsd_getcwd.c compat_netbsd
file compat/netbsd/netbsd_getdents.c compat_netbsd
file compat/netbsd/netbsd_misc.c compat_netbsd
+file compat/netbsd/netbsd_pos_io.c compat_netbsd
file compat/netbsd/netbsd_signal.c compat_netbsd
file compat/netbsd/netbsd_stat.c compat_netbsd
file compat/netbsd/netbsd_sysent.c compat_netbsd
diff --git a/sys/compat/netbsd/netbsd_pos_io.c b/sys/compat/netbsd/netbsd_pos_io.c
new file mode 100644
index 00000000000..9a970fbfb79
--- /dev/null
+++ b/sys/compat/netbsd/netbsd_pos_io.c
@@ -0,0 +1,219 @@
+/* $OpenBSD: netbsd_pos_io.c,v 1.1 1999/09/17 12:13:47 kstailey Exp $ */
+
+/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ *
+ * @(#)vfs_syscalls.c 8.28 (Berkeley) 12/10/94
+ */
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/vnode.h>
+#include <sys/proc.h>
+#include <sys/uio.h>
+/*#include <sys/malloc.h>*/
+#ifdef KTRACE
+#include <sys/ktrace.h>
+#endif
+
+#include <compat/netbsd/netbsd_types.h>
+#include <compat/netbsd/netbsd_signal.h>
+#include <compat/netbsd/netbsd_syscallargs.h>
+
+static int netbsd_set_pos __P((struct proc *, int fd, off_t offset));
+/*
+ * sys_lseek's trimmed down
+ */
+static int
+netbsd_set_pos(p, fd, offset)
+ struct proc *p;
+ int fd;
+ off_t offset;
+{
+ register struct filedesc *fdp = p->p_fd;
+ register struct file *fp;
+ struct vnode *vp;
+ int special;
+
+ if ((u_int)fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL)
+ return (EBADF);
+ if (fp->f_type != DTYPE_VNODE)
+ return (ESPIPE);
+ vp = (struct vnode *)fp->f_data;
+ if (vp->v_type == VFIFO)
+ return (ESPIPE);
+ if (vp->v_type == VCHR)
+ special = 1;
+ else
+ special = 0;
+ if (!special && offset < 0)
+ return (EINVAL);
+ fp->f_offset = offset;
+ return (0);
+}
+
+/*
+ * Positional read system call.
+ */
+/* ARGSUSED */
+int
+netbsd_sys_pread(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct netbsd_sys_pread_args /* {
+ syscallarg(int) fd;
+ syscallarg(void *) buf;
+ syscallarg(size_t) nbyte;
+ syscallarg(off_t) offset;
+ } */ *uap = v;
+ register struct file *fp;
+ register struct filedesc *fdp = p->p_fd;
+ struct uio auio;
+ struct iovec aiov;
+ long cnt, error = 0;
+#ifdef KTRACE
+ struct iovec ktriov;
+#endif
+
+ if ((error = netbsd_set_pos(p, SCARG(uap, fd), SCARG(uap, offset))))
+ return (error);
+ fp = fdp->fd_ofiles[SCARG(uap, fd)];
+ /* Don't allow nbyte to be larger than max return val */
+ if (SCARG(uap, nbyte) > SSIZE_MAX)
+ return(EINVAL);
+ aiov.iov_base = (caddr_t)SCARG(uap, buf);
+ aiov.iov_len = SCARG(uap, nbyte);
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_resid = SCARG(uap, nbyte);
+ auio.uio_rw = UIO_READ;
+ auio.uio_segflg = UIO_USERSPACE;
+ auio.uio_procp = p;
+#ifdef KTRACE
+ /*
+ * if tracing, save a copy of iovec
+ */
+ if (KTRPOINT(p, KTR_GENIO))
+ ktriov = aiov;
+#endif
+ cnt = SCARG(uap, nbyte);
+ error = (*fp->f_ops->fo_read)(fp, &auio, fp->f_cred);
+ if (error)
+ if (auio.uio_resid != cnt && (error == ERESTART ||
+ error == EINTR || error == EWOULDBLOCK))
+ error = 0;
+ cnt -= auio.uio_resid;
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_GENIO) && error == 0)
+ ktrgenio(p->p_tracep, SCARG(uap, fd), UIO_READ, &ktriov,
+ cnt, error);
+#endif
+ *retval = cnt;
+ return (error);
+}
+
+/*
+ * Positional scatter read system call.
+ */
+/* ARGSUSED */
+int
+netbsd_sys_preadv(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+#if 0
+ struct netbsd_sys_preadv_args /* {
+ syscallarg(int) fd;
+ syscallarg(const struct iovec *) iovp;
+ syscallarg(int) iovcnt;
+ syscallarg(off_t) offset;
+ } */ *uap = v;
+#else
+ return (0);
+#endif
+}
+
+/*
+ * Positional write system call.
+ */
+/* ARGSUSED */
+int
+netbsd_sys_pwrite(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+#if 0
+ struct netbsd_sys_pwrite_args /* {
+ syscallarg(int) fd;
+ syscallarg(const void *) buf;
+ syscallarg(size_t) nbyte;
+ syscallarg(off_t) offset;
+ } */ *uap = v;
+#else
+ return (0);
+#endif
+}
+
+/*
+ * Positional gather write system call.
+ */
+/* ARGSUSED */
+int
+netbsd_sys_pwritev(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+#if 0
+ struct netbsd_sys_pwritev_args /* {
+ syscallarg(int) fd;
+ syscallarg(const struct iovec *) iovp;
+ syscallarg(int) iovcnt;
+ syscallarg(off_t) offset;
+ } */ *uap = v;
+#else
+ return (0);
+#endif
+}
diff --git a/sys/compat/netbsd/netbsd_stat.c b/sys/compat/netbsd/netbsd_stat.c
index 05d799f8cfe..cdffe5a1d40 100644
--- a/sys/compat/netbsd/netbsd_stat.c
+++ b/sys/compat/netbsd/netbsd_stat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netbsd_stat.c,v 1.2 1999/09/14 01:05:25 kstailey Exp $ */
+/* $OpenBSD: netbsd_stat.c,v 1.3 1999/09/17 12:13:47 kstailey Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -88,7 +88,7 @@ openbsd_to_netbsd_stat(obst, nbst)
nbst->st_blksize = obst->st_blksize;
nbst->st_flags = obst->st_flags;
nbst->st_gen = obst->st_gen;
- memcpy(nbst->st_qspare, obst->st_qspare, sizeof(nbst->st_qspare));
+ bcopy(obst->st_qspare, nbst->st_qspare, sizeof(obst->st_qspare));
}
/*
@@ -138,7 +138,7 @@ netbsd_sys___lstat13(p, v, retval)
{
register struct netbsd_sys___lstat13_args /* {
syscallarg(const char *) path;
- syscallarg(struct netbsd_stat *) nsb;
+ syscallarg(struct netbsd_stat *) ub;
} */ *uap = v;
struct netbsd_stat nsb;
struct stat sb;
@@ -173,7 +173,7 @@ netbsd_sys___fstat13(p, v, retval)
{
register struct netbsd_sys___fstat13_args /* {
syscallarg(int) fd;
- syscallarg(struct netbsd_stat *) nsb;
+ syscallarg(struct netbsd_stat *) ub;
} */ *uap = v;
int fd = SCARG(uap, fd);
register struct filedesc *fdp = p->p_fd;
@@ -202,6 +202,6 @@ netbsd_sys___fstat13(p, v, retval)
if (error)
return (error);
openbsd_to_netbsd_stat(&sb, &nsb);
- error = copyout(&nsb, SCARG(uap, ub), sizeof(nsb));
+ error = copyout(&nsb, SCARG(uap, ub), sizeof(nsb));
return (error);
}
diff --git a/sys/compat/netbsd/netbsd_stat.h b/sys/compat/netbsd/netbsd_stat.h
index 364e6176255..8bf88cd5094 100644
--- a/sys/compat/netbsd/netbsd_stat.h
+++ b/sys/compat/netbsd/netbsd_stat.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netbsd_stat.h,v 1.1 1999/09/12 14:15:16 kstailey Exp $ */
+/* $OpenBSD: netbsd_stat.h,v 1.2 1999/09/17 12:13:47 kstailey Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -78,7 +78,7 @@ struct netbsd_stat {
dev_t st_dev; /* inode's device */
ino_t st_ino; /* inode's number */
mode_t st_mode; /* inode protection mode */
- nlink_t st_nlink; /* number of hard links */
+ netbsd_nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */
dev_t st_rdev; /* device type */
diff --git a/sys/compat/netbsd/netbsd_types.h b/sys/compat/netbsd/netbsd_types.h
index 89aaa47aefb..ffdbff50435 100644
--- a/sys/compat/netbsd/netbsd_types.h
+++ b/sys/compat/netbsd/netbsd_types.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netbsd_types.h,v 1.1 1999/09/12 14:15:17 kstailey Exp $ */
+/* $OpenBSD: netbsd_types.h,v 1.2 1999/09/17 12:13:47 kstailey Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993, 1994
@@ -42,3 +42,4 @@
typedef int64_t netbsd_blkcnt_t; /* fs block count */
typedef u_int32_t netbsd_blksize_t; /* fs optimal block size */
+typedef u_int32_t netbsd_nlink_t; /* link count */
diff --git a/sys/compat/netbsd/syscalls.master b/sys/compat/netbsd/syscalls.master
index 2a06d789fea..5f96d87747a 100644
--- a/sys/compat/netbsd/syscalls.master
+++ b/sys/compat/netbsd/syscalls.master
@@ -1,4 +1,4 @@
-; $OpenBSD: syscalls.master,v 1.5 1999/09/15 20:41:16 kstailey Exp $
+; $OpenBSD: syscalls.master,v 1.6 1999/09/17 12:13:47 kstailey Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -355,12 +355,10 @@
171 UNIMPL 1.0 shmsys
#endif
172 UNIMPL
-173 UNIMPL
-;173 STD { ssize_t sys_pread(int fd, void *buf, \
-; size_t nbyte, int pad, off_t offset); }
-174 UNIMPL
-;174 STD { ssize_t sys_pwrite(int fd, const void *buf, \
-; size_t nbyte, int pad, off_t offset); }
+173 STD { ssize_t netbsd_sys_pread(int fd, void *buf, \
+ size_t nbyte, int pad, off_t offset); }
+174 STD { ssize_t netbsd_sys_pwrite(int fd, const void *buf, \
+ size_t nbyte, int pad, off_t offset); }
#ifdef NTP
175 NOARGS { int sys_ntp_gettime(struct ntptimeval *ntvp); }
176 NOARGS { int sys_ntp_adjtime(struct timex *tp); }
@@ -585,14 +583,12 @@
#else
288 UNIMPL
#endif
-289 UNIMPL
-;289 STD { ssize_t netbsd_sys_preadv(int fd, \
-; const struct iovec *iovp, int iovcnt, \
-; int pad, off_t offset); }
-290 UNIMPL
-;290 STD { ssize_t netbsd_sys_pwritev(int fd, \
-; const struct iovec *iovp, int iovcnt, \
-; int pad, off_t offset); }
+289 STD { ssize_t netbsd_sys_preadv(int fd, \
+ const struct iovec *iovp, int iovcnt, \
+ int pad, off_t offset); }
+290 STD { ssize_t netbsd_sys_pwritev(int fd, \
+ const struct iovec *iovp, int iovcnt, \
+ int pad, off_t offset); }
291 STD { int netbsd_sys___sigaction14(int signum, \
const struct netbsd_sigaction *nsa, \
struct netbsd_sigaction *osa); }