<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">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: &lt;1993May18.212907.26320@ncar.ucar.edu&gt;
Sender: news@ncar.ucar.edu (USENET Maintenance)
Organization: NCAR, Research Applications Program
References: &lt;1993May17.171218.24669@imagen.com&gt; &lt;1993May17.215055.3313@ncar.ucar.edu&gt; &lt;1993May18.161610.15464@imagen.com&gt;
Date: Tue, 18 May 1993 21:29:07 GMT
Lines: 46

In article &lt;1993May18.161610.15464@imagen.com&gt; pomeranz@imagen.com
    (Hal Pomeranz) writes:

&gt;Rahul Dhesi (dhesi@rahul.net) pointed out a subtle problem with my
&gt;script.  It may be a problem with Tres Hofmeister's as well, but I
&gt;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])
  	&amp;&amp; $dev &lt; 0 &amp;&amp; ($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])
  	&amp;&amp; $dev &lt; 0 &amp;&amp; ($prune = 1)) {
+ 
+ 	# Skip hard links to plain files if we've already processed them.
+ 	return if $nlink &gt; 1 &amp;&amp; -f $name &amp;&amp; $seen{"$dev:$ino"}++;
  
  	$uid = $gid = -1;
  	$file = $name;


</pre></body></html>