3 # supported_filesystems()
4 # Returns a list of filesystem types on which dumping is supported
5 sub supported_filesystems
8 push(@rv, "ufs") if (&has_command("ufsdump"));
15 # Display common options
16 print "<tr> <td valign=top><b>",&hlink($text{'dump_dest'}, "dest"),
17 "</b></td> <td colspan=3>\n";
18 printf "<input type=radio name=mode value=0 %s> %s\n",
19 $_[0]->{'host'} ? '' : 'checked', $text{'dump_file'};
20 printf "<input name=file size=50 value='%s'> %s<br>\n",
21 $_[0]->{'host'} ? '' : $_[0]->{'file'},
22 &file_chooser_button("file");
23 printf "<input type=radio name=mode value=1 %s>\n",
24 $_[0]->{'host'} ? 'checked' : '';
25 print &text('dump_host',
26 "<input name=host size=15 value='$_[0]->{'host'}'>",
27 "<input name=huser size=8 value='$_[0]->{'huser'}'>",
28 "<input name=hfile size=20 value='$_[0]->{'hfile'}'>"),
31 print "<tr> <td><b>",&hlink($text{'dump_update'},"update"),
33 printf "<td><input name=update type=radio value=1 %s> %s\n",
34 $_[0]->{'update'} ? 'checked' : '', $text{'yes'};
35 printf "<input name=update type=radio value=0 %s> %s</td>\n",
36 $_[0]->{'update'} ? '' : 'checked', $text{'no'};
38 print "<td><b>",&hlink($text{'dump_verify'},"verify"),"</b></td>\n";
39 printf "<td><input name=verify type=radio value=1 %s> %s\n",
40 $_[0]->{'verify'} ? 'checked' : '', $text{'yes'};
41 printf "<input name=verify type=radio value=0 %s> %s</td> </tr>\n",
42 $_[0]->{'verify'} ? '' : 'checked', $text{'no'};
44 print "<tr> <td><b>",&hlink($text{'dump_level'},"level"),"</b></td>\n";
45 print "<td><select name=level>\n";
47 printf "<option value=%d %s>%d %s\n",
48 $l, $_[0]->{'level'} == $l ? "selected" : "", $l,
49 $text{'dump_level_'.$l};
51 print "</select></td>\n";
53 print "<td><b>",&hlink($text{'dump_offline'},"offline"),"</b></td>\n";
54 printf "<td><input name=offline type=radio value=1 %s> %s\n",
55 $_[0]->{'offline'} ? 'checked' : '', $text{'yes'};
56 printf "<input name=offline type=radio value=0 %s> %s</td> </tr>\n",
57 $_[0]->{'offline'} ? '' : 'checked', $text{'no'};
63 # Parse common options
64 if ($in{'mode'} == 0) {
65 $in{'file'} =~ /\S/ || &error($text{'dump_efile'});
66 $_[0]->{'file'} = $in{'file'};
67 delete($_[0]->{'host'});
68 delete($_[0]->{'huser'});
69 delete($_[0]->{'hfile'});
72 gethostbyname($in{'host'}) || &check_ipaddress($in{'host'}) ||
73 &error($text{'dump_ehost'});
74 $_[0]->{'host'} = $in{'host'};
75 $in{'huser'} =~ /^\S+$/ || &error($text{'dump_ehuser'});
76 $_[0]->{'huser'} = $in{'huser'};
77 $in{'hfile'} || &error($text{'dump_ehfile'});
78 $_[0]->{'hfile'} = $in{'hfile'};
79 delete($_[0]->{'file'});
82 $_[0]->{'update'} = $in{'update'};
83 $_[0]->{'verify'} = $in{'verify'};
84 $_[0]->{'level'} = $in{'level'};
85 $_[0]->{'offline'} = $in{'offline'};
88 # execute_dump(&dump, filehandle, escape)
89 # Executes a dump and displays the output
93 local $cmd = "ufsdump $_[0]->{'level'}";
94 $cmd .= "u" if ($_[0]->{'update'});
95 $cmd .= "v" if ($_[0]->{'verify'});
96 $cmd .= "o" if ($_[0]->{'offline'});
97 if ($_[0]->{'huser'}) {
98 $cmd .= "f '$_[0]->{'huser'}@$_[0]->{'host'}:$_[0]->{'hfile'}'";
100 elsif ($_[0]->{'host'}) {
101 $cmd .= "f '$_[0]->{'host'}:$_[0]->{'hfile'}'";
104 $cmd .= "f '$_[0]->{'file'}'";
106 $cmd .= " '$_[0]->{'dir'}'";
108 &system_logged("sync");
110 &additional_log('exec', undef, $cmd);
111 open(CMD, "$cmd 2>&1 </dev/null |");
114 print $fh &html_escape($_);
126 if ($_[0]->{'file'}) {
127 return "<tt>".&html_escape($_[0]->{'file'})."</tt>";
129 elsif ($_[0]->{'huser'}) {
130 return "<tt>".&html_escape("$_[0]->{'huser'}@$_[0]->{'host'}:$_[0]->{'hfile'}")."</tt>";
133 return "<tt>".&html_escape("$_[0]->{'host'}:$_[0]->{'hfile'}")."</tt>";
137 # missing_restore_command(filesystem)
138 sub missing_restore_command
140 return &has_command("ufsrestore") ? undef : "ufsrestore";
143 # restore_form(filesystem)
147 print "<tr> <td valign=top><b>",&hlink($text{'restore_src'}, "rsrc"),
149 printf "<td colspan=3><input type=radio name=mode value=0 checked> %s\n",
151 printf "<input name=file size=50> %s<br>\n",
152 &file_chooser_button("file");
153 printf "<input type=radio name=mode value=1>\n";
154 print &text('dump_host',
155 "<input name=host size=15>",
156 "<input name=huser size=8>",
157 "<input name=hfile size=20>"),
160 print "<tr> <td><b>",&hlink($text{'restore_files'},"rfiles"),
162 print "<td colspan=3><input type=radio name=files_def value=1 checked> ",
163 "$text{'restore_all'}\n";
164 print "<input type=radio name=files_def value=0> $text{'restore_sel'}\n";
165 print "<input name=files size=40></td> </tr>\n";
167 print "<tr> <td><b>",&hlink($text{'restore_dir'},"rdir"),"</td>\n";
168 print "<td><input name=dir size=40> ",&file_chooser_button("dir", 1),
171 print "<tr> <td><b>",&hlink($text{'restore_test'},"rtest"),"</td>\n";
172 print "<td><input type=radio name=test value=1> $text{'yes'}\n";
173 print "<input type=radio name=test value=0 checked> $text{'no'}</td> </tr>\n";
176 # parse_restore(filesystem)
177 # Parses inputs from restore_form() and returns a command to be passed to
183 $cmd .= ($in{'test'} ? " t" : " x");
184 if ($in{'mode'} == 0) {
185 $in{'file'} || &error($text{'restore_efile'});
186 $cmd .= "f '$in{'file'}'";
189 gethostbyname($in{'host'}) || &check_ipaddress($in{'host'}) ||
190 &error($text{'restore_ehost'});
191 $in{'huser'} =~ /^\S*$/ || &error($text{'restore_ehuser'});
192 $in{'hfile'} || &error($text{'restore_ehfile'});
194 $cmd .= "f '$in{'huser'}@$in{'host'}:$in{'hfile'}'";
197 $cmd .= "f '$in{'host'}:$in{'hfile'}'";
201 if (!$in{'files_def'}) {
202 $in{'files'} || &error($text{'restore_efiles'});
203 $cmd .= " $in{'files'}";
205 -d $in{'dir'} || &error($text{'restore_edir'});
210 # restore_backup(filesystem, command)
211 # Restores a backup based on inputs from restore_form(), and displays the results
214 &additional_log('exec', undef, $_[1]);
216 &foreign_require("proc", "proc-lib.pl");
217 local ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", "cd '$in{'dir'}' ; $_[1]");
220 local $rv = &wait_for($fh, "(next volume #)", "(set owner.mode for.*\\[yn\\])", "(Directories already exist, set modes anyway. \\[yn\\])", "((.*)\\[yn\\])", "(.*\\n)");
222 print &html_escape($matches[1]);
225 return $text{'restore_evolume'};
228 syswrite($fh, "1\n");
231 elsif ($rv == 1 || $rv == 2) {
232 syswrite($fh, "n\n");
235 return &text('restore_equestion',
236 "<tt>$matches[2]</tt>");