1#!/usr/local/bin/perl
2# edit_part.cgi
3# Edit an existing partition
4
5require './format-lib.pl';
6$access{'view'} && &error($text{'ecannot'});
7$d = $ARGV[0]; $p = $ARGV[1];
8@dlist = &list_disks();
9$dinfo = $dlist[$d];
10&can_edit_disk($dinfo->{'device'}) || &error($text{'edit_ecannot'});
11&ui_print_header(undef, $text{'edit_title'}, "");
12print "<table width=100%><tr> <td valign=top>\n";
13
14print "<table border width=100%>\n";
15print "<tr $tb> <td><b>$text{'edit_header'}</b></td> </tr>\n";
16print "<form action=save_part.cgi><tr $cb><td><table>\n";
17print "<input type=hidden name=disk value=$d>\n";
18print "<input type=hidden name=part value=$p>\n";
19@plist = &list_partitions($dinfo->{'device'});
20$pinfo = $plist[$p];
21$new = !$pinfo->{'end'};
22
23$dinfo->{'device'} =~ /c(\d+)t(\d+)d(\d+)/;
24print "<tr> <td><b>$text{'edit_location'}</b></td>\n";
25print "<td>$pinfo->{'desc'}</td> </tr>\n";
26
27$dev = $pinfo->{'device'};
28print "<tr> <td><b>$text{'edit_dev'}</b></td> <td><tt>$dev</tt></td> </tr>\n";
29
30print "<tr> <td><b>$text{'edit_type'}</b></td> <td><select name=tag>\n";
31foreach $t (&list_tags()) {
32	printf "<option %s>$t</option>\n", $t eq $pinfo->{'tag'} ? "selected" : "";
33	}
34print "</select></td> </tr>\n";
35
36print "<tr> <td><b>$text{'edit_flags'}</b></td>\n";
37printf "<td nowrap><input type=checkbox name=writable value=1 %s> %s\n",
38	$pinfo->{'flag'} =~ /^w.$/ ? "checked" : "", $text{'edit_w'};
39printf "<input type=checkbox name=mountable value=1 %s> %s</td> </tr>\n",
40	$pinfo->{'flag'} =~ /^.m$/ ? "checked" : "", $text{'edit_m'};
41
42print "<tr> <td><b>$text{'edit_extent'}</b></td>\n";
43printf "<td nowrap><input name=start size=6 value=\"%s\"> - \n",
44	$pinfo->{'end'} ? $pinfo->{'start'} : "";
45printf "<input name=end size=6 value=\"%s\">\n",
46	$pinfo->{'end'} ? $pinfo->{'end'} : "";
47print "of $dinfo->{'cyl'}</td> </tr>\n";
48
49if ($pinfo->{'end'}) {
50	print "<tr> <td><b>$text{'edit_stat'}</b></td>\n";
51	@stat = &device_status($dev);
52	if ($stat[1] eq "meta") {
53		print "<td>$text{'edit_meta'}</td> </tr>\n";
54		}
55	elsif ($stat[1] eq "metadb") {
56		print "<td>$text{'edit_metadb'}</td> </tr>\n";
57		}
58	elsif (@stat) {
59		local $msg = $stat[2] ? 'edit_mount' : 'edit_umount';
60		$msg .= 'vm' if ($stat[1] eq 'swap');
61		print "<td>",&text($msg, "<tt>$stat[0]</tt>",
62				   "<tt>$stat[1]</tt>"),"</td> </tr>\n";
63		}
64	else { print "<td>$text{'edit_nouse'}</td> </tr>\n"; }
65
66	if ($stat[1] !~ /^meta/) {
67		print "<tr> <td><b>$text{'edit_fs'}</b></td>\n";
68		$fs = &filesystem_type($dev);
69		printf "<td>%s</td> </tr>\n", $fs ? &fstype_name($fs) : "None";
70		}
71	}
72
73print "</table></td></tr></table><p>\n";
74if (@stat) { print "<b>$text{'edit_inuse'}</b>.\n"; }
75elsif ($new) {
76	print "<input type=submit value=\"$text{'edit_setup'}\">\n";
77	}
78else {
79	print "<input type=submit value=\"$text{'edit_change'}\">\n";
80	print "<input type=submit name=delete value=\"$text{'delete'}\">\n";
81	}
82print "</form>\n";
83
84print "</td> <td valign=top>\n";
85print "<table border width=100%>\n";
86print "<tr $tb> <td colspan=2><b>$text{'edit_tasks'}</b></td> </tr>\n";
87
88print "<tr $cb> <form action=newfs_form.cgi>\n";
89print "<td valign=top nowrap><b>$text{'edit_newfs'}</b><br>\n";
90if (!$new && (!@stat || $stat[2] == 0)) {
91	print "<input type=hidden name=dev value=$dev>\n";
92	print "<input type=submit value=\"$text{'create'}\"></td>\n";
93	print "<td>$text{'edit_newdesc1'}</td>\n";
94	}
95elsif ($new) {
96	print "</td> <td>$text{'edit_newdesc2'}</td>\n";
97	}
98else {
99	print "</td> <td>$text{'edit_newdesc3'}</td>\n";
100	}
101print "</form> </tr>\n";
102
103
104print "<tr $cb> <form action=fsck_form.cgi>\n";
105print "<td valign=top><b>$text{'edit_fsckfs'}</b><br>\n";
106if (!$new && (!@stat || $stat[2] == 0) && $fs eq "ufs") {
107	print "<input type=hidden name=dev value=$dev>\n";
108	print "<input type=submit value=\"$text{'edit_fsck'}\"></td>\n";
109	print "<td>$text{'edit_fsckdesc1'}</td>\n";
110	}
111elsif ($new) {
112	print "</td> <td>$text{'edit_fsckdesc2'}</td>\n";
113	}
114elsif (@stat && $stat[2]) {
115	print "</td> <td>$text{'edit_fsckdesc3'}</td>\n";
116	}
117elsif (!$fs) {
118	print "</td> <td>$text{'edit_fsckdesc4'}</td>\n";
119	}
120else {
121	print "</td> <td>$text{'edit_fsckdesc5'}</td>\n";
122	}
123print "</form> </tr>\n";
124
125print "<tr $cb> <form action=tunefs_form.cgi>\n";
126print "<td valign=top><b>$text{'edit_tunefs'}</b><br>\n";
127if (!$new && (!@stat || $stat[2] == 0) && $fs eq "ufs") {
128	print "<input type=hidden name=dev value=$dev>\n";
129	print "<input type=submit value=\"$text{'edit_tune'}\"></td>\n";
130	print "<td>$text{'edit_tunedesc1'}</td>\n";
131	}
132elsif ($new) {
133	print "</td> <td>$text{'edit_tunedesc2'}</td>\n";
134	}
135elsif (@stat && $stat[2]) {
136	print "</td> <td>$text{'edit_tunedesc3'}</td>\n";
137	}
138elsif (!$fs) {
139	print "</td> <td>$text{'edit_tunedesc4'}</td>\n";
140	}
141elsif ($fs ne "ufs") {
142	print "</td> <td>$text{'edit_tunedesc5'}</td>\n";
143	}
144print "</form> </tr>\n";
145
146print "</table>\n";
147print "</td></tr></table>\n";
148&ui_print_footer("", $text{'index_return'});
149
150