summaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorDenis Vlasenko2007-06-16 00:30:52 +0000
committerDenis Vlasenko2007-06-16 00:30:52 +0000
commit53a0e971960a520bd859b8aac6dbebec2045115f (patch)
tree7fbf136ec7cba71b8e463825b32c5ef3a9eb6ce2 /findutils
parentb941129ccb7901b0715c6affa9d0347f6fa5e64d (diff)
downloadbusybox-53a0e971960a520bd859b8aac6dbebec2045115f.zip
busybox-53a0e971960a520bd859b8aac6dbebec2045115f.tar.gz
find: make -size match GNU find
Diffstat (limited to 'findutils')
-rw-r--r--findutils/Config.in2
-rw-r--r--findutils/find.c36
2 files changed, 35 insertions, 3 deletions
diff --git a/findutils/Config.in b/findutils/Config.in
index bcdc024..f8ad98d 100644
--- a/findutils/Config.in
+++ b/findutils/Config.in
@@ -30,7 +30,7 @@ config FEATURE_FIND_MTIME
files, in days.
config FEATURE_FIND_MMIN
- bool "Enable modified time matching (-min) option"
+ bool "Enable modified time matching (-mmin) option"
default y
depends on FIND
help
diff --git a/findutils/find.c b/findutils/find.c
index 386bc54..036d13f 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -45,6 +45,14 @@
* (no output)
*/
+/* Testing script
+ * ./busybox find "$@" | tee /tmp/bb_find
+ * echo ==================
+ * /path/to/gnu/find "$@" | tee /tmp/std_find
+ * echo ==================
+ * diff -u /tmp/std_find /tmp/bb_find && echo Identical
+ */
+
#include <fnmatch.h>
#include "libbb.h"
#if ENABLE_FEATURE_FIND_REGEX
@@ -82,7 +90,7 @@ USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; unsigned *subst_count; int
USE_FEATURE_FIND_USER( ACTS(user, uid_t uid;))
USE_FEATURE_FIND_GROUP( ACTS(group, gid_t gid;))
USE_FEATURE_FIND_PAREN( ACTS(paren, action ***subexpr;))
-USE_FEATURE_FIND_SIZE( ACTS(size, off_t size;))
+USE_FEATURE_FIND_SIZE( ACTS(size, char size_char; off_t size;))
USE_FEATURE_FIND_PRUNE( ACTS(prune))
USE_FEATURE_FIND_DELETE(ACTS(delete))
@@ -314,6 +322,10 @@ ACTF(paren)
#if ENABLE_FEATURE_FIND_SIZE
ACTF(size)
{
+ if (ap->size_char == '+')
+ return statbuf->st_size > ap->size;
+ if (ap->size_char == '-')
+ return statbuf->st_size < ap->size;
return statbuf->st_size == ap->size;
}
#endif
@@ -714,11 +726,31 @@ static action*** parse_params(char **argv)
#endif
#if ENABLE_FEATURE_FIND_SIZE
else if (parm == PARM_size) {
+/* -size n[bckw]: file uses n units of space
+ * b (default): units are 512-byte blocks
+ * c: 1 byte
+ * k: kilobytes
+ * w: 2-byte words
+ */
+#if ENABLE_LFS
+#define XATOU_SFX xatoull_sfx
+#else
+#define XATOU_SFX xatoul_sfx
+#endif
+ static const struct suffix_mult find_suffixes[] = {
+ { "c", 1 },
+ { "w", 2 },
+ { "b"+1, 512 },
+ { "b", 512 },
+ { "k", 1024 },
+ { NULL, 0 }
+ };
action_size *ap;
if (!*++argv)
bb_error_msg_and_die(bb_msg_requires_arg, arg);
ap = ALLOC_ACTION(size);
- ap->size = XATOOFF(arg1);
+ ap->size_char = arg1[0];
+ ap->size = XATOU_SFX(plus_minus_num(arg1), find_suffixes);
}
#endif
#if ENABLE_FEATURE_FIND_PRUNE