From 08210d6a85527b0759f6dc4411f742bc13a4939f Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 29 Jul 2015 15:52:19 +0800 Subject: [PATCH] common/syncfs: fall back to sync(2) if syncfs(2) not available Fixes: #12512 Signed-off-by: Kefu Chai --- src/common/sync_filesystem.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/common/sync_filesystem.h b/src/common/sync_filesystem.h index ecfc77a39333b..8f45d04b3f6ba 100644 --- a/src/common/sync_filesystem.h +++ b/src/common/sync_filesystem.h @@ -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; -- 2.39.5