C file synchronization
c, file, synchronization
Solution
From `man 3 open`:
If both `O_DSYNC` and `O_RSYNC` are set in `oflag`, all I/O operations on the file descriptor shall complete as defined by synchronized I/O data integrity completion.
Therefore, the correct call is
open("file.txt", O_DSYNC | O_RSYNC);
Note that `fopen` does not take `O_` flags (it uses mode strings like `"r+"`), and you therefore cannot use any of the `O_*SYNC` options with it directly.
Problem
I would like to open a file in C where the reads and writes are both synchronized. Is the proper way ``` fopen("file.txt", O_DSYNCH | O_RSYNCH) ``` or ``` fopen("file.txt", O_SYNCH) ``` This is for use on Linux