From 0013adeebae84f892a6fdd013e5d1530bb28292b Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Fri, 5 Apr 2013 00:49:07 +0300 Subject: [PATCH] Ticket #2992: mc fails to link when system lib does not contain strverscmp Signed-off-by: Slava Zanko --- lib/strutil/strverscmp.c | 3 ++- src/filemanager/filegui.c | 37 +++++++++++++++++-------- src/filemanager/mountlist.c | 54 +++++++++++++++++++------------------ 3 files changed, 56 insertions(+), 38 deletions(-) diff --git a/lib/strutil/strverscmp.c b/lib/strutil/strverscmp.c index 606bf8960..daadaef7f 100644 --- a/lib/strutil/strverscmp.c +++ b/lib/strutil/strverscmp.c @@ -1,7 +1,7 @@ /* Compare strings while treating digits characters numerically. - Copyright (C) 1997, 2002, 2011 + Copyright (C) 1997, 2002, 2011, 2013 The Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -54,6 +54,7 @@ str_verscmp (const char *s1, const char *s2) { #ifdef HAVE_STRVERSCMP return strverscmp (s1, s2); + #else /* HAVE_STRVERSCMP */ unsigned char *p1 = (unsigned char *) s1; unsigned char *p2 = (unsigned char *) s2; diff --git a/src/filemanager/filegui.c b/src/filemanager/filegui.c index c88bbb23e..6c9d71328 100644 --- a/src/filemanager/filegui.c +++ b/src/filemanager/filegui.c @@ -97,6 +97,7 @@ #else #define STRUCT_STATVFS struct statvfs #define STATFS statvfs + /* Return true if statvfs works. This is false for statvfs on systems with GNU libc on Linux kernels before 2.6.36, which stats all preceding entries in /proc/mounts; that makes df hang if even one @@ -108,22 +109,13 @@ statvfs_works (void) return 1; } #else + #include #include #define STAT_STATFS2_BSIZE 1 - -static int -statvfs_works (void) -{ - static int statvfs_works_cache = -1; - struct utsname name; - - if (statvfs_works_cache < 0) - statvfs_works_cache = (uname (&name) == 0 && 0 <= strverscmp (name.release, "2.6.36")); - return statvfs_works_cache; -} #endif #endif + #else #define STATFS statfs #define STRUCT_STATVFS struct statfs @@ -280,6 +272,29 @@ struct /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ +/* Return true if statvfs works. This is false for statvfs on systems + with GNU libc on Linux kernels before 2.6.36, which stats all + preceding entries in /proc/mounts; that makes df hang if even one + of the corresponding file systems is hard-mounted but not available. */ + +#if USE_STATVFS && ! (! STAT_STATVFS && STAT_STATVFS64) +static int +statvfs_works (void) +{ +#if ! (__linux__ && (__GLIBC__ || __UCLIBC__)) + return 1; +#else + static int statvfs_works_cache = -1; + struct utsname name; + + if (statvfs_works_cache < 0) + statvfs_works_cache = (uname (&name) == 0 && 0 <= str_verscmp (name.release, "2.6.36")); + return statvfs_works_cache; +} +#endif +#endif + +/* --------------------------------------------------------------------------------------------- */ static gboolean filegui__check_attrs_on_fs (const char *fs_path) { diff --git a/src/filemanager/mountlist.c b/src/filemanager/mountlist.c index ad1e9d7eb..1fd8640b9 100644 --- a/src/filemanager/mountlist.c +++ b/src/filemanager/mountlist.c @@ -2,10 +2,8 @@ Return a list of mounted file systems Copyright (C) 1991, 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. - - Copyright (C) 1991, 1992, 2011 - The Free Software Foundation, Inc. + 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 + Free Software Foundation, Inc. This file is part of the Midnight Commander. @@ -295,34 +293,12 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED) #define PROPAGATE_TOP_BIT(x) ((x) | ~ (EXTRACT_TOP_BIT (x) - 1)) #ifdef STAT_STATVFS -/* Return true if statvfs works. This is false for statvfs on systems - with GNU libc on Linux kernels before 2.6.36, which stats all - preceding entries in /proc/mounts; that makes df hang if even one - of the corresponding file systems is hard-mounted but not available. */ #if ! (__linux__ && (__GLIBC__ || __UCLIBC__)) -/* The FRSIZE fallback is not required in this case. */ #undef STAT_STATFS2_FRSIZE -static int -statvfs_works (void) -{ - return 1; -} #else -#include /* for strverscmp */ #include #include #define STAT_STATFS2_BSIZE 1 - -static int -statvfs_works (void) -{ - static int statvfs_works_cache = -1; - struct utsname name; - - if (statvfs_works_cache < 0) - statvfs_works_cache = (uname (&name) == 0 && 0 <= strverscmp (name.release, "2.6.36")); - return statvfs_works_cache; -} #endif #endif @@ -337,6 +313,8 @@ statvfs_works (void) #endif #endif /* STAT_READ_FILSYS */ +#include "lib/strutil.h" + /*** file scope type declarations ****************************************************************/ /* A mount table entry. */ @@ -372,6 +350,30 @@ static struct mount_entry *mc_mount_list = NULL; /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ +#ifdef STAT_STATVFS +/* Return true if statvfs works. This is false for statvfs on systems + with GNU libc on Linux kernels before 2.6.36, which stats all + preceding entries in /proc/mounts; that makes df hang if even one + of the corresponding file systems is hard-mounted but not available. */ +static int +statvfs_works (void) +{ +#if ! (__linux__ && (__GLIBC__ || __UCLIBC__)) + /* The FRSIZE fallback is not required in this case. */ + return 1; +#else + static int statvfs_works_cache = -1; + struct utsname name; + + if (statvfs_works_cache < 0) + statvfs_works_cache = (uname (&name) == 0 && 0 <= str_verscmp (name.release, "2.6.36")); + return statvfs_works_cache; +} +#endif +#endif + +/* --------------------------------------------------------------------------------------------- */ + #ifdef HAVE_INFOMOUNT_LIST static void free_mount_entry (struct mount_entry *me)