File::Find in FreeBSD msdosfs mounts

S

Senandung Mendonan

Dear group,

I wrote this perl snippet below on FreeBSD-5.2.1, which I find works
in normal UFS -type filesystems, but doesn't work in msdosfs mounts
(File::Find's find() doesn't traverse into directories). The -f test
inside wanted() also fails. Is this just me, or is this an issue with
FreeBSD?

#!/usr/bin/perl -w

use strict;
use Digest::MD5;
use File::Find;
use Data::Dumper;

my %md5sums = ();

foreach my $dir (@ARGV) {
# Somehow find() does not work in FAT partitions!
find { no_chdir => 1,
wanted => sub {
return unless -f;
# Get relative file name as key
my $file = $_;
$file =~ s/$dir(\/|)*//g;
open my $fh, $_ or
warn "Can't open `$_': $!\n" and return;
$md5sums{$file} =
Digest::MD5->new->addfile($fh)->hexdigest, ' ', $_;
}
}, $dir;
}

print Dumper \%md5sums;

btw, my msdosfs mount in /etc/fstab is as follows:-
/dev/ad0s6 /d msdosfs rw 0
0

Appreciate any pointers. Meanwhile I'll just use find shell command.
Thanks.

--mendonan
 
J

Joe Smith

Senandung said:
Dear group,

I wrote this perl snippet below on FreeBSD-5.2.1, which I find works
in normal UFS -type filesystems, but doesn't work in msdosfs mounts
(File::Find's find() doesn't traverse into directories). The -f test
inside wanted() also fails. Is this just me, or is this an issue with
FreeBSD?

What happens if you set File::Find::dont_use_nlink?

Version 1.06 of File::Find (dated January 2004) has this warning:

=head1 CAVEAT

=over 2

=item $dont_use_nlink

You can set the variable C<$File::Find::dont_use_nlink> to 1, if you want to
force File::Find to always stat directories. This was used for file systems
that do not have an C<nlink> count matching the number of sub-directories.
Examples are ISO-9660 (CD-ROM), AFS, HPFS (OS/2 file system), FAT (DOS file
system) and a couple of others.

You shouldn't need to set this variable, since File::Find should now detect
such file systems on-the-fly and switch itself to using stat. This works even
for parts of your file system, like a mounted CD-ROM.

If you do set C<$File::Find::dont_use_nlink> to 1, you will notice slow-downs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top