Subject: Re: COMPAT_LINUX: a problem with dup2()
To: Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 12/31/2000 11:27:53
> [compiled on pwoerpc Linux]
>   (void*)ptr=mmap(NULL,512,PROT_READ,MAP_PRIVATE|MAP_FILE,fd,0);
> [ktrace from powerpc NetBSD]
>    325 ktrace   EMUL  "netbsd"
[...]
>    325 mmap     CALL  dup2(0,0x200)
>    325 mmap     RET   dup2 -1 errno 9 Bad file descriptor

> I wonder if NetBSD does'nt think this is a real NetBSD executable,
> and get it running by chance, because the syscalls I use have same
> syscall number and arguments on NetBSD and Linux.

> Here the problem is not mmap(), it's dup2(), [...]  We need a
> workaround for this, since Linux can call dup2() with values NetBSD
> does not accept.

I think dup2 is a red herring.

I think what's happening is, NetBSD is mistaking the executable for a
real NetBSD executable.  Most of the syscalls appear compatible, but
I'd offer a small wager that the Linux syscall number for mmap is the
same as the NetBSD syscalls number for dup2.  Note that the arguments
to dup2 (0,0x200) are the same bits as the first two arguments to mmap
(nil pointer, 512).

Get NetBSD to recognize it as a Linux executable and I feel sure the
dup2 problem will vanish.

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B