This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: open() and fopen()


On Fri, 23 Nov 2001, Muzaffer Ozakca muttered drunkenly:
> As you know, there are 2 different open() calls:
> 
> a) open(char *path, int flags, mode_t mode)
> b) open(char *path, int flags)
> 
> How does the compiler distinguish between two? I guess stdarg stuff
> cannot be used, as we should know beforehand the number and types of
> the arguments.

stdarg stuff is used, because we do know that at argument parse time.

,----[ open(2) ]
|        mode  should  always  be  specified when O_CREAT is in the
|        flags, and is ignored otherwise.
`----

so if (flags | O_CREAT), then you'd better have passed a mode too.

> Anybody knows what fopen() does call? is it open() in the C library or directly the system call SYS_open, using syscall().

stdio/fopen.c:fopen() calls sysdeps/generic/sysd-stdio.c:__stdio_open()
(the HURD has its own version), which sanitizes the arguments and calls
__open() (the syscall).

(btw, does anyone know why libio is in glibc? Is it just called by
libstdc++'s iostreams normally --- and why on earth doesn't libstdc++
just call stdio?)

-- 
`Many people have tried whispering in his ear, and indeed bellowing
 with megaphones but up to now he's seemed to be completely
 clue-immune.' --- John Winters


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]