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:umper;
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
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:umper;
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