stealth technology for find(1)
David L. Stevens
dls at mentor.cc.purdue.edu
Tue Aug 8 14:13:10 AEST 1989
Index: /usr/src/usr.bin/find/find.c 4.3BSD
Description:
find(1) changes atimes for all directories it searches, which makes
the "-atime" predicate less useful. The find(1) itself changes the directory
access times so they never age.
Repeat-By:
find / -atime ...
Fix:
Save the utimes for directories before reading them and restore them
on the way back up. (Works for root or directory owners, only) Diffs follow:
*** NEW find.c Mon Aug 7 22:33:48 1989
--- OLD find.c Mon Aug 7 22:30:29 1989
***************
*** 6,11 ****
--- 6,14 ----
#include <sys/param.h>
#include <sys/dir.h>
#include <sys/stat.h>
+ #ifdef STEALTH
+ #include <sys/time.h>
+ #endif /* STEALTH */
#define A_DAY 86400L /* a day full of seconds */
#define EQ(x, y) (strcmp(x, y)==0)
***************
*** 665,670 ****
--- 668,676 ----
char *endofname;
auto char sbkeep_dir[MAXPATHLEN+MAXNAMLEN+2];
struct stat lstatb;
+ #ifdef STEALTH
+ struct timeval tvp[2];
+ #endif /* STEALTH */
if ((follow?stat(fname, &Statb):lstat(fname, &Statb))<0) {
fprintf(stderr, "find: bad status < %s >\n", name);
***************
*** 699,704 ****
--- 705,714 ----
if (chdir(fname) == -1)
return(0);
+ #ifdef STEALTH
+ tvp[0].tv_sec = Statb.st_atime;
+ tvp[1].tv_sec = Statb.st_mtime;
+ #endif /* STEALTH */
if ((dir = opendir(".")) == NULL) {
fprintf(stderr, "find: cannot open < %s >\n", name);
rv = 0;
***************
*** 725,730 ****
--- 735,743 ----
ret:
if(dir)
closedir(dir);
+ #ifdef STEALTH
+ (void) utimes(".", tvp);
+ #endif /* STEALTH */
if (chdir(*sbkeep_dir ? sbkeep_dir : "..") == -1) {
*endofname = '\0';
fprintf(stderr, "find: bad directory <%s>\n", name);
--
+-DLS (dls at mentor.cc.purdue.edu)
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list