diff options
author | Bruno Haible <bruno@clisp.org> | 2019-01-27 00:21:17 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2019-01-27 00:21:17 +0100 |
commit | a3d1c7849936e481ae10dea5312a36a448a5d5bf (patch) | |
tree | 93851bf05208256b2a656b5548a55876ed1cd96e | |
parent | 29c58de5bde12dd975966479c495e9516893125d (diff) | |
download | gnulib-a3d1c7849936e481ae10dea5312a36a448a5d5bf.tar.gz |
mountlist: Use Linux code on Android.
* lib/mountlist.c (setmntent, endmntent): Define fallbacks.
(unescape_tab, read_file_system_list): Enable Linux code on Android
as well.
* m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Test for setmntent
and endmntent.
* modules/mountlist (Depends-on): Add 'getline'.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | lib/mountlist.c | 15 | ||||
-rw-r--r-- | m4/ls-mntd-fs.m4 | 4 | ||||
-rw-r--r-- | modules/mountlist | 1 |
4 files changed, 25 insertions, 5 deletions
@@ -1,5 +1,15 @@ 2019-01-26 Bruno Haible <bruno@clisp.org> + mountlist: Use Linux code on Android. + * lib/mountlist.c (setmntent, endmntent): Define fallbacks. + (unescape_tab, read_file_system_list): Enable Linux code on Android + as well. + * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Test for setmntent + and endmntent. + * modules/mountlist (Depends-on): Add 'getline'. + +2019-01-26 Bruno Haible <bruno@clisp.org> + localename tests: Fix test failure on Android. * modules/localename-tests (Depends-on): Add 'setlocale'. diff --git a/lib/mountlist.c b/lib/mountlist.c index 937b3bb761..9b54a2cf70 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -123,6 +123,15 @@ # include <sys/mntent.h> #endif +#ifdef MOUNTED_GETMNTENT1 +# if !HAVE_SETMNTENT /* Android <= 4.4 */ +# define setmntent(fp,mode) fopen (fp, mode) +# endif +# if !HAVE_ENDMNTENT /* Android <= 4.4 */ +# define endmntent(fp) fclose (fp) +# endif +#endif + #ifndef HAVE_HASMNTOPT # define hasmntopt(mnt, opt) ((char *) 0) #endif @@ -383,7 +392,7 @@ dev_from_mount_options (char const *mount_options) #endif -#if defined MOUNTED_GETMNTENT1 && defined __linux__ /* GNU/Linux, Android */ +#if defined MOUNTED_GETMNTENT1 && (defined __linux__ || defined __ANDROID__) /* GNU/Linux, Android */ /* Unescape the paths in mount tables. STR is updated in place. */ @@ -429,7 +438,7 @@ read_file_system_list (bool need_fs_type) { FILE *fp; -# ifdef __linux__ +# if defined __linux__ || defined __ANDROID__ /* Try parsing mountinfo first, as that make device IDs available. Note we could use libmount routines to simplify this parsing a little (and that code is in previous versions of this function), however @@ -522,7 +531,7 @@ read_file_system_list (bool need_fs_type) goto free_then_fail; } else /* fallback to /proc/self/mounts (/etc/mtab). */ -# endif /* __linux __ */ +# endif /* __linux __ || __ANDROID__ */ { struct mntent *mnt; char const *table = MOUNTED; diff --git a/m4/ls-mntd-fs.m4 b/m4/ls-mntd-fs.m4 index ba38439271..05474c2ddd 100644 --- a/m4/ls-mntd-fs.m4 +++ b/m4/ls-mntd-fs.m4 @@ -1,4 +1,4 @@ -# serial 37 +# serial 38 # How to list mounted file systems. # Copyright (C) 1998-2004, 2006, 2009-2019 Free Software Foundation, Inc. @@ -123,7 +123,7 @@ $ac_includes_default [Define if there is a function named getmntent for reading the list of mounted file systems, and that function takes a single argument. (4.3BSD, SunOS, HP-UX, Irix)]) - AC_CHECK_FUNCS([hasmntopt]) + AC_CHECK_FUNCS([setmntent endmntent hasmntopt]) fi fi diff --git a/modules/mountlist b/modules/mountlist index 1e7d22a5e0..81ab2bfe40 100644 --- a/modules/mountlist +++ b/modules/mountlist @@ -9,6 +9,7 @@ m4/fstypename.m4 m4/mountlist.m4 Depends-on: +getline stdbool stdint strstr-simple |