Merge branch '2992_strverscmp'

* 2992_strverscmp:
  Ticket #2992: mc fails to link when system lib does not contain strverscmp
This commit is contained in:
Slava Zanko 2013-07-09 13:54:20 +03:00
commit b3bc7a077e
3 changed files with 56 additions and 38 deletions

View File

@ -1,7 +1,7 @@
/* /*
Compare strings while treating digits characters numerically. Compare strings while treating digits characters numerically.
Copyright (C) 1997, 2002, 2011 Copyright (C) 1997, 2002, 2011, 2013
The Free Software Foundation, Inc. The Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
@ -54,6 +54,7 @@ str_verscmp (const char *s1, const char *s2)
{ {
#ifdef HAVE_STRVERSCMP #ifdef HAVE_STRVERSCMP
return strverscmp (s1, s2); return strverscmp (s1, s2);
#else /* HAVE_STRVERSCMP */ #else /* HAVE_STRVERSCMP */
unsigned char *p1 = (unsigned char *) s1; unsigned char *p1 = (unsigned char *) s1;
unsigned char *p2 = (unsigned char *) s2; unsigned char *p2 = (unsigned char *) s2;

View File

@ -97,6 +97,7 @@
#else #else
#define STRUCT_STATVFS struct statvfs #define STRUCT_STATVFS struct statvfs
#define STATFS statvfs #define STATFS statvfs
/* Return true if statvfs works. This is false for statvfs on systems /* 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 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 preceding entries in /proc/mounts; that makes df hang if even one
@ -108,22 +109,13 @@ statvfs_works (void)
return 1; return 1;
} }
#else #else
#include <sys/utsname.h> #include <sys/utsname.h>
#include <sys/statfs.h> #include <sys/statfs.h>
#define STAT_STATFS2_BSIZE 1 #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
#endif #endif
#else #else
#define STATFS statfs #define STATFS statfs
#define STRUCT_STATVFS struct statfs #define STRUCT_STATVFS struct statfs
@ -280,6 +272,29 @@ struct
/*** file scope functions ************************************************************************/ /*** 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 static gboolean
filegui__check_attrs_on_fs (const char *fs_path) filegui__check_attrs_on_fs (const char *fs_path)
{ {

View File

@ -2,10 +2,8 @@
Return a list of mounted file systems Return a list of mounted file systems
Copyright (C) 1991, 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, Copyright (C) 1991, 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013
Free Software Foundation, Inc.
Copyright (C) 1991, 1992, 2011
The Free Software Foundation, Inc.
This file is part of the Midnight Commander. 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)) #define PROPAGATE_TOP_BIT(x) ((x) | ~ (EXTRACT_TOP_BIT (x) - 1))
#ifdef STAT_STATVFS #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__)) #if ! (__linux__ && (__GLIBC__ || __UCLIBC__))
/* The FRSIZE fallback is not required in this case. */
#undef STAT_STATFS2_FRSIZE #undef STAT_STATFS2_FRSIZE
static int
statvfs_works (void)
{
return 1;
}
#else #else
#include <string.h> /* for strverscmp */
#include <sys/utsname.h> #include <sys/utsname.h>
#include <sys/statfs.h> #include <sys/statfs.h>
#define STAT_STATFS2_BSIZE 1 #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
#endif #endif
@ -337,6 +313,8 @@ statvfs_works (void)
#endif #endif
#endif /* STAT_READ_FILSYS */ #endif /* STAT_READ_FILSYS */
#include "lib/strutil.h"
/*** file scope type declarations ****************************************************************/ /*** file scope type declarations ****************************************************************/
/* A mount table entry. */ /* A mount table entry. */
@ -372,6 +350,30 @@ static struct mount_entry *mc_mount_list = NULL;
/*** file scope functions ************************************************************************/ /*** 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 #ifdef HAVE_INFOMOUNT_LIST
static void static void
free_mount_entry (struct mount_entry *me) free_mount_entry (struct mount_entry *me)