Index: conf/files
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/conf/files,v
retrieving revision 1.19
diff -u -u -r1.19 files
--- conf/files	19 Oct 2003 00:23:20 -0000	1.19
+++ conf/files	19 Oct 2003 10:08:57 -0000
@@ -1581,3 +1581,5 @@
 dev/drm/radeon/radeon_state.c		optional radeondrm
 dev/drm/tdfx/tdfx_drv.c			optional tdfxdrm
 emulation/43bsd/43bsd_socket.c		optional compat_43
+emulation/43bsd/43bsd_stats.c		optional compat_43
+emulation/43bsd/43bsd_file.c		optional compat_43
Index: emulation/43bsd/43bsd_file.c
===================================================================
RCS file: emulation/43bsd/43bsd_file.c
diff -N emulation/43bsd/43bsd_file.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ emulation/43bsd/43bsd_file.c	20 Oct 2003 01:35:17 -0000
@@ -0,0 +1,64 @@
+/*
+ * 43BSD_FILE.C		- 4.3BSD compatibility file syscalls
+ *
+ * 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.
+ *
+ * $DragonFly$
+ * 	from: DragonFly kern/vfs_syscalls.c,v 1.20
+ *
+ * These syscalls used to live in kern/vfs_syscalls.c.  They are modified
+ * to use the new split syscalls.
+ */
+
+#include "opt_compat.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/sysproto.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/kern_syscall.h>
+
+int
+oftruncate(struct oftruncate_args *uap)
+{
+	int error;
+
+	error = kern_ftruncate(uap->fd, uap->length);
+
+	return (error);
+}
Index: emulation/43bsd/43bsd_stats.c
===================================================================
RCS file: emulation/43bsd/43bsd_stats.c
diff -N emulation/43bsd/43bsd_stats.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ emulation/43bsd/43bsd_stats.c	16 Oct 2003 00:23:59 -0000
@@ -0,0 +1,98 @@
+/*
+ * 43BSD_STATS.C	- 4.3BSD compatibility stats syscalls
+ *
+ * Copyright (c) 1982, 1986, 1989, 1991, 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.
+ *
+ * $DragonFly$
+ * 	from: DragonFly kern/kern_descrip.c,v 1.16
+ *
+ * These syscalls used to live in kern/kern_descrip.c.  They are modified
+ * to use the new split syscalls.
+ */
+
+#include "opt_compat.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/sysproto.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/stat.h>
+#include <sys/kern_syscall.h>
+
+static int
+compat_43_copyout_stat(struct stat *st, struct ostat *uaddr)
+{
+	struct ostat ost;
+	int error;
+
+	ost.st_dev = st->st_dev;
+	ost.st_ino = st->st_ino;
+	ost.st_mode = st->st_mode;
+	ost.st_nlink = st->st_nlink;
+	ost.st_uid = st->st_uid;
+	ost.st_gid = st->st_gid;
+	ost.st_rdev = st->st_rdev;
+	if (st->st_size < (quad_t)1 << 32)
+		ost.st_size = st->st_size;
+	else
+		ost.st_size = -2;
+	ost.st_atime = st->st_atime;
+	ost.st_mtime = st->st_mtime;
+	ost.st_ctime = st->st_ctime;
+	ost.st_blksize = st->st_blksize;
+	ost.st_blocks = st->st_blocks;
+	ost.st_flags = st->st_flags;
+	ost.st_gen = st->st_gen;
+
+	error = copyout(&ost, uaddr, sizeof(ost));
+	return (error);
+}
+
+int
+ofstat(struct ofstat_args *uap)
+{
+	struct stat st;
+	int error;
+
+	error = kern_fstat(uap->fd, &st);
+
+	if (error == 0) {
+		error = compat_43_copyout_stat(&st, uap->sb);
+	}
+	return (error);
+}
Index: emulation/linux/linux_file.c
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/linux_file.c,v
retrieving revision 1.11
diff -u -u -r1.11 linux_file.c
--- emulation/linux/linux_file.c	17 Oct 2003 05:25:45 -0000	1.11
+++ emulation/linux/linux_file.c	20 Oct 2003 01:39:40 -0000
@@ -700,6 +700,21 @@
 }
 
 int
+linux_ftruncate(struct linux_ftruncate_args *args)
+{
+	int error;
+
+#ifdef DEBUG
+	if (ldebug(ftruncate))
+		printf(ARGS(ftruncate, "%d, %ld"), args->fd,
+		    (long)args->length);
+#endif
+	error = kern_ftruncate(args->fd, args->length);
+
+	return error;
+}
+
+int
 linux_link(struct linux_link_args *args)
 {
     struct link_args bsd;
Index: emulation/linux/linux_stats.c
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/linux_stats.c,v
retrieving revision 1.9
diff -u -u -r1.9 linux_stats.c
--- emulation/linux/linux_stats.c	29 Sep 2003 18:52:09 -0000	1.9
+++ emulation/linux/linux_stats.c	20 Oct 2003 01:39:25 -0000
@@ -44,6 +44,7 @@
 #include <sys/vnode.h>
 #include <sys/device.h>
 #include <sys/file2.h>
+#include <sys/kern_syscall.h>
 
 #include <arch_linux/linux.h>
 #include <arch_linux/linux_proto.h>
@@ -155,29 +156,17 @@
 int
 linux_newfstat(struct linux_newfstat_args *args)
 {
-	struct thread *td = curthread;
-	struct proc *p = td->td_proc;
-	struct filedesc *fdp;
-	struct file *fp;
 	struct stat buf;
 	int error;
 
-	KKASSERT(p);
-
 #ifdef DEBUG
 	if (ldebug(newfstat))
 		printf(ARGS(newfstat, "%d, *"), args->fd);
 #endif
+	error = kern_fstat(args->fd, &buf);
 
-	fdp = p->p_fd;
-	if ((unsigned)args->fd >= fdp->fd_nfiles ||
-	    (fp = fdp->fd_ofiles[args->fd]) == NULL)
-		return (EBADF);
-
-	error = fo_stat(fp, &buf, td);
-	if (!error)
+	if (error == 0)
 		error = newstat_copyout(&buf, args->buf);
-
 	return (error);
 }
 
@@ -468,29 +457,17 @@
 int
 linux_fstat64(struct linux_fstat64_args *args)
 {
-	struct thread *td = curthread;
-	struct proc *p = td->td_proc;
-	struct filedesc *fdp;
-	struct file *fp;
 	struct stat buf;
 	int error;
 
-	KKASSERT(p);
-
 #ifdef DEBUG
 	if (ldebug(fstat64))
 		printf(ARGS(fstat64, "%d, *"), args->fd);
 #endif
+	error = kern_fstat(args->fd, &buf);
 
-	fdp = p->p_fd;
-	if ((unsigned)args->fd >= fdp->fd_nfiles ||
-	    (fp = fdp->fd_ofiles[args->fd]) == NULL)
-		return (EBADF);
-
-	error = fo_stat(fp, &buf, td);
-	if (!error)
+	if (error == 0)
 		error = stat64_copyout(&buf, args->statbuf);
-
 	return (error);
 }
 
Index: emulation/linux/i386/linux_proto.h
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux_proto.h,v
retrieving revision 1.9
diff -u -u -r1.9 linux_proto.h
--- emulation/linux/i386/linux_proto.h	27 Aug 2003 06:30:03 -0000	1.9
+++ emulation/linux/i386/linux_proto.h	19 Oct 2003 07:33:51 -0000
@@ -2,7 +2,7 @@
  * System call prototypes.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $DragonFly: src/sys/emulation/linux/i386/linux_proto.h,v 1.9 2003/08/27 06:30:03 rob Exp $
+ * $DragonFly$
  * created from DragonFly: src/sys/emulation/linux/i386/syscalls.master,v 1.3 2003/08/07 21:17:18 dillon Exp 
  */
 
@@ -516,6 +516,14 @@
 	char *	path;	char path_[PAD_(char *)];
 	l_ulong	length;	char length_[PAD_(l_ulong)];
 };
+struct	linux_ftruncate_args {
+#ifdef _KERNEL
+	union sysmsg sysmsg;
+#endif
+	union usrmsg usrmsg;
+	int	fd;	char fd_[PAD_(int)];
+	long	length;	char length_[PAD_(long)];
+};
 struct	linux_statfs_args {
 #ifdef _KERNEL
 	union sysmsg sysmsg;
@@ -1310,6 +1318,7 @@
 int	linux_readdir (struct linux_readdir_args *);
 int	linux_mmap (struct linux_mmap_args *);
 int	linux_truncate (struct linux_truncate_args *);
+int	linux_ftruncate (struct linux_ftruncate_args *);
 int	linux_statfs (struct linux_statfs_args *);
 int	linux_fstatfs (struct linux_fstatfs_args *);
 int	linux_ioperm (struct linux_ioperm_args *);
Index: emulation/linux/i386/linux_syscall.h
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux_syscall.h,v
retrieving revision 1.9
diff -u -u -r1.9 linux_syscall.h
--- emulation/linux/i386/linux_syscall.h	27 Aug 2003 06:30:03 -0000	1.9
+++ emulation/linux/i386/linux_syscall.h	19 Oct 2003 07:33:51 -0000
@@ -2,7 +2,7 @@
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $DragonFly: src/sys/emulation/linux/i386/linux_syscall.h,v 1.9 2003/08/27 06:30:03 rob Exp $
+ * $DragonFly$
  * created from DragonFly: src/sys/emulation/linux/i386/syscalls.master,v 1.3 2003/08/07 21:17:18 dillon Exp 
  */
 
@@ -90,7 +90,7 @@
 #define	LINUX_SYS_linux_mmap	90
 #define	LINUX_SYS_munmap	91
 #define	LINUX_SYS_linux_truncate	92
-#define	LINUX_SYS_oftruncate	93
+#define	LINUX_SYS_linux_ftruncate	93
 #define	LINUX_SYS_fchmod	94
 #define	LINUX_SYS_fchown	95
 #define	LINUX_SYS_getpriority	96
Index: emulation/linux/i386/linux_sysent.c
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux_sysent.c,v
retrieving revision 1.9
diff -u -u -r1.9 linux_sysent.c
--- emulation/linux/i386/linux_sysent.c	27 Aug 2003 06:30:03 -0000	1.9
+++ emulation/linux/i386/linux_sysent.c	19 Oct 2003 07:33:51 -0000
@@ -2,7 +2,7 @@
  * System call switch table.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $DragonFly: src/sys/emulation/linux/i386/linux_sysent.c,v 1.9 2003/08/27 06:30:03 rob Exp $
+ * $DragonFly$
  * created from DragonFly: src/sys/emulation/linux/i386/syscalls.master,v 1.3 2003/08/07 21:17:18 dillon Exp 
  */
 
@@ -110,7 +110,7 @@
 	{ AS(linux_mmap_args), (sy_call_t *)linux_mmap },	/* 90 = linux_mmap */
 	{ AS(munmap_args), (sy_call_t *)munmap },	/* 91 = munmap */
 	{ AS(linux_truncate_args), (sy_call_t *)linux_truncate },	/* 92 = linux_truncate */
-	{ AS(oftruncate_args), (sy_call_t *)oftruncate },	/* 93 = oftruncate */
+	{ AS(linux_ftruncate_args), (sy_call_t *)linux_ftruncate },	/* 93 = linux_ftruncate */
 	{ AS(fchmod_args), (sy_call_t *)fchmod },	/* 94 = fchmod */
 	{ AS(fchown_args), (sy_call_t *)fchown },	/* 95 = fchown */
 	{ AS(getpriority_args), (sy_call_t *)getpriority },	/* 96 = getpriority */
Index: emulation/linux/i386/linux_union.h
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux_union.h,v
retrieving revision 1.5
diff -u -u -r1.5 linux_union.h
--- emulation/linux/i386/linux_union.h	27 Aug 2003 06:30:03 -0000	1.5
+++ emulation/linux/i386/linux_union.h	19 Oct 2003 07:33:51 -0000
@@ -2,7 +2,7 @@
  * Union of syscall args for messaging.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $DragonFly: src/sys/emulation/linux/i386/linux_union.h,v 1.5 2003/08/27 06:30:03 rob Exp $
+ * $DragonFly$
  * created from DragonFly: src/sys/emulation/linux/i386/syscalls.master,v 1.3 2003/08/07 21:17:18 dillon Exp 
  */
 
@@ -74,6 +74,7 @@
 	struct	linux_readdir_args linux_readdir;
 	struct	linux_mmap_args linux_mmap;
 	struct	linux_truncate_args linux_truncate;
+	struct	linux_ftruncate_args linux_ftruncate;
 	struct	linux_statfs_args linux_statfs;
 	struct	linux_fstatfs_args linux_fstatfs;
 	struct	linux_ioperm_args linux_ioperm;
Index: emulation/linux/i386/syscalls.master
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/syscalls.master,v
retrieving revision 1.3
diff -u -u -r1.3 syscalls.master
--- emulation/linux/i386/syscalls.master	7 Aug 2003 21:17:18 -0000	1.3
+++ emulation/linux/i386/syscalls.master	19 Oct 2003 07:33:43 -0000
@@ -152,7 +152,7 @@
 90	STD	LINUX	{ int linux_mmap(struct l_mmap_argv *ptr); }
 91	NOPROTO	LINUX	{ int munmap(caddr_t addr, int len); }
 92	STD	LINUX	{ int linux_truncate(char *path, l_ulong length); }
-93	NOPROTO	LINUX	{ int oftruncate(int fd, long length); }
+93	STD	LINUX	{ int linux_ftruncate(int fd, long length); }
 94	NOPROTO	LINUX	{ int fchmod(int fd, int mode); }
 95	NOPROTO	LINUX	{ int fchown(int fd, int uid, int gid); }
 96	NOPROTO	LINUX	{ int getpriority(int which, int who); }
Index: kern/kern_descrip.c
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/kern/kern_descrip.c,v
retrieving revision 1.16
diff -u -u -r1.16 kern_descrip.c
--- kern/kern_descrip.c	15 Oct 2003 06:38:46 -0000	1.16
+++ kern/kern_descrip.c	20 Oct 2003 01:43:32 -0000
@@ -670,92 +670,61 @@
 	return (error);
 }
 
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
-/*
- * Return status information about a file descriptor.
- */
-/* ARGSUSED */
 int
-ofstat(struct ofstat_args *uap)
+kern_fstat(int fd, struct stat *ub)
 {
 	struct thread *td = curthread;
 	struct proc *p = td->td_proc;
 	struct filedesc *fdp;
 	struct file *fp;
-	struct stat ub;
-	struct ostat oub;
 	int error;
 
 	KKASSERT(p);
+
 	fdp = p->p_fd;
-	if ((unsigned)uap->fd >= fdp->fd_nfiles ||
-	    (fp = fdp->fd_ofiles[uap->fd]) == NULL)
+	if ((unsigned)fd >= fdp->fd_nfiles ||
+	    (fp = fdp->fd_ofiles[fd]) == NULL)
 		return (EBADF);
 	fhold(fp);
-	error = fo_stat(fp, &ub, td);
-	if (error == 0) {
-		cvtstat(&ub, &oub);
-		error = copyout((caddr_t)&oub, (caddr_t)uap->sb, sizeof (oub));
-	}
+	error = fo_stat(fp, ub, td);
 	fdrop(fp, td);
+
 	return (error);
 }
-#endif /* COMPAT_43 || COMPAT_SUNOS */
 
 /*
  * Return status information about a file descriptor.
  */
-/* ARGSUSED */
 int
 fstat(struct fstat_args *uap)
 {
-	struct thread *td = curthread;
-	struct proc *p = td->td_proc;
-	struct filedesc *fdp = p->p_fd;
-	struct file *fp;
-	struct stat ub;
+	struct stat st;
 	int error;
 
-	KKASSERT(p);
-	fdp = p->p_fd;
-	if ((unsigned)uap->fd >= fdp->fd_nfiles ||
-	    (fp = fdp->fd_ofiles[uap->fd]) == NULL)
-		return (EBADF);
-	fhold(fp);
-	error = fo_stat(fp, &ub, td);
+	error = kern_fstat(uap->fd, &st);
+
 	if (error == 0)
-		error = copyout((caddr_t)&ub, (caddr_t)uap->sb, sizeof (ub));
-	fdrop(fp, td);
+		error = copyout(&st, uap->sb, sizeof(st));
 	return (error);
 }
 
 /*
- * Return status information about a file descriptor.
+ * XXX: This is for source compatibility with NetBSD.  Probably doesn't
+ * belong here.
  */
-/* ARGSUSED */
 int
 nfstat(struct nfstat_args *uap)
 {
-	struct thread *td = curthread;
-	struct proc *p = td->td_proc;
-	struct filedesc *fdp;
-	struct file *fp;
-	struct stat ub;
-	struct nstat nub;
+	struct stat st;
+	struct nstat nst;
 	int error;
 
-	KKASSERT(p);
-	fdp = p->p_fd;
-	if ((unsigned)uap->fd >= fdp->fd_nfiles ||
-	    (fp = fdp->fd_ofiles[uap->fd]) == NULL)
-		return (EBADF);
-	fhold(fp);
-	error = fo_stat(fp, &ub, td);
+	error = kern_fstat(uap->fd, &st);
+
 	if (error == 0) {
-		cvtnstat(&ub, &nub);
-		error = copyout((caddr_t)&nub, (caddr_t)uap->sb, sizeof (nub));
+		cvtnstat(&st, &nst);
+		error = copyout(&nst, uap->sb, sizeof (nst));
 	}
-	fdrop(fp, td);
 	return (error);
 }
 
Index: kern/vfs_syscalls.c
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.20
diff -u -u -r1.20 vfs_syscalls.c
--- kern/vfs_syscalls.c	9 Oct 2003 22:27:19 -0000	1.20
+++ kern/vfs_syscalls.c	19 Oct 2003 10:10:43 -0000
@@ -62,6 +62,7 @@
 #include <sys/namei.h>
 #include <sys/dirent.h>
 #include <sys/extattr.h>
+#include <sys/kern_syscall.h>
 
 #include <machine/limits.h>
 #include <vfs/union/union.h>
@@ -2188,14 +2189,8 @@
 	return (error);
 }
 
-/*
- * ftruncate_args(int fd, int pad, off_t length)
- *
- * Truncate a file given a file descriptor.
- */
-/* ARGSUSED */
 int
-ftruncate(struct ftruncate_args *uap)
+kern_ftruncate(int fd, off_t length)
 {
 	struct thread *td = curthread;
 	struct proc *p = td->td_proc;
@@ -2204,9 +2199,9 @@
 	struct file *fp;
 	int error;
 
-	if (uap->length < 0)
+	if (length < 0)
 		return(EINVAL);
-	if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+	if ((error = getvnode(p->p_fd, fd, &fp)) != 0)
 		return (error);
 	if ((fp->f_flag & FWRITE) == 0)
 		return (EINVAL);
@@ -2217,52 +2212,48 @@
 		error = EISDIR;
 	else if ((error = vn_writechk(vp)) == 0) {
 		VATTR_NULL(&vattr);
-		vattr.va_size = SCARG(uap, length);
+		vattr.va_size = length;
 		error = VOP_SETATTR(vp, &vattr, fp->f_cred, td);
 	}
 	VOP_UNLOCK(vp, 0, td);
 	return (error);
 }
 
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
 /*
- * otruncate_args(char *path, long length)
+ * ftruncate_args(int fd, int pad, off_t length)
  *
- * Truncate a file given its path name.
+ * Truncate a file given a file descriptor.
  */
 /* ARGSUSED */
 int
-otruncate(struct otruncate_args *uap)
+ftruncate(struct ftruncate_args *uap)
 {
-	struct truncate_args /* {
-		syscallarg(char *) path;
-		syscallarg(int) pad;
-		syscallarg(off_t) length;
-	} */ nuap;
+	int error;
 
-	SCARG(&nuap, path) = SCARG(uap, path);
-	SCARG(&nuap, length) = SCARG(uap, length);
-	return (truncate(&nuap));
+	error = kern_ftruncate(uap->fd, uap->length);
+
+	return (error);
 }
 
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
 /*
- * oftruncate_args(int fd, long length)
+ * otruncate_args(char *path, long length)
  *
- * Truncate a file given a file descriptor.
+ * Truncate a file given its path name.
  */
 /* ARGSUSED */
 int
-oftruncate(struct oftruncate_args *uap)
+otruncate(struct otruncate_args *uap)
 {
-	struct ftruncate_args /* {
-		syscallarg(int) fd;
+	struct truncate_args /* {
+		syscallarg(char *) path;
 		syscallarg(int) pad;
 		syscallarg(off_t) length;
 	} */ nuap;
 
-	SCARG(&nuap, fd) = SCARG(uap, fd);
+	SCARG(&nuap, path) = SCARG(uap, path);
 	SCARG(&nuap, length) = SCARG(uap, length);
-	return (ftruncate(&nuap));
+	return (truncate(&nuap));
 }
 #endif /* COMPAT_43 || COMPAT_SUNOS */
 
Index: sys/kern_syscall.h
===================================================================
RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/sys/kern_syscall.h,v
retrieving revision 1.7
diff -u -u -r1.7 kern_syscall.h
--- sys/kern_syscall.h	17 Oct 2003 05:25:45 -0000	1.7
+++ sys/kern_syscall.h	19 Oct 2003 07:41:31 -0000
@@ -47,6 +47,7 @@
  */
 int kern_dup(enum dup_type type, int old, int new, int *res);
 int kern_fcntl(int fd, int cmd, union fcntl_dat *dat);
+int kern_fstat(int fd, struct stat *st);
 
 /*
  * Prototypes for syscalls in kern/sys_generic.c
@@ -74,5 +75,10 @@
 int kern_setsockopt(int s, struct sockopt *sopt);
 int kern_socket(int domain, int type, int protocol, int *res);
 int kern_socketpair(int domain, int type, int protocol, int *sockv);
+
+/*
+ * Prototypes for syscalls in kern/vfs_syscalls.c
+ */
+int kern_ftruncate(int fd, off_t length);
 
 #endif /* !_SYS_KERN_SYSCALL_H_ */

