develooper Front page | perl.perl5.porters | Postings from October 2001

Re: find2perl and File::Find on cdrom filesystems (with Tel's patchapplied to perl-current)

Thread Next
From:
David Dyck
Date:
October 18, 2001 11:15
Subject:
Re: find2perl and File::Find on cdrom filesystems (with Tel's patchapplied to perl-current)
Message ID:
Pine.LNX.4.33.0110180940510.16600-100000@dd.tc.fluke.com
On Thu, 18 Oct 2001, Tels wrote:
> Please see
> http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-07/msg01486.html
> for the second round of me trying to get it patched.

Thank you for bringing the above link back from history.
In it you mention some context of the linux tmpfs where
nlink was set to 1.  "nlink and temporary file systems"
 http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-02/msg01036.html

I'd guess that since linux was changed to provide traditional Unix
semantics for nlink, that your patch wasn't determined to be "needed".

Maybe linux needs to change the way that cdrom file systems are presented
also :-) (I don't know what nlink is displayed as on other systems cdroms)

earlier Tels wrote:
> If I remember correctly, my solution does not slow it down except for one
> "if ()". There are no additional stats because:

> * if the nlink count is > 2, all is well and we precede as usual.
> * if it is below (aka 1 or 0), we have a filesystem with wrong nlink count
> and do like dont_use_nlink variable was temp. == 1. In this case the slow
> method is used, but it would have to be used anyway.

I see you were also concerned with /cdrom at that
time.  I hope others on the list will also examine your
patch that I tested and found it meets my needs.

=== credits for this patch from Tels <perl_dummy@bloodgate.com>
===  (I bumped the version number, and applied and tested it
      against perl-current 5.7.2  DEVEL12440 through diffs 12497.gz [dcd])

--- lib/File/Find.pm.orig	Sun Sep 23 00:49:36 2001
+++ lib/File/Find.pm	Thu Oct 18 10:40:11 2001
@@ -2,7 +2,7 @@
 use 5.006;
 use strict;
 use warnings;
-our $VERSION = '1.02';
+our $VERSION = '1.03';
 require Exporter;
 require Cwd;

@@ -180,9 +180,6 @@
 filehandle that caches the information from the preceding
 stat(), lstat(), or filetest.

-Set the variable C<$File::Find::dont_use_nlink> if you're using AFS,
-since AFS cheats.
-
 Here's another interesting wanted function.  It will find all symbolic
 links that don't resolve:

@@ -195,6 +192,23 @@

 =head1 CAVEAT

+=over 2
+
+=item $dont_use_nlink
+
+You can set the variable C&lt;$File::Find::dont_use_nlink&gt; to 1, if you want to
+force File::Find to always stat directories. This was used for systems
+that do not have the correct C&lt;nlink&gt; count for directories. Examples are
+ISO-9660 (CD-R), AFS, and operating systems like OS/2, DOS and a couple of
+others.
+
+Since now File::Find should now detect such things on-the-fly and switch it
+self to using stat, this will probably not a problem to you.
+
+If you do set $dont_use_nlink to 1, you will notice slow-downs.
+
+=item symlinks
+
 Be aware that the option to follow symbolic links can be dangerous.
 Depending on the structure of the directory tree (including symbolic
 links to directories) you might traverse a given (physical) directory
@@ -203,6 +217,8 @@
 might cause very unpleasant surprises, since you delete or change files
 in an unknown directory.

+=back
+
 =head1 NOTES

 =over 4
@@ -643,6 +659,7 @@
     my $dir_pref;
     my $dir_rel = $File::Find::current_dir;
     my $tainted = 0;
+    my $no_nlink;

     if ($Is_MacOS) {
 	$dir_pref= ($p_dir =~ /:$/) ? $p_dir : "$p_dir:"; # preface
@@ -736,7 +753,15 @@
 	@filenames = &$pre_process(@filenames) if $pre_process;
 	push @Stack,[$CdLvl,$dir_name,"",-2]   if $post_process;

-	if ($nlink == 2 && !$avoid_nlink) {
+ 	# default: use whatever was specifid
+	  # (if $nlink &gt;= 2, and $avoid_nlink == 0, this will switch back)
+	  $no_nlink = $avoid_nlink;
+	  # if dir has wrong nlink count, force switch to slower stat method
+	  $no_nlink = 1 if ($nlink < 2);
+
+ 	if ($nlink == 2 && !$no_nlink) {
+
+
 	    # This dir has no subdirectories.
 	    for my $FN (@filenames) {
 		next if $FN =~ $File::Find::skip_pattern;
@@ -753,7 +778,7 @@

 	    for my $FN (@filenames) {
 		next if $FN =~ $File::Find::skip_pattern;
-		if ($subcount > 0 || $avoid_nlink) {
+		if ($subcount > 0 || $no_nlink) {
 		    # Seen all the subdirs?
 		    # check for directoriness.
 		    # stat is faster for a file in the current directory



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About