Factor out fsync/fdsync