#!/usr/local/bin/perl # edit_mount.cgi # Display a form for editing or creating a permanent or temporary mounting. require './mount-lib.pl'; &error_setup($text{'edit_err'}); &ReadParse(); if (defined($in{index})) { if ($in{temp}) { # Edit a temporary mount, existing only in the mnttab @mlist = &list_mounted(); @minfo = @{$mlist[$in{index}]}; $mnow = 1; $msave = 0; } else { # Edit a permanent mount, which may or may not be currently # mounted. @mlist = &list_mounts(); @minfo = @{$mlist[$in{index}]}; $msave = 1; $mnow = (&get_mounted($minfo[0], $minfo[1]) >= 0); } if ($in{index} >= @mlist) { &error($text{'edit_egone'}); } &can_edit_fs(@minfo) && !$access{'only'} || &error($text{'edit_ecannot'}); $type = $minfo[2]; &ui_print_header(undef, $text{'edit_title'}, ""); $newm = 0; } else { # creating a new mount (temporary or permanent) $type = $in{type}; &ui_print_header(undef, $text{'create_title'}, ""); $newm = 1; } @mmodes = &mount_modes($type); $msave = ($mmodes[0]==0 ? 0 : $msave); $mnow = ($mmodes[1]==0 ? $msave : $mnow); print "
\n"; print "\n"; if (!$newm) { print "\n"; print "\n"; print "\n"; print "\n"; } print "\n"; print "\n"; print "\n"; print "
",&text('edit_header', &fstype_name($type)), "
\n"; print "\n"; if ($type eq "swap") { print "\n", &nice_size($free*1024); } print "\n"; # Show save mount options if ($mmodes[0] != 0 && !$access{'simple'}) { print "\n"; } # Show mount now options if ($mmodes[1] == 1 && ($mmodes[3] == 0 || !$mnow) && !$access{'simple'}) { print "\n"; } # Show fsck order options if ($mmodes[2] && !$access{'simple'}) { print "\n"; printf "\n"; } # Show filesystem-specific mount source &generate_location($type, $minfo[1] || $in{'newdev'}); print "
",&hlink("$text{'edit_dir'}", "edit_dir"), "$text{'edit_swap'}\n"; } else { local $dir = $minfo[0] || $in{'newdir'}; if (@access_fs == 1) { # Make relative to first allowed dir $dir =~ s/^$access_fs[0]\///; } print "\n"; if ($access{'browse'}) { print &file_chooser_button("directory", 1); } } if (!$newm && (($size,$free) = &disk_space($type, $minfo[0]))) { print " " x 8; printf "$text{'edit_size'} %s / \n", &nice_size($size*1024); printf "$text{'edit_free'} %s
$text{'edit_savemount'} \n"; printf " $text{'edit_boot'}\n", $minfo[5] eq "yes" || $newm ? "checked" : ""; if ($mmodes[0] != 1) { printf " %s\n", $minfo[5] eq "no" ? "checked" : "", $text{'edit_save'}; } if (!$newm && $mmodes[1] == 0) { printf " %s\n", $minfo[5] eq "" && !$newm ? "checked" : "", $text{'edit_delete'}; } else { printf " %s\n", $minfo[5] eq "" && !$newm ? "checked" : "", $text{'edit_dont'}; } print "
$text{'edit_now'} \n"; printf " %s\n", $mnow || $newm ? "checked" : "", $text{'edit_mount'}; if ($mmodes[0] == 0) { printf " %s\n", $mnow || $newm ? "" : "checked", $text{'edit_delete'}; } else { printf " %s\n", $mnow || $newm ? "" : "checked", $newm ? $text{'edit_dont2'} : $text{'edit_unmount'}; } print "
$text{'edit_order'} %s\n", $newm || $minfo[4] == 0 ? "checked" : "", $text{'no'}; printf " %s\n", $minfo[4] == 1 ? "checked" : "", $text{'edit_first'}; printf " %s 1 ? $minfo[4] : 2 , $minfo[4] > 1 ? "checked" : "", $text{'edit_second'}; print "

\n"; if (!$access{'simple'} || !defined($access{'opts'}) || $access{'opts'} =~ /$type/) { # generate mount options if ($in{'advanced'}) { $access{'simopts'} = 0; print &ui_hidden("nosimopts", 1),"\n"; } print "\n"; print "\n"; print "
$text{'edit_adv'}
\n"; &parse_options($type, $minfo[3]); &generate_options($type, $newm); if ($access{'simopts'}) { print "\n"; } print "
", &ui_submit($text{'edit_advanced'}, "advanced"), "
\n"; } if ($access{'simple'}) { # buttons for mounting/unmounting print "\n"; if ($newm) { print ""; } elsif ($msave && $mnow) { print "\n"; if ($mmodes[1]) { print "\n"; } print "\n"; } elsif ($msave) { print "\n"; print "\n"; print "\n"; } else { print "\n"; if ($mmodes[0]) { print "\n"; } print "\n"; } print "

\n"; } else { # Save and other buttons print "\n"; if ($newm) { print ""; } elsif ($mnow && $minfo[2] ne "swap") { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } else { print ""; } print "
\n"; } &ui_print_footer($in{'return'}, $text{'index_return'});