From owner-freebsd-questions@FreeBSD.ORG Sun Dec 28 16:35:30 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE2201065676 for ; Sun, 28 Dec 2008 16:35:30 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from mail.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 8B98E8FC12 for ; Sun, 28 Dec 2008 16:35:29 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from localhost (mail.rachie.is-a-geek.net [192.168.2.101]) by mail.rachie.is-a-geek.net (Postfix) with ESMTP id 5250EAFBC02; Sun, 28 Dec 2008 07:35:29 -0900 (AKST) From: Mel To: freebsd-questions@freebsd.org Date: Sun, 28 Dec 2008 07:35:28 -0900 User-Agent: KMail/1.9.10 References: <20081228060658.GA73070@osiris.chen.org.nz> In-Reply-To: <20081228060658.GA73070@osiris.chen.org.nz> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200812280735.28751.fbsd.questions@rachie.is-a-geek.net> Cc: Mitar , Jonathan Chen Subject: Re: Open with O_APPEND fails X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Dec 2008 16:35:30 -0000 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 > > > > 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.