lkml.org 
[lkml]   [1996]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: problem with O_CREAT ?
   From: Andrew Tridgell <tridge@arvidsjaur.anu.edu.au>
Date: Sun, 16 Jun 1996 23:38:16 +1000

There may be a problem with the handling of O_CREAT in linux.

I've always thought that O_CREAT should be ignored in a open() call if
the file exists. I don't have the posix specs handy, so please correct
me if this is wrong.

You're right! This is definitely a place where we're not conformant
with the POSIX specs.

I had a look at linux/fs/open.c and the problem seems to be this but
of code in do_open() which assumes that O_CREAT implies opening for
writing:

if (flag & (O_TRUNC | O_CREAT))
flag |= 2;

changing it to:

if (flag & O_TRUNC)
flag |= 2;

would probably "fix" the problem, but might have some nasty side effects.

I've taken a look at the code, too, and I think your fix should be safe.
I haven't tried it though. It's definitely worth experimenting with.

- Ted


\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.021 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site