Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Feb 2010 16:03:12 +0200
From:      Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To:        Stefan Midjich <swehack@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Does getc(3) use the read(2) syscall?
Message-ID:  <20100203140312.GA34290@pm513-1.comsys.ntu-kpi.kiev.ua>
In-Reply-To: <e0e25d5e1002030326p5e0ef0a1q5ebc77a4e1c69b7c@mail.gmail.com>
References:  <e0e25d5e1002030326p5e0ef0a1q5ebc77a4e1c69b7c@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello,

On Wed, Feb 03, 2010 at 12:26:02PM +0100, Stefan Midjich wrote:
> I'm having trouble looking this function up in the source tree, the trail
> seems to end at __sys_read which has a bunch of prototypes but i can't find
> the actual function code.
> 
> So my question is primarily, does getc use the read system call eventually?

The easiest way is to write a simple program with this function and
run it under ktrace and verify all calls in the output of kdump.

> 
> But i would also love it if someone could show me where __sys_read is
> defined.

Quick check of the path gave me the following:
getc -> __sgetc -> __srget -> __srefill -> _sread ->
     [._read ] -> __sread -> _read

Look how Assembler files for system calls invocations are generated in
the lib/libc/sys/Makefile.inc file, and look at macro variables defined
in the amd64/SYS.h file.  If you understand the idea, then check read.S
file in the <obj>/lib/libc/ directory and the output of "nm read.So".

Declaration of _read() in libc/stdio/stdio.c is done by a trick with
two header files namespace.h included before and un-namespace.h included
after another header files.

Looks like that __sys_read in libc/ is used in directories with thread
code and prototype for __sys_read is defined there.



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