When a file is closed using close() or fclose() (for example), does Linux guarantee that the file is written back to (persistent) disc?
What I mean is, if close() returns 0 and then immediately afterwards the power fails, are previously written data guaranteed to persist, i.e. be durable?
The fsync() system call does provide this guarantee. Is closing a file also sufficient?
I can’t find anything which makes any claim one way or another at the moment.
Question 2:
If close() does implicitly do an fsync(), is there a way of telling it not to?
From ‘
man 2 close‘:The man page says that if you want to be sure that your data are on disk, you have to use fsync() yourself.