From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Viro To: 9fans@cse.psu.edu Subject: Re: [9fans] 9fs/9auth for FreeBSD In-Reply-To: <20010328215030.A51B0199F4@mail.cse.psu.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Date: Wed, 28 Mar 2001 17:22:21 -0500 Topicbox-Message-UUID: 76342b58-eac9-11e9-9e20-41e7f4b1d025 On Wed, 28 Mar 2001, Russ Cox wrote: > O_APPEND probably isn't needed on BSD kernels, either. That was me > being paranoid based on the comment that writes didn't always get > treated as appends. > > No, it's needed. The behavior on FreeBSD really is what > I said -- if you do a write with a file offset > that is not the end of the file, the write fails. > It doesn't pretend the offset really is at the > end (as Plan 9 and apparently Linux do). It fails. Umm... Actually, I was wrong - what actually happens with append-only on Linux looks so: * if file is marked append-only you can't open it for write without O_APPEND. open() will fail with -EPERM * You can't turn O_APPEND off (with fcntl()) if file is append-only * For any O_APPEND opened file write() ignores position and goes to the end of file. In case of FreeBSD you can open append-only files for write without O_APPEND, but attempt to write not at the EOF will fail. We could easily switch to Plan9 behaviour - all it takes is if (IS_APPEND(inode)) { - if ((flag & FMODE_WRITE) && !(flag & O_APPEND)) - goto exit; @@ if (IS_APPEND(inode)) { + if (flag & FMODE_WRITE) + flag |= O_APPEND; in open_namei(). I'm not sure that it's the right thing to do, though. Failing on write() is definitely too late, but silently adding O_APPEND may be rather confusing. Hell knows... I'll look at it.