diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-12 22:31:15 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-12 22:31:15 +0000 |
commit | 5fa7148761097d067c3f6723ca55c6284d1152ac (patch) | |
tree | 94e33f089502ba8625c31f72b93ae365e906d9d0 | |
parent | 16c2c700fd26825fbd3e9591b5f590f5d2abf65d (diff) | |
download | busybox-w32-5fa7148761097d067c3f6723ca55c6284d1152ac.tar.gz busybox-w32-5fa7148761097d067c3f6723ca55c6284d1152ac.tar.bz2 busybox-w32-5fa7148761097d067c3f6723ca55c6284d1152ac.zip |
build system: add "release" target
find: support -size N (needed for above)
-rw-r--r-- | Makefile.custom | 16 | ||||
-rw-r--r-- | findutils/find.c | 14 | ||||
-rw-r--r-- | include/libbb.h | 21 | ||||
-rw-r--r-- | include/usage.h | 35 |
4 files changed, 63 insertions, 23 deletions
diff --git a/Makefile.custom b/Makefile.custom index d257f6de5..816bee5db 100644 --- a/Makefile.custom +++ b/Makefile.custom | |||
@@ -42,6 +42,22 @@ check test: busybox | |||
42 | bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \ | 42 | bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \ |
43 | $(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:1=),-v) | 43 | $(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:1=),-v) |
44 | 44 | ||
45 | .PHONY: release | ||
46 | release: distclean | ||
47 | cd ..; \ | ||
48 | rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \ | ||
49 | cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && \ | ||
50 | find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \ | ||
51 | -name .svn \ | ||
52 | -print \ | ||
53 | -exec rm -r -f {} \; && \ | ||
54 | find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \ | ||
55 | -name .\#* \ | ||
56 | -print \ | ||
57 | -exec rm -f {} \; && \ | ||
58 | tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \ | ||
59 | busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/; | ||
60 | |||
45 | .PHONY: checkhelp | 61 | .PHONY: checkhelp |
46 | checkhelp: | 62 | checkhelp: |
47 | $(Q)$(srctree)/scripts/checkhelp.awk \ | 63 | $(Q)$(srctree)/scripts/checkhelp.awk \ |
diff --git a/findutils/find.c b/findutils/find.c index edb8482d8..bf6b71a83 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
@@ -69,6 +69,7 @@ USE_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;)) | |||
69 | USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;)) | 69 | USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;)) |
70 | USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; int *subst_count; int exec_argc;)) | 70 | USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; int *subst_count; int exec_argc;)) |
71 | USE_DESKTOP( ACTS(paren, action ***subexpr;)) | 71 | USE_DESKTOP( ACTS(paren, action ***subexpr;)) |
72 | USE_DESKTOP( ACTS(size, off_t size;)) | ||
72 | USE_DESKTOP( ACTS(prune)) | 73 | USE_DESKTOP( ACTS(prune)) |
73 | 74 | ||
74 | static action ***actions; | 75 | static action ***actions; |
@@ -225,6 +226,7 @@ ACTF(paren) | |||
225 | { | 226 | { |
226 | return exec_actions(ap->subexpr, fileName, statbuf); | 227 | return exec_actions(ap->subexpr, fileName, statbuf); |
227 | } | 228 | } |
229 | |||
228 | /* | 230 | /* |
229 | * -prune: if -depth is not given, return true and do not descend | 231 | * -prune: if -depth is not given, return true and do not descend |
230 | * current dir; if -depth is given, return false with no effect. | 232 | * current dir; if -depth is given, return false with no effect. |
@@ -235,6 +237,11 @@ ACTF(prune) | |||
235 | { | 237 | { |
236 | return SKIP; | 238 | return SKIP; |
237 | } | 239 | } |
240 | |||
241 | ACTF(size) | ||
242 | { | ||
243 | return statbuf->st_size == ap->size; | ||
244 | } | ||
238 | #endif | 245 | #endif |
239 | 246 | ||
240 | 247 | ||
@@ -487,6 +494,13 @@ action*** parse_params(char **argv) | |||
487 | else if (strcmp(arg, "-prune") == 0) { | 494 | else if (strcmp(arg, "-prune") == 0) { |
488 | (void) ALLOC_ACTION(prune); | 495 | (void) ALLOC_ACTION(prune); |
489 | } | 496 | } |
497 | else if (strcmp(arg, "-size") == 0) { | ||
498 | action_size *ap; | ||
499 | if (!*++argv) | ||
500 | bb_error_msg_and_die(bb_msg_requires_arg, arg); | ||
501 | ap = ALLOC_ACTION(size); | ||
502 | ap->size = XATOOFF(arg1); | ||
503 | } | ||
490 | #endif | 504 | #endif |
491 | else | 505 | else |
492 | bb_show_usage(); | 506 | bb_show_usage(); |
diff --git a/include/libbb.h b/include/libbb.h index ef5086d6c..1d91a0a72 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -85,7 +85,7 @@ | |||
85 | /* CONFIG_LFS is on */ | 85 | /* CONFIG_LFS is on */ |
86 | # if ULONG_MAX > 0xffffffff | 86 | # if ULONG_MAX > 0xffffffff |
87 | /* "long" is long enough on this system */ | 87 | /* "long" is long enough on this system */ |
88 | # define XSTRTOOFF xstrtoul | 88 | # define XATOOFF(a) xatoul_range(a, 0, LONG_MAX) |
89 | /* usage: sz = BB_STRTOOFF(s, NULL, 10); if (errno || sz < 0) die(); */ | 89 | /* usage: sz = BB_STRTOOFF(s, NULL, 10); if (errno || sz < 0) die(); */ |
90 | # define BB_STRTOOFF bb_strtoul | 90 | # define BB_STRTOOFF bb_strtoul |
91 | # define STRTOOFF strtoul | 91 | # define STRTOOFF strtoul |
@@ -93,22 +93,23 @@ | |||
93 | # define OFF_FMT "l" | 93 | # define OFF_FMT "l" |
94 | # else | 94 | # else |
95 | /* "long" is too short, need "long long" */ | 95 | /* "long" is too short, need "long long" */ |
96 | # define XSTRTOOFF xstrtoull | 96 | # define XATOOFF(a) xatoull_range(a, 0, LLONG_MAX) |
97 | # define BB_STRTOOFF bb_strtoull | 97 | # define BB_STRTOOFF bb_strtoull |
98 | # define STRTOOFF strtoull | 98 | # define STRTOOFF strtoull |
99 | # define OFF_FMT "ll" | 99 | # define OFF_FMT "ll" |
100 | # endif | 100 | # endif |
101 | #else | 101 | #else |
102 | # if 0 /* #if UINT_MAX == 0xffffffff */ | 102 | /* CONFIG_LFS is off */ |
103 | /* Doesn't work. off_t is a long. gcc will throw warnings on printf("%d", off_t) | 103 | # if UINT_MAX == 0xffffffff |
104 | * even if long==int on this arch. Crap... */ | 104 | /* While sizeof(off_t) == sizeof(int), off_t is typedef'ed to long anyway. |
105 | # define XSTRTOOFF xstrtou | 105 | * gcc will throw warnings on printf("%d", off_t). Crap... */ |
106 | # define BB_STRTOOFF bb_strtoi | 106 | # define XATOOFF(a) xatoi_u(a) |
107 | # define BB_STRTOOFF bb_strtou | ||
107 | # define STRTOOFF strtol | 108 | # define STRTOOFF strtol |
108 | # define OFF_FMT "" | 109 | # define OFF_FMT "l" |
109 | # else | 110 | # else |
110 | # define XSTRTOOFF xstrtoul | 111 | # define XATOOFF(a) xatoul_range(a, 0, LONG_MAX) |
111 | # define BB_STRTOOFF bb_strtol | 112 | # define BB_STRTOOFF bb_strtoul |
112 | # define STRTOOFF strtol | 113 | # define STRTOOFF strtol |
113 | # define OFF_FMT "l" | 114 | # define OFF_FMT "l" |
114 | # endif | 115 | # endif |
diff --git a/include/usage.h b/include/usage.h index b9310ac1f..0fba9b848 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -866,24 +866,33 @@ USE_FEATURE_DATE_ISOFMT( \ | |||
866 | "\nEXPRESSION may consist of:\n" \ | 866 | "\nEXPRESSION may consist of:\n" \ |
867 | " -follow Dereference symbolic links\n" \ | 867 | " -follow Dereference symbolic links\n" \ |
868 | " -name PATTERN File name (leading directories removed) matches PATTERN\n" \ | 868 | " -name PATTERN File name (leading directories removed) matches PATTERN\n" \ |
869 | " -print Print (default and assumed)\n" \ | 869 | " -print Print (default and assumed)" \ |
870 | USE_FEATURE_FIND_PRINT0( \ | 870 | USE_FEATURE_FIND_PRINT0( \ |
871 | " -print0 Delimit output with null characters rather than\n newlines" \ | 871 | "\n -print0 Delimit output with null characters rather than" \ |
872 | ) USE_FEATURE_FIND_TYPE( \ | 872 | "\n newlines" \ |
873 | ) USE_FEATURE_FIND_TYPE( \ | ||
873 | "\n -type X Filetype matches X (where X is one of: f,d,l,b,c,...)" \ | 874 | "\n -type X Filetype matches X (where X is one of: f,d,l,b,c,...)" \ |
874 | ) USE_FEATURE_FIND_PERM( \ | 875 | ) USE_FEATURE_FIND_PERM( \ |
875 | "\n -perm PERMS Permissions match any of (+NNN); all of (-NNN);\n or exactly (NNN)" \ | 876 | "\n -perm PERMS Permissions match any of (+NNN); all of (-NNN);" \ |
876 | ) USE_FEATURE_FIND_MTIME( \ | 877 | "\n or exactly (NNN)" \ |
877 | "\n -mtime DAYS Modified time is greater than (+N); less than (-N);\n or exactly (N) days" \ | 878 | ) USE_FEATURE_FIND_MTIME( \ |
878 | ) USE_FEATURE_FIND_MMIN( \ | 879 | "\n -mtime DAYS Modified time is greater than (+N); less than (-N);" \ |
879 | "\n -mmin MINS Modified time is greater than (+N); less than (-N);\n or exactly (N) minutes" \ | 880 | "\n or exactly (N) days" \ |
880 | ) USE_FEATURE_FIND_NEWER( \ | 881 | ) USE_FEATURE_FIND_MMIN( \ |
882 | "\n -mmin MINS Modified time is greater than (+N); less than (-N);" \ | ||
883 | "\n or exactly (N) minutes" \ | ||
884 | ) USE_FEATURE_FIND_NEWER( \ | ||
881 | "\n -newer FILE Modified time is more recent than FILE's" \ | 885 | "\n -newer FILE Modified time is more recent than FILE's" \ |
882 | ) USE_FEATURE_FIND_INUM( \ | 886 | ) USE_FEATURE_FIND_INUM( \ |
883 | "\n -inum N File has inode number N" \ | 887 | "\n -inum N File has inode number N" \ |
884 | ) USE_FEATURE_FIND_EXEC( \ | 888 | ) USE_FEATURE_FIND_EXEC( \ |
885 | "\n -exec CMD Execute CMD with all instances of {} replaced by the" \ | 889 | "\n -exec CMD Execute CMD with all instances of {} replaced by the" \ |
886 | "\n files matching EXPRESSION") | 890 | "\n files matching EXPRESSION" \ |
891 | ) USE_DESKTOP( \ | ||
892 | "\n -size N File size is N" \ | ||
893 | "\n -prune Stop traversing current subtree" \ | ||
894 | "\n (expr) Group" \ | ||
895 | ) | ||
887 | 896 | ||
888 | #define find_example_usage \ | 897 | #define find_example_usage \ |
889 | "$ find / -name passwd\n" \ | 898 | "$ find / -name passwd\n" \ |