> a) Where is `write' actually defined? (Or does `write' simply call  
> `_write'?)

/sys/src/libc/9sys/write.c
it calls pwrite.

>b) Why do some syscalls have `_' prefixes while others do not?

_write is there to allow executables to work that pre-date the introduction of 
pwrite
(it's a similar tale for read).  a few others emulate calls for executables 
that pre-date
the 4th edition changes (eg, stat, wstat, fwstat and others).  most of those 
could probably
be removed now.  one implication is that plan 9 actually has even fewer real 
system calls.

>c) How are the parameters to the libc syscall wrapper passed onto the  
>actual kernel-side implementation?

the sys calls find their parameters in the usual place for
the particular architecture's calling sequence, except that
when the compiler uses a register for the first argument (eg, mips, sparc, 
power, amd64)
that value is also put on the stack inside the sys call routine in libc,
and replaced by the system call number, before using which ever trap
convention is used on that platform to do the actual system call.
the kernel carefully copies them in from the stack (just in case).
seek has special handling because of the returned vlong.

Reply via email to