Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Nov 2000 00:10:56 -0600
From:      "G. Adam Stanislav" <adam@whizkidtech.net>
To:        Michael Bacarella <mbac@mmap.nyct.net>
Cc:        hackers@FreeBSD.org
Subject:   Re: Kernel calls, are they documented somewhere?
Message-ID:  <20001102001056.A276@whizkidtech.net>
In-Reply-To: <20001102001202.A14447@mmap.nyct.net>; from mbac@mmap.nyct.net on Thu, Nov 02, 2000 at 12:12:02AM -0500
References:  <20001101222558.A408@whizkidtech.net> <20001102001202.A14447@mmap.nyct.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Nov 02, 2000 at 12:12:02AM -0500, Michael Bacarella wrote:
>gcc does not generate code that can make FreeBSD system calls directly.
>Most system calls as we know them by the manual have corresponding
>wrappers in libc. See /usr/src/lib/libc if you have the source installed.

I do have the source code, and I have studied it, but it is uncommented.
And, it seems, not all of it is included. For example, there is a
/usr/src/lib/libc/sys/open.2 but no corresponding open.c. I have been
unable to find the source code for open() in libc. There is an open.c
in /usr/src/lib/libstand/ but it makes no system calls. Actually, it
looks like a system call (it assigns its own file descriptors to files
it opens), but it does not behave like our kernel (since it returns -1
on errors, while our kernel has been returning 2 in my tests when trying
to open a non-existing file as O_RDONLY:

	sub	eax, eax	; EAX = 0 = O_RDONLY
	push	eax
	push	eax
	push	esi		; points at file name
	push	eax		; fake return address
	int	80h
	add	esp, byte 16

(That's NASM syntax.) If the file exists, I get a file descriptor in EAX,
otherwise EAX = 2. It would be nice if I could get some kind of formal
confirmation that this is how it is supposed to be, and that all FreeBSD
versions behave like that.

Adam

-- 
Apply standard disk lamer


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




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