From: Valdis.Kletnieks@vt.edu
To: Andrew Morton <akpm@osdl.org>
Cc: jcwren@jcwren.com, linux-kernel@vger.kernel.org
Subject: Re: Bug in open() function (?)
Date: Sat, 12 Jul 2003 01:11:12 -0400 [thread overview]
Message-ID: <200307120511.h6C5BCSe017963@turing-police.cc.vt.edu> (raw)
In-Reply-To: Your message of "Fri, 11 Jul 2003 20:38:09 PDT." <20030711203809.3c320823.akpm@osdl.org>
[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]
On Fri, 11 Jul 2003 20:38:09 PDT, Andrew Morton said:
> "J.C. Wren" <jcwren@jcwren.com> wrote:
> >
> > I was playing around today and found that if an existing file is opened wit
h
> > O_TRUNC | O_RDONLY, the existing file is truncated.
>
> Well that's fairly idiotic, isn't it?
Not idiotic at all, and even if it was, it's still contrary to specific
language in the manpage.
I could *easily* see some program having a line of code:
if (do_ro_testing) openflags |= O_RDONLY;
I'd not be surprised if J.C. was playing around because a file unexpectedly
shrank to zero size because of code like this. There's a LOT of programs that
implement some sort of "don't really do it" option, from "/bin/bash -n" to
"cdrecord -dummy". So you do something like the above to make your
file R/O - and O_TRUNC *STILL* zaps the file, in *direct violation* of
the language in the manpage.
Whoops. Ouch. Where's the backup tapes?
> The Open Group go on to say "The result of using O_TRUNC with O_RDONLY is
> undefined" which is also rather silly.
>
> I'd be inclined to leave it as-is, really.
I hate to think how many programmers are relying on the *documented* behavior to
prevent data loss during debugging/test runs....
/Valdis
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
next prev parent reply other threads:[~2003-07-12 4:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-12 1:17 [PATCH] [2.5] adding ppp xon/xoff support Samuel Thibault
2003-07-12 1:30 ` Paul Mackerras
2003-07-12 2:42 ` Samuel Thibault
2003-07-12 3:09 ` Bug in open() function (?) J.C. Wren
2003-07-12 3:38 ` Andrew Morton
2003-07-12 5:11 ` Valdis.Kletnieks [this message]
2003-07-12 5:23 ` Andrew Morton
2003-07-12 6:14 ` Valdis.Kletnieks
2003-07-12 9:37 ` Andries Brouwer
2003-07-12 12:04 ` jw schultz
2003-07-12 5:39 ` J.C. Wren
2003-07-26 21:35 ` [PATCH] [2.6] adding xon/xoff support to ppp Samuel Thibault
2003-07-17 7:54 Bug in open() function (?) Michael Kerrisk
2003-07-17 10:54 ` Andries Brouwer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200307120511.h6C5BCSe017963@turing-police.cc.vt.edu \
--to=valdis.kletnieks@vt.edu \
--cc=akpm@osdl.org \
--cc=jcwren@jcwren.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).