From 938fa45c8d815d7bfe93074bd0ef0cc3ca2185af Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 12 May 2012 14:52:47 -0700 Subject: [PATCH] Module doesn't even support osf-1, so no need for ui-related functions --- mount/osf1-lib.pl | 1046 --------------------------------------------- 1 file changed, 1046 deletions(-) diff --git a/mount/osf1-lib.pl b/mount/osf1-lib.pl index 8833ad386..435199e1a 100755 --- a/mount/osf1-lib.pl +++ b/mount/osf1-lib.pl @@ -314,824 +314,6 @@ return ($_[0] eq "nfs" || $_[0] eq "tmpfs" || $_[0] eq "cachefs" || $_[0] eq "autofs" || $_[0] eq "lofs" || $_[0] eq "rumba"); } - -# generate_location(type, location) -# Output HTML for editing the mount location of some filesystem. -sub generate_location -{ -if ($_[0] eq "nfs") { - # NFS mount from some host and directory - if ($_[1] =~ /^nfs:/) { $nfsmode = 2; } - elsif (!$_[1] || $_[1] =~ /^([A-z0-9\-\.]+):([^,]+)$/) { - $nfsmode = 0; $nfshost = $1; $nfspath = $2; - } - else { $nfsmode = 1; } - if ($gconfig{'os_version'} >= 2.6) { - # Solaris 2.6 can list multiple NFS servers in mount - print " NFS Source\n"; - printf "\n", - $nfsmode == 0 ? "checked" : ""; - print "NFS Hostname\n"; - print "\n"; - print &nfs_server_chooser_button("nfs_host"); - print " NFS Directory\n"; - print "\n"; - print &nfs_export_chooser_button("nfs_host", "nfs_dir"); - print " \n"; - - print " \n"; - printf "\n", - $nfsmode == 1 ? "checked" : ""; - print "Multiple NFS Servers\n"; - printf "\n", - $nfsmode == 1 ? $_[1] : ""; - print " \n"; - - if ($gconfig{'os_version'} >= 7) { - print " \n"; - printf "\n", - $nfsmode == 2 ? "checked" : ""; - print "WebNFS URL \n"; - printf "\n", - $nfsmode == 2 ? $_[1] : ""; - print " \n"; - } - } - else { - print " NFS Hostname\n"; - print "\n"; - print &nfs_server_chooser_button("nfs_host"); - print "\n"; - print "NFS Directory\n"; - print "\n"; - print &nfs_export_chooser_button("nfs_host", "nfs_dir"); - print " \n"; - } - } -elsif ($_[0] eq "tmpfs") { - # Location is irrelevant for tmpfs filesystems - } -elsif ($_[0] eq "ufs") { - # Mounted from a normal disk, raid (MD) device or from - # somewhere else - print " UFS Disk\n"; - print "\n"; - if ($_[1] =~ /^\/dev\/dsk\/c([0-9]+)t([0-9]+)d([0-9]+)s([0-9]+)$/) { - $ufs_dev = 0; - $scsi_c = $1; $scsi_t = $2; $scsi_d = $3; $scsi_s = $4; - } - elsif ($_[1] eq "") { - $ufs_dev = 0; $scsi_c = $scsi_t = $scsi_s = $scsi_d = 0; - } - elsif ($_[1] =~ /^\/dev\/md\/dsk\/d([0-9]+)$/) { - $ufs_dev = 1; $scsi_md = $1; - } - else { - $ufs_dev = 2; $scsi_path = $_[1]; - } - printf " SCSI Disk:\n", - $ufs_dev == 0 ? "checked" : ""; - print "Controller \n"; - print "Target \n"; - print "Unit \n"; - print "Partition
\n"; - - printf " RAID Device:\n", - $ufs_dev == 1 ? "checked" : ""; - print "Unit
\n"; - - printf " Other Device:\n", - $ufs_dev == 2 ? "checked" : ""; - print "
\n"; - print " \n"; - } -elsif ($_[0] eq "swap") { - # Swapping to a disk partition or a file - print " Swap File\n"; - print "\n"; - if ($_[1] =~ /^\/dev\/dsk\/c([0-9]+)t([0-9]+)d([0-9]+)s([0-9]+)$/) { - $swap_dev = 0; - $scsi_c = $1; $scsi_t = $2; $scsi_d = $3; $scsi_s = $4; - } - elsif ($_[1] eq "") { - $swap_dev = 1; $scsi_path = ""; - } - else { - $swap_dev = 1; $scsi_path = $_[1]; - } - printf " SCSI Disk:\n", - $swap_dev == 0 ? "checked" : ""; - print "Controller \n"; - print "Target \n"; - print "Unit \n"; - print "Partition
\n"; - - printf " File:\n", - $swap_dev == 1 ? "checked" : ""; - print "
\n"; - print " \n"; - } -elsif ($_[0] eq "hsfs") { - # Mounting a SCSI cdrom - print " CDROM Disk\n"; - print "\n"; - if ($_[1] =~ /^\/dev\/dsk\/c([0-9]+)t([0-9]+)d([0-9]+)s([0-9]+)$/) { - $hsfs_dev = 0; - $scsi_c = $1; $scsi_t = $2; $scsi_d = $3; $scsi_s = $4; - } - elsif ($_[1] eq "") { - $hsfs_dev = 0; - $scsi_c = 0; $scsi_t = 6; $scsi_d = 0; $scsi_s = 0; - } - else { - $hsfs_dev = 1; $scsi_path = $_[1]; - } - printf " SCSI Device:\n", - $hsfs_dev == 0 ? "checked" : ""; - print "Controller \n"; - print "Target \n"; - print "Unit \n"; - print "Partition
\n"; - - printf " Other Device:\n", - $hsfs_dev == 1 ? "checked" : ""; - print "
\n"; - print " \n"; - } -elsif ($_[0] eq "pcfs") { - # Mounting a SCSI msdos filesystem - print " MS-DOS Disk\n"; - print "\n"; - if ($_[1] =~ /^\/dev\/dsk\/c([0-9]+)t([0-9]+)d([0-9]+)s([0-9]+)$/) { - $pcfs_dev = 0; - $scsi_c = $1; $scsi_t = $2; $scsi_d = $3; $scsi_s = $4; - } - elsif ($_[1] eq "") { - $pcfs_dev = 1; $scsi_path = ""; - } - else { - $pcfs_dev = 1; $scsi_path = $_[1]; - } - printf " SCSI Device:\n", - $pcfs_dev == 0 ? "checked" : ""; - print "Controller \n"; - print "Target \n"; - print "Unit \n"; - print "Partition
\n"; - - printf " Other Device:\n", - $pcfs_dev == 1 ? "checked" : ""; - print "
\n"; - print " \n"; - } -elsif ($_[0] eq "lofs") { - # Mounting some directory to another location - print " Original Directory\n"; - print "\n"; - print &file_chooser_button("lofs_src", 1); - print " \n"; - } -elsif ($_[0] eq "cachefs") { - # Mounting a cached filesystem of some type.. need a location for - # the source of the mount - print " Cache Source\n"; - print " \n"; - } -elsif ($_[0] eq "autofs") { - # An automounter entry.. can be -hosts, -xfn or from some mapping - print " Automounter map\n"; - printf "\n", - $_[1] eq "-hosts" || $_[1] eq "-xfn" ? "" : "checked"; - printf "Use map
\n", - $_[1] eq "-hosts" || $_[1] eq "-xfn" ? "" : $_[1]; - printf "\n", - $_[1] eq "-hosts" ? "checked" : ""; - print "All NFS exports map
\n"; - printf "\n", - $_[1] eq "-xfn" ? "checked" : ""; - print "Federated Naming Service map \n"; - } -elsif ($_[0] eq "rumba") { - # Windows filesystem - $_[1] =~ /^\\\\(.*)\\(.*)$/; - print " Server Name\n"; - print "\n"; - print &smb_server_chooser_button("rumba_server"); - print "\n"; - print "Share Name\n"; - print "\n"; - print &smb_share_chooser_button("rumba_server", "rumba_share"); - print " \n"; - } -} - - -# generate_options(type, newmount) -# Output HTML for editing mount options for a partilcar filesystem -# under this OS -sub generate_options -{ -if ($_[0] eq "nfs") { - # Solaris NFS has many options, not all of which are editable here - print " Read-Only?\n"; - printf " Yes\n", - defined($options{"ro"}) ? "checked" : ""; - printf " No\n", - defined($options{"ro"}) ? "" : "checked"; - - print "Disallow setuid programs?\n"; - printf " Yes\n", - defined($options{"nosuid"}) ? "checked" : ""; - printf " No \n", - defined($options{"nosuid"}) ? "" : "checked"; - - print " Files inherit parent GID?\n"; - printf " Yes\n", - defined($options{"grpid"}) ? "" : "checked"; - printf " No\n", - defined($options{"grpid"}) ? "checked" : ""; - - print "Return error on timeouts?\n"; - printf " Yes\n", - defined($options{"soft"}) ? "checked" : ""; - printf " No \n", - defined($options{"soft"}) ? "" : "checked"; - - print " Retry mounts in background?\n"; - printf " Yes\n", - defined($options{"bg"}) ? "checked" : ""; - printf " No\n", - defined($options{"bg"}) ? "" : "checked"; - - print "Display quotas?\n"; - printf " Yes\n", - defined($options{"quota"}) ? "checked" : ""; - printf " No \n", - defined($options{"quota"}) ? "" : "checked"; - - print " Allow user interrupt?\n"; - printf " Yes\n", - defined($options{"nointr"}) ? "" : "checked"; - printf " No\n", - defined($options{"nointr"}) ? "checked" : ""; - - print "NFS version\n"; - printf " Highest\n", - defined($options{"vers"}) ? "" : "checked"; - printf "\n", - defined($options{"vers"}) ? "checked" : ""; - print " \n"; - - print " Protocol\n"; - print "\n"; - - print "NFS Port\n"; - printf " Default\n", - defined($options{"port"}) ? "" : "checked"; - printf "\n", - defined($options{"port"}) ? "checked" : ""; - print " \n"; - - print " Timeout\n"; - printf " Default\n", - defined($options{"timeo"}) ? "" : "checked"; - printf "\n", - defined($options{"timeo"}) ? "checked" : ""; - printf "\n"; - - print "Number of Retransmissions\n"; - printf " Default\n", - defined($options{"retrans"}) ? "" : "checked"; - printf "\n", - defined($options{"retrans"}) ? "checked" : ""; - print " \n"; - - print " Authentication\n"; - $nfs_auth = $options{'sec'} ? $options{'sec'} : - defined($options{"secure"}) ? "dh" : - defined($options{"kerberos"}) ? "krb" : ""; - print "\n"; - - if ($gconfig{'os_version'} >= 7) { - print "WebNFS mount? \n"; - printf " Yes\n", - defined($options{'public'}) ? "checked" : ""; - printf " No\n", - defined($options{'public'}) ? "" : "checked"; - print "\n"; - } - print "\n"; - } -if ($_[0] eq "ufs") { - # Solaris UFS also has many options, not all of which are here - print " Read-Only?\n"; - printf " Yes\n", - defined($options{"ro"}) ? "checked" : ""; - printf " No\n", - defined($options{"ro"}) ? "" : "checked"; - - print "Disallow setuid programs?\n"; - printf " Yes\n", - defined($options{"nosuid"}) ? "checked" : ""; - printf " No \n", - defined($options{"nosuid"}) ? "" : "checked"; - - print " Allow user interrupt?\n"; - printf " Yes\n", - defined($options{"nointr"}) ? "" : "checked"; - printf " No\n", - defined($options{"nointr"}) ? "checked" : ""; - - print "Enable quotas at boot time?\n"; - printf " Yes\n", - defined($options{"quota"}) || defined($options{"rq"}) ? - "checked" : ""; - printf " No \n", - defined($options{"quota"}) || defined($options{"rq"}) ? - "" : "checked"; - - print " Action on error\n"; - print "\n"; - - print "Repair Delay\n"; - $options{toosoon} =~ /([0-9]+)([A-z])/; - print "\n"; - print " \n"; - - if ($gconfig{'os_version'} >= 7) { - print " Update access times? \n"; - printf " Yes\n", - defined($options{'noatime'}) ? "" : "checked"; - printf " No\n", - defined($options{'noatime'}) ? "checked" : ""; - print "\n"; - - print "Force direct IO? \n"; - printf " Yes\n", - defined($options{'forcedirectio'}) ? "checked" : ""; - printf " No\n", - defined($options{'forcedirectio'}) ? "" : "checked"; - print " \n"; - - print " Allow large files? \n"; - printf " Yes\n", - defined($options{'nolargefiles'}) ? "" : "checked"; - printf " No\n", - defined($options{'nolargefiles'}) ? "checked" : ""; - print "\n"; - - print "Enabled logging? \n"; - printf " Yes\n", - defined($options{'logging'}) ? "checked" : ""; - printf " No\n", - defined($options{'logging'}) ? "" : "checked"; - print " \n"; - } - } -if ($_[0] eq "hsfs") { - # Solaris hsfs is used for CDROMs - print " Ignore Unix attributes?\n"; - printf " Yes\n", - defined($options{"nrr"}) ? "checked" : ""; - printf " No\n", - defined($options{"nrr"}) ? "" : "checked"; - - print "Ignore trailing dot?\n"; - printf " Yes\n", - defined($options{"notraildot"}) ? "checked" : ""; - printf " No \n", - defined($options{"notraildot"}) ? "" : "checked"; - - print " Use lower case?\n"; - printf " Yes\n", - defined($options{"nomaplcase"}) ? "" : "checked"; - printf " No\n", - defined($options{"nomaplcase"}) ? "checked" : ""; - - print "Disallow setuid programs?\n"; - printf" Yes\n", - defined($options{"nosuid"}) ? "checked" : ""; - printf " No \n", - defined($options{"nosuid"}) ? "" : "checked"; - } -if ($_[0] eq "pcfs") { - # Solaris pcfs for for FAT filesystems. It doesn't have many options - print " Read Only? \n"; - printf " Yes\n", - defined($options{"ro"}) ? "checked" : ""; - printf " No\n", - defined($options{"ro"}) ? "" : "checked"; - - if ($gconfig{'os_version'} >= 7) { - print "Force lower case? \n"; - printf " Yes\n", - defined($options{'foldcase'}) ? "checked" : ""; - printf " No\n", - defined($options{'foldcase'}) ? "" : "checked"; - print "\n"; - } - else { - print " \n"; - } - } -if ($_[0] eq "lofs") { - # No options as far as I know - print " No Options Available \n"; - } -if ($_[0] eq "tmpfs") { - # Solaris tmpfs (virtual memory) filesystem. Only one option - print " Size   \n"; - printf" Maximum\n", - defined($options{"size"}) ? "" : "checked"; - printf"  \n", - defined($options{"size"}) ? "checked" : ""; - ($tmpsz = $options{size}) =~ s/[A-z]+$//g; - print "\n"; - print "\n"; - print " \n"; - } -if ($_[0] eq "swap") { - # Solaris swap has no options - print " No Options Available \n"; - } -if ($_[0] eq "cachefs") { - # The caching filesystem has lots of options.. cachefs mounts can - # be of an existing 'manually' mounted back filesystem, or of a - # back-filesystem that has been automatically mounted by the cache. - # The user should never see the automatic mountings made by cachefs. - print " Real filesystem type\n"; - print "\n"; - - print "Real mount point\n"; - printf" Automatic\n", - defined($options{"backpath"}) ? "" : "checked"; - printf "\n", - defined($options{"backpath"}) ? "checked" : ""; - print " \n"; - - print " Cache directory\n"; - printf "\n", - defined($options{"cachedir"}) ? $options{"cachedir"} : "/cache"; - - print "Write mode\n"; - printf" Write-around\n", - defined($options{"non-shared"}) ? "" : "checked"; - printf " Non-shared\n", - defined($options{"non-shared"}) ? "checked" : ""; - print " \n"; - - print " Consistency check\n"; - print "\n"; - - print "Check permissions in cache?\n"; - printf " Yes\n", - defined($options{"local-access"}) ? "checked" : ""; - printf " No \n", - defined($options{"local-access"}) ? "" : "checked"; - - print " Read-Only?\n"; - printf " Yes\n", - defined($options{"ro"}) ? "checked" : ""; - printf " No\n", - defined($options{"ro"}) ? "" : "checked"; - - print "Disallow setuid programs?\n"; - printf " Yes\n", - defined($options{"nosuid"}) ? "checked" : ""; - printf " No \n", - defined($options{"nosuid"}) ? "" : "checked"; - } -if ($_[0] eq "autofs") { - # Autofs has lots of options, depending on the type of file - # system being automounted.. the fstype options determines this - local($fstype); - $fstype = $options{fstype} eq "" ? "nfs" : $options{fstype}; - if ($gconfig{'os_version'} >= 2.6) { - print " Browsing enabled? \n"; - printf " Yes\n", - defined($options{'nobrowse'}) ? "" : "checked"; - printf " No\n", - defined($options{'nobrowse'}) ? "checked" : ""; - print " \n"; - } - &generate_options($fstype); - print "\n"; - } -if ($_[0] eq "rumba") { - # SMB filesystems have a few options.. - print " Server Hostname\n"; - printf " Automatic\n", - defined($options{"machinename"}) ? "" : "checked"; - printf "\n", - defined($options{"machinename"}) ? "checked" : ""; - print "\n"; - - print "Client Name\n"; - printf " Automatic\n", - defined($options{"clientname"}) ? "" : "checked"; - printf "\n", - defined($options{"clientname"}) ? "checked" : ""; - print " \n"; - - print " Login Name\n"; - print "\n"; - - print "Login Password\n"; - print " \n"; - - print " User files are owned by\n"; - printf "\n", - defined($options{'uid'}) ? getpwuid($options{'uid'}) : ""; - print &user_chooser_button("rumba_uid", 0),"\n"; - - print "Group files are owned by\n"; - printf "\n", - defined($options{'gid'}) ? getgrgid($options{'gid'}) : ""; - print &group_chooser_button("rumba_gid", 0),"\n"; - - print " File permissions\n"; - printf "\n", - defined($options{fmode}) ? $options{fmode} : "755"; - - print "Directory permissions\n"; - printf " \n", - defined($options{dmode}) ? $options{dmode} : "755"; - - print " Read/write access is safe?\n"; - printf" Yes\n", - defined($options{"readwrite"}) ? "checked" : ""; - printf " No\n", - defined($options{"readwrite"}) ? "" : "checked"; - - print "Files can be read-only?\n"; - printf" Yes\n", - defined($options{"readonly"}) ? "checked" : ""; - printf " No \n", - defined($options{"readonly"}) ? "" : "checked"; - - print " Send password in upper case?\n"; - printf" Yes\n", - defined($options{"noupper"}) ? "" : "checked"; - printf " No\n", - defined($options{"noupper"}) ? "checked" : ""; - - print "Use attrE commands?\n"; - printf" Yes\n", - defined($options{"attr"}) ? "checked" : ""; - printf " No \n", - defined($options{"attr"}) ? "" : "checked"; - } -} - - -# check_location(type) -# Parse and check inputs from %in, calling &error() if something is wrong. -# Returns the location string for storing in the fstab file -sub check_location -{ -if ($_[0] eq "nfs") { - local($out, $temp, $mout, $dirlist); - - if ($in{'nfs_serv'} == 1) { - # multiple servers listed.. assume the user has a brain - return $in{'nfs_list'}; - } - elsif ($in{'nfs_serv'} == 2) { - # NFS url.. check syntax - if ($in{'nfs_url'} !~ /^nfs:\/\/([^\/ ]+)(\/([^\/ ]*))?$/) { - &error("'$in{'nfs_url'}' is not a valid NFS URL"); - } - return $in{'nfs_url'}; - } - - # Use dfshares to see if the host exists and is up - if ($in{nfs_host} !~ /^\S+$/) { - &error("'$in{nfs_host}' is not a valid hostname"); - } - $out = &backquote_command("dfshares '$in{nfs_host}' 2>&1"); - if ($out =~ /Unknown host/) { - &error("The host '$in{nfs_host}' does not exist"); - } - elsif ($out =~ /Timed out/) { - &error("The host '$in{nfs_host}' is down or does not ". - "support NFS"); - } - elsif ($out =~ /Program not registered/) { - &error("The host '$in{nfs_host}' does not support NFS"); - } - - # Try a test mount to see if filesystem is available - foreach (split(/\n/, $out)) { - if (/^\s*([^ :]+):(\/\S+)\s+/) { $dirlist .= "$2\n"; } - } - if ($in{nfs_dir} !~ /^\S+$/) { - &error("'$in{nfs_dir}' is not a valid directory name. The ". - "available directories on $in{nfs_host} are:". - "
$dirlist
"); - } - $temp = &transname(); - &make_dir($temp, 0755); - $mout = &backquote_command("mount $in{nfs_host}:$in{nfs_dir} $temp 2>&1"); - if ($mout =~ /No such file or directory/) { - rmdir($temp); - &error("The directory '$in{nfs_dir}' does not exist on the ". - "host $in{nfs_host}. The available directories are:". - "
$dirlist
"); - } - elsif ($mout =~ /Permission denied/) { - rmdir($temp); - &error("This host is not allowed to mount the directory ". - "$in{nfs_dir} from $in{nfs_host}"); - } - elsif ($?) { - rmdir($temp); - &error("NFS Error - $mout"); - } - # It worked! unmount - &execute_command("umount $temp"); - &unlink_file($temp); - return "$in{nfs_host}:$in{nfs_dir}"; - } -elsif ($_[0] eq "ufs") { - # Get the device name - if ($in{ufs_dev} == 0) { - $in{ufs_c} =~ /^[0-9]+$/ || - &error("'$in{ufs_c}' is not a valid SCSI controller"); - $in{ufs_t} =~ /^[0-9]+$/ || - &error("'$in{ufs_t}' is not a valid SCSI target"); - $in{ufs_d} =~ /^[0-9]+$/ || - &error("'$in{ufs_d}' is not a valid SCSI unit"); - $in{ufs_s} =~ /^[0-9]+$/ || - &error("'$in{ufs_s}' is not a valid SCSI partition"); - $dv = "/dev/dsk/c$in{ufs_c}t$in{ufs_t}d$in{ufs_d}s$in{ufs_s}"; - } - elsif ($in{ufs_dev} == 1) { - $in{ufs_md} =~ /^[0-9]+$/ || - &error("'$in{ufs_md}' is not a valid RAID unit"); - $dv = "/dev/md/dsk/d$in{ufs_md}"; - } - else { - $in{ufs_path} =~ /^\/\S+$/ || - &error("'$in{ufs_path}' is not a valid pathname"); - $dv = $in{ufs_path}; - } - - &fstyp_check($dv, "ufs"); - return $dv; - } -elsif ($_[0] eq "lofs") { - # Get and check the original directory - $dv = $in{'lofs_src'}; - if (!(-r $dv)) { &error("'$in{lofs_src}' does not exist"); } - if (!(-d $dv)) { &error("'$in{lofs_src}' is not a directory"); } - return $dv; - } -elsif ($_[0] eq "swap") { - if ($in{swap_dev} == 0) { - $in{swap_c} =~ /^[0-9]+$/ || - &error("'$in{swap_c}' is not a valid SCSI controller"); - $in{swap_t} =~ /^[0-9]+$/ || - &error("'$in{swap_t}' is not a valid SCSI target"); - $in{swap_d} =~ /^[0-9]+$/ || - &error("'$in{swap_d}' is not a valid SCSI unit"); - $in{swap_s} =~ /^[0-9]+$/ || - &error("'$in{swap_s}' is not a valid SCSI partition"); - $dv="/dev/dsk/c$in{swap_c}t$in{swap_t}d$in{swap_d}s$in{swap_s}"; - } - else { $dv = $in{swap_path}; } - - if (!open(SWAPFILE, $dv)) { - if ($! =~ /No such file/ && $in{swap_dev}) { - if ($dv !~ /^\/dev/) { - &swap_form($dv); - } - else { - &error("The swap file '$dv' does not exist"); - } - } - elsif ($! =~ /No such file/) { - &error("The SCSI target '$in{swap_t}' does not exist"); - } - elsif ($! =~ /No such device or address/) { - &error("The partition '$in{swap_s}' does not exist"); - } - else { - &error("Failed to open '$dv' : $!"); - } - } - close(SWAPFILE); - return $dv; - } -elsif ($_[0] eq "tmpfs") { - # Ram-disk filesystems have no location - return "swap"; - } -elsif ($_[0] eq "cachefs") { - # In order to check the location for the caching filesystem, we need - # to check the back filesystem - if (!$in{cfs_noback}) { - # The back filesystem is manually mounted.. hopefully - local($bidx, @mlist, @binfo); - $bidx = &get_mounted($in{cfs_backpath}, "*"); - if ($bidx < 0) { - &error("The back filesystem '$in{cfs_backpath}' is ". - "not mounted"); - } - @mlist = &list_mounted(); - @binfo = @{$mlist[$bidx]}; - if ($binfo[2] ne $in{cfs_backfstype}) { - &error("The back filesystem is '$binfo[2]', not ". - "'$in{cfs_backfstype}'"); - } - } - else { - # Need to automatically mount the back filesystem.. check - # it for sanity first. - # But HOW? - $in{cfs_src} =~ /^\S+$/ || - &error("'$in{cfs_src}' is not a valid cache source"); - } - return $in{cfs_src}; - } -elsif ($_[0] eq "autofs") { - # An autofs filesystem can be either mounted from the special - # -hosts and -xfn maps, or from a normal map. The map can be a file - # name (if it starts with /), or an NIS map (if it doesn't) - if ($in{autofs_type} == 0) { - # Normal map - $in{autofs_map} =~ /\S/ || - &error("You did not enter an automount map name"); - if ($in{autofs_map} =~ /^\// && !(-r $in{autofs_map})) { - &error("The map file '$in{autofs_map}' does not exist"); - } - return $in{autofs_map}; - } - elsif ($in{autofs_type} == 1) { - # Special hosts map (automount all shares from some host) - return "-hosts"; - } - else { - # Special FNS map (not sure what this does) - return "-xfn"; - } - } -elsif ($_[0] eq "rumba") { - # Cannot check much here.. - return "\\\\$in{rumba_server}\\$in{rumba_share}"; - } -} - - # fstyp_check(device, type) # Check if some device exists, and contains a filesystem of the given type, # using the fstyp command. @@ -1195,234 +377,6 @@ else { } } - -# check_options(type) -# Read options for some filesystem from %in, and use them to update the -# %options array. Options handled by the user interface will be set or -# removed, while unknown options will be left untouched. -sub check_options -{ -local($k, @rv); -if ($_[0] eq "nfs") { - # NFS has lots of options to parse - if ($in{'nfs_ro'}) { - # Read-only - $options{"ro"} = ""; delete($options{"rw"}); - } - else { - # Read-write - $options{"rw"} = ""; delete($options{"ro"}); - } - - delete($options{'quota'}); delete($options{'noquota'}); - if ($in{'nfs_quota'}) { $options{'quota'} = ""; } - - delete($options{"nosuid"}); delete($options{"suid"}); - if ($in{nfs_nosuid}) { $options{"nosuid"} = ""; } - - delete($options{"grpid"}); - if ($in{nfs_grpid}) { $options{"grpid"} = ""; } - - delete($options{"soft"}); delete($options{"hard"}); - if ($in{nfs_soft}) { $options{"soft"} = ""; } - - delete($options{"bg"}); delete($options{"fg"}); - if ($in{nfs_bg}) { $options{"bg"} = ""; } - - delete($options{"intr"}); delete($options{"nointr"}); - if ($in{nfs_nointr}) { $options{"nointr"} = ""; } - - delete($options{"vers"}); - if (!$in{nfs_vers_def}) { $options{"vers"} = $in{nfs_vers}; } - - delete($options{"proto"}); - if ($in{nfs_proto} ne "") { $options{"proto"} = $in{nfs_proto}; } - - delete($options{"port"}); - if (!$in{nfs_port_def}) { $options{"port"} = $in{nfs_port}; } - - delete($options{"timeo"}); - if (!$in{nfs_timeo_def}) { $options{"timeo"} = $in{nfs_timeo}; } - - delete($options{"secure"}); delete($options{"kerberos"}); - delete($options{"sec"}); - if ($gconfig{'os_version'} >= 2.6) { - if ($in{'nfs_auth'}) { $options{'sec'} = $in{'nfs_auth'}; } - } - else { - if ($in{'nfs_auth'} eq "dh") { $options{"secure"} = ""; } - elsif ($in{'nfs_auth'} eq "krb") { $options{"kerberos"} = ""; } - } - - if ($gconfig{'os_version'} >= 7) { - delete($options{'public'}); - $options{'public'} = "" if ($in{'nfs_public'}); - } - } -elsif ($_[0] eq "ufs") { - # UFS also has lots of options.. - if ($in{ufs_ro}) { - # read-only (and thus no quota) - $options{"ro"} = ""; delete($options{"rw"}); - delete($options{"rq"}); delete($options{"quota"}); - } - elsif ($in{ufs_quota}) { - # read-write, with quota - delete($options{"ro"}); $options{"rw"} = ""; - $options{"quota"} = ""; - } - else { - # read-write, without quota - delete($options{"ro"}); $options{"rw"} = ""; - delete($options{"quota"}); - } - - delete($options{"nosuid"}); - if ($in{ufs_nosuid}) { $options{"nosuid"} = ""; } - - delete($options{"intr"}); delete($options{"nointr"}); - if ($in{ufs_nointr}) { $options{"nointr"} = ""; } - - delete($options{"onerror"}); - if ($in{ufs_onerror} ne "panic") { - $options{"onerror"} = $in{ufs_onerror}; - } - - delete($options{"toosoon"}); - if ($in{ufs_toosoon_time}) { - $options{"toosoon"} = $in{ufs_toosoon_time}. - $in{ufs_toosoon_units}; - } - if ($gconfig{'os_version'} >= 7) { - delete($options{'noatime'}); - $options{'noatime'} = "" if ($in{'ufs_noatime'}); - - delete($options{'forcedirectio'}); - delete($options{'noforcedirectio'}); - $options{'forcedirectio'} = "" if ($in{'ufs_force'}); - - delete($options{'nolargefiles'});delete($options{'largefiles'}); - $options{'nolargefiles'} = "" if ($in{'ufs_nolarge'}); - - delete($options{'logging'}); delete($options{'nologging'}); - $options{'logging'} = "" if ($in{'ufs_logging'}); - } - } -elsif ($_[0] eq "lofs") { - # Loopback has no options to parse - } -elsif ($_[0] eq "swap") { - # Swap has no options to parse - } -elsif ($_[0] eq "pcfs") { - # PCFS has only 2 options - delete($options{'ro'}); delete($options{'rw'}); - $options{'ro'} = "" if ($in{'pcfs_rp'}); - - delete($options{'foldcase'}); delete($options{'nofoldcase'}); - $options{'foldcase'} = "" if ($in{'pcfs_foldcase'}); - } -elsif ($_[0] eq "tmpfs") { - # Ram-disk filesystems have only one option - delete($options{"size"}); - if (!$in{"tmpfs_size_def"}) { - $options{"size"} = "$in{tmpfs_size}$in{tmpfs_unit}"; - } - } -elsif ($_[0] eq "cachefs") { - # The caching filesystem has lots of options - $options{"backfstype"} = $in{"cfs_backfstype"}; - - delete($options{"backpath"}); - if (!$in{"cfs_noback"}) { - # A back filesystem was given.. (alreadys checked) - $options{"backpath"} = $in{"cfs_backpath"}; - } - - if ($in{"cfs_cachedir"} !~ /^\/\S+/) { - &error("'$in{cfs_cachedir}' is not a valid cache directory"); - } - $options{"cachedir"} = $in{"cfs_cachedir"}; - - delete($options{"write-around"}); delete($options{"non-shared"}); - if ($in{"cfs_wmode"}) { - $options{"non-shared"} = ""; - } - - delete($options{"noconst"}); delete($options{"demandconst"}); - if ($in{"cfs_con"} == 0) { $options{"noconst"} = ""; } - elsif ($in{"cfs_con"} == 2) { $options{"demandconst"} = ""; } - - delete($options{"ro"}); delete($options{"rw"}); - if ($in{"cfs_ro"}) { $options{"ro"} = ""; } - - delete($options{"suid"}); delete($options{"nosuid"}); - if ($in{"cfs_nosuid"}) { $options{"nosuid"} = ""; } - } -elsif ($_[0] eq "autofs") { - # The options for autofs depend on the type of the automounted - # filesystem.. - $options{"fstype"} = $in{"autofs_fstype"}; - if ($gconfig{'os_version'} >= 2.6) { - delete($options{'nobrowse'}); delete($options{'browse'}); - $options{'nobrowse'} = "" if ($in{'auto_nobrowse'}); - } - return &check_options($options{"fstype"}); - } -elsif ($_[0] eq "rumba") { - # Options for smb filesystems.. - delete($options{machinename}); - if (!$in{rumba_mname_def}) { $options{machinename} = $in{rumba_mname}; } - - delete($options{clientname}); - if (!$in{rumba_cname_def}) { $options{clientname} = $in{rumba_cname}; } - - delete($options{username}); - if ($in{rumba_username}) { $options{username} = $in{rumba_username}; } - - delete($options{password}); - if ($in{rumba_password}) { $options{password} = $in{rumba_password}; } - - delete($options{uid}); - if ($in{rumba_uid} ne "") { $options{uid} = getpwnam($in{rumba_uid}); } - - delete($options{gid}); - if ($in{rumba_gid} ne "") { $options{gid} = getgrnam($in{rumba_gid}); } - - delete($options{fmode}); - if ($in{rumba_fmode} !~ /^[0-7]{3}$/) { - &error("'$in{rumba_fmode}' is not a valid octal file mode"); - } - elsif ($in{rumba_fmode} ne "755") { $options{fmode} = $in{rumba_fmode}; } - - delete($options{dmode}); - if ($in{rumba_dmode} !~ /^[0-7]{3}$/) { - &error("'$in{rumba_dmode}' is not a valid octal directory mode"); - } - elsif ($in{rumba_dmode} ne "755") { $options{dmode} = $in{rumba_dmode}; } - - delete($options{'readwrite'}); - if ($in{'rumba_readwrite'}) { $options{'readwrite'} = ""; } - - delete($options{'readonly'}); - if ($in{'rumba_readonly'}) { $options{'readonly'} = ""; } - - delete($options{'attr'}); - if ($in{'rumba_attr'}) { $options{'attr'} = ""; } - - delete($options{'noupper'}); - if ($in{'rumba_noupper'}) { $options{'noupper'} = ""; } - } - -# Return options string -foreach $k (keys %options) { - if ($options{$k} eq "") { push(@rv, $k); } - else { push(@rv, "$k=$options{$k}"); } - } -return @rv ? join(',' , @rv) : "-"; -} - - # create_swap(path, size, units) # Attempt to create a swap file sub create_swap