Received: with ECARTIS (v1.0.0; list linux-xfs); Thu, 17 Oct 2002 02:39:09 -0700 (PDT) Received: from sisko.scot.redhat.com (pc-62-31-74-29-ed.blueyonder.co.uk [62.31.74.29]) by oss.sgi.com (8.12.5/8.12.5) with SMTP id g9H9d5tG023009 for ; Thu, 17 Oct 2002 02:39:05 -0700 Received: (from sct@localhost) by sisko.scot.redhat.com (8.11.6/8.11.2) id g9H9cph03599; Thu, 17 Oct 2002 10:38:51 +0100 Date: Thu, 17 Oct 2002 10:38:51 +0100 From: "Stephen C. Tweedie" To: Andi Kleen Cc: "Stephen C. Tweedie" , linux-xfs@oss.sgi.com Subject: Re: to compare journalised file systems Message-ID: <20021017103851.A3277@redhat.com> References: <20021016203853.GH27982@plato.local.lan> <20021016214759.GI27982@plato.local.lan> <20021017000107.A21179@wotan.suse.de> <20021016230948.B524@redhat.com> <20021017001549.A27231@wotan.suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20021017001549.A27231@wotan.suse.de>; from ak@suse.de on Thu, Oct 17, 2002 at 12:15:49AM +0200 X-archive-position: 1066 X-ecartis-version: Ecartis v1.0.0 Sender: linux-xfs-bounce@oss.sgi.com Errors-to: linux-xfs-bounce@oss.sgi.com X-original-sender: sct@redhat.com Precedence: bulk X-list: linux-xfs Hi, On Thu, Oct 17, 2002 at 12:15:49AM +0200, Andi Kleen wrote: > > lseek is ignored on O_APPEND files --- the write always re-seeks to > > EOF. pwrite goes down that same code path too so it also gets the > > append enforced. In your testing were you testing real writes, or > > just the lseeks? > > I was testing a real write. Another hole is pwrite(). No, both work fine. The lseek only operates on the internal f_pos, it doesn't affect the file. The write does affect the file but it re-seeks back to EOF, so the write always appends. Tested on both 2.4 and 2.5. > #include > #include > > main(int ac, char **av) > { > int fd = open(av[1], O_APPEND|O_WRONLY); > > if (lseek(fd, 100, SEEK_SET) < 0) perror("expected lseek error"); > if (write(fd, "1", 1) < 0) perror("expected write error"); > else printf("write succeeded\n"); > > } > % gcc -o tseek tseek.c > % dd if=/dev/zero of=/tmp/TEST bs=1k count=10 > % su > # chattr +a /tmp/TEST > % ./tseek /tmp/TEST > write succeeded Fine. That's correct behaviour. Do an "ls -l /tmp/TEST" afterwards and you'll see that it got exactly one byte longer as a result of the one-byte write. The write was an append despite the lseek. This is the behaviour required by SingleUnix. Internally, O_APPEND is enforced in generic_file_write, not by lseek. (Any filesystem which overrides generic_file_write needs to do the appropriate logic itself.) Cheers, Stephen