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:
[email protected] (Tres Hofmeister)
Subject: Re: SOURCE: change UIDs thoughout your filesystems
Message-ID: <
[email protected]>
Sender:
[email protected] (USENET Maintenance)
Organization: NCAR, Research Applications Program
References: <
[email protected]> <
[email protected]> <
[email protected]>
Date: Tue, 18 May 1993 21:29:07 GMT
Lines: 46
In article <
[email protected]>
[email protected]
(Hal Pomeranz) writes:
>Rahul Dhesi (
[email protected]) 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
[email protected]
*** 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;