1############################################################ 2# 3# $Id: Freebsd.pm 185 2010-07-15 19:25:30Z trevor $ 4# Sys::Filesystem - Retrieve list of filesystems and their properties 5# 6# Copyright 2004,2005,2006 Nicola Worthington 7# Copyright 2009 Jens Rehsack 8# 9# Licensed under the Apache License, Version 2.0 (the "License"); 10# you may not use this file except in compliance with the License. 11# You may obtain a copy of the License at 12# 13# http://www.apache.org/licenses/LICENSE-2.0 14# 15# Unless required by applicable law or agreed to in writing, software 16# distributed under the License is distributed on an "AS IS" BASIS, 17# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18# See the License for the specific language governing permissions and 19# limitations under the License. 20# 21############################################################ 22 23package Sys::Filesystem::Freebsd; 24 25# vim:ts=4:sw=4:tw=78 26 27use strict; 28use warnings; 29use vars qw(@ISA $VERSION); 30 31require Sys::Filesystem::Unix; 32use Carp qw(croak); 33 34$VERSION = '1.30'; 35@ISA = qw(Sys::Filesystem::Unix); 36 37sub version() 38{ 39 return $VERSION; 40} 41 42my @keys = qw(fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno); 43my %special_fs = ( 44 swap => 1, 45 proc => 1, 46 devpts => 1, 47 tmpfs => 1, 48 ); 49 50my $mount_rx = qr|^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)|; 51my $swap_rx = qr|^(/[/\w]+)\s+|; 52 53sub new 54{ 55 ref( my $class = shift ) && croak 'Class name required'; 56 my %args = @_; 57 my $self = bless( {}, $class ); 58 59 $args{fstab} ||= $ENV{PATH_FSTAB} || '/etc/fstab'; 60 61 my @mounts = map { $_ =~ s/[\cI]+/ /g; chomp; $_ } qx( /sbin/mount -p ); 62 $self->readMounts( $mount_rx, [ 0, 1, 2 ], \@keys, \%special_fs, @mounts ); 63 $self->readSwap( $swap_rx, qx( /sbin/swapctl -l ) ); 64 unless ( $self->readFsTab( $args{fstab}, \@keys, [ 0, 1, 2 ], \%special_fs ) ) 65 { 66 croak "Unable to open fstab file ($args{fstab})\n"; 67 } 68 69 $self; 70} 71 721; 73 74# See the fstab(5) manual page for important information on automatic mounts 75# of network filesystems before modifying this file. 76# 77# Device Mountpoint FStype Options Dump Pass# 78#/dev/da0s1b none swap sw 0 0 79#/dev/da1s1b none swap sw 0 0 80#/dev/da0s1a / ufs rw 1 1 81#/dev/da1s1e /home ufs rw 2 2 82#/dev/da0s1e /usr ufs rw 2 2 83#/dev/da1s1f /var ufs rw 2 2 84#/dev/acd0c /cdrom cd9660 ro,noauto 0 0 85#/var/tmp /tmp null rw 0 0 86#proc /proc procfs rw 0 0 87#/etc/portal.conf /p portal rw 0 0 88 89############################################################################### 90# POD 91 92=pod 93 94=head1 NAME 95 96Sys::Filesystem::Freebsd - Return Freebsd filesystem information to Sys::Filesystem 97 98=head1 SYNOPSIS 99 100See L<Sys::Filesystem>. 101 102=head1 INHERITANCE 103 104 Sys::Filesystem::Freebsd 105 ISA Sys::Filesystem::Unix 106 ISA UNIVERSAL 107 108=head1 METHODS 109 110=over 4 111 112=item version () 113 114Return the version of the (sub)module. 115 116=back 117 118=head1 ATTRIBUTES 119 120The following is a list of filesystem properties which may 121be queried as methods through the parent L<Sys::Filesystem> object. 122 123=over 4 124 125=item fs_spec 126 127Describes the block special device or remote filesystem to be mounted. 128 129=item fs_file 130 131Describes the mount point for the filesystem. For swap partitions, 132this field should be specified as none. If the name of the mount 133point contains spaces these can be escaped as \040. 134 135=item fs_vfstype 136 137Dscribes the type of the filesystem. 138 139=item fs_mntops 140 141Describes the mount options associated with the filesystem. 142 143=item fs_freq 144 145Used for these filesystems by the 146L<dump(8)> command to determine which filesystems need to be dumped. 147 148=item fs_passno 149 150Used by the L<fsck(8)> program to determine the order in which filesystem 151checks are done at reboot time. 152 153=back 154 155=head1 SEE ALSO 156 157L<Sys::Filesystem>, L<Sys::Filesystem::Unix>, L<fstab(5)> 158 159=head1 VERSION 160 161$Id: Freebsd.pm 185 2010-07-15 19:25:30Z trevor $ 162 163=head1 AUTHOR 164 165Nicola Worthington <nicolaw@cpan.org> - L<http://perlgirl.org.uk> 166 167Jens Rehsack <rehsack@cpan.org> - L<http://www.rehsack.de> 168 169=head1 COPYRIGHT 170 171Copyright 2004,2005,2006 Nicola Worthington. 172 173Copyright 2009,2010 Jens Rehsack. 174 175This software is licensed under The Apache Software License, Version 2.0. 176 177L<http://www.apache.org/licenses/LICENSE-2.0> 178 179=cut 180 181