bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mountlist: Port better to Android


From: Bruno Haible
Subject: mountlist: Port better to Android
Date: Sat, 26 Jan 2019 22:59:01 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )

The 'mountlist' module, on Android, relies on the getmntent(FILE*) function
and the MOUNTED macro.

The correct value of MOUNTED is "/proc/mounts", because /etc/mtab does not
exist.

- In Bionic releases after 2015-01-08:
  MOUNTED and _PATH_MOUNTED are defined as "/proc/mounts".
- In Bionic releases between 2014-01-09 and 2015-01-08:
  MOUNTED and _PATH_MOUNTED are defined as "/etc/mtab".
- In Bionic releases before 2014-01-09:
  MOUNTED is not defined. Only _PATH_MOUNTED is defined, as "/etc/mtab".

In particular, this leads to configure failing on Android 4.3:

  checking for getmntent... yes
  checking for one-argument getmntent function... no
  ...
  configure: error: could not determine how to read list of mounted file systems

This patch fixes both issues (the missing value of MOUNTED in older releases,
and the wrong one in newer releases).


2019-01-26  Bruno Haible  <address@hidden>

        mountlist: Port better to Android.
        * lib/mountlist.c (MOUNTED): Redefine on Android.
        * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Redefine MOUNTED on
        Android.

diff --git a/lib/mountlist.c b/lib/mountlist.c
index 0528d8a..937b3bb 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -66,7 +66,12 @@
                                    also (obsolete) 4.3BSD, SunOS */
 # include <mntent.h>
 # include <sys/types.h>
-# if !defined MOUNTED
+# if defined __ANDROID__        /* Android */
+   /* Bionic versions from between 2014-01-09 and 2015-01-08 define MOUNTED to
+      an incorrect value; older Bionic versions don't define it at all.  */
+#  undef MOUNTED
+#  define MOUNTED "/proc/mounts"
+# elif !defined MOUNTED
 #  if defined _PATH_MOUNTED     /* GNU libc  */
 #   define MOUNTED _PATH_MOUNTED
 #  endif
diff --git a/m4/ls-mntd-fs.m4 b/m4/ls-mntd-fs.m4
index 2de7b71..ba38439 100644
--- a/m4/ls-mntd-fs.m4
+++ b/m4/ls-mntd-fs.m4
@@ -1,4 +1,4 @@
-# serial 36
+# serial 37
 # How to list mounted file systems.
 
 # Copyright (C) 1998-2004, 2006, 2009-2019 Free Software Foundation, Inc.
@@ -99,11 +99,14 @@ $ac_includes_default
 #include <stdio.h>
 
 #include <mntent.h>
-#if !defined MOUNTED
-# if defined _PATH_MOUNTED      /* GNU libc  */
+#if defined __ANDROID__        /* Android */
+# undef MOUNTED
+# define MOUNTED "/proc/mounts"
+#elif !defined MOUNTED
+# if defined _PATH_MOUNTED     /* GNU libc  */
 #  define MOUNTED _PATH_MOUNTED
 # endif
-# if defined MNT_MNTTAB /* HP-UX.  */
+# if defined MNT_MNTTAB        /* HP-UX.  */
 #  define MOUNTED MNT_MNTTAB
 # endif
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]