Path: utzoo!utgpu!watmath!iuvax!purdue!mentor.cc.purdue.edu!dls From: dls@mentor.cc.purdue.edu (David L. Stevens) Newsgroups: comp.bugs.4bsd Subject: stealth technology for find(1) Keywords: atimes, utimes(2), find(1) Message-ID: <3584@mentor.cc.purdue.edu> Date: 8 Aug 89 04:13:10 GMT Organization: PUCC UNIX Group Lines: 68 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 #include #include + #ifdef STEALTH + #include + #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@mentor.cc.purdue.edu)