From 5ca80ffd75a08c06332bf9ea7394e23e82a2368b Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 27 Nov 2019 18:03:00 +0000 Subject: Use an LFS version of fcntl function when available glibc-2.28 introduced fcntl64 as an LFS version of fcntl function, use this new function when available. * configure.ac (AC_CHECK_FUNCS): Add fcntl64. * largefile_wrappers.h (fcntl_fd): New macro. * strace.c (set_cloexec_flag): Use it instead of fcntl. --- configure.ac | 1 + largefile_wrappers.h | 6 ++++++ strace.c | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 2cf5110c0..f92f9e050 100644 --- a/configure.ac +++ b/configure.ac @@ -266,6 +266,7 @@ AC_CHECK_FUNCS(m4_normalize([ be64toh fallocate fanotify_mark + fcntl64 fopen64 fork fputs_unlocked diff --git a/largefile_wrappers.h b/largefile_wrappers.h index 902dc98a4..b52e22189 100644 --- a/largefile_wrappers.h +++ b/largefile_wrappers.h @@ -24,6 +24,11 @@ # else # define fopen_stream fopen # endif +# ifdef HAVE_FCNTL64 +# define fcntl_fd fcntl64 +# else +# define fcntl_fd fcntl +# endif # define strace_stat_t struct stat64 # define stat_file stat64 # define struct_dirent struct dirent64 @@ -33,6 +38,7 @@ # else # define open_file open # define fopen_stream fopen +# define fcntl_fd fcntl # define strace_stat_t struct stat # define stat_file stat # define struct_dirent struct dirent diff --git a/strace.c b/strace.c index 23bd17b9c..86ca3c356 100644 --- a/strace.c +++ b/strace.c @@ -422,7 +422,7 @@ set_cloexec_flag(int fd) { int flags, newflags; - flags = fcntl(fd, F_GETFD); + flags = fcntl_fd(fd, F_GETFD); if (flags < 0) { /* Can happen only if fd is bad. * Should never happen: if it does, we have a bug @@ -436,7 +436,7 @@ set_cloexec_flag(int fd) if (flags == newflags) return; - if (fcntl(fd, F_SETFD, newflags)) /* never fails */ + if (fcntl_fd(fd, F_SETFD, newflags)) /* never fails */ perror_msg_and_die("fcntl(%d, F_SETFD, %#x)", fd, newflags); } -- cgit v1.2.1