[OpenWrt-Devel] [PATCH 7/8] tools/findutils: improve cygwin compatibility

Rosen Penev rosenp at gmail.com
Mon Oct 7 21:02:24 EDT 2019


From: Alexey Loukianov <lx2 at lexa2.ru>

Environment block size on Windows is limited to ~32k. But
contrary to typical posix limitation process arguments are
not included in environment block and are separate from it.
Thus it is not required to compare env_size with arg_max
when checking for execl(e) limits in findutils.

This is important due to a fact that some software like
linux kernel backports tend to export a lot of environment
variables during build which leads to find/xargs failing
with "environment is too large for exec" message when
working under cygwin.

Signed-off-by: Alexey Loukianov <lx2 at lexa2.ru>
Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 ...cygwin-env-is-not-included-into-args.patch | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 tools/findutils/patches/900-cygwin-env-is-not-included-into-args.patch

diff --git a/tools/findutils/patches/900-cygwin-env-is-not-included-into-args.patch b/tools/findutils/patches/900-cygwin-env-is-not-included-into-args.patch
new file mode 100644
index 0000000000..d96b2fce91
--- /dev/null
+++ b/tools/findutils/patches/900-cygwin-env-is-not-included-into-args.patch
@@ -0,0 +1,33 @@
+Index: findutils-4.6.0/lib/buildcmd.c
+===================================================================
+--- findutils-4.6.0.orig/lib/buildcmd.c
++++ findutils-4.6.0/lib/buildcmd.c
+@@ -509,6 +509,8 @@ bc_init_controlinfo (struct buildcmd_con
+ 
+   ctl->exit_if_size_exceeded = 0;
+ 
++
++#ifndef __CYGWIN__
+   /* Take the size of the environment into account.  */
+   if (size_of_environment > ctl->posix_arg_size_max)
+     {
+@@ -525,9 +527,19 @@ bc_init_controlinfo (struct buildcmd_con
+     }
+   else
+     {
++      ctl->posix_arg_size_max -= headroom;
+       ctl->posix_arg_size_max -= size_of_environment;
++    }
++#else
++  if (headroom >= ctl->posix_arg_size_max)
++    {
++      return BC_INIT_CANNOT_ACCOMODATE_HEADROOM;
++    }
++  else
++    {
+       ctl->posix_arg_size_max -= headroom;
+     }
++#endif
+ 
+   /* need to subtract 2 on the following line - for Linux/PPC */
+   ctl->max_arg_count = (ctl->posix_arg_size_max / sizeof (char*)) - 2u;
-- 
2.17.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list