Historical Question About Bopen(2)
I just got bit by the behavior of Bopen and I'm wondering how it came to be:
Biobuf*
Bopen(char *name, int mode)
{
Biobuf *bp;
int fd;
switch(mode&~(OCEXEC|ORCLOSE|OTRUNC)) {
[...]
case OWRITE:
fd = create(name, mode, 0666);
break;
}
if(fd < 0)
return nil;
bp = Bfdopen(fd, mode);
[...]
return bp;
}
Bopen unconditionally calls create if it's called with OWRITE and ignores
OTRUNC. I was trying to append to the file and wondered why my Bseeks were
all returning 0. Does anyone know why Bopen behaves this way instead of
more conventionally (create of the file doesn't exist or if | OTRUNC,
otherwise open?) When I wrote a replacement function which does that everything
seemed to work, but I'm not sure if there's some landmine lurking I didn't think
of.
------------------------------------------
9fans: 9fans
Permalink:
https://9fans.topicbox.com/groups/9fans/Ta80d13c1be99c865-M39feca20b5f0c37778ac038f
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription