\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 "
\n",
- defined($options{"nosuid"}) ? "" : "checked";
- }
-if ($_[0] eq "pcfs") {
- # Solaris pcfs for for FAT filesystems. It doesn't have many options
- 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 "
\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