fuse2-0007-util-ulockmgr_server.c-conditionally-define-closefro.patch (1467B)
1 From: Sam James <sam@gentoo.org> 2 Date: Sat, 24 Jul 2021 22:02:45 +0100 3 Subject: [PATCH] util/ulockmgr_server.c: conditionally define closefrom (fix 4 glibc-2.34+) 5 6 closefrom(3) has joined us in glibc-land from *BSD and Solaris. Since 7 it's available in glibc 2.34+, we want to detect it and only define our 8 fallback if the libc doesn't provide it. 9 10 Bug: https://bugs.gentoo.org/803923 11 Signed-off-by: Sam James <sam@gentoo.org> 12 13 diff --git a/configure.ac b/configure.ac 14 index 9946a0e..a2d481a 100644 15 --- a/configure.ac 16 +++ b/configure.ac 17 @@ -55,6 +55,7 @@ fi 18 19 AC_CHECK_FUNCS([fork setxattr fdatasync splice vmsplice utimensat]) 20 AC_CHECK_FUNCS([posix_fallocate]) 21 +AC_CHECK_FUNCS([closefrom]) 22 AC_CHECK_MEMBERS([struct stat.st_atim]) 23 AC_CHECK_MEMBERS([struct stat.st_atimespec]) 24 25 diff --git a/util/ulockmgr_server.c b/util/ulockmgr_server.c 26 index 273c7d9..a04dac5 100644 27 --- a/util/ulockmgr_server.c 28 +++ b/util/ulockmgr_server.c 29 @@ -22,6 +22,10 @@ 30 #include <sys/socket.h> 31 #include <sys/wait.h> 32 33 +#ifdef HAVE_CONFIG_H 34 + #include "config.h" 35 +#endif 36 + 37 struct message { 38 unsigned intr : 1; 39 unsigned nofd : 1; 40 @@ -124,6 +128,7 @@ static int receive_message(int sock, void *buf, size_t buflen, int *fdp, 41 return res; 42 } 43 44 +#if !defined(HAVE_CLOSEFROM) 45 static int closefrom(int minfd) 46 { 47 DIR *dir = opendir("/proc/self/fd"); 48 @@ -141,6 +146,7 @@ static int closefrom(int minfd) 49 } 50 return 0; 51 } 52 +#endif 53 54 static void send_reply(int cfd, struct message *msg) 55 {