Messages in this thread | | | Date | Mon, 17 Jun 1996 16:24:56 -0400 | From | "Theodore Y. Ts'o" <> | Subject | Re: 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
| |