man 2 write states:
POSIX requires that a read(2) that can be proved to occur after a write() has returned will return the new data. Note that not all filesystems are POSIX conforming.
In Linux, is this also true for stat(2) and fstat(2), in particular, for the stat.st_size member?
Specifically, if you open a file with O_CREAT, successfully write 948427 bytes to it, then either stat or fstat it, are you guaranteed to see a st_size of 948427?
(If so, is this a guarantee for POSIX filesystems, or something that typical Linux filesystems provide in practice, or a property of certain filesystems and not others?)
write()to be able to return it withstat(). The OS needs to know the file size at least to allocate data blocks and to put append-mode writes in the correct position anyway. Now, NFS and such remote filesystems could be different, as all the data isn't available locally. I don't know ifstat()goes to the server on NFS, but AFAIU, reads in general don't, so in the case of multiple clients writing, the read-after-write guarantees might not hold.