3 # Display a list of known filesystems, and indicate which are currently mounted
5 require './mount-lib.pl';
6 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
7 &help_search_link("mount fstab vfstab", "man"));
9 # List filesystems from fstab and mtab
10 @mounted = &list_mounted();
12 $no = "<font color=#ff0000>$text{'no'}</a>";
13 foreach (&list_fstypes()) { $can_edit{$_}++; }
15 foreach $m (&list_mounts()) {
16 $m->[0] = "swap" if ($m->[2] eq "swap");
17 $mounts{$m->[0],$m->[1]} = $i++;
21 foreach $m (&list_mounted()) {
22 $m->[0] = "swap" if ($m->[2] eq "swap");
23 $mounted{$m->[0],$m->[1]} = $i++;
24 push(@all, $m) if (!defined($mounts{$m->[0],$m->[1]}));
28 if ($config{'sort_mode'} == 2) {
29 @all = sort { lc($a->[0]) cmp lc($b->[0]) } @all;
31 elsif ($config{'sort_mode'} == 1) {
32 @all = sort { &fstype_name($a->[2]) cmp &fstype_name($b->[2]) } @all;
35 # Build visible filesystems list
38 $p = &simplify_mount_path($minfo[0], $minfo[2]);
39 next if ($ignore{$minfo[2]});
40 @mmodes = &mount_modes($minfo[2], $minfo[0], $minfo[1]);
41 $canedit = $can_edit{$minfo[2]} && !$mmodes[4] &&
43 next if (!$canedit && $access{'hide'});
48 # Show table of all visible filesystems
50 print &ui_columns_start([ $text{'index_dir'},
53 $config{'show_used'} ? ( $text{'index_used'} )
56 $text{'index_perm'} ], 100);
57 foreach $m (@visible) {
59 $p = &simplify_mount_path($minfo[0], $minfo[2]);
61 $midx = $mounts{$minfo[0],$minfo[1]};
62 $medidx = $mounted{$minfo[0],$minfo[1]};
63 @mmodes = &mount_modes($minfo[2], $minfo[0], $minfo[1]);
64 $canedit = $can_edit{$minfo[2]} && !$mmodes[4] &&
67 if ($canedit && !$access{'only'}) {
69 push(@cols, "<a href=\"edit_mount.cgi?".
70 "index=$midx\">$p</a>");
73 push(@cols, "<a href=\"edit_mount.cgi?".
74 "temp=1&index=$medidx\">$p</a>");
80 local $fsn = &fstype_name($minfo[2]);
81 $fsn .= " ($minfo[2])" if (uc($fsn) ne uc($minfo[2]));
82 push(@cols, $minfo[2] eq "*" ? $text{'index_auto'} : $fsn);
83 push(@cols, &device_name($minfo[1]));
84 if ($config{'show_used'}) {
85 # Add disk space used column
86 ($total, $free) = &disk_space($minfo[2],$minfo[0]);
87 if ($total > 0 && $total >= $free) {
88 $pc = int(100*($total-$free) / $total);
90 $pc >= 99 ? "<font color=red>$pc %</font>" :
91 $pc >= 95 ? "<font color=orange>$pc %</font>" :
98 if (&can_edit_fs(@minfo)) {
101 "<a href='unmount.cgi?index=$medidx'>$yes</a>" :
102 "<a href='mount.cgi?index=$midx'>$no</a>");
105 push(@cols, defined($medidx) ? $yes : $no);
107 push(@cols, defined($midx) ? $yes : $no);
108 print &ui_columns_row(\@cols);
110 print &ui_columns_end(),"<br>\n";
113 print "<b>$text{'index_none'}</b><p>\n";
117 &ui_print_footer("/", $text{'index'});
119 sub simplify_mount_path
121 if ($_[1] eq "swap") {
122 return "<i>$text{'index_swap'}</i>";
124 elsif (length($_[0]) > 20) {
125 return &html_escape("... ".substr($_[0], length($_[0])-20));
127 elsif ($_[0] eq "/") {
128 return "/ (<i>$text{'index_root'}</i>)";
131 return &html_escape($_[0]);
137 return if (!$access{'create'} || $access{'only'});
139 print "<form action=\"edit_mount.cgi\">\n";
140 print "<input type=submit value=\"$text{'index_add'}\"> $text{'index_type'}:\n";
141 print "<select name=type>\n";
143 foreach $fs (sort { &fstype_name($a) cmp &fstype_name($b) } &list_fstypes()) {
144 local $nm = &fstype_name($fs);
145 if (!$donefs{$nm}++ && &can_fstype($fs)) {
146 print "<option value=\"$fs\">$nm ($fs)\n";
149 print "</select></form>\n";