aboutsummaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorPaul Fox <pgf@brightstareng.com>2006-01-13 21:05:41 +0000
committerPaul Fox <pgf@brightstareng.com>2006-01-13 21:05:41 +0000
commit72d1a2357d2168f241458e4d6cebb7589ac82f4f (patch)
treef3152b7eb88a52763740683d918e61aacbb9ade9 /findutils
parent4a1865ca5eaf6bebc76ef8066c19e95df0edc7c3 (diff)
downloadbusybox-w32-72d1a2357d2168f241458e4d6cebb7589ac82f4f.tar.gz
busybox-w32-72d1a2357d2168f241458e4d6cebb7589ac82f4f.tar.bz2
busybox-w32-72d1a2357d2168f241458e4d6cebb7589ac82f4f.zip
add find's "-mmin" option. configurable.
Diffstat (limited to 'findutils')
-rw-r--r--findutils/Config.in10
-rw-r--r--findutils/find.c27
2 files changed, 36 insertions, 1 deletions
diff --git a/findutils/Config.in b/findutils/Config.in
index 3c28ec03a..050fe901d 100644
--- a/findutils/Config.in
+++ b/findutils/Config.in
@@ -17,7 +17,15 @@ config CONFIG_FEATURE_FIND_MTIME
17 depends on CONFIG_FIND 17 depends on CONFIG_FIND
18 help 18 help
19 Allow searching based on the modification time of 19 Allow searching based on the modification time of
20 files. 20 files, in days.
21
22config CONFIG_FEATURE_FIND_MMIN
23 bool " Enable modified time matching (-min) option"
24 default y
25 depends on CONFIG_FIND
26 help
27 Allow searching based on the modification time of
28 files, in minutes.
21 29
22config CONFIG_FEATURE_FIND_PERM 30config CONFIG_FEATURE_FIND_PERM
23 bool " Enable permissions matching (-perm) option" 31 bool " Enable permissions matching (-perm) option"
diff --git a/findutils/find.c b/findutils/find.c
index 75ed4e208..603c20643 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -53,6 +53,11 @@ static char mtime_char;
53static int mtime_days; 53static int mtime_days;
54#endif 54#endif
55 55
56#ifdef CONFIG_FEATURE_FIND_MMIN
57static char mmin_char;
58static int mmin_mins;
59#endif
60
56#ifdef CONFIG_FEATURE_FIND_XDEV 61#ifdef CONFIG_FEATURE_FIND_XDEV
57static dev_t *xdev_dev; 62static dev_t *xdev_dev;
58static int xdev_count = 0; 63static int xdev_count = 0;
@@ -109,6 +114,17 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
109 goto no_match; 114 goto no_match;
110 } 115 }
111#endif 116#endif
117#ifdef CONFIG_FEATURE_FIND_MMIN
118 if (mmin_char != 0) {
119 time_t file_age = time(NULL) - statbuf->st_mtime;
120 time_t mmin_secs = mmin_mins * 60;
121 if (!((isdigit(mmin_char) && file_age >= mmin_secs &&
122 file_age < mmin_secs + 60) ||
123 (mmin_char == '+' && file_age >= mmin_secs + 60) ||
124 (mmin_char == '-' && file_age < mmin_secs)))
125 goto no_match;
126 }
127#endif
112#ifdef CONFIG_FEATURE_FIND_XDEV 128#ifdef CONFIG_FEATURE_FIND_XDEV
113 if (xdev_count) { 129 if (xdev_count) {
114 int i; 130 int i;
@@ -239,6 +255,17 @@ int find_main(int argc, char **argv)
239 if ((mtime_char = argv[i][0]) == '-') 255 if ((mtime_char = argv[i][0]) == '-')
240 mtime_days = -mtime_days; 256 mtime_days = -mtime_days;
241#endif 257#endif
258#ifdef CONFIG_FEATURE_FIND_MMIN
259 } else if (strcmp(argv[i], "-mmin") == 0) {
260 char *end;
261 if (++i == argc)
262 bb_error_msg_and_die(msg_req_arg, "-mmin");
263 mmin_mins = strtol(argv[i], &end, 10);
264 if (end[0] != '\0')
265 bb_error_msg_and_die(msg_invalid_arg, argv[i], "-mmin");
266 if ((mmin_char = argv[i][0]) == '-')
267 mmin_mins = -mmin_mins;
268#endif
242#ifdef CONFIG_FEATURE_FIND_XDEV 269#ifdef CONFIG_FEATURE_FIND_XDEV
243 } else if (strcmp(argv[i], "-xdev") == 0) { 270 } else if (strcmp(argv[i], "-xdev") == 0) {
244 struct stat stbuf; 271 struct stat stbuf;