[lkml]   [1996]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: problem with O_CREAT ?
   From: Andrew Tridgell <>
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

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.071 / U:12.924 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site