Re: Write is not atomic?

2012-10-15 Thread Juliusz Chroboczek
> This seems out of context. > If the file was open(2)ed with O_APPEND, the file offset is first > set to the end of the file before writing. The adjustment of the > file offset and the write operation are performed as an atomic > step. > Sounds different, doesn't it? Ye

Re: Write is not atomic?

2012-10-15 Thread Jochen Striepe
Hello, On Mon, Oct 15, 2012 at 11:36:15PM +0200, Juliusz Chroboczek wrote: > The Linux manual page for write(2) says: > > The adjustment of the file offset and the write operation are > performed as an atomic step. This seems out of context. Over here write(2) reads: If t

Re: Write is not atomic?

2012-10-15 Thread Max Filippov
On Tue, Oct 16, 2012 at 3:24 AM, Philippe Troin wrote: > On Tue, 2012-10-16 at 10:13 +1100, Dave Chinner wrote: >> On Mon, Oct 15, 2012 at 11:36:15PM +0200, Juliusz Chroboczek wrote: >> > The following fragment of code >> > >> > int fd; >> > fd = open("exemple", O_CREAT | O_WRONLY | O_TRUN

Re: Write is not atomic?

2012-10-15 Thread Juliusz Chroboczek
> You don't check return code here, does write succeed at all? Yes, both writes return 6. > Does it ever produce e.g. OuOuilleille No. > (as this is what atomicity is about here)? I was referring to the claim that under Linux writing and adjusting the file offset are performed as an atomic ste

Re: Write is not atomic?

2012-10-15 Thread Philippe Troin
On Tue, 2012-10-16 at 10:13 +1100, Dave Chinner wrote: > On Mon, Oct 15, 2012 at 11:36:15PM +0200, Juliusz Chroboczek wrote: > > Hi, > > > > The Linux manual page for write(2) says: > > > > The adjustment of the file offset and the write operation are > > performed as an atomic step. > >

Re: Write is not atomic?

2012-10-15 Thread Dave Chinner
On Mon, Oct 15, 2012 at 11:36:15PM +0200, Juliusz Chroboczek wrote: > Hi, > > The Linux manual page for write(2) says: > > The adjustment of the file offset and the write operation are > performed as an atomic step. That's wrong. The file offset update is not synchronised at all with the

Re: Write is not atomic?

2012-10-15 Thread Max Filippov
On Tue, Oct 16, 2012 at 1:36 AM, Juliusz Chroboczek wrote: > Hi, > > The Linux manual page for write(2) says: > > The adjustment of the file offset and the write operation are > performed as an atomic step. > > This is apparently an extension to POSIX, which says > > This volume of IEE

Write is not atomic?

2012-10-15 Thread Juliusz Chroboczek
Hi, The Linux manual page for write(2) says: The adjustment of the file offset and the write operation are performed as an atomic step. This is apparently an extension to POSIX, which says This volume of IEEE Std 1003.1-2001 does not specify behavior of concurrent writes to a fi