From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 7F9AC1F453 for ; Sat, 26 Jan 2019 23:41:20 +0000 (UTC) Received: from localhost ([127.0.0.1]:36900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnXZe-0006Ls-T8 for normalperson@yhbt.net; Sat, 26 Jan 2019 18:41:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnXXb-0004ug-8T for bug-gnulib@gnu.org; Sat, 26 Jan 2019 18:39:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gnXLV-0005A2-G1 for bug-gnulib@gnu.org; Sat, 26 Jan 2019 18:26:42 -0500 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::8]:35624) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gnXLR-00057B-T9 for bug-gnulib@gnu.org; Sat, 26 Jan 2019 18:26:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1548545192; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=JoLMLlBFxNcGPNqBaaBa0g9ont4XX6SPI4lb2CXVJq4=; b=Q/HqeJma5jUZQW3Xi0q5zMCdc04FsIzeLvAotKkxlRaq3M+xp2N5uHOQsA3y6rkjx0 i/+/SVaw6vYLiEMEUiH+vFRacGekYeygP94dhr+MmZmvD3yUs+1jS/PrZUCCD7A/ki0i mrBhcoRRKZ2uja928dSPiNrTDiOKL7kVVZ6bIWRx/Jdl6rRizLAwBS1G88cklqfLidEZ QL3fgnDrk885BJDtsISgmYoVsGiHkTXSMuLW7mRYmcFtViixR5qvEhvB0Kn3zt5imij9 lkgyXqepeBJpz9zEJTpqj9G7fMKc662NxGrX+LyyqWxrcS/bEkqJo0kDaRFtxv+Y3REM IPDA== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf2y/s=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 44.9 DYNA|AUTH) with ESMTPSA id v0a34ev0QNQWod1 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Sun, 27 Jan 2019 00:26:32 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: mountlist: Use Linux code on Android Date: Sun, 27 Jan 2019 00:26:31 +0100 Message-ID: <2040804.EzfLWZXfGv@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <2310297.vOPnbdt5Vf@omega> References: <2310297.vOPnbdt5Vf@omega> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::8 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" The Linux code that reads from /proc is also applicable on Android. Notes: - This compiler ("gcc -mandroid") defines the preprocessor symbol __ANDROID__ but does NOT define __linux__. - This version of Android does not have setmntent and endmntent, but these functions are easy to substitute. - This version of Android also does not have getline, so this requires a dependency to the 'getline' module. 2019-01-26 Bruno Haible 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'. diff --git a/lib/mountlist.c b/lib/mountlist.c index 937b3bb..9b54a2c 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -123,6 +123,15 @@ # include #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 ba38439..05474c2 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 1e7d22a..81ab2bf 100644 --- a/modules/mountlist +++ b/modules/mountlist @@ -9,6 +9,7 @@ m4/fstypename.m4 m4/mountlist.m4 Depends-on: +getline stdbool stdint strstr-simple