kern/85175: linux emulation layer without COMPAT_43

Divacky Roman xdivac02 at stud.fit.vutbr.cz
Sun Aug 21 08:10:21 GMT 2005


>Number:         85175
>Category:       kern
>Synopsis:       linux emulation layer without COMPAT_43
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 21 08:10:20 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Divacky Roman
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
home
>Environment:
FreeBSD witten 7.0-CURRENT FreeBSD 7.0-CURRENT #64: Sun Aug 21 09:42:53 CEST
2005     root at witten:/usr/obj/usr/src/sys/NEOLOGISM  i386


	
>Description:

Currently linux emulation layer requires COMPAT_43, with this patch it doesnt.
its basically a rewrite of old dfly patch. with this applied there is no wide
used user of COMPAT_43 anymore, hence we can get rid of it in GENERIC
(possibly)

this also obsoletes kern/73165

>How-To-Repeat:
apply the patch

>Fix:

? cscope.in.out
? cscope.out
? cscope.po.out
Index: compat/linux/linux_file.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_file.c,v
retrieving revision 1.91
diff -u -r1.91 linux_file.c
--- compat/linux/linux_file.c	13 Apr 2005 04:31:43 -0000	1.91
+++ compat/linux/linux_file.c	20 Aug 2005 10:34:48 -0000
@@ -29,7 +29,6 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/sys/compat/linux/linux_file.c,v 1.91 2005/04/13 04:31:43 mdodd Exp $");
 
-#include "opt_compat.h"
 #include "opt_mac.h"
 
 #include <sys/param.h>
@@ -54,8 +53,6 @@
 #include <ufs/ufs/quota.h>
 #include <ufs/ufs/ufsmount.h>
 
-#include "opt_compat.h"
-
 #ifdef COMPAT_LINUX32
 #include <machine/../linux32/linux.h>
 #include <machine/../linux32/linux32_proto.h>
@@ -666,6 +663,21 @@
 	error = kern_truncate(td, path, UIO_SYSSPACE, args->length);
 	LFREEPATH(path);
 	return (error);
+}
+
+int
+linux_ftruncate(struct thread *td, struct linux_ftruncate_args *args)
+{
+	struct ftruncate_args /* {
+		int fd;
+		int pad;
+		off_t length;
+		} */ nuap;
+	   
+	nuap.fd = args->fd;
+	nuap.pad = 0;
+	nuap.length = args->length;
+	return (ftruncate(td, &nuap));
 }
 
 int
Index: compat/linux/linux_getcwd.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_getcwd.c,v
retrieving revision 1.19
diff -u -r1.19 linux_getcwd.c
--- compat/linux/linux_getcwd.c	9 Jul 2005 12:34:49 -0000	1.19
+++ compat/linux/linux_getcwd.c	20 Aug 2005 10:34:48 -0000
@@ -39,7 +39,6 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/sys/compat/linux/linux_getcwd.c,v 1.19 2005/07/09 12:34:49 jhb Exp $");
 
-#include "opt_compat.h"
 #include "opt_mac.h"
 
 #include <sys/param.h>
@@ -58,8 +57,6 @@
 #include <sys/malloc.h>
 #include <sys/dirent.h>
 #include <ufs/ufs/dir.h>	/* XXX only for DIRBLKSIZ */
-
-#include "opt_compat.h"
 
 #ifdef COMPAT_LINUX32
 #include <machine/../linux32/linux.h>
Index: compat/linux/linux_ioctl.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_ioctl.c,v
retrieving revision 1.128
diff -u -r1.128 linux_ioctl.c
--- compat/linux/linux_ioctl.c	9 Aug 2005 10:19:41 -0000	1.128
+++ compat/linux/linux_ioctl.c	20 Aug 2005 10:34:49 -0000
@@ -2258,6 +2258,29 @@
 	return (ENOENT);
 }
 
+
+ /*
+* If we fault in bsd_to_linux_ifreq() then we will fault when we call
+* the native ioctl().  Thus, we don't really need to check the return
+* value of this function.
+*/
+static int
+bsd_to_linux_ifreq(struct ifreq *arg)
+{
+	struct ifreq ifr;
+	size_t ifr_len = sizeof(struct ifreq);
+	int error;
+	
+	if ((error = copyin(arg, &ifr, ifr_len)))
+		return (error);
+	
+	*(u_short *)&ifr.ifr_addr = ifr.ifr_addr.sa_family;
+	
+	error = copyout(&ifr, arg, ifr_len);
+
+	return (error);
+}
+
 /*
  * Socket related ioctls
  */
@@ -2389,8 +2412,9 @@
 		break;
 
 	case LINUX_SIOCGIFADDR:
-		args->cmd = OSIOCGIFADDR;
+		args->cmd = SIOCGIFADDR;
 		error = ioctl(td, (struct ioctl_args *)args);
+		bsd_to_linux_ifreq((struct ifreq *)args->arg);
 		break;
 
 	case LINUX_SIOCSIFADDR:
@@ -2400,18 +2424,21 @@
 		break;
 
 	case LINUX_SIOCGIFDSTADDR:
-		args->cmd = OSIOCGIFDSTADDR;
+		args->cmd = SIOCGIFDSTADDR;
 		error = ioctl(td, (struct ioctl_args *)args);
+		bsd_to_linux_ifreq((struct ifreq *)args->arg);
 		break;
 
 	case LINUX_SIOCGIFBRDADDR:
-		args->cmd = OSIOCGIFBRDADDR;
+		args->cmd = SIOCGIFBRDADDR;
 		error = ioctl(td, (struct ioctl_args *)args);
+		bsd_to_linux_ifreq((struct ifreq *)args->arg);
 		break;
 
 	case LINUX_SIOCGIFNETMASK:
-		args->cmd = OSIOCGIFNETMASK;
+		args->cmd = SIOCGIFNETMASK;
 		error = ioctl(td, (struct ioctl_args *)args);
+		bsd_to_linux_ifreq((struct ifreq *)args->arg);
 		break;
 
 	case LINUX_SIOCSIFNETMASK:
Index: compat/linux/linux_misc.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_misc.c,v
retrieving revision 1.170
diff -u -r1.170 linux_misc.c
--- compat/linux/linux_misc.c	7 Jul 2005 19:17:55 -0000	1.170
+++ compat/linux/linux_misc.c	20 Aug 2005 10:34:49 -0000
@@ -72,8 +72,6 @@
 
 #include <posix4/sched.h>
 
-#include "opt_compat.h"
-
 #include <compat/linux/linux_sysproto.h>
 
 #ifdef COMPAT_LINUX32
@@ -1402,3 +1400,19 @@
 	td->td_retval[0] = 20 - td->td_retval[0];
 	return error;
 }
+
+int
+linux_sethostname(struct thread *td, struct linux_sethostname_args *args)
+{
+	struct proc *p = td->td_proc;
+	int name[2];
+	int error;
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_HOSTNAME;
+	if ((error = suser_cred(p->p_ucred, SUSER_ALLOWJAIL)))
+		return (error);
+	return (userland_sysctl(td, name, 2, 0, 0, 0, args->hostname, 
+		 args->len, 0, 0));
+}
+
Index: compat/linux/linux_socket.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_socket.c,v
retrieving revision 1.59
diff -u -r1.59 linux_socket.c
--- compat/linux/linux_socket.c	9 Jul 2005 12:26:22 -0000	1.59
+++ compat/linux/linux_socket.c	20 Aug 2005 10:34:49 -0000
@@ -30,13 +30,8 @@
 __FBSDID("$FreeBSD: src/sys/compat/linux/linux_socket.c,v 1.59 2005/07/09 12:26:22 jhb Exp $");
 
 /* XXX we use functions that might not exist. */
-#include "opt_compat.h"
 #include "opt_inet6.h"
 
-#ifndef COMPAT_43
-#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!"
-#endif
-
 #include <sys/param.h>
 #include <sys/proc.h>
 #include <sys/systm.h>
@@ -62,8 +57,6 @@
 #include <netinet6/ip6_var.h>
 #endif
 
-#include "opt_compat.h"
-
 #ifdef COMPAT_LINUX32
 #include <machine/../linux32/linux.h>
 #include <machine/../linux32/linux32_proto.h>
@@ -343,6 +336,48 @@
 	return ret_flags;
 }
 
+/*
+* If bsd_to_linux_sockaddr() or linux_to_bsd_sockaddr() faults, then the
+* native syscall will fault.  Thus, we don't really need to check the
+* return values for these functions.
+*/
+
+static int
+bsd_to_linux_sockaddr(struct sockaddr *arg)
+{
+	struct sockaddr sa;
+	size_t sa_len = sizeof(struct sockaddr);
+	int error;
+	
+	if ((error = copyin(arg, &sa, sa_len)))
+		return (error);
+	
+	*(u_short *)&sa = sa.sa_family;
+	
+	error = copyout(&sa, arg, sa_len);
+	
+	return (error);
+}
+
+static int
+linux_to_bsd_sockaddr(struct sockaddr *arg, int len)
+{
+	struct sockaddr sa;
+	size_t sa_len = sizeof(struct sockaddr);
+	int error;
+
+	if ((error = copyin(arg, &sa, sa_len)))
+		return (error);
+
+	sa.sa_family = *(sa_family_t *)&sa;
+	sa.sa_len = len;
+
+	error = copyout(&sa, arg, sa_len);
+
+	return (error);
+}
+
+
 static int
 linux_sa_put(struct osockaddr *osa)
 {
@@ -685,7 +720,8 @@
 	/* XXX: */
 	bsd_args.name = (struct sockaddr * __restrict)PTRIN(linux_args.addr);
 	bsd_args.anamelen = PTRIN(linux_args.namelen);/* XXX */
-	error = oaccept(td, &bsd_args);
+	error = accept(td, &bsd_args);
+	bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.name);
 	if (error)
 		return (error);
 	if (linux_args.addr) {
@@ -732,7 +768,8 @@
 	/* XXX: */
 	bsd_args.asa = (struct sockaddr * __restrict)PTRIN(linux_args.addr);
 	bsd_args.alen = PTRIN(linux_args.namelen);	/* XXX */
-	error = ogetsockname(td, &bsd_args);
+	error = getsockname(td, &bsd_args);
+	bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.asa);
 	if (error)
 		return (error);
 	error = linux_sa_put(PTRIN(linux_args.addr));
@@ -751,7 +788,7 @@
 linux_getpeername(struct thread *td, struct linux_getpeername_args *args)
 {
 	struct linux_getpeername_args linux_args;
-	struct ogetpeername_args /* {
+	struct getpeername_args /* {
 		int fdes;
 		caddr_t asa;
 		int *alen;
@@ -762,9 +799,10 @@
 		return (error);
 
 	bsd_args.fdes = linux_args.s;
-	bsd_args.asa = (caddr_t)PTRIN(linux_args.addr);
+	bsd_args.asa = (struct sockaddr *)PTRIN(linux_args.addr);
 	bsd_args.alen = (int *)PTRIN(linux_args.namelen);
-	error = ogetpeername(td, &bsd_args);
+	error = getpeername(td, &bsd_args);
+	bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.asa);
 	if (error)
 		return (error);
 	error = linux_sa_put(PTRIN(linux_args.addr));
@@ -920,11 +958,15 @@
 		struct sockaddr * __restrict from;
 		socklen_t * __restrict fromlenaddr;
 	} */ bsd_args;
+	size_t len;
 	int error;
 
 	if ((error = copyin(args, &linux_args, sizeof(linux_args))))
 		return (error);
 
+	if ((error = copyin((void *)linux_args.fromlen, &len, sizeof(size_t))))
+		return (error);
+
 	bsd_args.s = linux_args.s;
 	bsd_args.buf = PTRIN(linux_args.buf);
 	bsd_args.len = linux_args.len;
@@ -932,7 +974,11 @@
 	/* XXX: */
 	bsd_args.from = (struct sockaddr * __restrict)PTRIN(linux_args.from);
 	bsd_args.fromlenaddr = PTRIN(linux_args.fromlen);/* XXX */
-	error = orecvfrom(td, &bsd_args);
+	
+	linux_to_bsd_sockaddr((struct sockaddr *)bsd_args.from, len);
+	error = recvfrom(td, &bsd_args);
+	bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.from);
+	
 	if (error)
 		return (error);
 	if (linux_args.from) {
@@ -1004,7 +1050,14 @@
 	bsd_args.s = linux_args.s;
 	bsd_args.msg = PTRIN(linux_args.msg);
 	bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags);
-	error = recvmsg(td, &bsd_args);
+	/* XXXRD: from the dfly patch */
+	if (msg.msg_name) {
+	   	linux_to_bsd_sockaddr((struct sockaddr *)msg.msg_name,
+		      msg.msg_namelen);
+		error = recvmsg(td, &bsd_args);
+		bsd_to_linux_sockaddr((struct sockaddr *)msg.msg_name);
+	} else
+	   	error = recvmsg(td, &bsd_args);
 	if (error)
 		return (error);
 
@@ -1092,7 +1145,17 @@
 	bsd_args.name = name;
 	bsd_args.val = PTRIN(linux_args.optval);
 	bsd_args.valsize = linux_args.optlen;
-	return (setsockopt(td, &bsd_args));
+
+	/* XXXRD: from dfly patch */
+	if (name == IPV6_NEXTHOP) {
+		linux_to_bsd_sockaddr((struct sockaddr *)bsd_args.val,
+			bsd_args.valsize);
+		error = setsockopt(td, &bsd_args);
+		bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.val);
+	} else
+		error = setsockopt(td, &bsd_args);
+
+	return (error);
 }
 
 struct linux_getsockopt_args {
@@ -1142,7 +1205,15 @@
 	bsd_args.name = name;
 	bsd_args.val = PTRIN(linux_args.optval);
 	bsd_args.avalsize = PTRIN(linux_args.optlen);
-	return (getsockopt(td, &bsd_args));
+
+	/* XXXRD: from dfly patch */
+	if (name == IPV6_NEXTHOP) {
+		error = getsockopt(td, &bsd_args);
+		bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.val);
+	} else
+		error = getsockopt(td, &bsd_args);
+
+	return (error);
 }
 
 int
Index: compat/linux/linux_stats.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_stats.c,v
retrieving revision 1.72
diff -u -r1.72 linux_stats.c
--- compat/linux/linux_stats.c	23 Jun 2005 22:13:29 -0000	1.72
+++ compat/linux/linux_stats.c	20 Aug 2005 10:34:49 -0000
@@ -46,8 +46,6 @@
 #include <sys/systm.h>
 #include <sys/vnode.h>
 
-#include "opt_compat.h"
-
 #ifdef COMPAT_LINUX32
 #include <machine/../linux32/linux.h>
 #include <machine/../linux32/linux32_proto.h>
@@ -175,6 +173,65 @@
 		error = newstat_copyout(&buf, args->buf);
 
 	return (error);
+}
+
+static int
+stat_copyout(struct stat *buf, void *ubuf)
+{
+	struct l_stat lbuf;
+	
+	bzero(&lbuf, sizeof(lbuf));
+	lbuf.st_dev = buf->st_dev;
+	lbuf.st_ino = buf->st_ino;
+	lbuf.st_mode = buf->st_mode;
+	lbuf.st_nlink = buf->st_nlink;
+	lbuf.st_uid = buf->st_uid;
+	lbuf.st_gid = buf->st_gid;
+	lbuf.st_rdev = buf->st_rdev;
+	if (buf->st_size < (quad_t)1 << 32)
+		lbuf.st_size = buf->st_size;
+	else
+		lbuf.st_size = -2;
+	lbuf.st_atime = buf->st_atime;
+	lbuf.st_mtime = buf->st_mtime;
+	lbuf.st_ctime = buf->st_ctime;
+	lbuf.st_blksize = buf->st_blksize;
+	lbuf.st_blocks = buf->st_blocks;
+	lbuf.st_flags = buf->st_flags;
+	lbuf.st_gen = buf->st_gen;
+
+	return (copyout(&lbuf, ubuf, sizeof(lbuf)));
+}
+
+int
+linux_stat(struct thread *td, struct linux_stat_args *args)
+{
+	struct stat buf;
+	int error;
+#ifdef DEBUG
+	if (ldebug(stat))
+	printf(ARGS(stat, "%s, *"), args->path);
+#endif
+	error = kern_stat(td, args->path, UIO_SYSSPACE, &buf);
+	if (error)
+		return (error);
+	return(stat_copyout(&buf, args->up));
+}
+
+int
+linux_lstat(struct thread *td, struct linux_lstat_args *args)
+{
+	struct stat buf;
+	int error;
+
+#ifdef DEBUG
+	if (ldebug(lstat))
+	printf(ARGS(lstat, "%s, *"), args->path);
+#endif
+	error = kern_lstat(td, args->path, UIO_SYSSPACE, &buf);
+	if (error)
+		return (error);
+	return(stat_copyout(&buf, args->up));
 }
 
 /* XXX - All fields of type l_int are defined as l_long on i386 */
Index: compat/linux/linux_sysctl.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_sysctl.c,v
retrieving revision 1.14
diff -u -r1.14 linux_sysctl.c
--- compat/linux/linux_sysctl.c	14 Jan 2005 04:44:56 -0000	1.14
+++ compat/linux/linux_sysctl.c	20 Aug 2005 10:34:49 -0000
@@ -38,8 +38,6 @@
 #include <sys/systm.h>
 #include <sys/sbuf.h>
 
-#include "opt_compat.h"
-
 #ifdef COMPAT_LINUX32
 #include <machine/../linux32/linux.h>
 #include <machine/../linux32/linux32_proto.h>
Index: compat/linux/linux_uid16.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_uid16.c,v
retrieving revision 1.16
diff -u -r1.16 linux_uid16.c
--- compat/linux/linux_uid16.c	14 Jan 2005 04:44:56 -0000	1.16
+++ compat/linux/linux_uid16.c	20 Aug 2005 10:34:49 -0000
@@ -36,8 +36,6 @@
 #include <sys/sysproto.h>
 #include <sys/systm.h>
 
-#include "opt_compat.h"
-
 #ifdef COMPAT_LINUX32
 #include <machine/../linux32/linux.h>
 #include <machine/../linux32/linux32_proto.h>
Index: i386/linux/linux.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux.h,v
retrieving revision 1.64
diff -u -r1.64 linux.h
--- i386/linux/linux.h	13 Apr 2005 04:31:43 -0000	1.64
+++ i386/linux/linux.h	20 Aug 2005 10:34:50 -0000
@@ -170,6 +170,24 @@
 	l_ulong		__unused5;
 };
 
+struct l_stat {
+	l_ushort        st_dev;
+	l_ulong         st_ino;
+	l_ushort        st_mode;
+	l_ushort        st_nlink;
+	l_ushort        st_uid;
+	l_ushort        st_gid;
+	l_ushort        st_rdev;
+	l_long          st_size;
+	struct l_timespec       st_atimespec;
+	struct l_timespec       st_mtimespec;
+	struct l_timespec       st_ctimespec;
+	l_long          st_blksize;
+	l_long          st_blocks;
+	l_ulong         st_flags;
+	l_ulong         st_gen;
+};
+
 struct l_stat64 {
 	l_ushort	st_dev;
 	u_char		__pad0[10];
Index: i386/linux/linux_dummy.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux_dummy.c,v
retrieving revision 1.38
diff -u -r1.38 linux_dummy.c
--- i386/linux/linux_dummy.c	28 Mar 2004 21:43:27 -0000	1.38
+++ i386/linux/linux_dummy.c	20 Aug 2005 10:34:50 -0000
@@ -37,7 +37,6 @@
 #include <i386/linux/linux_proto.h>
 #include <compat/linux/linux_util.h>
 
-DUMMY(stat);
 DUMMY(stime);
 DUMMY(fstat);
 DUMMY(olduname);
Index: i386/linux/linux_proto.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux_proto.h,v
retrieving revision 1.65
diff -u -r1.65 linux_proto.h
--- i386/linux/linux_proto.h	13 Jul 2005 20:35:09 -0000	1.65
+++ i386/linux/linux_proto.h	20 Aug 2005 10:34:50 -0000
@@ -228,6 +228,16 @@
 struct linux_sigpending_args {
 	char mask_l_[PADL_(l_osigset_t *)]; l_osigset_t * mask; char mask_r_[PADR_(l_osigset_t *)];
 };
+struct linux_sethostname_args {
+/* XXXRD: wtf?
+#ifdef _KERNEL
+	union sysmsg sysmsg;
+#endif
+	union usrmsg usrmsg;
+*/
+	char *  hostname;       char hostname_[PAD_(char *)];
+	u_int   len;    char len_[PAD_(u_int)];
+};
 struct linux_setrlimit_args {
 	char resource_l_[PADL_(l_uint)]; l_uint resource; char resource_r_[PADR_(l_uint)];
 	char rlim_l_[PADL_(struct l_rlimit *)]; struct l_rlimit * rlim; char rlim_r_[PADR_(struct l_rlimit *)];
@@ -251,6 +261,16 @@
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char to_l_[PADL_(char *)]; char * to; char to_r_[PADR_(char *)];
 };
+struct linux_lstat_args {
+/* XXXRD: wtf? 
+#ifdef _KERNEL
+	union sysmsg sysmsg;
+#endif
+	union usrmsg usrmsg;
+*/	
+	char *  path;   char path_[PAD_(char *)];
+	struct l_stat * up;     char up_[PAD_(struct l_stat *)];
+};
 struct linux_readlink_args {
 	char name_l_[PADL_(char *)]; char * name; char name_r_[PADR_(char *)];
 	char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
@@ -281,6 +301,16 @@
 	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
 	char who_l_[PADL_(int)]; int who; char who_r_[PADR_(int)];
 };
+struct linux_ftruncate_args {
+/* XXXRD: wtf?
+#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 {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char buf_l_[PADL_(struct l_statfs_buf *)]; struct l_statfs_buf * buf; char buf_r_[PADR_(struct l_statfs_buf *)];
@@ -747,18 +777,21 @@
 int	linux_setregid16(struct thread *, struct linux_setregid16_args *);
 int	linux_sigsuspend(struct thread *, struct linux_sigsuspend_args *);
 int	linux_sigpending(struct thread *, struct linux_sigpending_args *);
+int	linux_sethostname(struct thread *, struct linux_sethostname_args *);
 int	linux_setrlimit(struct thread *, struct linux_setrlimit_args *);
 int	linux_old_getrlimit(struct thread *, struct linux_old_getrlimit_args *);
 int	linux_getgroups16(struct thread *, struct linux_getgroups16_args *);
 int	linux_setgroups16(struct thread *, struct linux_setgroups16_args *);
 int	linux_old_select(struct thread *, struct linux_old_select_args *);
 int	linux_symlink(struct thread *, struct linux_symlink_args *);
+int	linux_lstat(struct thread *, struct linux_lstat_args *);
 int	linux_readlink(struct thread *, struct linux_readlink_args *);
 int	linux_uselib(struct thread *, struct linux_uselib_args *);
 int	linux_reboot(struct thread *, struct linux_reboot_args *);
 int	linux_readdir(struct thread *, struct linux_readdir_args *);
 int	linux_mmap(struct thread *, struct linux_mmap_args *);
 int	linux_truncate(struct thread *, struct linux_truncate_args *);
+int	linux_ftruncate(struct thread *, struct linux_ftruncate_args *);
 int	linux_getpriority(struct thread *, struct linux_getpriority_args *);
 int	linux_statfs(struct thread *, struct linux_statfs_args *);
 int	linux_fstatfs(struct thread *, struct linux_fstatfs_args *);
Index: i386/linux/linux_syscall.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux_syscall.h,v
retrieving revision 1.59
diff -u -r1.59 linux_syscall.h
--- i386/linux/linux_syscall.h	13 Jul 2005 20:35:09 -0000	1.59
+++ i386/linux/linux_syscall.h	20 Aug 2005 10:34:50 -0000
@@ -71,7 +71,7 @@
 #define	LINUX_SYS_linux_setregid16	71
 #define	LINUX_SYS_linux_sigsuspend	72
 #define	LINUX_SYS_linux_sigpending	73
-#define	LINUX_SYS_osethostname	74
+#define	LINUX_SYS_linux_sethostname	74
 #define	LINUX_SYS_linux_setrlimit	75
 #define	LINUX_SYS_linux_old_getrlimit	76
 #define	LINUX_SYS_getrusage	77
@@ -81,7 +81,7 @@
 #define	LINUX_SYS_linux_setgroups16	81
 #define	LINUX_SYS_linux_old_select	82
 #define	LINUX_SYS_linux_symlink	83
-#define	LINUX_SYS_ostat	84
+#define	LINUX_SYS_linux_lstat	84
 #define	LINUX_SYS_linux_readlink	85
 #define	LINUX_SYS_linux_uselib	86
 #define	LINUX_SYS_swapon	87
@@ -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_linux_getpriority	96
Index: i386/linux/linux_sysent.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux_sysent.c,v
retrieving revision 1.66
diff -u -r1.66 linux_sysent.c
--- i386/linux/linux_sysent.c	13 Jul 2005 20:35:09 -0000	1.66
+++ i386/linux/linux_sysent.c	20 Aug 2005 10:34:51 -0000
@@ -7,7 +7,6 @@
  */
 
 #include <bsm/audit_kevents.h>
-#include "opt_compat.h"
 #include <sys/param.h>
 #include <sys/sysent.h>
 #include <sys/sysproto.h>
@@ -16,6 +15,7 @@
 #include <i386/linux/linux_proto.h>
 
 #define AS(name) (sizeof(struct name) / sizeof(register_t))
+#define compat(n, name) 0, (sy_call_t *)nosys
 
 /* The casts are bogus but will do for now. */
 struct sysent linux_sysent[] = {
@@ -94,7 +94,7 @@
 	{ SYF_MPSAFE | AS(linux_setregid16_args), (sy_call_t *)linux_setregid16, AUE_NULL },	/* 71 = linux_setregid16 */
 	{ SYF_MPSAFE | AS(linux_sigsuspend_args), (sy_call_t *)linux_sigsuspend, AUE_NULL },	/* 72 = linux_sigsuspend */
 	{ SYF_MPSAFE | AS(linux_sigpending_args), (sy_call_t *)linux_sigpending, AUE_NULL },	/* 73 = linux_sigpending */
-	{ SYF_MPSAFE | AS(sethostname_args), (sy_call_t *)osethostname, AUE_NULL },	/* 74 = osethostname */
+	{ SYF_MPSAFE | AS(linux_sethostname_args), (sy_call_t *)linux_sethostname, AUE_NULL },	/* 74 = osethostname */
 	{ SYF_MPSAFE | AS(linux_setrlimit_args), (sy_call_t *)linux_setrlimit, AUE_NULL },	/* 75 = linux_setrlimit */
 	{ SYF_MPSAFE | AS(linux_old_getrlimit_args), (sy_call_t *)linux_old_getrlimit, AUE_NULL },	/* 76 = linux_old_getrlimit */
 	{ SYF_MPSAFE | AS(getrusage_args), (sy_call_t *)getrusage, AUE_NULL },	/* 77 = getrusage */
@@ -104,7 +104,7 @@
 	{ SYF_MPSAFE | AS(linux_setgroups16_args), (sy_call_t *)linux_setgroups16, AUE_NULL },	/* 81 = linux_setgroups16 */
 	{ SYF_MPSAFE | AS(linux_old_select_args), (sy_call_t *)linux_old_select, AUE_NULL },	/* 82 = linux_old_select */
 	{ SYF_MPSAFE | AS(linux_symlink_args), (sy_call_t *)linux_symlink, AUE_NULL },	/* 83 = linux_symlink */
-	{ SYF_MPSAFE | AS(ostat_args), (sy_call_t *)ostat, AUE_NULL },	/* 84 = ostat */
+	{ SYF_MPSAFE | AS(linux_stat_args), (sy_call_t *)linux_lstat, AUE_NULL },	/* 84 = ostat */
 	{ SYF_MPSAFE | AS(linux_readlink_args), (sy_call_t *)linux_readlink, AUE_NULL },	/* 85 = linux_readlink */
 	{ AS(linux_uselib_args), (sy_call_t *)linux_uselib, AUE_NULL },	/* 86 = linux_uselib */
 	{ SYF_MPSAFE | AS(swapon_args), (sy_call_t *)swapon, AUE_NULL },	/* 87 = swapon */
@@ -113,7 +113,7 @@
 	{ SYF_MPSAFE | AS(linux_mmap_args), (sy_call_t *)linux_mmap, AUE_NULL },	/* 90 = linux_mmap */
 	{ SYF_MPSAFE | AS(munmap_args), (sy_call_t *)munmap, AUE_NULL },	/* 91 = munmap */
 	{ SYF_MPSAFE | AS(linux_truncate_args), (sy_call_t *)linux_truncate, AUE_NULL },	/* 92 = linux_truncate */
-	{ SYF_MPSAFE | AS(oftruncate_args), (sy_call_t *)oftruncate, AUE_NULL },	/* 93 = oftruncate */
+	{ SYF_MPSAFE | AS(linux_ftruncate_args), (sy_call_t *)linux_ftruncate, AUE_NULL },	/* 93 = oftruncate */
 	{ SYF_MPSAFE | AS(fchmod_args), (sy_call_t *)fchmod, AUE_NULL },	/* 94 = fchmod */
 	{ SYF_MPSAFE | AS(fchown_args), (sy_call_t *)fchown, AUE_NULL },	/* 95 = fchown */
 	{ SYF_MPSAFE | AS(linux_getpriority_args), (sy_call_t *)linux_getpriority, AUE_NULL },	/* 96 = linux_getpriority */
Index: i386/linux/linux_sysvec.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux_sysvec.c,v
retrieving revision 1.138
diff -u -r1.138 linux_sysvec.c
--- i386/linux/linux_sysvec.c	29 Jul 2005 19:40:39 -0000	1.138
+++ i386/linux/linux_sysvec.c	20 Aug 2005 10:34:51 -0000
@@ -29,13 +29,6 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/sys/i386/linux/linux_sysvec.c,v 1.138 2005/07/29 19:40:39 jhb Exp $");
 
-/* XXX we use functions that might not exist. */
-#include "opt_compat.h"
-
-#ifndef COMPAT_43
-#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!"
-#endif
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/exec.h>
Index: i386/linux/syscalls.master
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/syscalls.master,v
retrieving revision 1.62
diff -u -r1.62 syscalls.master
--- i386/linux/syscalls.master	13 Jul 2005 20:32:42 -0000	1.62
+++ i386/linux/syscalls.master	20 Aug 2005 10:34:51 -0000
@@ -11,7 +11,7 @@
 ;		there is no audit event for the call at this time. For the
 ;		case where the event exists, but we don't want auditing, the
 ;		event should be #defined to AUE_NULL in audit_kevents.h.
-;	type	one of STD, OBSOL, UNIMPL, COMPAT
+;	type	one of STD, OBSOL, UNIMPL
 ;	name	psuedo-prototype of syscall routine
 ;		If one of the following alts is different, then all appear:
 ;	altname	name of system call if different
@@ -21,12 +21,9 @@
 
 ; types:
 ;	AUE_NULL	STD	always included
-;	COMPAT	included on COMPAT #ifdef
-;	LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h
 ;	OBSOL	obsolete, not included in system, only specifies name
 ;	AUE_NULL	UNIMPL	not implemented, placeholder only
 
-#include "opt_compat.h"
 #include <sys/param.h>
 #include <sys/sysent.h>
 #include <sys/sysproto.h>
@@ -68,7 +65,7 @@
 				    l_uid16_t uid, l_gid16_t gid); }
 17	AUE_NULL	UNIMPL	break
 18	AUE_NULL	MSTD	{ int linux_stat(char *path, \
-				    struct ostat *up); }
+				    struct l_stat *up); }
 19	AUE_NULL	MSTD	{ int linux_lseek(l_uint fdes, l_off_t off, \
 				    l_int whence); }
 20	AUE_NULL	MSTD	{ int linux_getpid(void); }
@@ -83,7 +80,7 @@
 				    l_long addr, l_long data); }
 27	AUE_NULL	MSTD	{ int linux_alarm(l_uint secs); }
 28	AUE_NULL	MSTD	{ int linux_fstat(l_uint fd, \
-				    struct ostat *up); }
+				    struct l_stat *up); }
 29	AUE_NULL	MSTD	{ int linux_pause(void); }
 30	AUE_NULL	MSTD	{ int linux_utime(char *fname, \
 				    struct l_utimbuf *times); }
@@ -139,9 +136,8 @@
 72	AUE_NULL	MSTD	{ int linux_sigsuspend(l_int hist0, \
 				    l_int hist1, l_osigset_t mask); }
 73	AUE_NULL	MSTD	{ int linux_sigpending(l_osigset_t *mask); }
-74	AUE_NULL	MNOPROTO { int osethostname(char *hostname, \
-				    u_int len); } osethostname \
-				    sethostname_args int
+74	AUE_NULL	MSTD	{ int linux_sethostname(char *hostname, \
+				    u_int len); }
 75	AUE_NULL	MSTD	{ int linux_setrlimit(l_uint resource, \
 				    struct l_rlimit *rlim); }
 76	AUE_NULL	MSTD	{ int linux_old_getrlimit(l_uint resource, \
@@ -159,7 +155,7 @@
 82	AUE_NULL	MSTD	{ int linux_old_select( \
 				    struct l_old_select_argv *ptr); }
 83	AUE_NULL	MSTD	{ int linux_symlink(char *path, char *to); }
-84	AUE_NULL	MNOPROTO	{ int ostat(char *path, struct ostat *up); }
+84	AUE_NULL	MSTD	{ int linux_stat(char *path, struct l_stat *up); }
 85	AUE_NULL	MSTD	{ int linux_readlink(char *name, char *buf, \
 				    l_int count); }
 86	AUE_NULL	STD	{ int linux_uselib(char *library); }
@@ -172,7 +168,7 @@
 91	AUE_NULL	MNOPROTO	{ int munmap(caddr_t addr, int len); }
 92	AUE_NULL	MSTD	{ int linux_truncate(char *path, \
 				    l_ulong length); }
-93	AUE_NULL	MNOPROTO	{ int oftruncate(int fd, long length); }
+93	AUE_NULL	MNOPROTO	{ int linux_ftruncate(int fd, long length); }
 94	AUE_NULL	MNOPROTO	{ int fchmod(int fd, int mode); }
 95	AUE_NULL	MNOPROTO	{ int fchown(int fd, int uid, int gid); }
 96	AUE_NULL	MSTD	{ int linux_getpriority(int which, int who); }
Index: modules/linux/Makefile
===================================================================
RCS file: /home/ncvs/src/sys/modules/linux/Makefile,v
retrieving revision 1.63
diff -u -r1.63 Makefile
--- modules/linux/Makefile	4 Jun 2005 16:57:04 -0000	1.63
+++ modules/linux/Makefile	20 Aug 2005 10:34:51 -0000
@@ -6,8 +6,7 @@
 SRCS=	linux_dummy.c linux_file.c linux_getcwd.c linux_ioctl.c linux_ipc.c \
 	linux_machdep.c linux_mib.c linux_misc.c linux_signal.c linux_socket.c \
 	linux_stats.c linux_sysctl.c linux_sysent.c linux_sysvec.c \
-	linux_util.c opt_compat.h opt_inet6.h opt_mac.h \
-	opt_vmpage.h vnode_if.h
+	linux_util.c opt_inet6.h opt_mac.h opt_vmpage.h vnode_if.h
 OBJS=	linux_locore.o
 
 .if ${MACHINE_ARCH} == "i386"
@@ -36,9 +35,6 @@
 
 linux_genassym.o: linux_genassym.c linux.h @ machine
 	${CC} -c ${CFLAGS:N-fno-common} ${.IMPSRC}
-
-opt_compat.h:
-	echo "#define COMPAT_43 1" > opt_compat.h
 
 opt_inet6.h:
 	echo "#define INET6 1" > opt_inet6.h
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list