3 # Display a form for editing or creating a permanent or temporary mounting.
5 require './mount-lib.pl';
6 &error_setup($text{'edit_err'});
8 if (defined($in{index})) {
10 # Edit a temporary mount, existing only in the mnttab
11 @mlist = &list_mounted();
12 @minfo = @{$mlist[$in{index}]};
13 $mnow = 1; $msave = 0;
16 # Edit a permanent mount, which may or may not be currently
18 @mlist = &list_mounts();
19 @minfo = @{$mlist[$in{index}]};
20 $msave = 1; $mnow = (&get_mounted($minfo[0], $minfo[1]) >= 0);
22 if ($in{index} >= @mlist) {
23 &error($text{'edit_egone'});
25 &can_edit_fs(@minfo) && !$access{'only'} ||
26 &error($text{'edit_ecannot'});
28 &ui_print_header(undef, $text{'edit_title'}, "");
32 # creating a new mount (temporary or permanent)
34 &ui_print_header(undef, $text{'create_title'}, "");
37 @mmodes = &mount_modes($type);
38 $msave = ($mmodes[0]==0 ? 0 : $msave);
39 $mnow = ($mmodes[1]==0 ? $msave : $mnow);
41 print "<form action=\"save_mount.cgi\">\n";
42 print "<input name=return type=hidden value='$in{'return'}'>\n";
44 print "<input type=hidden name=old value=\"$in{index}\">\n";
45 print "<input type=hidden name=temp value=\"$in{temp}\">\n";
47 print "<input type=hidden name=oldmnow value=$mnow>\n";
48 print "<input type=hidden name=oldmsave value=$msave>\n";
50 print "<input type=hidden name=type value=\"$type\">\n";
51 print "<table border width=100%>\n";
52 print "<tr $tb> <td><b>",&text('edit_header', &fstype_name($type)),
54 print "<tr $cb> <td><table>\n";
56 print "<tr> <td>",&hlink("<b>$text{'edit_dir'}</b>", "edit_dir"), "</td>\n";
57 if ($type eq "swap") {
58 print "<td colspan=3><i>$text{'edit_swap'}</i></b>\n";
61 local $dir = $minfo[0] || $in{'newdir'};
62 if (@access_fs == 1) {
63 # Make relative to first allowed dir
64 $dir =~ s/^$access_fs[0]\///;
66 print "<td colspan=3><input size=30 name=directory value=\"",
68 if ($access{'browse'}) {
69 print &file_chooser_button("directory", 1);
72 if (!$newm && (($size,$free) = &disk_space($type, $minfo[0]))) {
74 printf "<b>$text{'edit_size'}</b> <i>%s</i> / \n",
75 &nice_size($size*1024);
76 printf "<b>$text{'edit_free'}</b> <i>%s</i></td>\n",
77 &nice_size($free*1024);
79 print "</td> </tr>\n";
81 # Show save mount options
82 if ($mmodes[0] != 0 && !$access{'simple'}) {
83 print "<tr> <td><b>$text{'edit_savemount'}</b></td> <td colspan=3>\n";
84 printf "<input type=radio name=msave value=2 %s> $text{'edit_boot'}\n",
85 $minfo[5] eq "yes" || $newm ? "checked" : "";
86 if ($mmodes[0] != 1) {
87 printf "<input type=radio name=msave value=1 %s> %s\n",
88 $minfo[5] eq "no" ? "checked" : "", $text{'edit_save'};
90 if (!$newm && $mmodes[1] == 0) {
91 printf "<input type=radio name=msave value=0 %s> %s\n",
92 $minfo[5] eq "" && !$newm ? "checked" : "",
96 printf "<input type=radio name=msave value=0 %s> %s\n",
97 $minfo[5] eq "" && !$newm ? "checked" : "",
100 print "</td> </tr>\n";
103 # Show mount now options
104 if ($mmodes[1] == 1 && ($mmodes[3] == 0 || !$mnow) && !$access{'simple'}) {
105 print "<tr> <td><b>$text{'edit_now'}</b></td> <td colspan=3>\n";
106 printf "<input type=radio name=mmount value=1 %s> %s\n",
107 $mnow || $newm ? "checked" : "", $text{'edit_mount'};
108 if ($mmodes[0] == 0) {
109 printf "<input type=radio name=mmount value=0 %s> %s\n",
110 $mnow || $newm ? "" : "checked", $text{'edit_delete'};
113 printf "<input type=radio name=mmount value=0 %s> %s\n",
114 $mnow || $newm ? "" : "checked",
115 $newm ? $text{'edit_dont2'} : $text{'edit_unmount'};
117 print "</td> </tr>\n";
120 # Show fsck order options
121 if ($mmodes[2] && !$access{'simple'}) {
122 print "<tr> <td><b>$text{'edit_order'}</b></td>\n";
123 printf "<td colspan=3><input type=radio name=order value=0 %s> %s\n",
124 $newm || $minfo[4] == 0 ? "checked" : "", $text{'no'};
125 printf "<input type=radio name=order value=1 %s> %s\n",
126 $minfo[4] == 1 ? "checked" : "", $text{'edit_first'};
127 printf "<input type=radio name=order value=%s %s> %s</td\n",
128 $minfo[4] > 1 ? $minfo[4] : 2 , $minfo[4] > 1 ? "checked" : "",
129 $text{'edit_second'};
133 # Show filesystem-specific mount source
134 &generate_location($type, $minfo[1] || $in{'newdev'});
135 print "</table></td> </tr></table><p>\n";
137 if (!$access{'simple'} || !defined($access{'opts'}) ||
138 $access{'opts'} =~ /$type/) {
139 # generate mount options
140 if ($in{'advanced'}) {
141 $access{'simopts'} = 0;
142 print &ui_hidden("nosimopts", 1),"\n";
144 print "<table border width=100%>\n";
145 print "<tr $tb> <td><b>$text{'edit_adv'}</b></td> </tr>\n";
146 print "<tr $cb> <td><table width=100%>\n";
147 &parse_options($type, $minfo[3]);
148 &generate_options($type, $newm);
149 if ($access{'simopts'}) {
150 print "<tr> <td colspan=4>",
151 &ui_submit($text{'edit_advanced'}, "advanced"),
154 print "</table></td> </tr></table>\n";
157 if ($access{'simple'}) {
158 # buttons for mounting/unmounting
159 print "<table width=100%><tr>\n";
161 print "<td><input type=submit ",
162 "value=\"$text{'edit_create'}\"></td>";
164 elsif ($msave && $mnow) {
165 print "<td width=33%><input type=submit ",
166 "value=\"$text{'edit_save_apply'}\"></td>\n";
168 print "<td align=center width=33%><input type=submit ",
169 "value=\"$text{'edit_umount'}\" name=umount></td>\n";
171 print "<td align=right width=33%><input type=submit ",
172 "value=\"$text{'edit_del_umount'}\" name=delete></td>\n";
175 print "<td width=33%><input type=submit ",
176 "value=\"$text{'save'}\"></td>\n";
177 print "<td align=center width=33%><input type=submit ",
178 "value=\"$text{'edit_mount'}\" name=mount></td>\n";
179 print "<td align=right width=33%><input type=submit ",
180 "value=\"$text{'edit_delete'}\" name=delete></td>\n";
183 print "<td width=33%><input type=submit ",
184 "value=\"$text{'save'}\"></td>\n";
186 print "<td align=middle width=33%><input type=submit ",
187 "value=\"$text{'edit_perm'}\" name=perm></td>\n";
189 print "<td align=right width=33%><input type=submit ",
190 "value=\"$text{'edit_umount'}\" name=umount></td>\n";
192 print "</tr></table></form>\n";
195 # Save and other buttons
196 print "<table width=100%><tr>\n";
198 print "<td><input type=submit value=\"$text{'create'}\"></td>";
200 elsif ($mnow && $minfo[2] ne "swap") {
201 print "<td><input type=submit value=\"$text{'save'}\"></td>\n";
202 print "</form><form action=../proc/index_search.cgi>\n";
203 print "<input type=hidden name=mode value=3>\n";
204 print "<input type=hidden name=fs value=$minfo[0]>\n";
205 print "<td align=right><input type=submit ",
206 "value=\"$text{'edit_list'}\"></td>\n";
209 print "<td><input type=submit value=\"$text{'save'}\"></td>";
211 print "</tr></table></form>\n";
213 &ui_print_footer($in{'return'}, $text{'index_return'});