O_APPEND, lseek() and pwrite()

From: Timo Sirainen
Date: Sat Apr 07 2007 - 11:35:42 EST


If I open a file with O_APPEND and write() to it, it looks like the file offset is updated and I can get it with lseek(SEEK_CUR). Can I trust that this behavior won't change in future Linux versions? Apparently this isn't standard, because at least OS X and Solaris don't do this.

pwrite() ignores the file offset if the fd has O_APPEND set (with 2.6.20). http://www.opengroup.org/austin/mailarchives/ag/ msg09453.html suggests that it shouldn't ignore it. Could this be changed? For now I can of course just change the flag with fcntl().

I guess there aren't any limits to how large blocks write() accepts without the data being mixed with another process's writes (both with O_APPEND)? And I guess there aren't any horrible performance problems with this, so that this is actually a good idea compared to file lock + write() + unlock? :)

Attachment: PGP.sig
Description: This is a digitally signed message part