Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 08 Oct 2002 14:14:58 +0300
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        Alfred Perlstein <bright@mu.org>
Cc:        emulation@FreeBSD.org, audit@FreeBSD.org, marcel@FreeBSD.org
Subject:   Linuxlator patches for review [was: Who currently maintains Linuxlator?]
Message-ID:  <3DA2BE32.BDEC28B5@FreeBSD.org>
References:  <20021006110243.GA70993@vega.vega.com> <20021006183650.GY95327@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------2C056B357B94AA92275BD099
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit

See attached. As it was suggested, I'm also CC'ing marcel,
freebsd-audit and freebsd-emulation. I'd like to hear any suggestion
or comments. Please note that changes were not tested on alpha,
because I don't have any axp hardware.

Thanks!

-Maxim

Alfred Perlstein wrote:
> 
> * Maxim Sobolev <sobomax@FreeBSD.org> [021006 04:02] wrote:
> > Folks,
> >
> > I've cooked bunch of patches to make Linux CrossOver plugin working
> > on FreeBSD (Linux IPC_64 syscalls, mmap2(2), ftruncate64(2) and
> > so on). To whom I should send those patches for review, or should
> > I commit them right away?
> 
> If no one else steps forwward i can look at them.
> 
> >
> > Thanks!
> >
> > -Maxim
> 
> --
> -Alfred Perlstein [alfred@freebsd.org]
> 'Instead of asking why a piece of software is using "1970s technology,"
>  start asking why software is ignoring 30 years of accumulated wisdom.'
--------------2C056B357B94AA92275BD099
Content-Type: text/plain; charset=koi8-r;
 name="diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="diff"

? compat/linux/linux_ipc.c,v
? compat/linux/linux_ipc.h,v
? compat/linux/linux_stats.c,v
? i386/linux/linux_dummy.c,v
? i386/linux/linux_machdep.c,v
Index: compat/linux/linux_ioctl.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_ioctl.c,v
retrieving revision 1.93
diff -d -u -r1.93 linux_ioctl.c
--- compat/linux/linux_ioctl.c	20 Sep 2002 19:19:58 -0000	1.93
+++ compat/linux/linux_ioctl.c	8 Oct 2002 10:49:53 -0000
@@ -61,6 +61,7 @@
 #include <compat/linux/linux_util.h>
 
 static linux_ioctl_function_t linux_ioctl_cdrom;
+static linux_ioctl_function_t linux_ioctl_vfat;
 static linux_ioctl_function_t linux_ioctl_console;
 static linux_ioctl_function_t linux_ioctl_disk;
 static linux_ioctl_function_t linux_ioctl_socket;
@@ -71,6 +72,8 @@
 
 static struct linux_ioctl_handler cdrom_handler =
 { linux_ioctl_cdrom, LINUX_IOCTL_CDROM_MIN, LINUX_IOCTL_CDROM_MAX };
+static struct linux_ioctl_handler vfat_handler =
+{ linux_ioctl_vfat, LINUX_IOCTL_VFAT_MIN, LINUX_IOCTL_VFAT_MAX };
 static struct linux_ioctl_handler console_handler =
 { linux_ioctl_console, LINUX_IOCTL_CONSOLE_MIN, LINUX_IOCTL_CONSOLE_MAX };
 static struct linux_ioctl_handler disk_handler =
@@ -85,6 +88,7 @@
 { linux_ioctl_private, LINUX_IOCTL_PRIVATE_MIN, LINUX_IOCTL_PRIVATE_MAX };
 
 DATA_SET(linux_ioctl_handler_set, cdrom_handler);
+DATA_SET(linux_ioctl_handler_set, vfat_handler);
 DATA_SET(linux_ioctl_handler_set, console_handler);
 DATA_SET(linux_ioctl_handler_set, disk_handler);
 DATA_SET(linux_ioctl_handler_set, socket_handler);
@@ -1473,6 +1477,13 @@
 	return (error);
 }
 
+static int
+linux_ioctl_vfat(struct thread *td, struct linux_ioctl_args *args)
+{
+
+	return (ENOIOCTL);
+}
+
 /*
  * Sound related ioctls
  */
@@ -1559,6 +1570,10 @@
 		int version = linux_get_oss_version(td->td_proc);
 		return (copyout(&version, (caddr_t)args->arg, sizeof(int)));
 	}
+
+	case LINUX_SOUND_MIXER_READ_STEREODEVS:
+		args->cmd = SOUND_MIXER_READ_STEREODEVS;
+		return (ioctl(td, (struct ioctl_args *)args));
 
 	case LINUX_SOUND_MIXER_READ_DEVMASK:
 		args->cmd = SOUND_MIXER_READ_DEVMASK;
Index: compat/linux/linux_ioctl.h
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_ioctl.h,v
retrieving revision 1.14
diff -d -u -r1.14 linux_ioctl.h
--- compat/linux/linux_ioctl.h	20 Sep 2002 19:19:58 -0000	1.14
+++ compat/linux/linux_ioctl.h	8 Oct 2002 10:49:54 -0000
@@ -120,6 +120,14 @@
 #define	LINUX_DVD_HOST_SEND_RPC_STATE	11
 
 /*
+ * VFAT
+ */
+#define	LINUX_VFAT_READDIR_BOTH	0x7201
+
+#define	LINUX_IOCTL_VFAT_MIN	LINUX_VFAT_READDIR_BOTH
+#define	LINUX_IOCTL_VFAT_MAX	LINUX_VFAT_READDIR_BOTH
+
+/*
  * console
  */
 #define	LINUX_KIOCSOUND		0x4B2F
@@ -210,6 +218,7 @@
 #define	LINUX_SOUND_MIXER_WRITE_LINE2	0x4d0F
 #define	LINUX_SOUND_MIXER_WRITE_LINE3	0x4d10
 #define	LINUX_OSS_GETVERSION		0x4d76
+#define	LINUX_SOUND_MIXER_READ_STEREODEVS	0x4dfb
 #define	LINUX_SOUND_MIXER_READ_DEVMASK	0x4dfe
 #define	LINUX_SOUND_MIXER_WRITE_RECSRC	0x4dff
 #define	LINUX_SNDCTL_DSP_RESET		0x5000
Index: compat/linux/linux_ipc.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_ipc.c,v
retrieving revision 1.30
diff -d -u -r1.30 linux_ipc.c
--- compat/linux/linux_ipc.c	2 Jun 2002 20:05:42 -0000	1.30
+++ compat/linux/linux_ipc.c	8 Oct 2002 10:49:54 -0000
@@ -35,8 +35,11 @@
 #include <sys/sem.h>
 #include <sys/shm.h>
 
+#include <machine/limits.h>
+
 #include <machine/../linux/linux.h>
 #include <machine/../linux/linux_proto.h>
+#include <machine/../linux/linux_ipc64.h>
 #include <compat/linux/linux_ipc.h>
 #include <compat/linux/linux_util.h>
 
@@ -126,6 +129,22 @@
     lpp->seq = bpp->seq;
 }
 
+struct l_msqid_ds {
+	struct l_ipc_perm	msg_perm;
+	struct l_msg		*msg_first;	/* first message on queue,unused */
+	struct l_msg		*msg_last;	/* last message in queue,unused */
+	l_time_t		msg_stime;	/* last msgsnd time */
+	l_time_t		msg_rtime;	/* last msgrcv time */
+	l_time_t		msg_ctime;	/* last change time */
+	l_ulong			msg_lcbytes;	/* Reuse junk fields for 32 bit */
+	l_ulong			msg_lqbytes;	/* ditto */
+	l_ushort		msg_cbytes;	/* current number of bytes on queue */
+	l_ushort		msg_qnum;	/* number of messages in queue */
+	l_ushort		msg_qbytes;	/* max number of bytes on queue */
+	l_pid_t			msg_lspid;	/* pid of last msgsnd */
+	l_pid_t			msg_lrpid;	/* last receive pid */
+};
+
 struct l_semid_ds {
 	struct l_ipc_perm	sem_perm;
 	l_time_t		sem_otime;
@@ -199,6 +218,195 @@
     lsp->private3 = bsp->shm_internal;	/* this goes (yet) SOS */
 }
 
+static void
+linux_ipc_perm_to_ipc64_perm(struct l_ipc_perm *in, struct l_ipc64_perm *out)
+{
+
+	/* XXX: do we really need to do something here? */
+	out->key = in->key;
+	out->uid = in->uid;
+	out->gid = in->gid;
+	out->cuid = in->cuid;
+	out->cgid = in->cgid;
+	out->mode = in->mode;
+	out->seq = in->seq;
+}
+    
+static int
+linux_msqid_pullup(l_int ver, struct l_msqid_ds *linux_msqid, caddr_t uaddr)
+{
+	struct l_msqid64_ds linux_msqid64;
+	int error;
+
+	if (ver == LINUX_IPC_64) {
+		error = copyin(uaddr, &linux_msqid64, sizeof(linux_msqid64));
+		if (error != 0)
+			return (error);
+
+		bzero(linux_msqid, sizeof(*linux_msqid));
+
+		linux_msqid->msg_perm.uid = linux_msqid64.msg_perm.uid;
+		linux_msqid->msg_perm.gid = linux_msqid64.msg_perm.gid;
+		linux_msqid->msg_perm.mode = linux_msqid64.msg_perm.mode;
+
+		if (linux_msqid64.msg_qbytes > USHRT_MAX)
+			linux_msqid->msg_lqbytes = linux_msqid64.msg_qbytes;
+		else
+			linux_msqid->msg_qbytes = linux_msqid64.msg_qbytes;
+	} else {
+		error = copyin(uaddr, linux_msqid, sizeof(*linux_msqid));
+	}
+	return (error);
+}
+
+static int
+linux_msqid_pushdown(l_int ver, struct l_msqid_ds *linux_msqid, caddr_t uaddr)
+{
+	struct l_msqid64_ds linux_msqid64;
+
+	if (ver == LINUX_IPC_64) {
+		bzero(&linux_msqid64, sizeof(linux_msqid64));
+
+		linux_ipc_perm_to_ipc64_perm(&linux_msqid->msg_perm,
+		    &linux_msqid64.msg_perm);
+
+		linux_msqid64.msg_stime = linux_msqid->msg_stime;
+		linux_msqid64.msg_rtime = linux_msqid->msg_rtime;
+		linux_msqid64.msg_ctime = linux_msqid->msg_ctime;
+
+		if (linux_msqid->msg_cbytes == 0)
+			linux_msqid64.msg_cbytes = linux_msqid->msg_lcbytes;
+		else
+			linux_msqid64.msg_cbytes = linux_msqid->msg_cbytes;
+
+		linux_msqid64.msg_qnum = linux_msqid->msg_qnum;
+
+		if (linux_msqid->msg_qbytes == 0)
+			linux_msqid64.msg_qbytes = linux_msqid->msg_lqbytes;
+		else
+			linux_msqid64.msg_qbytes = linux_msqid->msg_qbytes;
+
+		linux_msqid64.msg_lspid = linux_msqid->msg_lspid;
+		linux_msqid64.msg_lrpid = linux_msqid->msg_lrpid;
+
+		return (copyout(&linux_msqid64, uaddr, sizeof(linux_msqid64)));
+	} else {
+		return (copyout(linux_msqid, uaddr, sizeof(*linux_msqid)));
+	}
+}
+
+static int
+linux_semid_pullup(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr)
+{
+	struct l_semid64_ds linux_semid64;
+	int error;
+
+	if (ver == LINUX_IPC_64) {
+		error = copyin(uaddr, &linux_semid64, sizeof(linux_semid64));
+		if (error != 0)
+			return (error);
+
+		bzero(linux_semid, sizeof(*linux_semid));
+
+		linux_semid->sem_perm.uid = linux_semid64.sem_perm.uid;
+		linux_semid->sem_perm.gid = linux_semid64.sem_perm.gid;
+		linux_semid->sem_perm.mode = linux_semid64.sem_perm.mode;
+	} else {
+		error = copyin(uaddr, linux_semid, sizeof(*linux_semid));
+	}
+	return (error);
+}
+
+static int
+linux_semid_pushdown(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr)
+{
+	struct l_semid64_ds linux_semid64;
+
+	if (ver == LINUX_IPC_64) {
+		bzero(&linux_semid64, sizeof(linux_semid64));
+
+		linux_ipc_perm_to_ipc64_perm(&linux_semid->sem_perm,
+		    &linux_semid64.sem_perm);
+
+		linux_semid64.sem_otime = linux_semid->sem_otime;
+		linux_semid64.sem_ctime = linux_semid->sem_ctime;
+		linux_semid64.sem_nsems = linux_semid->sem_nsems;
+
+		return (copyout(&linux_semid64, uaddr, sizeof(linux_semid64)));
+	} else {
+		return (copyout(linux_semid, uaddr, sizeof(*linux_semid)));
+	}
+}
+
+static int
+linux_shmid_pullup(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr)
+{
+	struct l_shmid64_ds linux_shmid64;
+	int error;
+
+	if (ver == LINUX_IPC_64) {
+		error = copyin(uaddr, &linux_shmid64, sizeof(linux_shmid64));
+		if (error != 0)
+			return (error);
+
+		bzero(linux_shmid, sizeof(*linux_shmid));
+
+		linux_shmid->shm_perm.uid = linux_shmid64.shm_perm.uid;
+		linux_shmid->shm_perm.gid = linux_shmid64.shm_perm.gid;
+		linux_shmid->shm_perm.mode = linux_shmid64.shm_perm.mode;
+	} else {
+		error = copyin(uaddr, linux_shmid, sizeof(*linux_shmid));
+	}
+	return (error);
+}
+
+static int
+linux_shmid_pushdown(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr)
+{
+	struct l_shmid64_ds linux_shmid64;
+
+	if (ver == LINUX_IPC_64) {
+		bzero(&linux_shmid64, sizeof(linux_shmid64));
+
+		linux_ipc_perm_to_ipc64_perm(&linux_shmid->shm_perm,
+		    &linux_shmid64.shm_perm);
+
+		linux_shmid64.shm_segsz = linux_shmid->shm_segsz;
+		linux_shmid64.shm_atime = linux_shmid->shm_atime;
+		linux_shmid64.shm_dtime = linux_shmid->shm_dtime;
+		linux_shmid64.shm_ctime = linux_shmid->shm_ctime;
+		linux_shmid64.shm_cpid = linux_shmid->shm_cpid;
+		linux_shmid64.shm_lpid = linux_shmid->shm_lpid;
+		linux_shmid64.shm_nattch = linux_shmid->shm_nattch;
+
+		return (copyout(&linux_shmid64, uaddr, sizeof(linux_shmid64)));
+	} else {
+		return (copyout(linux_shmid, uaddr, sizeof(*linux_shmid)));
+	}
+}
+
+static int
+linux_shminfo_pushdown(l_int ver, struct l_shminfo *linux_shminfo,
+    caddr_t uaddr)
+{
+	struct l_shminfo64 linux_shminfo64;
+
+	if (ver == LINUX_IPC_64) {
+		bzero(&linux_shminfo64, sizeof(linux_shminfo64));
+
+		linux_shminfo64.shmmax = linux_shminfo->shmmax;
+		linux_shminfo64.shmmin = linux_shminfo->shmmin;
+		linux_shminfo64.shmmni = linux_shminfo->shmmni;
+		linux_shminfo64.shmseg = linux_shminfo->shmseg;
+		linux_shminfo64.shmall = linux_shminfo->shmall;
+
+		return (copyout(&linux_shminfo64, uaddr,
+		    sizeof(linux_shminfo64)));
+	} else {
+		return (copyout(linux_shminfo, uaddr, sizeof(*linux_shminfo)));
+	}
+}
+
 int
 linux_semop(struct thread *td, struct linux_semop_args *args)
 {
@@ -254,7 +462,7 @@
 	bsd_args.semnum = args->semnum;
 	bsd_args.arg = unptr;
 
-	switch (args->cmd) {
+	switch (args->cmd & ~LINUX_IPC_64) {
 	case LINUX_IPC_RMID:
 		bsd_args.cmd = IPC_RMID;
 		break;
@@ -275,8 +483,8 @@
 		break;
 	case LINUX_IPC_SET:
 		bsd_args.cmd = IPC_SET;
-		error = copyin((caddr_t)args->arg.buf, &linux_semid,
-		    sizeof(linux_semid));
+		error = linux_semid_pullup(args->cmd & LINUX_IPC_64,
+		    &linux_semid, (caddr_t)args->arg.buf);
 		if (error)
 			return (error);
 		unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds));
@@ -284,7 +492,7 @@
 		return __semctl(td, &bsd_args);
 	case LINUX_IPC_STAT:
 	case LINUX_SEM_STAT:
-		if( args->cmd == LINUX_IPC_STAT )
+		if((args->cmd & ~LINUX_IPC_64) == LINUX_IPC_STAT)
 			bsd_args.cmd = IPC_STAT;
 		else
 			bsd_args.cmd = SEM_STAT;
@@ -295,14 +503,10 @@
 		td->td_retval[0] = IXSEQ_TO_IPCID(bsd_args.semid, 
 							unptr->buf->sem_perm);
 		bsd_to_linux_semid_ds(unptr->buf, &linux_semid);
-		return copyout(&linux_semid, (caddr_t)args->arg.buf,
-					    sizeof(linux_semid));
+		return (linux_semid_pushdown(args->cmd & LINUX_IPC_64,
+		    &linux_semid, (caddr_t)args->arg.buf));
 	case LINUX_IPC_INFO:
 	case LINUX_SEM_INFO:
-		error = copyin((caddr_t)args->arg.buf, &linux_seminfo, 
-						sizeof(linux_seminfo) );
-		if (error)
-			return error;
 		bcopy(&seminfo, &linux_seminfo, sizeof(linux_seminfo) );
 /* XXX BSD equivalent?
 #define used_semids 10
@@ -321,7 +525,8 @@
 	case LINUX_SETALL:
 		/* FALLTHROUGH */
 	default:
-		uprintf("linux: 'ipc' typ=%d not implemented\n", args->cmd);
+		uprintf("linux: 'ipc' typ=%d not implemented\n",
+		  args->cmd & ~LINUX_IPC_64);
 		return EINVAL;
 	}
 	return __semctl(td, &bsd_args);
@@ -385,12 +590,28 @@
 	struct	msqid_ds *buf;
     } */ bsd_args;
     int error;
+    caddr_t sg = stackgap_init();
 
+    bsd_args.buf = (struct msqid_ds*)stackgap_alloc(&sg,
+      sizeof(struct l_msqid_ds));
+    error = linux_msqid_pullup(args->cmd & LINUX_IPC_64,
+      (struct l_msqid_ds *)bsd_args.buf, (caddr_t)args->buf);
+    if (error != 0)
+	return (error);
     bsd_args.msqid = args->msqid;
-    bsd_args.cmd = args->cmd;
-    bsd_args.buf = (struct msqid_ds *)args->buf;
+    bsd_args.cmd = args->cmd & ~LINUX_IPC_64;
+
     error = msgctl(td, &bsd_args);
-    return ((args->cmd == LINUX_IPC_RMID && error == EINVAL) ? 0 : error);
+    if (error != 0)
+	if (bsd_args.cmd != LINUX_IPC_RMID || error != EINVAL)
+	    return (error);
+
+    if (bsd_args.cmd == LINUX_IPC_STAT) {
+	return (linux_msqid_pushdown(args->cmd & LINUX_IPC_64,
+	  (struct l_msqid_ds *)bsd_args.buf, (caddr_t)args->buf));
+    }
+
+    return (0);
 }
 
 int
@@ -456,7 +677,7 @@
     int error;
     caddr_t sg = stackgap_init();
 
-    switch (args->cmd) {
+    switch (args->cmd & ~LINUX_IPC_64) {
 
 	case LINUX_IPC_INFO:
 	bsd_args.shmid = args->shmid;
@@ -465,7 +686,8 @@
 	if ((error = shmctl(td, &bsd_args)))
 		return error;
 	bsd_to_linux_shminfo( (struct shminfo *)bsd_args.buf, &linux_shminfo );
-	return copyout(&linux_shminfo, (caddr_t)args->buf, sizeof(shminfo));
+	return (linux_shminfo_pushdown(args->cmd & LINUX_IPC_64,
+	  &linux_shminfo, (caddr_t)args->buf));
 
 	case LINUX_SHM_INFO:
 	bsd_args.shmid = args->shmid;
@@ -483,7 +705,8 @@
 	if ((error = shmctl(td, &bsd_args)))
 	    return error;
 	bsd_to_linux_shmid_ds(bsd_args.buf, &linux_shmid);
-	return copyout(&linux_shmid, (caddr_t)args->buf, sizeof(linux_shmid));
+	return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64,
+	  &linux_shmid, (caddr_t)args->buf));
 
 	case LINUX_SHM_STAT:
 	bsd_args.shmid = args->shmid;
@@ -493,11 +716,13 @@
 	    return error;
 	}
 	bsd_to_linux_shmid_ds(bsd_args.buf, &linux_shmid);
-	return copyout(&linux_shmid, (caddr_t)args->buf, sizeof(linux_shmid));
+	return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64,
+	  &linux_shmid, (caddr_t)args->buf));
 
     case LINUX_IPC_SET:
-	if ((error = copyin((caddr_t)args->buf, &linux_shmid,
-		sizeof(linux_shmid))))
+	error = linux_shmid_pullup(args->cmd & LINUX_IPC_64,
+	  &linux_shmid, (caddr_t)args->buf);
+	if (error != 0)
 	    return error;
 	bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
 	linux_to_bsd_shmid_ds(&linux_shmid, bsd_args.buf);
@@ -511,8 +736,9 @@
 	if (args->buf == NULL)
 	    bsd_args.buf = NULL;
 	else {
-	    if ((error = copyin((caddr_t)args->buf, &linux_shmid, 
-		    		sizeof(linux_shmid))))
+	    error = linux_shmid_pullup(args->cmd & LINUX_IPC_64,
+	      &linux_shmid, (caddr_t)args->buf);
+	    if (error != 0)
 		return error;
 	    bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
 	    linux_to_bsd_shmid_ds(&linux_shmid, bsd_args.buf);
@@ -522,7 +748,8 @@
     case LINUX_SHM_LOCK:
     case LINUX_SHM_UNLOCK:
     default:
-	uprintf("linux: 'ipc' typ=%d not implemented\n", args->cmd);
+	uprintf("linux: 'ipc' typ=%d not implemented\n",
+	  args->cmd & ~LINUX_IPC_64);
 	return EINVAL;
     }
 }
Index: compat/linux/linux_ipc.h
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_ipc.h,v
retrieving revision 1.8
diff -d -u -r1.8 linux_ipc.h
--- compat/linux/linux_ipc.h	20 Mar 2002 05:42:02 -0000	1.8
+++ compat/linux/linux_ipc.h	8 Oct 2002 10:49:54 -0000
@@ -31,6 +31,15 @@
 #ifndef _LINUX_IPC_H_
 #define _LINUX_IPC_H_
 
+/*
+ * Version flags for semctl, msgctl, and shmctl commands
+ * These are passed as bitflags or-ed with the actual command
+ */
+#define	LINUX_IPC_OLD	0	/* Old version (no 32-bit UID support on many
+				   architectures) */
+#define	LINUX_IPC_64	0x0100	/* New version (support 32-bit UIDs, bigger
+				   message sizes, etc. */
+
 #ifdef __i386__
 
 struct linux_msgctl_args 
Index: i386/linux/linux_dummy.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux_dummy.c,v
retrieving revision 1.34
diff -d -u -r1.34 linux_dummy.c
--- i386/linux/linux_dummy.c	2 Jun 2002 20:05:51 -0000	1.34
+++ i386/linux/linux_dummy.c	8 Oct 2002 10:49:54 -0000
@@ -63,9 +63,7 @@
 DUMMY(capget);
 DUMMY(capset);
 DUMMY(sendfile);
-DUMMY(mmap2);
 DUMMY(truncate64);
-DUMMY(ftruncate64);
 DUMMY(setfsuid);
 DUMMY(setfsgid);
 DUMMY(pivot_root);
Index: i386/linux/linux_ipc64.h
===================================================================
RCS file: i386/linux/linux_ipc64.h
diff -N i386/linux/linux_ipc64.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ i386/linux/linux_ipc64.h	8 Oct 2002 10:49:54 -0000
@@ -0,0 +1,145 @@
+/*-
+ * Copyright (c) 2002 Maxim Sobolev <sobomax@FreeBSD.org>
+ * 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 
+ *    in this position and unchanged.
+ * 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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _I386_LINUX_LINUX_IPC64_H_
+#define	_I386_LINUX_LINUX_IPC64_H_
+
+/*
+ * The ipc64_perm structure for i386 architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 32-bit mode_t and seq
+ * - 2 miscellaneous 32-bit values
+ */
+
+struct l_ipc64_perm
+{
+	l_key_t		key;
+	l_uid_t		uid;
+	l_gid_t		gid;
+	l_uid_t		cuid;
+	l_gid_t		cgid;
+	l_mode_t	mode;
+	l_ushort	__pad1;
+	l_ushort	seq;
+	l_ushort	__pad2;
+	l_ulong		__unused1;
+	l_ulong		__unused2;
+};
+
+/*
+ * The msqid64_ds structure for i386 architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 64-bit time_t to solve y2038 problem
+ * - 2 miscellaneous 32-bit values
+ */
+
+struct l_msqid64_ds {
+	struct l_ipc64_perm msg_perm;
+	l_time_t	msg_stime;	/* last msgsnd time */
+	l_ulong		__unused1;
+	l_time_t	msg_rtime;	/* last msgrcv time */
+	l_ulong		__unused2;
+	l_time_t	msg_ctime;	/* last change time */
+	l_ulong		__unused3;
+	l_ulong		msg_cbytes;	/* current number of bytes on queue */
+	l_ulong		msg_qnum;	/* number of messages in queue */
+	l_ulong		msg_qbytes;	/* max number of bytes on queue */
+	l_pid_t		msg_lspid;	/* pid of last msgsnd */
+	l_pid_t		msg_lrpid;	/* last receive pid */
+	l_ulong		__unused4;
+	l_ulong		__unused5;
+};
+
+/*
+ * The semid64_ds structure for i386 architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 64-bit time_t to solve y2038 problem
+ * - 2 miscellaneous 32-bit values
+ */
+
+struct l_semid64_ds {
+	struct l_ipc64_perm sem_perm;	/* permissions */
+	l_time_t	sem_otime;	/* last semop time */
+	l_ulong		__unused1;
+	l_time_t	sem_ctime;	/* last change time */
+	l_ulong		__unused2;
+	l_ulong		sem_nsems;	/* no. of semaphores in array */
+	l_ulong		__unused3;
+	l_ulong		__unused4;
+};
+
+/*
+ * The shmid64_ds structure for i386 architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 64-bit time_t to solve y2038 problem
+ * - 2 miscellaneous 32-bit values
+ */
+
+struct l_shmid64_ds {
+	struct l_ipc64_perm shm_perm;	/* operation perms */
+	l_size_t	shm_segsz;	/* size of segment (bytes) */
+	l_time_t	shm_atime;	/* last attach time */
+	l_ulong		__unused1;
+	l_time_t	shm_dtime;	/* last detach time */
+	l_ulong		__unused2;
+	l_time_t	shm_ctime;	/* last change time */
+	l_ulong		__unused3;
+	l_pid_t		shm_cpid;	/* pid of creator */
+	l_pid_t		shm_lpid;	/* pid of last operator */
+	l_ulong		shm_nattch;	/* no. of current attaches */
+	l_ulong		__unused4;
+	l_ulong		__unused5;
+};
+
+struct l_shminfo64 {
+	l_ulong   	shmmax;
+	l_ulong   	shmmin;
+	l_ulong   	shmmni;
+	l_ulong   	shmseg;
+	l_ulong   	shmall;
+	l_ulong   	__unused1;
+	l_ulong   	__unused2;
+	l_ulong   	__unused3;
+	l_ulong   	__unused4;
+};
+
+#endif /* !_I386_LINUX_LINUX_IPC64_H_ */
Index: i386/linux/linux_machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux_machdep.c,v
retrieving revision 1.30
diff -d -u -r1.30 linux_machdep.c
--- i386/linux/linux_machdep.c	2 Oct 2002 07:44:22 -0000	1.30
+++ i386/linux/linux_machdep.c	8 Oct 2002 10:49:54 -0000
@@ -385,19 +385,33 @@
 #define STACK_SIZE  (2 * 1024 * 1024)
 #define GUARD_SIZE  (4 * PAGE_SIZE)
 
+static int linux_mmap_common(struct thread *, struct l_mmap_argv *);
+
+int
+linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
+{
+	struct l_mmap_argv linux_args;
+
+#ifdef DEBUG
+	if (ldebug(mmap2))
+		printf(ARGS(mmap2, "%p, %d, %d, 0x%08x, %d, %d"),       
+		    (void *)args->addr, args->len, args->prot,       
+		    args->flags, args->fd, args->pgoff);       
+#endif
+
+	linux_args.addr = (l_caddr_t)args->addr;
+	linux_args.len = args->len;
+	linux_args.prot = args->prot;
+	linux_args.flags = args->flags;
+	linux_args.fd = args->fd;
+	linux_args.pos = args->pgoff * PAGE_SIZE;
+
+	return (linux_mmap_common(td, &linux_args));
+}
+
 int
 linux_mmap(struct thread *td, struct linux_mmap_args *args)
 {
-	struct proc *p = td->td_proc;
-	struct mmap_args /* {
-		caddr_t addr;
-		size_t len;
-		int prot;
-		int flags;
-		int fd;
-		long pad;
-		off_t pos;
-	} */ bsd_args;
 	int error;
 	struct l_mmap_argv linux_args;
 
@@ -408,22 +422,39 @@
 #ifdef DEBUG
 	if (ldebug(mmap))
 		printf(ARGS(mmap, "%p, %d, %d, 0x%08x, %d, %d"),
-		    (void *)linux_args.addr, linux_args.len, linux_args.prot,
-		    linux_args.flags, linux_args.fd, linux_args.pos);
+		    (void *)linux_args->addr, linux_args->len, linux_args->prot,
+		    linux_args->flags, linux_args->fd, linux_args->pos);
 #endif
 
+	return (linux_mmap_common(td, &linux_args));
+}
+
+static int
+linux_mmap_common(struct thread *td, struct l_mmap_argv *linux_args)
+{
+	struct proc *p = td->td_proc;
+	struct mmap_args /* {
+		caddr_t addr;
+		size_t len;
+		int prot;
+		int flags;
+		int fd;
+		long pad;
+		off_t pos;
+	} */ bsd_args;
+
 	bsd_args.flags = 0;
-	if (linux_args.flags & LINUX_MAP_SHARED)
+	if (linux_args->flags & LINUX_MAP_SHARED)
 		bsd_args.flags |= MAP_SHARED;
-	if (linux_args.flags & LINUX_MAP_PRIVATE)
+	if (linux_args->flags & LINUX_MAP_PRIVATE)
 		bsd_args.flags |= MAP_PRIVATE;
-	if (linux_args.flags & LINUX_MAP_FIXED)
+	if (linux_args->flags & LINUX_MAP_FIXED)
 		bsd_args.flags |= MAP_FIXED;
-	if (linux_args.flags & LINUX_MAP_ANON)
+	if (linux_args->flags & LINUX_MAP_ANON)
 		bsd_args.flags |= MAP_ANON;
 	else
 		bsd_args.flags |= MAP_NOSYNC;
-	if (linux_args.flags & LINUX_MAP_GROWSDOWN) {
+	if (linux_args->flags & LINUX_MAP_GROWSDOWN) {
 		bsd_args.flags |= MAP_STACK;
 
 		/* The linux MAP_GROWSDOWN option does not limit auto
@@ -448,7 +479,7 @@
 		 */
 
 		/* This gives us TOS */
-		bsd_args.addr = linux_args.addr + linux_args.len;
+		bsd_args.addr = linux_args->addr + linux_args->len;
 
 		if (bsd_args.addr > p->p_vmspace->vm_maxsaddr) {
 			/* Some linux apps will attempt to mmap
@@ -472,8 +503,8 @@
 		}
 
 		/* This gives us our maximum stack size */
-		if (linux_args.len > STACK_SIZE - GUARD_SIZE)
-			bsd_args.len = linux_args.len;
+		if (linux_args->len > STACK_SIZE - GUARD_SIZE)
+			bsd_args.len = linux_args->len;
 		else
 			bsd_args.len  = STACK_SIZE - GUARD_SIZE;
 
@@ -485,16 +516,16 @@
 		 */
 		bsd_args.addr -= bsd_args.len;
 	} else {
-		bsd_args.addr = linux_args.addr;
-		bsd_args.len  = linux_args.len;
+		bsd_args.addr = linux_args->addr;
+		bsd_args.len  = linux_args->len;
 	}
 
-	bsd_args.prot = linux_args.prot | PROT_READ;	/* always required */
-	if (linux_args.flags & LINUX_MAP_ANON)
+	bsd_args.prot = linux_args->prot | PROT_READ;	/* always required */
+	if (linux_args->flags & LINUX_MAP_ANON)
 		bsd_args.fd = -1;
 	else
-		bsd_args.fd = linux_args.fd;
-	bsd_args.pos = linux_args.pos;
+		bsd_args.fd = linux_args->fd;
+	bsd_args.pos = linux_args->pos;
 	bsd_args.pad = 0;
 
 #ifdef DEBUG
@@ -775,4 +806,20 @@
 	}
 
 	return (error);
+}
+
+int
+linux_ftruncate64(struct thread *td, struct linux_ftruncate64_args *args)
+{
+	struct ftruncate_args sa;
+
+#ifdef DEBUG
+	if (ldebug(ftruncate64))
+		printf(ARGS(ftruncate64, "%d, %d"), args->fd, args->length);
+#endif
+
+	sa.fd = args->fd;
+	sa.pad = 0;
+	sa.length = args->length;
+	return ftruncate(td, &sa);
 }
Index: alpha/linux/linux_ipc64.h
===================================================================
RCS file: alpha/linux/linux_ipc64.h
diff -N alpha/linux/linux_ipc64.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ alpha/linux/linux_ipc64.h	8 Oct 2002 10:49:54 -0000
@@ -0,0 +1,133 @@
+/*-
+ * Copyright (c) 2002 Maxim Sobolev <sobomax@FreeBSD.org>
+ * 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 
+ *    in this position and unchanged.
+ * 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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _ALPHA_LINUX_LINUX_IPC64_H_
+#define	_ALPHA_LINUX_LINUX_IPC64_H_
+
+/*
+ * The ipc64_perm structure for alpha architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 32-bit seq
+ * - 2 miscellaneous 64-bit values
+ */
+
+struct l_ipc64_perm
+{
+	l_key_t		key;
+	l_uid_t		uid;
+	l_gid_t		gid;
+	l_uid_t		cuid;
+	l_gid_t		cgid;
+	l_mode_t	mode;
+	l_ushort	seq;
+	l_ushort	__pad1;
+	l_ulong		__unused1;
+	l_ulong		__unused2;
+};
+
+/*
+ * The msqid64_ds structure for alpha architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 2 miscellaneous 64-bit values
+ */
+
+struct l_msqid64_ds {
+	struct l_ipc64_perm msg_perm;
+	l_time_t	msg_stime;	/* last msgsnd time */
+	l_time_t	msg_rtime;	/* last msgrcv time */
+	l_time_t	msg_ctime;	/* last change time */
+	l_ulong		msg_cbytes;	/* current number of bytes on queue */
+	l_ulong		msg_qnum;	/* number of messages in queue */
+	l_ulong		msg_qbytes;	/* max number of bytes on queue */
+	l_pid_t		msg_lspid;	/* pid of last msgsnd */
+	l_pid_t		msg_lrpid;	/* last receive pid */
+	l_ulong		__unused1;
+	l_ulong		__unused2;
+};
+
+/*
+ * The semid64_ds structure for alpha architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 2 miscellaneous 64-bit values
+ */
+
+struct l_semid64_ds {
+	struct l_ipc64_perm sem_perm;	/* permissions */
+	l_time_t	sem_otime;	/* last semop time */
+	l_time_t	sem_ctime;	/* last change time */
+	l_ulong		sem_nsems;	/* no. of semaphores in array */
+	l_ulong		__unused1;
+	l_ulong		__unused2;
+};
+
+/*
+ * The shmid64_ds structure for alpha architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 2 miscellaneous 64-bit values
+ */
+
+struct l_shmid64_ds {
+	struct l_ipc64_perm shm_perm;	/* operation perms */
+	l_size_t	shm_segsz;	/* size of segment (bytes) */
+	l_time_t	shm_atime;	/* last attach time */
+	l_time_t	shm_dtime;	/* last detach time */
+	l_time_t	shm_ctime;	/* last change time */
+	l_pid_t		shm_cpid;	/* pid of creator */
+	l_pid_t		shm_lpid;	/* pid of last operator */
+	l_ulong		shm_nattch;	/* no. of current attaches */
+	l_ulong		__unused1;
+	l_ulong		__unused2;
+};
+
+struct l_shminfo64 {
+	l_ulong   	shmmax;
+	l_ulong   	shmmin;
+	l_ulong   	shmmni;
+	l_ulong   	shmseg;
+	l_ulong   	shmall;
+	l_ulong   	__unused1;
+	l_ulong   	__unused2;
+	l_ulong   	__unused3;
+	l_ulong   	__unused4;
+};
+
+#endif /* !_ALPHA_LINUX_LINUX_IPC64_H_ */

--------------2C056B357B94AA92275BD099--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-emulation" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3DA2BE32.BDEC28B5>