I am working with a C/C++ system in a Linux environment where I am moving files using the rename() function available in stdio.h.
After the move I am need of functionality to sync this to the underlying storage to make the change permanent. If I had a file descriptor I would be able to use fsync() or fdatasync().
Is there an elegant way of doing this? Or do I have to do something like this:
rename(old_path, new_path);
int fd = open(new_path, O_APPEND | O_WRONLY);
fdatasync(fd);
close(fd);
Will that even work?