#!/usr/local/bin/perl # index.cgi # Display a list of known filesystems, and indicate which are currently mounted require './mount-lib.pl'; &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("mount fstab vfstab", "man")); # List filesystems from fstab and mtab @mounted = &list_mounted(); $yes = $text{'yes'}; $no = "$text{'no'}"; foreach (&list_fstypes()) { $can_edit{$_}++; } $i = 0; foreach $m (&list_mounts()) { $m->[0] = "swap" if ($m->[2] eq "swap"); $mounts{$m->[0],$m->[1]} = $i++; push(@all, $m); } $i = 0; foreach $m (&list_mounted()) { $m->[0] = "swap" if ($m->[2] eq "swap"); $mounted{$m->[0],$m->[1]} = $i++; push(@all, $m) if (!defined($mounts{$m->[0],$m->[1]})); } # Sort by chosen mode if ($config{'sort_mode'} == 2) { @all = sort { lc($a->[0]) cmp lc($b->[0]) } @all; } elsif ($config{'sort_mode'} == 1) { @all = sort { &fstype_name($a->[2]) cmp &fstype_name($b->[2]) } @all; } # Build visible filesystems list foreach $m (@all) { @minfo = @$m; $p = &simplify_mount_path($minfo[0], $minfo[2]); next if ($ignore{$minfo[2]}); @mmodes = &mount_modes($minfo[2], $minfo[0], $minfo[1]); $canedit = $can_edit{$minfo[2]} && !$mmodes[4] && &can_edit_fs(@minfo); next if (!$canedit && $access{'hide'}); push(@visible, $m); } if (@visible) { # Show table of all visible filesystems &show_button(); print &ui_columns_start([ $text{'index_dir'}, $text{'index_type'}, $text{'index_dev'}, $config{'show_used'} ? ( $text{'index_used'} ) : ( ), $text{'index_use'}, $text{'index_perm'} ], 100); foreach $m (@visible) { @minfo = @$m; $p = &simplify_mount_path($minfo[0], $minfo[2]); $midx = $mounts{$minfo[0],$minfo[1]}; $medidx = $mounted{$minfo[0],$minfo[1]}; @mmodes = &mount_modes($minfo[2], $minfo[0], $minfo[1]); $canedit = $can_edit{$minfo[2]} && !$mmodes[4] && &can_edit_fs(@minfo); local @cols; if ($canedit && !$access{'only'}) { if (defined($midx)) { push(@cols, "$p"); } else { push(@cols, "$p"); } } else { push(@cols, $p); } local $fsn = &fstype_name($minfo[2]); $fsn .= " ($minfo[2])" if (uc($fsn) ne uc($minfo[2])); push(@cols, $minfo[2] eq "*" ? $text{'index_auto'} : $fsn); push(@cols, &device_name($minfo[1])); if ($config{'show_used'}) { # Add disk space used column ($total, $free) = &disk_space($minfo[2],$minfo[0]); if ($total > 0 && $total >= $free) { $pc = int(100*($total-$free) / $total); push(@cols, $pc >= 99 ? "$pc %" : $pc >= 95 ? "$pc %" : $pc."%"); } else { push(@cols, ""); } } if (&can_edit_fs(@minfo)) { push(@cols, defined($medidx) ? "$yes" : "$no"); } else { push(@cols, defined($medidx) ? $yes : $no); } push(@cols, defined($midx) ? $yes : $no); print &ui_columns_row(\@cols); } print &ui_columns_end(),"
\n"; } else { print "$text{'index_none'}

\n"; } &show_button(); &ui_print_footer("/", $text{'index'}); 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 ($_[0] eq "/") { return "/ ($text{'index_root'})"; } else { return &html_escape($_[0]); } } sub show_button { return if (!$access{'create'} || $access{'only'}); local %donefs; print "

\n"; print " $text{'index_type'}:\n"; print "
\n"; }