* RE: incompatible open modes
@ 2003-07-31 18:29 Ata, John
2003-07-31 19:14 ` Richard B. Johnson
0 siblings, 1 reply; 4+ messages in thread
From: Ata, John @ 2003-07-31 18:29 UTC (permalink / raw)
To: Linux Kernel Mailing List
Hi Andries,
If that's what's been decided... I presume for backwards compatability,
but it does seem rather odd though. After all, it seems like O_RDONLY
is supposed to safeguard someone from accidently overwriting a file.
Otherwise why not automatically open everything read/write? Going down
the same path, what's next: automatically write enabling a file which
has been openend for O_RDONLY the next time someone performs a write
operation on it? ;-)
Take care,
John
-----Original Message-----
From: Andries Brouwer [mailto:aebr@win.tue.nl]
Sent: Thursday, July 31, 2003 1:36 PM
To: Zack Brown
Cc: Ata, John; Linux Kernel Mailing List
Subject: Re: incompatible open modes
> On Thu, Jul 31, 2003 at 12:09:14PM -0400, Ata, John wrote:
> > the manpage on "open" states that if a file is opened
"O_RDONLY|O_TRUNC",
> > the O_TRUNC is either ignored or an error is returned. The 2.4
kernel
> > appears to cheerfully truncate the file on open. I wondered
which
> > behavior is actually intended.
> >
> > O_TRUNC
> > If the file already exists and is a regular file and the
open
> > mode allows writing (i.e., is O_RDWR or O_WRONLY) it will
be
> > truncated to length 0.
> > Otherwise the effect of O_TRUNC is unspecified.
> > (On many Linux versions it will be ignored; on other versions
> > it will return an error.)
This was just recently discussed, and it became clear that the
parenthetical
remark only led to confusion. It has been deleted. Instead
The (undefined) effect of O_RDONLY | O_TRUNC various among
implementations. On many systems the file is actually
truncated.
has been added.
Andries
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: incompatible open modes
2003-07-31 18:29 incompatible open modes Ata, John
@ 2003-07-31 19:14 ` Richard B. Johnson
0 siblings, 0 replies; 4+ messages in thread
From: Richard B. Johnson @ 2003-07-31 19:14 UTC (permalink / raw)
To: Ata, John; +Cc: Linux Kernel Mailing List
On Thu, 31 Jul 2003, Ata, John wrote:
> Hi Andries,
>
> If that's what's been decided... I presume for backwards compatability,
> but it does seem rather odd though. After all, it seems like O_RDONLY
> is supposed to safeguard someone from accidently overwriting a file.
> Otherwise why not automatically open everything read/write? Going down
> the same path, what's next: automatically write enabling a file which
> has been openend for O_RDONLY the next time someone performs a write
> operation on it? ;-)
>
> Take care,
> John
Historically, the word "undefined" has become synonymous with
"worst possible thing" under Unix. If some operation is "undefined"
the implementor is free to low-level format your hard disk.
This is not a good thing. For instance, the MS-DOS 'open' has
defaults that are not harmful. Not so with Unix. There are no
defaults! You must be explicit. You can even create a file you
can't delete if you don't set the permissions correctly when
opening O_CREAT. Note you can even create a file called "*" and
"*.*". So, under Unix you gotta be careful. Like somebody's
.sig said; "Unix gives you enough rope to shoot yourself!"
Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <6DED202D454D3B4EB7D98A7439218D610C9AB7@vahqex2.gfgsi.com>]
* Re: incompatible open modes
[not found] <6DED202D454D3B4EB7D98A7439218D610C9AB7@vahqex2.gfgsi.com>
@ 2003-07-31 17:03 ` Zack Brown
2003-07-31 17:35 ` Andries Brouwer
0 siblings, 1 reply; 4+ messages in thread
From: Zack Brown @ 2003-07-31 17:03 UTC (permalink / raw)
To: Ata, John; +Cc: Linux Kernel Mailing List
Hi John,
The best place to ask is on the linux-kernel mailing list (CCed).
Good luck,
Zack
On Thu, Jul 31, 2003 at 12:09:14PM -0400, Ata, John wrote:
> Hi Zach,
>
> I don't know if you're the right contact... just wondered how I go about
> getting information as to the intent of the Linux kernel... the manpage on
> "open" states that if a file is opened "O_RDONLY|O_TRUNC", the O_TRUNC is
> either ignored or an error is returned. The 2.4 kernel appears to
> cheerfully truncate the file on open. I wondered which behavior is
> actually intended.
>
> Thanks for your time...
>
> Take care,
> ------
> John G. Ata
> DigitalNet, LLC
> XTS-400 Software Development
> MailTo:John.Ata@DigitalNet.com
> Phone:(703) 563-8092
>
> O_TRUNC
> If the file already exists and is a regular file and the
> open
> mode allows writing (i.e., is O_RDWR or O_WRONLY) it
> will be
> truncated to length 0. If the file is a FIFO or terminal
> device
> file, the O_TRUNC flag is ignored. Otherwise the
> effect of
> O_TRUNC is unspecified. (On many Linux versions it
> will be
> ignored; on other versions it will return an error.)
--
Zack Brown
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: incompatible open modes
2003-07-31 17:03 ` Zack Brown
@ 2003-07-31 17:35 ` Andries Brouwer
0 siblings, 0 replies; 4+ messages in thread
From: Andries Brouwer @ 2003-07-31 17:35 UTC (permalink / raw)
To: Zack Brown; +Cc: Ata, John, Linux Kernel Mailing List
> On Thu, Jul 31, 2003 at 12:09:14PM -0400, Ata, John wrote:
> > the manpage on "open" states that if a file is opened "O_RDONLY|O_TRUNC",
> > the O_TRUNC is either ignored or an error is returned. The 2.4 kernel
> > appears to cheerfully truncate the file on open. I wondered which
> > behavior is actually intended.
> >
> > O_TRUNC
> > If the file already exists and is a regular file and the open
> > mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be
> > truncated to length 0.
> > Otherwise the effect of O_TRUNC is unspecified.
> > (On many Linux versions it will be ignored; on other versions
> > it will return an error.)
This was just recently discussed, and it became clear that the parenthetical
remark only led to confusion. It has been deleted. Instead
The (undefined) effect of O_RDONLY | O_TRUNC various among
implementations. On many systems the file is actually
truncated.
has been added.
Andries
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-07-31 19:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-31 18:29 incompatible open modes Ata, John
2003-07-31 19:14 ` Richard B. Johnson
[not found] <6DED202D454D3B4EB7D98A7439218D610C9AB7@vahqex2.gfgsi.com>
2003-07-31 17:03 ` Zack Brown
2003-07-31 17:35 ` Andries Brouwer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).