Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Dec 2008 07:35:28 -0900
From:      Mel <fbsd.questions@rachie.is-a-geek.net>
To:        freebsd-questions@freebsd.org
Cc:        Mitar <mmitar@gmail.com>, Jonathan Chen <jonc@chen.org.nz>
Subject:   Re: Open with O_APPEND fails
Message-ID:  <200812280735.28751.fbsd.questions@rachie.is-a-geek.net>
In-Reply-To: <20081228060658.GA73070@osiris.chen.org.nz>
References:  <f63c4b2d0812271246u18a881e6j87e0054c24f4661a@mail.gmail.com> <f63c4b2d0812272046x3977f7d6q7fb1305164db973b@mail.gmail.com> <20081228060658.GA73070@osiris.chen.org.nz>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 27 December 2008 21:06:58 Jonathan Chen wrote:
> On Sun, Dec 28, 2008 at 05:46:39AM +0100, Mitar wrote:
> > Hi!
> >
> > On Sun, Dec 28, 2008 at 5:10 AM, Mel
> >
> > <fbsd.questions@rachie.is-a-geek.net> wrote:
> > > open(2) will succeed but write(2) will fail with EBADF as documented
> > > (and I verified this behavior). Still no EACCES as you and the
> > > bugreporter are seeing.
> >
> > Where is documented that write would fail if file is opened only with
> > O_APPEND?

Implicitly in write(2) manpage:
     The write(), writev(), pwrite() and pwritev() system calls will fail and
     the file pointer will remain unchanged if:

     [EBADF]            The d argument is not a valid descriptor open for
                        writing.

> > Just O_APPEND should also open file for writing as appending 
> > is also writing. It cannot be used without "write" semantics so file
> > has to be open also for writing.
>
> If I recall correctly, this behaviour has been standard on UNIX-like
> OS's for a *very* long time now. If you are seeing a write allowed
> with just O_APPEND on Linux, it would very likely be a Linux only
> "feature".

Yup. Append is a bad english choice for the constant as it implies writes like 
you say, but really should be O_ATEND, because that's all that it does: seek 
to EOF.

-- 
Mel

Problem with today's modular software: they start with the modules
    and never get to the software part.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812280735.28751.fbsd.questions>