Subject: Re: /dev/stdout wierdness
To: \"Jaromír\" Dolecek <jdolecek@netbsd.org>
From: None <jchacon@genuity.net>
List: tech-userlevel
Date: 02/21/2001 22:42:56
Yeah...It only happens if:
fdesc is mounted
MAKEDEV has been run with fdesc mounted (so the right links/devices exist
for /dev/stdout)
Basically I have a repeatable test case where open with O_TRUNC is ignored
without fdesc and enforced on fdesc for opens of /dev/stdout.
(sort calls fopen ("/dev/stdout", "w") and the fopen code for "w" calls open
with O_TRUNC in the flags).
Now, what's the right behavior? My opinion is the non-fdesc version does the
right thing since
1. The docs for fd(4) state:
Flags to the open(2) call other than O_RDONLY, O_WRONLY and O_RDWR are
ignored.
2. It makes the most sense since re-opening /dev/stdout should just be
equivilant to dup'ing it, not truncating the file it may be connected to
also.
I've poked a little bit one night on this but nothing obvious jumped out of
either code base that looked wrong. Shouldn't be too hard to track down so
I'm gonna look again this week.
James
>
>Frank van der Linden wrote:
>> James Chacon was looking into this; it appears to only happen if
>> you use the fdesc filesystem. It can also lead to a problem when
>> compiling ktruss, which I've experienced myself. I haven't looked
>> in to it myself, James will know more.
>
>Cool :)
>
>Jaromir
>--
>Jaromir Dolecek <jdolecek@NetBSD.org> http://www.ics.muni.cz/~dolecek/
>@@@@ Wanna a real operating system ? Go and get NetBSD, dammit! @@@@
>
>
>
>