From a082a3975f069c309553f625e580cd9d7142380e Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Fri, 2 Dec 2022 22:32:59 +0100 Subject: [PATCH] Assume fsync(2) exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is required by POSIX.1-2001. Cc: Christian Göttsche Signed-off-by: Alejandro Colomar --- configure.ac | 2 +- lib/commonio.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 56fa3fb4..b3d00488 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ AC_CHECK_HEADERS(crypt.h utmp.h \ dnl shadow now uses the libc's shadow implementation AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])]) -AC_CHECK_FUNCS(arc4random_buf fsync futimes \ +AC_CHECK_FUNCS(arc4random_buf futimes \ getentropy getrandom getspnam getusershell \ getutent initgroups lckpwdf lutimes \ setgroups updwtmp updwtmpx innetgr getpwnam_r \ diff --git a/lib/commonio.c b/lib/commonio.c index 7234e613..119d506e 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -986,13 +986,11 @@ int commonio_close (struct commonio_db *db) if (fflush (db->fp) != 0) { errors++; } -#ifdef HAVE_FSYNC + if (fsync (fileno (db->fp)) != 0) { errors++; } -#else /* !HAVE_FSYNC */ - sync (); -#endif /* !HAVE_FSYNC */ + if (fclose (db->fp) != 0) { errors++; }