bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* fts: Add support for Android
@ 2019-01-27 10:32 Bruno Haible
  2019-01-27 10:35 ` Bruno Haible
  0 siblings, 1 reply; 2+ messages in thread
From: Bruno Haible @ 2019-01-27 10:32 UTC (permalink / raw)
  To: bug-gnulib

On Android 4.3 (on a Linux ext4 file system), I see the 'test-fts' test fail.
There are two problems:

  1) fts_open apparently fails with error EINVAL. This happens because the
     test program uses the 'fts_open' etc. symbols from libc instead of those
     from libgnu.a - but the flag definitions come from gnulib's fts_.h, not
     from the libc's <fts.h>.
     The cause is that the GCC wrapper program passes '-lc' before all other
     arguments. This may be seen as a bug in this GCC wrapper. But on the
     other hand, symbols from a gnulib module may end up in shared libraries,
     and when shared libraries are involved, it is more hairy to control the
     precedence of symbols. For this reason, gnulib generally just avoids
     defining symbols that exist in libc. Let me do the same thing here.

  2) The mkdir() call in the loop in test-fts.c fails with error EMLINK; the
     test thus produces the error message
       t-fts.tmp/d/64999: Too many links
     The fix is to treat EMLINK like EMFILE here. (I think EMLINK is a more
     sensible error number for this kind of failure, compared to EMFILE,
     anyway.)


2019-01-26  Bruno Haible  <bruno@clisp.org>

	fts: Add support for Android.
	* m4/fts.m4 (gl_FUNC_FTS_CORE): Avoid conflicts between the symbols
	defined by this module and the ones in libc.
	* tests/test-fts.c (main): Treat mkdir error EMLINK like EMFILE.

diff --git a/m4/fts.m4 b/m4/fts.m4
index a9bf6a6..fa51ab4 100644
--- a/m4/fts.m4
+++ b/m4/fts.m4
@@ -1,4 +1,4 @@
-#serial 21
+#serial 22
 dnl Copyright (C) 2005-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -28,4 +28,22 @@ AC_DEFUN([gl_FUNC_FTS_CORE],
         ]])
     fi
   fi
+
+  AC_CHECK_FUNC([fts_open])
+  if test $ac_cv_func_fts_open = yes; then
+    dnl The system already has the symbols fts_open, etc.
+    dnl Avoid conflicts between these symbols and ours at the linker level.
+    AC_DEFINE([fts_open], [rpl_fts_open],
+      [Define to the overridden function name])
+    AC_DEFINE([fts_close], [rpl_fts_close],
+      [Define to the overridden function name])
+    AC_DEFINE([fts_read], [rpl_fts_read],
+      [Define to the overridden function name])
+    AC_DEFINE([fts_set], [rpl_fts_set],
+      [Define to the overridden function name])
+    AC_DEFINE([fts_children], [rpl_fts_children],
+      [Define to the overridden function name])
+    AC_DEFINE([fts_cross_check], [rpl_fts_cross_check],
+      [Define to the overridden function name])
+  fi
 ])
diff --git a/tests/test-fts.c b/tests/test-fts.c
index 14d3702..4c6bdb6 100644
--- a/tests/test-fts.c
+++ b/tests/test-fts.c
@@ -102,7 +102,7 @@ main (void)
 
   /* Create directories BASE, BASE/d, BASE/d/1, BASE/d/2, ..., BASE/d/65536,
      to stress-test fts.  Stop if directory creation fails due to
-     EMFILE problems, or if BASE/d's link count no longer matches the
+     EMFILE or EMLINK problems, or if BASE/d's link count no longer matches the
      Unix tradition.  See:
      https://bugzilla.kernel.org/show_bug.cgi?id=196405
      for more info.  */
@@ -115,7 +115,9 @@ main (void)
       sprintf (buf, "%s/d/%i", base, i);
       if (mkdir (buf, 0777) != 0)
         {
-          if (errno != EMFILE || i <= needles)
+          if (errno == EMFILE || errno == EMLINK)
+            break;
+          if (i <= needles)
             perror_exit (buf, 77);
           break;
         }



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: fts: Add support for Android
  2019-01-27 10:32 fts: Add support for Android Bruno Haible
@ 2019-01-27 10:35 ` Bruno Haible
  0 siblings, 0 replies; 2+ messages in thread
From: Bruno Haible @ 2019-01-27 10:35 UTC (permalink / raw)
  To: bug-gnulib

Followup: Enable Linux specific optimizations on Android as well.
__linux__ is not defined by "gcc -mandroid" in this environment.


2019-01-26  Bruno Haible  <bruno@clisp.org>

	fts: Optimize on Android.
	* lib/fts.c: Treat Android like Linux.

diff --git a/lib/fts.c b/lib/fts.c
index 47de580..58232ac 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -653,7 +653,7 @@ enum leaf_optimization
     NOSTAT_LEAF_OPTIMIZATION
   };
 
-#if defined __linux__ \
+#if (defined __linux__ || defined __ANDROID__) \
   && HAVE_SYS_VFS_H && HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE
 
 # include <sys/vfs.h>



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-27 10:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-27 10:32 fts: Add support for Android Bruno Haible
2019-01-27 10:35 ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).