Article 2851 of comp.lang.perl: Xref: feenix.metronet.com comp.lang.perl:2851 Newsgroups: comp.lang.perl Path: feenix.metronet.com!news.utdallas.edu!tamsun.tamu.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ncar!tres From: tres@rap.ucar.edu (Tres Hofmeister) Subject: Re: SOURCE: change UIDs thoughout your filesystems Message-ID: <1993May18.212907.26320@ncar.ucar.edu> Sender: news@ncar.ucar.edu (USENET Maintenance) Organization: NCAR, Research Applications Program References: <1993May17.171218.24669@imagen.com> <1993May17.215055.3313@ncar.ucar.edu> <1993May18.161610.15464@imagen.com> Date: Tue, 18 May 1993 21:29:07 GMT Lines: 46 In article <1993May18.161610.15464@imagen.com> pomeranz@imagen.com (Hal Pomeranz) writes: >Rahul Dhesi (dhesi@rahul.net) pointed out a subtle problem with my >script. It may be a problem with Tres Hofmeister's as well, but I >haven't had the chance to scope out his code. The `mvids' script I posted (a modified version of Tom Christiansen's original) has the same problem. I've included a patch below which I believe takes care of it. The only real change is to keep track on a per filesystem basis of which plain files have a link count greater than one, and to skip them if they've been seen already, a one line change. This is basically what Hal suggested. I sure learn a lot reading this newsgroup... -- Tres Hofmeister tres@ncar.ucar.edu *** mvids.old Tue May 18 15:03:29 1993 --- mvids Tue May 18 15:03:12 1993 *************** *** 195,202 **** # $_ contains the filename component of the pathname. # Prune NFS filesystems. ! unless ((($dev, $user, $group) = (lstat($_))[0,4,5]) && $dev < 0 && ($prune = 1)) { $uid = $gid = -1; $file = $name; --- 195,205 ---- # $_ contains the filename component of the pathname. # Prune NFS filesystems. ! unless ((($dev, $ino, $nlink, $user, $group) = (lstat($_))[0,1,3,4,5]) && $dev < 0 && ($prune = 1)) { + + # Skip hard links to plain files if we've already processed them. + return if $nlink > 1 && -f $name && $seen{"$dev:$ino"}++; $uid = $gid = -1; $file = $name;