Skip to content

Commit

Permalink
common/syncfs: fall back to sync(2) if syncfs(2) not available
Browse files Browse the repository at this point in the history
Fixes: #12512
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 08210d6)
  • Loading branch information
tchaikov authored and smithfarm committed Aug 14, 2015
1 parent 40494c6 commit d0d6727
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/common/sync_filesystem.h
Expand Up @@ -34,18 +34,21 @@ inline int sync_filesystem(int fd)
#ifdef HAVE_SYS_SYNCFS
if (syncfs(fd) == 0)
return 0;
else
return -errno;
#elif defined(SYS_syncfs)
if (syscall(SYS_syncfs, fd) == 0)
return 0;
else
return -errno;
#elif defined(__NR_syncfs)
if (syscall(__NR_syncfs, fd) == 0)
return 0;
else
#endif

#if defined(HAVE_SYS_SYNCFS) || defined(SYS_syncfs) || defined(__NR_syncfs)
else if (errno == ENOSYS) {
sync();
return 0;
} else {
return -errno;
}
#else
sync();
return 0;
Expand Down

0 comments on commit d0d6727

Please sign in to comment.