aboutsummaryrefslogtreecommitdiff
path: root/findutils/find.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2014-06-22 13:54:40 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2014-06-22 13:54:40 +0200
commitf92f1d0181853b989f9377debb56902e3e21c9a8 (patch)
tree14c0bb888dea4b92e0f8dcaec2aa9c2a40eb3966 /findutils/find.c
parent6be3a5242ce4855734a4cdd5770b6ea7adaf2b3d (diff)
downloadbusybox-w32-f92f1d0181853b989f9377debb56902e3e21c9a8.tar.gz
busybox-w32-f92f1d0181853b989f9377debb56902e3e21c9a8.tar.bz2
busybox-w32-f92f1d0181853b989f9377debb56902e3e21c9a8.zip
find: use sysconf(_SC_ARG_MAX) to determine the command-line size limit
The find utility uses a hardcoded value of 32 * 1024 as the limit of the command-line length when calling 'find -exec ... {} +'. This results in over 4 times more execve() calls than in coreutils' find. This patch uses the limit defined in system headers. Based on the patch by Bartosz Golaszewski <bartekgola@gmail.com>. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'findutils/find.c')
-rw-r--r--findutils/find.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/findutils/find.c b/findutils/find.c
index 493f72e61..56a7ed3ab 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -419,6 +419,7 @@ struct globals {
419 smallint need_print; 419 smallint need_print;
420 smallint xdev_on; 420 smallint xdev_on;
421 recurse_flags_t recurse_flags; 421 recurse_flags_t recurse_flags;
422 IF_FEATURE_FIND_EXEC_PLUS(unsigned max_argv_len;)
422} FIX_ALIASING; 423} FIX_ALIASING;
423#define G (*(struct globals*)&bb_common_bufsiz1) 424#define G (*(struct globals*)&bb_common_bufsiz1)
424#define INIT_G() do { \ 425#define INIT_G() do { \
@@ -428,6 +429,7 @@ struct globals {
428 /* we have to zero it out because of NOEXEC */ \ 429 /* we have to zero it out because of NOEXEC */ \
429 memset(&G, 0, sizeof(G)); \ 430 memset(&G, 0, sizeof(G)); \
430 IF_FEATURE_FIND_MAXDEPTH(G.minmaxdepth[1] = INT_MAX;) \ 431 IF_FEATURE_FIND_MAXDEPTH(G.minmaxdepth[1] = INT_MAX;) \
432 IF_FEATURE_FIND_EXEC_PLUS(G.max_argv_len = bb_arg_max() - 2048;) \
431 G.need_print = 1; \ 433 G.need_print = 1; \
432 G.recurse_flags = ACTION_RECURSE; \ 434 G.recurse_flags = ACTION_RECURSE; \
433} while (0) 435} while (0)
@@ -677,7 +679,7 @@ ACTF(exec)
677 ap->file_len += strlen(fileName) + sizeof(char*) + 1; 679 ap->file_len += strlen(fileName) + sizeof(char*) + 1;
678 /* If we have lots of files already, exec the command */ 680 /* If we have lots of files already, exec the command */
679 rc = 1; 681 rc = 1;
680 if (ap->file_len >= 32*1024) 682 if (ap->file_len >= G.max_argv_len)
681 rc = do_exec(ap, NULL); 683 rc = do_exec(ap, NULL);
682 return rc; 684 return rc;
683 } 685 }