[BusyBox 0001178]: 'find' does not act as it is (with patch)
bugs at busybox.net
bugs at busybox.net
Fri Jan 26 00:04:50 PST 2007
The following issue has been SUBMITTED.
======================================================================
http://busybox.net/bugs/view.php?id=1178
======================================================================
Reported By: rockeychu
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 1178
Category: Standards Compliance
Reproducibility: always
Severity: major
Priority: normal
Status: assigned
======================================================================
Date Submitted: 01-26-2007 00:04 PST
Last Modified: 01-26-2007 00:04 PST
======================================================================
Summary: 'find' does not act as it is (with patch)
Description:
When with any options of '-mtime', '-mmin', '-inum', 'perm' or '-newer',
find does not act it might be, it just gives oppsite results. It also
can't process (+N) or (-N) correctly.
Patch as following (also with a attachment):
Index: findutils/find.c
===================================================================
--- findutils/find.c (revision 17534)
+++ findutils/find.c (working copy)
@@ -147,7 +147,7 @@
#if ENABLE_FEATURE_FIND_PERM
ACTF(perm)
{
- return !((isdigit(ap->perm_char) && (statbuf->st_mode & 07777) ==
ap->perm_mask)
+ return ((isdigit(ap->perm_char) && (statbuf->st_mode & 07777) ==
ap->perm_mask)
|| (ap->perm_char == '-' && (statbuf->st_mode &
ap->perm_mask) == ap->perm_mask)
|| (ap->perm_char == '+' && (statbuf->st_mode &
ap->perm_mask) != 0));
}
@@ -157,7 +157,7 @@
{
time_t file_age = time(NULL) - statbuf->st_mtime;
time_t mtime_secs = ap->mtime_days * 24 * 60 * 60;
- return !((isdigit(ap->mtime_char) && file_age >= mtime_secs
+ return ((isdigit(ap->mtime_char) && file_age >= mtime_secs
&& file_age < mtime_secs + 24 *
60 * 60)
|| (ap->mtime_char == '+' && file_age >= mtime_secs + 24 *
60 * 60)
|| (ap->mtime_char == '-' && file_age < mtime_secs));
@@ -168,7 +168,7 @@
{
time_t file_age = time(NULL) - statbuf->st_mtime;
time_t mmin_secs = ap->mmin_mins * 60;
- return !((isdigit(ap->mmin_char) && file_age >= mmin_secs
+ return ((isdigit(ap->mmin_char) && file_age >= mmin_secs
&& file_age < mmin_secs + 60)
|| (ap->mmin_char == '+' && file_age >= mmin_secs + 60)
|| (ap->mmin_char == '-' && file_age < mmin_secs));
@@ -177,13 +177,13 @@
#if ENABLE_FEATURE_FIND_NEWER
ACTF(newer)
{
- return (ap->newer_mtime >= statbuf->st_mtime);
+ return (ap->newer_mtime < statbuf->st_mtime);
}
#endif
#if ENABLE_FEATURE_FIND_INUM
ACTF(inum)
{
- return (statbuf->st_ino != ap->inode_num);
+ return (statbuf->st_ino == ap->inode_num);
}
#endif
#if ENABLE_FEATURE_FIND_EXEC
@@ -391,10 +391,11 @@
if (!*++argv)
bb_error_msg_and_die(bb_msg_requires_arg,
arg);
ap = ALLOC_ACTION(perm);
- ap->perm_mask = xstrtol_range(arg1, 8, 0, 07777);
ap->perm_char = arg1[0];
- if (ap->perm_char == '-')
- ap->perm_mask = -ap->perm_mask;
+ ap->perm_mask =
xstrtol_range(isdigit(ap->perm_char)? arg1 : arg1 + 1, 8, 0, 07777);
+ //ap->perm_mask = xstrtol_range((ap->perm_char ==
'-' || ap->perm_char == '+')? arg1 + 1: arg1, 8, 0, 07777);
+ //if (ap->perm_char == '-')
+ // ap->perm_mask = -ap->perm_mask;
}
#endif
#if ENABLE_FEATURE_FIND_MTIME
@@ -403,10 +404,11 @@
if (!*++argv)
bb_error_msg_and_die(bb_msg_requires_arg,
arg);
ap = ALLOC_ACTION(mtime);
- ap->mtime_days = xatol(arg1);
ap->mtime_char = arg1[0];
- if (ap->mtime_char == '-')
- ap->mtime_days = -ap->mtime_days;
+ ap->mtime_days = xatol(isdigit(ap->mtime_char)?
arg1 : arg1 + 1);
+ //ap->mtime_days = xatol((ap->mtime_char == '-' ||
ap->mtime_char == '+')? arg1 + 1 : arg1);
+ //if (ap->mtime_char == '-')
+ // ap->mtime_days = -ap->mtime_days;
}
#endif
#if ENABLE_FEATURE_FIND_MMIN
@@ -415,10 +417,11 @@
if (!*++argv)
bb_error_msg_and_die(bb_msg_requires_arg,
arg);
ap = ALLOC_ACTION(mmin);
- ap->mmin_mins = xatol(arg1);
ap->mmin_char = arg1[0];
- if (ap->mmin_char == '-')
- ap->mmin_mins = -ap->mmin_mins;
+ ap->mmin_mins = xatol(isdigit(ap->mmin_char)? arg1
: arg1 + 1);
+ //ap->mmin_mins = xatol((ap->mmin_char == '-' ||
ap->mmin_char == '+')? arg1 + 1 : arg1);
+ //if (ap->mmin_char == '-')
+ // ap->mmin_mins = -ap->mmin_mins;
}
#endif
#if ENABLE_FEATURE_FIND_NEWER
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
01-26-07 00:04 rockeychu New Issue
01-26-07 00:04 rockeychu Status new => assigned
01-26-07 00:04 rockeychu Assigned To => BusyBox
01-26-07 00:04 rockeychu File Added: find.c_patch
======================================================================
More information about the busybox-cvs
mailing list