BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0001178 [BusyBox] Standards Compliance major always 01-26-07 00:04 01-26-07 15:00
Reporter rockeychu View Status public  
Assigned To BusyBox
Priority normal Resolution fixed  
Status closed   Product Version svn
Summary 0001178: '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
Additional Information
Attached Files  find.c_patch [^] (3,481 bytes) 01-26-07 00:04

- Relationships

- Notes
(0002052)
vda
01-26-07 15:00

Fixed in rev 17544. Thanks.
 

- 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
01-26-07 15:00 vda Status assigned => closed
01-26-07 15:00 vda Note Added: 0002052
01-26-07 15:00 vda Resolution open => fixed


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker