Subject: Re: syscalls return values
To: Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
From: Bill Studenmund <wrstuden@zembu.com>
List: tech-kern
Date: 01/19/2001 12:42:28
On Fri, 19 Jan 2001, Emmanuel Dreyfus wrote:

> I have a problem with the lstat system call in Linux emulation.
> According to Linux, it should return a long. 
> 
> If I write with a printf the return value in the kernel, at the end od
> linux_sys_lstat, I can see that everything went fine, and that the
> return value is 0. But the user process get a non zero return value. I
> think this is caused by a size mismatch: the kernel sets up a 32 bits
> long result, and the process reads a 64 bits value.

How are you returning the value?

For comparison, syscalls in NetBSD all have the following prototype:

int syscall(struct proc *p, void *v, register_t *retval);

So you want to shove the return value in *retval. What you return() from
this routine is the error code to be returned. libc glue takes care of
setting errno as needed for you.

I'm not 100% how linux syscalls work, but I'd expect they are about the
same.

Take care,

Bill