From 5949e01c6ba8a9792d19ab7e582253efd09447dc Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sun, 18 Sep 2022 19:23:59 -0700 Subject: [PATCH] Don't show non-editable filesystem types by default --- mount/index.cgi | 42 +++++++++++++++++++++++++++++------------- mount/lang/en | 3 +++ mount/linux-lib.pl | 7 +++++++ 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/mount/index.cgi b/mount/index.cgi index e80211baa..b852039dd 100755 --- a/mount/index.cgi +++ b/mount/index.cgi @@ -5,6 +5,7 @@ require './mount-lib.pl'; &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("mount fstab vfstab", "man")); +&ReadParse(); # List filesystems from fstab and mtab @mounted = &list_mounted(); @@ -40,12 +41,23 @@ foreach $m (@all) { $canedit = $can_edit{$minfo[2]} && !$mmodes[4] && &can_edit_fs(@minfo); next if (!$canedit && $access{'hide'}); + next if (!$canedit && !$in{'show'}); push(@visible, $m); } if (@visible) { # Show table of all visible filesystems - &show_button(); + if (!$access{'hide'}) { + if ($in{'show'}) { + $shower = &ui_link("index.cgi?show=0", + $text{'index_show0'}); + } + else { + $shower = &ui_link("index.cgi?show=1", + $text{'index_show1'}); + } + } + print &ui_links_row([ $shower ]) if ($shower); print &ui_columns_start([ $text{'index_dir'}, $text{'index_type'}, $text{'index_dev'}, @@ -103,7 +115,9 @@ if (@visible) { push(@cols, defined($midx) ? $yes : $no); print &ui_columns_row(\@cols); } - print &ui_columns_end(),"
\n"; + print &ui_columns_end(); + print &ui_links_row([ $shower ]) if ($shower); + print "

\n"; } else { print "$text{'index_none'}

\n"; @@ -117,8 +131,8 @@ sub simplify_mount_path if ($_[1] eq "swap") { return "$text{'index_swap'}"; } -elsif (length($_[0]) > 20) { - return &html_escape("... ".substr($_[0], length($_[0])-20)); +elsif (length($_[0]) > 40) { + return &html_escape("... ".substr($_[0], length($_[0])-40)); } elsif ($_[0] eq "/") { return "/ ($text{'index_root'})"; @@ -131,17 +145,19 @@ else { sub show_button { return if (!$access{'create'} || $access{'only'}); -local %donefs; -print "

\n"; -print " $text{'index_type'}:\n"; -print "
\n"; +my $def = defined(&preferred_fstype) ? &preferred_fstype() : undef; +print &ui_select("type", $def, \@opts); +print &ui_form_end(); } diff --git a/mount/lang/en b/mount/lang/en index 9942c8dcb..bc8c41a9c 100644 --- a/mount/lang/en +++ b/mount/lang/en @@ -12,6 +12,9 @@ index_return=filesystems list index_none=You do not have access to any mounted filesystems. index_mount2=Mount with password: index_root=Root filesystem +index_show1=Show all filesystems +index_show0=Hide non-editable filesystems +index_addtype=of type edit_title=Edit Mount create_title=Create Mount diff --git a/mount/linux-lib.pl b/mount/linux-lib.pl index 93b559b07..4e1b3b278 100755 --- a/mount/linux-lib.pl +++ b/mount/linux-lib.pl @@ -949,6 +949,13 @@ push(@sup, "swap"); return @sup; } +# preferred_fstype() +# Returns the default filesystem type for this OS +sub preferred_fstype +{ +return $ext4_support ? "ext4" : + $ext3_support ? "ext3" : "ext2"; +} # fstype_name(type) # Given a short filesystem type, return a human-readable name for it