mirror of
https://github.com/sheumann/hush.git
synced 2025-01-27 21:33:05 +00:00
add find's "-mmin" option. configurable.
This commit is contained in:
parent
4a1865ca5e
commit
72d1a2357d
@ -17,7 +17,15 @@ config CONFIG_FEATURE_FIND_MTIME
|
|||||||
depends on CONFIG_FIND
|
depends on CONFIG_FIND
|
||||||
help
|
help
|
||||||
Allow searching based on the modification time of
|
Allow searching based on the modification time of
|
||||||
files.
|
files, in days.
|
||||||
|
|
||||||
|
config CONFIG_FEATURE_FIND_MMIN
|
||||||
|
bool " Enable modified time matching (-min) option"
|
||||||
|
default y
|
||||||
|
depends on CONFIG_FIND
|
||||||
|
help
|
||||||
|
Allow searching based on the modification time of
|
||||||
|
files, in minutes.
|
||||||
|
|
||||||
config CONFIG_FEATURE_FIND_PERM
|
config CONFIG_FEATURE_FIND_PERM
|
||||||
bool " Enable permissions matching (-perm) option"
|
bool " Enable permissions matching (-perm) option"
|
||||||
|
@ -53,6 +53,11 @@ static char mtime_char;
|
|||||||
static int mtime_days;
|
static int mtime_days;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FEATURE_FIND_MMIN
|
||||||
|
static char mmin_char;
|
||||||
|
static int mmin_mins;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_FIND_XDEV
|
#ifdef CONFIG_FEATURE_FIND_XDEV
|
||||||
static dev_t *xdev_dev;
|
static dev_t *xdev_dev;
|
||||||
static int xdev_count = 0;
|
static int xdev_count = 0;
|
||||||
@ -109,6 +114,17 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
|||||||
goto no_match;
|
goto no_match;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_FEATURE_FIND_MMIN
|
||||||
|
if (mmin_char != 0) {
|
||||||
|
time_t file_age = time(NULL) - statbuf->st_mtime;
|
||||||
|
time_t mmin_secs = mmin_mins * 60;
|
||||||
|
if (!((isdigit(mmin_char) && file_age >= mmin_secs &&
|
||||||
|
file_age < mmin_secs + 60) ||
|
||||||
|
(mmin_char == '+' && file_age >= mmin_secs + 60) ||
|
||||||
|
(mmin_char == '-' && file_age < mmin_secs)))
|
||||||
|
goto no_match;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_FEATURE_FIND_XDEV
|
#ifdef CONFIG_FEATURE_FIND_XDEV
|
||||||
if (xdev_count) {
|
if (xdev_count) {
|
||||||
int i;
|
int i;
|
||||||
@ -239,6 +255,17 @@ int find_main(int argc, char **argv)
|
|||||||
if ((mtime_char = argv[i][0]) == '-')
|
if ((mtime_char = argv[i][0]) == '-')
|
||||||
mtime_days = -mtime_days;
|
mtime_days = -mtime_days;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_FEATURE_FIND_MMIN
|
||||||
|
} else if (strcmp(argv[i], "-mmin") == 0) {
|
||||||
|
char *end;
|
||||||
|
if (++i == argc)
|
||||||
|
bb_error_msg_and_die(msg_req_arg, "-mmin");
|
||||||
|
mmin_mins = strtol(argv[i], &end, 10);
|
||||||
|
if (end[0] != '\0')
|
||||||
|
bb_error_msg_and_die(msg_invalid_arg, argv[i], "-mmin");
|
||||||
|
if ((mmin_char = argv[i][0]) == '-')
|
||||||
|
mmin_mins = -mmin_mins;
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_FEATURE_FIND_XDEV
|
#ifdef CONFIG_FEATURE_FIND_XDEV
|
||||||
} else if (strcmp(argv[i], "-xdev") == 0) {
|
} else if (strcmp(argv[i], "-xdev") == 0) {
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
|
@ -722,6 +722,11 @@
|
|||||||
#else
|
#else
|
||||||
# define USAGE_FIND_MTIME(a)
|
# define USAGE_FIND_MTIME(a)
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_FEATURE_FIND_MMIN
|
||||||
|
#define USAGE_FIND_MMIN(a) a
|
||||||
|
#else
|
||||||
|
#define USAGE_FIND_MMIN(a)
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_FEATURE_FIND_NEWER
|
#ifdef CONFIG_FEATURE_FIND_NEWER
|
||||||
# define USAGE_FIND_NEWER(a) a
|
# define USAGE_FIND_NEWER(a) a
|
||||||
#else
|
#else
|
||||||
@ -752,7 +757,9 @@
|
|||||||
) USAGE_FIND_PERM( \
|
) USAGE_FIND_PERM( \
|
||||||
"\n\t-perm PERMS\tPermissions match any of (+NNN); all of (-NNN);\n\t\t\tor exactly (NNN)" \
|
"\n\t-perm PERMS\tPermissions match any of (+NNN); all of (-NNN);\n\t\t\tor exactly (NNN)" \
|
||||||
) USAGE_FIND_MTIME( \
|
) USAGE_FIND_MTIME( \
|
||||||
"\n\t-mtime TIME\tModified time is greater than (+N); less than (-N);\n\t\t\tor exactly (N) days" \
|
"\n\t-mtime DAYS\tModified time is greater than (+N); less than (-N);\n\t\t\tor exactly (N) days" \
|
||||||
|
) USAGE_FIND_MMIN( \
|
||||||
|
"\n\t-mmin MINS\tModified time is greater than (+N); less than (-N);\n\t\t\tor exactly (N) minutes" \
|
||||||
) USAGE_FIND_NEWER( \
|
) USAGE_FIND_NEWER( \
|
||||||
"\n\t-newer FILE\tModified time is more recent than FILE's" \
|
"\n\t-newer FILE\tModified time is more recent than FILE's" \
|
||||||
) USAGE_FIND_INUM( \
|
) USAGE_FIND_INUM( \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user