From: Werner Fink Date: Tue, 13 Mar 2012 15:15:43 +0000 (+0100) Subject: Use --enable-timeout-stat as well as --enable-timeout-stat=static X-Git-Tag: v22.17~9^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=378eea8bd5db4ed8244ce1a3f416137f131acdd5;p=psmisc Use --enable-timeout-stat as well as --enable-timeout-stat=static for a static background process which does the final stat system calls Signed-off-by: Werner Fink --- diff --git a/ChangeLog b/ChangeLog index bde0f6f..baba19e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ + * Make it possible to use --enable-timeout-stat as well as + --enable-timeout-stat=static for a static background process which + does the final stat system calls + * Do not mix HAVE_TIMEOUT_STAT with WITH_TIMEOUT_STAT * Add timeout.c/timeout.h for static background process which is able to read the file name from pipe, does the stat(2) system call, and writes the result back to a pipe. diff --git a/configure.ac b/configure.ac index 0615f5f..9265d82 100644 --- a/configure.ac +++ b/configure.ac @@ -30,12 +30,16 @@ AC_SUBST([SELINUX_LIB]) # Call fork before all stat calls to stop hanging on NFS mounts AC_SUBST([WITH_TIMEOUT_STAT]) AC_ARG_ENABLE([timeout_stat], - [AS_HELP_STRING([--enable-timeout-stat], [Use a timeout on stat calls])], + [AS_HELP_STRING([--enable-timeout-stat], [Use a timeout on stat calls (optional with argument "static" for a static background process)])], [enable_timeout_stat=$enableval], [enable_timeout_stat="no"]) if test "$enable_timeout_stat" = "yes"; then AC_DEFINE([WITH_TIMEOUT_STAT], [1], [Use timeout on stat calls]) fi +if test "$enable_timeout_stat" = "static"; then + AC_DEFINE([WITH_TIMEOUT_STAT], [2], [Use timeout on stat calls]) +fi +AM_CONDITIONAL([WANT_TIMEOUT_STAT], [test "$enable_timeout_stat" = "static"]) # Enable hardened compile and link flags AC_ARG_ENABLE([harden_flags], diff --git a/src/Makefile.am b/src/Makefile.am index d511f24..a28af7d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,6 +24,9 @@ if WANT_PEEKFD_MIPS endif fuser_SOURCES = fuser.c comm.h signals.c signals.h i18n.h fuser.h lists.h +if WANT_TIMEOUT_STAT + fuser_SOURCES += timeout.c timeout.h +endif fuser_LDADD = @LIBINTL@ diff --git a/src/fuser.c b/src/fuser.c index e4081eb..09548ff 100644 --- a/src/fuser.c +++ b/src/fuser.c @@ -111,9 +111,13 @@ static dev_t device(const char *path); #endif static char *expandpath(const char *path); -typedef int (*stat_t)(const char*, struct stat*); #ifdef WITH_TIMEOUT_STAT +# if (WITH_TIMEOUT_STAT == 2) +# include "timeout.h" +# else +typedef int (*stat_t)(const char*, struct stat*); static int timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds); +# endif #else #define timeout(func,path,buf,dummy) (func)((path),(buf)) #endif /* WITH_TIMEOUT_STAT */ @@ -1783,7 +1787,7 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head, * Execute stat(2) system call with timeout to avoid deadlock * on network based file systems. */ -#ifdef HAVE_TIMEOUT_STAT +#if defined(WITH_TIMEOUT_STAT) && (WITH_TIMEOUT_STAT == 1) static sigjmp_buf jenv;