1*4882a593SmuzhiyunFrom 5a43d0f724c56f8836f3f92411e0de1b5f82db32 Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Sam James <sam@gentoo.org> 3*4882a593SmuzhiyunDate: Sat, 24 Jul 2021 22:02:45 +0100 4*4882a593SmuzhiyunSubject: [PATCH] util/ulockmgr_server.c: conditionally define closefrom (fix 5*4882a593Smuzhiyun glibc-2.34+) 6*4882a593Smuzhiyun 7*4882a593Smuzhiyunclosefrom(3) has joined us in glibc-land from *BSD and Solaris. Since 8*4882a593Smuzhiyunit's available in glibc 2.34+, we want to detect it and only define our 9*4882a593Smuzhiyunfallback if the libc doesn't provide it. 10*4882a593Smuzhiyun 11*4882a593SmuzhiyunBug: https://bugs.gentoo.org/803923 12*4882a593SmuzhiyunSigned-off-by: Sam James <sam@gentoo.org> 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun[Retrieved from: 15*4882a593Smuzhiyunhttps://github.com/libfuse/libfuse/commit/5a43d0f724c56f8836f3f92411e0de1b5f82db32] 16*4882a593SmuzhiyunSigned-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 17*4882a593Smuzhiyun--- 18*4882a593Smuzhiyun configure.ac | 1 + 19*4882a593Smuzhiyun util/ulockmgr_server.c | 6 ++++++ 20*4882a593Smuzhiyun 2 files changed, 7 insertions(+) 21*4882a593Smuzhiyun 22*4882a593Smuzhiyundiff --git a/configure.ac b/configure.ac 23*4882a593Smuzhiyunindex 9946a0efa..a2d481aa9 100644 24*4882a593Smuzhiyun--- a/configure.ac 25*4882a593Smuzhiyun+++ b/configure.ac 26*4882a593Smuzhiyun@@ -55,6 +55,7 @@ fi 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun AC_CHECK_FUNCS([fork setxattr fdatasync splice vmsplice utimensat]) 29*4882a593Smuzhiyun AC_CHECK_FUNCS([posix_fallocate]) 30*4882a593Smuzhiyun+AC_CHECK_FUNCS([closefrom]) 31*4882a593Smuzhiyun AC_CHECK_MEMBERS([struct stat.st_atim]) 32*4882a593Smuzhiyun AC_CHECK_MEMBERS([struct stat.st_atimespec]) 33*4882a593Smuzhiyun 34*4882a593Smuzhiyundiff --git a/util/ulockmgr_server.c b/util/ulockmgr_server.c 35*4882a593Smuzhiyunindex 273c7d923..a04dac5c6 100644 36*4882a593Smuzhiyun--- a/util/ulockmgr_server.c 37*4882a593Smuzhiyun+++ b/util/ulockmgr_server.c 38*4882a593Smuzhiyun@@ -22,6 +22,10 @@ 39*4882a593Smuzhiyun #include <sys/socket.h> 40*4882a593Smuzhiyun #include <sys/wait.h> 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun+#ifdef HAVE_CONFIG_H 43*4882a593Smuzhiyun+ #include "config.h" 44*4882a593Smuzhiyun+#endif 45*4882a593Smuzhiyun+ 46*4882a593Smuzhiyun struct message { 47*4882a593Smuzhiyun unsigned intr : 1; 48*4882a593Smuzhiyun unsigned nofd : 1; 49*4882a593Smuzhiyun@@ -124,6 +128,7 @@ static int receive_message(int sock, void *buf, size_t buflen, int *fdp, 50*4882a593Smuzhiyun return res; 51*4882a593Smuzhiyun } 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun+#if !defined(HAVE_CLOSEFROM) 54*4882a593Smuzhiyun static int closefrom(int minfd) 55*4882a593Smuzhiyun { 56*4882a593Smuzhiyun DIR *dir = opendir("/proc/self/fd"); 57*4882a593Smuzhiyun@@ -141,6 +146,7 @@ static int closefrom(int minfd) 58*4882a593Smuzhiyun } 59*4882a593Smuzhiyun return 0; 60*4882a593Smuzhiyun } 61*4882a593Smuzhiyun+#endif 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun static void send_reply(int cfd, struct message *msg) 64*4882a593Smuzhiyun { 65