changeset 40144:cdd46dde7e34

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.
author Bruno Haible <bruno@clisp.org>
date Sat, 26 Jan 2019 22:49:57 +0100
parents 648fa64e008c
children 5b5be594d7f9
files ChangeLog lib/mountlist.c m4/ls-mntd-fs.m4
diffstat 3 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jan 26 21:46:40 2019 +0100
+++ b/ChangeLog	Sat Jan 26 22:49:57 2019 +0100
@@ -1,3 +1,10 @@
+2019-01-26  Bruno Haible  <bruno@clisp.org>
+
+	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.
+
 2019-01-26  Bruno Haible  <bruno@clisp.org>
 
 	striconveh: Fix use of uninitialized iconv_t.
--- a/lib/mountlist.c	Sat Jan 26 21:46:40 2019 +0100
+++ b/lib/mountlist.c	Sat Jan 26 22:49:57 2019 +0100
@@ -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
--- a/m4/ls-mntd-fs.m4	Sat Jan 26 21:46:40 2019 +0100
+++ b/m4/ls-mntd-fs.m4	Sat Jan 26 22:49:57 2019 +0100
@@ -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 @@
 #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