]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
stat,tail: fix android build and support inotify
authorPádraig Brady <P@draigBrady.com>
Wed, 30 Jan 2019 04:32:53 +0000 (20:32 -0800)
committerPádraig Brady <P@draigBrady.com>
Mon, 4 Feb 2019 01:18:08 +0000 (17:18 -0800)
* src/extract-magic: Treat android like linux,
which fixes the build by ensuring the constants are defined.
* src/stat.c: Support all constants on android, including
the android specific "sdcardfs".
* src/tail.c: Fix inclusion of statfs headers to be independent
of inotify availability, as fremote() is used on linux even
if inotify has been disabled.  Also enable fremote() on android.
* NEWS: Mention the improvment.
Fixes https://bugs.gnu.org/34239

NEWS
src/extract-magic
src/stat.c
src/tail.c

diff --git a/NEWS b/NEWS
index 4b6b8bff8d087b42847850f2c8d567024dc1dfb1..e6ccb19495852fea34d925dd158adb35b2895c55 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -69,6 +69,11 @@ GNU coreutils NEWS                                    -*- outline -*-
   and encodes and decodes printable text using various common encodings:
   base64,base64url,base32,base32hex,base16,base2,z85.
 
+** Improvements
+
+  stat and tail now know about the "sdcardfs" file system on Android.
+  stat -f -c%T now reports the file system type, and tail -f uses inotify.
+
 
 * Noteworthy changes in release 8.30 (2018-07-01) [stable]
 
index 48c38dff5adc509dcab9f6cb265fbbff968ffddf..892c1db1d6d863740ba3ff9e8de4048f5b036b59 100644 (file)
@@ -125,7 +125,7 @@ EOF
   print $emit_magic ? $magic_comment : $map_comment;
 
   $emit_magic
-    and print "\n#if defined __linux__\n";
+    and print "\n#if defined __linux__ || defined __ANDROID__\n";
   $emit_magic
     or print "static inline int\n"
       . "is_local_fs_type (unsigned long int magic)\n"
index f17246d30a2402ebfa9a2f229845f5077ba7eb81..c8f18094850e051145e02a5af5b0d32ff4bfa7ef 100644 (file)
@@ -235,7 +235,7 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
 #else
   switch (statfsbuf->f_type)
     {
-# if defined __linux__
+# if defined __linux__ || defined __ANDROID__
 
       /* Compare with what's in libc:
          f=/a/libc/sysdeps/unix/sysv/linux/linux_fsinfo.h
@@ -450,6 +450,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
       return "romfs";
     case S_MAGIC_RPC_PIPEFS: /* 0x67596969 local */
       return "rpc_pipefs";
+    case S_MAGIC_SDCARDFS: /* 0x5DCA2DF5 local */
+      return "sdcardfs";
     case S_MAGIC_SECURITYFS: /* 0x73636673 local */
       return "securityfs";
     case S_MAGIC_SELINUX: /* 0xF97CFF8C local */
index dee827bc8f662746dd0d2de1c95aa2eed8ae763f..8fab0499dc6ace8f9765a46d02939c015ccf105d 100644 (file)
 # include <sys/inotify.h>
 /* 'select' is used by tail_forever_inotify.  */
 # include <sys/select.h>
+#endif
 
-/* inotify needs to know if a file is local.  */
+/* Linux can optimize the handling of local files.  */
+#if defined __linux__ || defined __ANDROID__
 # include "fs.h"
 # include "fs-is-local.h"
 # if HAVE_SYS_STATFS_H
@@ -938,7 +940,8 @@ fremote (int fd, const char *name)
 {
   bool remote = true;           /* be conservative (poll by default).  */
 
-#if HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE && defined __linux__
+#if HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE \
+ && (defined __linux__ || defined __ANDROID__)
   struct statfs buf;
   int err = fstatfs (fd, &buf);
   if (err != 0)