Skip Menu |

This queue is for tickets about the Sys-Filesystem CPAN distribution.

Report information
The Basics
Id: 34577
Status: resolved
Priority: 0/
Queue: Sys-Filesystem

People
Owner: Nobody in particular
Requestors: lembark [...] wrkhors.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.22
Fixed in: 1.23



Subject: Module fails on AIX
AIX does not have a static mounts table (e.g., /etc/mtab). The only way to find the mount information necessary for the module to function is via running /usr/sbin/mount. This leaves v/1.22 failing its own tests on AIX (ours is 5.3). This patch adds a current mounts data structure from the output of /usr/ sbin/mount and uses it for the subsequent operations. The udpated code passes all tests on AIX-5.3. The patch also contains some POD describing the data structure used.
Subject: sys-filesystem-1.22.patch
Index: lib/Sys/Filesystem/Aix.pm =================================================================== --- lib/Sys/Filesystem/Aix.pm (revision 26986) +++ lib/Sys/Filesystem/Aix.pm (working copy) @@ -36,6 +36,19 @@ $args{fstab} ||= '/etc/filesystems'; + my %curr_mountz + = map + { + my ( $device, $path, $opts ) + = /^\s/ + ? ( split )[ 0, 1, -1 ] + : ( split )[ 1, 2, -1 ] + ; + + ( $path => [ 'mounted', $device, $opts ] ) + } + qx( /usr/sbin/mount ); + my @fstab_keys = qw(account boot check dev free mount nodename size type vfs vol log); my @special_fs = qw(swap procfs proc tmpfs nfs mntfs autofs); @@ -43,18 +56,34 @@ my $fstab = new FileHandle; if ($fstab->open($args{fstab})) { my $current_filesystem = '*UNDEFINED*'; - while (<$fstab>) { - next if (/^\s*#/ || /^\s*$/); + while (<$fstab>) + { + # skip comments and blank lines. + next if m{^ [*] }x || m{^ \s+ $}x; + # Found a new filesystem group if (/^\s*(.+?):\s*$/) { $current_filesystem = $1; $self->{$current_filesystem}->{filesystem} = $1; + # the filesystem is either currently mounted or is not, + # this does not need to be checked for each individual + # attribute. + + my ( $state, $device, $opts ) + = @{ $curr_mountz{ $current_filesystem } }; + + $state ||= 'unmounted'; + + $self->{ $current_filesystem }{ $state } = 1; + $self->{ $current_filesystem }{ device } = $device; + $self->{ $current_filesystem }{ options } = $opts; + # This matches a filesystem attribute } elsif (my ($key,$value) = $_ =~ /^\s*([a-z]{3,8})\s+=\s+"?(.+)"?\s*$/) { $self->{$current_filesystem}->{$key} = $value; - $self->{$current_filesystem}->{unmounted} = -1; # Unknown mount state? +# $self->{$current_filesystem}->{unmounted} = -1; # Unknown mount state? if ($key eq 'vfs') { if (grep(/^$value$/, @special_fs)) { $self->{$current_filesystem}->{special} = 1; @@ -167,6 +196,66 @@ L<perlgirl.org.uk> +=head2 Example /etc/filesystems + + + * @(#)filesystems @(#)29 1.22 src/bos/etc/filesystems/filesystems, cmdfs, bos530 9/8/00 13:57:45 + * IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * <snip> + * + * This version of /etc/filesystems assumes that only the root file system + * is created and ready. As new file systems are added, change the check, + * mount, free, log, vol and vfs entries for the appropriate stanza. + + /: + dev = /dev/hd4 + vol = "root" + mount = automatic + check = false + free = true + vfs = jfs2 + log = /dev/hd8 + type = bootfs + + /proc: + dev = /proc + vol = "/proc" + mount = true + check = false + free = false + vfs = procfs + + /scratch: + dev = /dev/fslv02 + vfs = jfs2 + log = INLINE + mount = true + account = false + + +=head2 Example /usr/sbin/mount output + + + node mounted mounted over vfs date options + -------- --------------- --------------- ------ ------------ --------------- + /dev/hd4 / jfs2 Mar 24 12:14 rw,log=/dev/hd8 + /proc /proc procfs Mar 24 12:15 rw + /dev/fslv02 /scratch jfs2 Mar 24 12:15 rw,log=INLINE + + +=head1 SEE ALSO + +=over4 + +=item filesystems(4) + +Manpage includes all known options, describes the format +and comment char's. + +=back + =head1 COPYRIGHT Copyright 2004,2005,2006 Nicola Worthington.
The patch fails if not all file systems are mounted, too. I fixed the patch from OP in hope to fit his intension.
--- lib/Sys/Filesystem/Aix.pm.orig 2006-06-01 21:10:48.000000000 +0200 +++ lib/Sys/Filesystem/Aix.pm 2008-10-16 16:07:33.000000000 +0200 @@ -36,6 +36,19 @@ $args{fstab} ||= '/etc/filesystems'; + my %curr_mountz + = map + { + my ( $device, $path, $opts ) + = /^\s/ + ? ( split )[ 0, 1, -1 ] + : ( split )[ 1, 2, -1 ] + ; + + ( $path => [ 'mounted', $device, $opts ] ) + } + qx( /usr/sbin/mount ); + my @fstab_keys = qw(account boot check dev free mount nodename size type vfs vol log); my @special_fs = qw(swap procfs proc tmpfs nfs mntfs autofs); @@ -43,18 +56,35 @@ my $fstab = new FileHandle; if ($fstab->open($args{fstab})) { my $current_filesystem = '*UNDEFINED*'; - while (<$fstab>) { - next if (/^\s*#/ || /^\s*$/); + while (<$fstab>) + { + # skip comments and blank lines. + + next if m{^ [*] }x || m{^ \s+ $}x; # Found a new filesystem group if (/^\s*(.+?):\s*$/) { $current_filesystem = $1; $self->{$current_filesystem}->{filesystem} = $1; + # the filesystem is either currently mounted or is not, + # this does not need to be checked for each individual + # attribute. + + my ( $state, $device, $opts ); + ( $state, $device, $opts ) = @{ $curr_mountz{ $current_filesystem } } + if( defined( $curr_mountz{ $current_filesystem } ) ); + + $state ||= 'unmounted'; + + $self->{ $current_filesystem }{ $state } = 1; + $self->{ $current_filesystem }{ device } = $device; + $self->{ $current_filesystem }{ options } = $opts; + # This matches a filesystem attribute } elsif (my ($key,$value) = $_ =~ /^\s*([a-z]{3,8})\s+=\s+"?(.+)"?\s*$/) { $self->{$current_filesystem}->{$key} = $value; - $self->{$current_filesystem}->{unmounted} = -1; # Unknown mount state? +# $self->{$current_filesystem}->{unmounted} = -1; # Unknown mount state? if ($key eq 'vfs') { if (grep(/^$value$/, @special_fs)) { $self->{$current_filesystem}->{special} = 1; @@ -167,6 +197,66 @@ L<perlgirl.org.uk> +=head2 Example /etc/filesystems + + + * @(#)filesystems @(#)29 1.22 src/bos/etc/filesystems/filesystems, cmdfs, bos530 9/8/00 13:57:45 + * IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * <snip> + * + * This version of /etc/filesystems assumes that only the root file system + * is created and ready. As new file systems are added, change the check, + * mount, free, log, vol and vfs entries for the appropriate stanza. + + /: + dev = /dev/hd4 + vol = "root" + mount = automatic + check = false + free = true + vfs = jfs2 + log = /dev/hd8 + type = bootfs + + /proc: + dev = /proc + vol = "/proc" + mount = true + check = false + free = false + vfs = procfs + + /scratch: + dev = /dev/fslv02 + vfs = jfs2 + log = INLINE + mount = true + account = false + + +=head2 Example /usr/sbin/mount output + + + node mounted mounted over vfs date options + -------- --------------- --------------- ------ ------------ --------------- + /dev/hd4 / jfs2 Mar 24 12:14 rw,log=/dev/hd8 + /proc /proc procfs Mar 24 12:15 rw + /dev/fslv02 /scratch jfs2 Mar 24 12:15 rw,log=INLINE + + +=head1 SEE ALSO + +=over4 + +=item filesystems(4) + +Manpage includes all known options, describes the format +and comment char's. + +=back + =head1 COPYRIGHT Copyright 2004,2005,2006 Nicola Worthington.
It's fixed now