Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

RE: File::Find

by ncw (Friar)
on Sep 16, 2000 at 15:01 UTC ( [id://32795]=note: print w/replies, xml ) Need Help??


in reply to File::Find

I've found another small problem with File::Find. If you are on a unix based platform, and you use File::Find on a non-unix partition eg dos, vfat (win9x), is9660 (cdrom) and AFS then File::Find doesn't work properly. You need to add
$File::Find::dont_use_nlink=1
Into your program and it will work fine. As I understand it this lowers the efficiency of File::Find because it has to look into each directory to see if there are entries in it rather than just looking at the nlink field in the inode. Non unix filesystems (and AFS ;-) don't set this properly.

This note is based on my experience with File::Find under Linux. It is probably similar under other *nix based systems but since foreign partition mounting is an OS specific thing YMMV.

Replies are listed 'Best First'.
RE: RE: File::Find
by tye (Sage) on Sep 17, 2000 at 01:28 UTC

    Actually the hack that dont_use_nlink disables only speeds up the most basic find operations where you don't care anything about the files to be found and then don't do anything with them. And it breaks File::Find on every platform I've ever used it on, just not on every file system on every platform.

    The default should be made to not use this bad hack on any platform. The days of "most file systems of most Unix systems" supporting this hack have long since passed (it has been a long time since I've seen a Unix system without a CD-ROM drive, just to pick one example).

    Sure, it was a cool hack a long time ago. And it can make just getting a listing of files much, much faster (depending on how your directories are structured). But a good module should err on the side of giving correct results over performance.

            - tye (but my friends call me "Tye")
RE: RE: File::Find
by merlyn (Sage) on Sep 16, 2000 at 21:55 UTC
    If you find an architecture on which you need to set this manually, please report it to the developers. This is supposed to be set automatically on those system which need it. If it isn't, it's a bug.

    -- Randal L. Schwartz, Perl hacker

      Here is my test prog :-
      use strict; use File::Find; my $dir = shift; my ($with, $without); print "Counting files in $dir\n"; # This is the default on Linux $File::Find::dont_use_nlink = 0; find(sub { $without++ }, $dir); $File::Find::dont_use_nlink = 1; find(sub { $with++ }, $dir); print "With \$File::Find::dont_use_nlink = 0: $without files found\n"; print "With \$File::Find::dont_use_nlink = 1: $with files found\n";
      I ran this on a mounted iso9660 disc like this (note if the disc has RockRidge extensions then it works properly!) :-
      $ ./file_find_test.pl /mnt/cdrom 
      Counting files in /mnt/cdrom
      With $File::Find::dont_use_nlink = 0: 29 files found
      With $File::Find::dont_use_nlink = 1: 1300 files found
      
      This was on Linux 2.2.17 with perl 5.00503 with the standard File::Find that comes with the distribution

      I agree with tye's comment here - $File::Find::dont_use_nlink should be 1 on all platforms - the slowdown isn't worth the incompatibilities.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://32795]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found