How write() works

Ángel González
Wed Dec 1 16:37:00 GMT 2010

Clyne wrote:
> Hi again,
> On 30/11/2010 16:58, wrote:
>> Yes, it's most definitely (1). The kernel usually decides when commit to
>> media happens, possibly juggling things to increase throughput. Elevator
>> and all those things. It wouldn't make sense to put the app to wait for
>> as long as this happens.
> Can I assume that other operations like moving, copying, linking etc
> also work in the same manner - i.e. that the kernel flushes the end
> results to disk when it sees fit?
> Thanks,
> Marcus.
Yes. You will need a fsync(2) on the folder (or a global sync(2) ) for that.

Also related is fdatasync(2), which can replace fsync(2) in almost every
case, as it's uncommon to need the atime/mtime of the file to be
completely exact.

More information about the Libc-help mailing list