Subject: Re: Linux emulation and not implemented syscalls
To: Bill Studenmund <wrstuden@nas.nasa.gov>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: tech-kern
Date: 08/16/1999 18:11:29
In message <Pine.SOL.3.96.990816165246.27345Q-100000@marcy.nas.nasa.gov>,
Bill Studenmund writes:

>> Which is already called via p_emul->e_nosys, iirc (at least on i386),
>> so no worries there.
>
>Cool!

Looks like the e_nosys struct field is acutally initialized to
<EMUL>_SYS_syscall, and the port-specific trap code special-cases
SYS_syscall (after mapping it for emuls where the emul_SYS_syscall
differs from the NetBSD one. But the sysent slot points to nosys().
So the typical code (from Alpha: i386 and mips are very similar,
modulo signed-ness cruft)


	callp = p->p_emul->e_sysent;
	numsys = p->p_emul->e_nsysent;
	/* ... */

	if (code < numsys)
		callp += code;
	else
		callp += p->p_emul->e_nosys;

ends up calling the sysent entry for SYS_syscall, which is nosys().
So if someone issued syscall(SYS_syscall, .. ) it'll end up calling
nosys(). Am I reading that right? If so, is that correct?

What happens on Linux if you try, syscall(SYS_syscall, ...)
say  with arguments to write() a const char * to fd 2?