mirror of
https://github.com/webmin/webmin.git
synced 2025-07-20 16:48:46 +00:00
Add support for gpart
in BSD Fdisk
https://github.com/webmin/webmin/issues/2364#issuecomment-2657006714
This commit is contained in:
File diff suppressed because it is too large
Load Diff
7
bsdfdisk/create_part.cgi
Executable file → Normal file
7
bsdfdisk/create_part.cgi
Executable file → Normal file
@ -19,7 +19,7 @@ $slice || &error($text{'slice_egone'});
|
||||
|
||||
# Validate inputs, starting with slice number
|
||||
my $part = { };
|
||||
$in{'letter'} =~ /^[a-d]$/i || &error($text{'npart_eletter'});
|
||||
$in{'letter'} =~ /^[a-z]$/i || &error($text{'npart_eletter'});
|
||||
$in{'letter'} = lc($in{'letter'});
|
||||
my ($clash) = grep { $_->{'letter'} eq $in{'letter'} } @{$slice->{'parts'}};
|
||||
$clash && &error(&text('npart_eclash', $in{'letter'}));
|
||||
@ -29,15 +29,18 @@ $part->{'letter'} = $in{'letter'};
|
||||
$in{'start'} =~ /^\d+$/ || &error($text{'nslice_estart'});
|
||||
$in{'end'} =~ /^\d+$/ || &error($text{'nslice_eend'});
|
||||
$in{'start'} < $in{'end'} || &error($text{'npart_erange'});
|
||||
$part->{'startblock'} = $in{'start'};
|
||||
$part->{'startblock'} = int($in{'start'}/2048)*2048; # 1MB alignment
|
||||
$part->{'blocks'} = $in{'end'} - $in{'start'};
|
||||
|
||||
# Slice type
|
||||
$part->{'type'} = $in{'type'};
|
||||
# Set partition properties
|
||||
$part->{'label'} = $in{'label'} if ($in{'label'} =~ /^[a-zA-Z0-9._-]+$/);
|
||||
|
||||
# Do the creation
|
||||
&ui_print_header($slice->{'desc'}, $text{'npart_title'}, "");
|
||||
|
||||
# Create the partition
|
||||
print &text('npart_creating', $in{'letter'}, $slice->{'desc'}),"<p>\n";
|
||||
my $err = &save_partition($disk, $slice, $part);
|
||||
if ($err) {
|
||||
|
4
bsdfdisk/create_slice.cgi
Executable file → Normal file
4
bsdfdisk/create_slice.cgi
Executable file → Normal file
@ -26,15 +26,17 @@ $slice->{'number'} = $in{'number'};
|
||||
$in{'start'} =~ /^\d+$/ || &error($text{'nslice_estart'});
|
||||
$in{'end'} =~ /^\d+$/ || &error($text{'nslice_eend'});
|
||||
$in{'start'} < $in{'end'} || &error($text{'nslice_erange'});
|
||||
$slice->{'startblock'} = $in{'start'};
|
||||
$slice->{'startblock'} = int($in{'start'}/2048)*2048; # Align to 1MB
|
||||
$slice->{'blocks'} = $in{'end'} - $in{'start'};
|
||||
|
||||
# Slice type
|
||||
$slice->{'type'} = $in{'type'};
|
||||
$slice->{'label'} = $in{'label'} if ($in{'label'} =~ /^[a-zA-Z0-9._-]+$/);
|
||||
|
||||
# Do the creation
|
||||
&ui_print_header($disk->{'desc'}, $text{'nslice_title'}, "");
|
||||
|
||||
# Create the slice
|
||||
print &text('nslice_creating', $in{'number'}, $disk->{'desc'}),"<p>\n";
|
||||
my $err = &create_slice($disk, $slice);
|
||||
if ($err) {
|
||||
|
4
bsdfdisk/edit_disk.cgi
Executable file → Normal file
4
bsdfdisk/edit_disk.cgi
Executable file → Normal file
@ -23,9 +23,9 @@ push(@info, &text('disk_dsize', &nice_size($disk->{'size'})));
|
||||
if ($disk->{'model'}) {
|
||||
push(@info, &text('disk_model', $disk->{'model'}));
|
||||
}
|
||||
push(@info, &text('disk_cylinders', $disk->{'cylinders'}));
|
||||
push(@info, &text('disk_blocks', $disk->{'blocks'}));
|
||||
push(@info, &text('disk_device', "<tt>$disk->{'device'}</tt>"));
|
||||
push(@info, &text('disk_scheme', uc($disk->{'type'} || "MBR")));
|
||||
print &ui_links_row(\@info),"<p>\n";
|
||||
|
||||
# Show partitions table
|
||||
@ -41,6 +41,7 @@ if (@{$disk->{'slices'}}) {
|
||||
$text{'disk_start'},
|
||||
$text{'disk_end'},
|
||||
$text{'disk_use'},
|
||||
$text{'disk_label'},
|
||||
]);
|
||||
foreach my $p (@{$disk->{'slices'}}) {
|
||||
# Create images for the extent
|
||||
@ -75,6 +76,7 @@ if (@{$disk->{'slices'}}) {
|
||||
$p->{'startblock'} + $p->{'blocks'} - 1,
|
||||
$use ? $use :
|
||||
$n ? &text('disk_scount', $n) : "",
|
||||
$p->{'label'},
|
||||
]);
|
||||
}
|
||||
print &ui_columns_end();
|
||||
|
4
bsdfdisk/edit_part.cgi
Executable file → Normal file
4
bsdfdisk/edit_part.cgi
Executable file → Normal file
@ -49,10 +49,14 @@ if ($canedit) {
|
||||
print &ui_table_row($text{'part_type'},
|
||||
&ui_select("type", $part->{'type'},
|
||||
[ &list_partition_types() ], 1, 0, 1));
|
||||
print &ui_table_row($text{'part_label'},
|
||||
&ui_textbox("label", $part->{'label'}, 20));
|
||||
}
|
||||
else {
|
||||
print &ui_table_row($text{'part_type'},
|
||||
$part->{'type'});
|
||||
print &ui_table_row($text{'part_label'},
|
||||
$part->{'label'});
|
||||
}
|
||||
|
||||
print &ui_table_row($text{'part_use'},
|
||||
|
11
bsdfdisk/edit_slice.cgi
Executable file → Normal file
11
bsdfdisk/edit_slice.cgi
Executable file → Normal file
@ -41,16 +41,19 @@ print &ui_table_row($text{'slice_sstart'},
|
||||
print &ui_table_row($text{'slice_send'},
|
||||
$slice->{'startblock'} + $slice->{'blocks'} - 1);
|
||||
|
||||
# GPT type selection
|
||||
print &ui_table_row($text{'slice_stype'},
|
||||
&ui_select("type", $slice->{'type'},
|
||||
[ sort { $a->[1] cmp $b->[1] }
|
||||
map { [ $_, &fdisk::tag_name($_) ] }
|
||||
&fdisk::list_tags() ]));
|
||||
[ &list_partition_types() ]));
|
||||
|
||||
print &ui_table_row($text{'slice_sactive'},
|
||||
$slice->{'active'} ? $text{'yes'} :
|
||||
&ui_yesno_radio("active", $slice->{'active'}));
|
||||
# Label field
|
||||
print &ui_table_row($text{'slice_label'},
|
||||
&ui_textbox("label", $slice->{'label'}, 20));
|
||||
|
||||
# Usage status
|
||||
print &ui_table_row($text{'slice_suse'},
|
||||
!@st ? $text{'part_nouse'} :
|
||||
$st[2] ? &text('part_inuse', $use) :
|
||||
@ -74,6 +77,7 @@ if (@{$slice->{'parts'}}) {
|
||||
$text{'slice_start'},
|
||||
$text{'slice_end'},
|
||||
$text{'slice_use'},
|
||||
$text{'slice_label'},
|
||||
]);
|
||||
foreach my $p (@{$slice->{'parts'}}) {
|
||||
# Create images for the extent
|
||||
@ -104,6 +108,7 @@ if (@{$slice->{'parts'}}) {
|
||||
$p->{'startblock'},
|
||||
$p->{'startblock'} + $p->{'blocks'} - 1,
|
||||
$use,
|
||||
$p->{'label'},
|
||||
]);
|
||||
}
|
||||
print &ui_columns_end();
|
||||
|
124
bsdfdisk/fsck.cgi
Executable file → Normal file
124
bsdfdisk/fsck.cgi
Executable file → Normal file
@ -1,62 +1,62 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Check the filesystem on a partition
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
no warnings 'uninitialized';
|
||||
require './bsdfdisk-lib.pl';
|
||||
our (%in, %text, $module_name);
|
||||
&ReadParse();
|
||||
&error_setup($text{'fsck_err'});
|
||||
|
||||
# Get the disk and slice
|
||||
my @disks = &list_disks_partitions();
|
||||
my ($disk) = grep { $_->{'device'} eq $in{'device'} } @disks;
|
||||
$disk || &error($text{'disk_egone'});
|
||||
my ($slice) = grep { $_->{'number'} eq $in{'slice'} } @{$disk->{'slices'}};
|
||||
$slice || &error($text{'slice_egone'});
|
||||
my ($object, $part);
|
||||
if ($in{'part'} ne '') {
|
||||
($part) = grep { $_->{'letter'} eq $in{'part'} }
|
||||
@{$slice->{'parts'}};
|
||||
$part || &error($text{'part_egone'});
|
||||
$object = $part;
|
||||
}
|
||||
else {
|
||||
$object = $slice;
|
||||
}
|
||||
|
||||
&ui_print_unbuffered_header($object->{'desc'}, $text{'fsck_title'}, "");
|
||||
|
||||
# Do the creation
|
||||
print &text('fsck_checking', "<tt>$object->{'device'}</tt>"),"<br>\n";
|
||||
print "<pre>\n";
|
||||
my $cmd = &get_check_filesystem_command($disk, $slice, $part);
|
||||
&additional_log('exec', undef, $cmd);
|
||||
my $fh = "CMD";
|
||||
&open_execute_command($fh, $cmd, 2);
|
||||
while(<$fh>) {
|
||||
print &html_escape($_);
|
||||
}
|
||||
close($fh);
|
||||
print "</pre>";
|
||||
if ($?) {
|
||||
print $text{'fsck_failed'},"<p>\n";
|
||||
}
|
||||
else {
|
||||
print $text{'fsck_done'},"<p>\n";
|
||||
}
|
||||
&webmin_log("fsck", $in{'part'} ne '' ? "part" : "object",
|
||||
$object->{'device'}, $object);
|
||||
|
||||
if ($in{'part'} ne '') {
|
||||
&ui_print_footer("edit_part.cgi?device=$in{'device'}&".
|
||||
"slice=$in{'slice'}&part=$in{'part'}",
|
||||
$text{'part_return'});
|
||||
}
|
||||
else {
|
||||
&ui_print_footer("edit_slice.cgi?device=$in{'device'}&".
|
||||
"slice=$in{'slice'}",
|
||||
$text{'slice_return'});
|
||||
}
|
||||
#!/usr/local/bin/perl
|
||||
# Check the filesystem on a partition
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
no warnings 'uninitialized';
|
||||
require './bsdfdisk-lib.pl';
|
||||
our (%in, %text, $module_name);
|
||||
&ReadParse();
|
||||
&error_setup($text{'fsck_err'});
|
||||
|
||||
# Get the disk and slice
|
||||
my @disks = &list_disks_partitions();
|
||||
my ($disk) = grep { $_->{'device'} eq $in{'device'} } @disks;
|
||||
$disk || &error($text{'disk_egone'});
|
||||
my ($slice) = grep { $_->{'number'} eq $in{'slice'} } @{$disk->{'slices'}};
|
||||
$slice || &error($text{'slice_egone'});
|
||||
my $object = $slice;
|
||||
|
||||
# Handle partitions if specified
|
||||
my $part;
|
||||
if ($in{'part'} ne '') {
|
||||
($part) = grep { $_->{'letter'} eq $in{'part'} }
|
||||
@{$slice->{'parts'}};
|
||||
$part || &error($text{'part_egone'});
|
||||
$object = $part;
|
||||
}
|
||||
|
||||
&ui_print_unbuffered_header($object->{'desc'}, $text{'fsck_title'}, "");
|
||||
|
||||
# Run filesystem check
|
||||
print &text('fsck_checking', "<tt>$object->{'device'}</tt>"),"<br>\n";
|
||||
print "<pre>\n";
|
||||
my $cmd = &get_check_filesystem_command($disk, $slice, $part);
|
||||
&additional_log('exec', undef, $cmd);
|
||||
my $fh = "CMD";
|
||||
&open_execute_command($fh, $cmd, 2);
|
||||
while(<$fh>) {
|
||||
print &html_escape($_);
|
||||
}
|
||||
close($fh);
|
||||
print "</pre>";
|
||||
if ($?) {
|
||||
print $text{'fsck_failed'},"<p>\n";
|
||||
}
|
||||
else {
|
||||
print $text{'fsck_done'},"<p>\n";
|
||||
}
|
||||
&webmin_log("fsck", $in{'part'} ne '' ? "part" : "object",
|
||||
$object->{'device'}, $object);
|
||||
|
||||
if ($in{'part'} ne '') {
|
||||
&ui_print_footer("edit_part.cgi?device=$in{'device'}&".
|
||||
"slice=$in{'slice'}&part=$in{'part'}",
|
||||
$text{'part_return'});
|
||||
}
|
||||
else {
|
||||
&ui_print_footer("edit_slice.cgi?device=$in{'device'}&".
|
||||
"slice=$in{'slice'}",
|
||||
$text{'slice_return'});
|
||||
}
|
||||
|
84
bsdfdisk/index.cgi
Executable file → Normal file
84
bsdfdisk/index.cgi
Executable file → Normal file
@ -1,41 +1,43 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Show a list of disks
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
no warnings 'uninitialized';
|
||||
require './bsdfdisk-lib.pl';
|
||||
our (%in, %text, %config, $module_name);
|
||||
|
||||
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
|
||||
&help_search_link("fdisk", "man"));
|
||||
|
||||
my $err = &check_fdisk();
|
||||
if ($err) {
|
||||
&ui_print_endpage(&text('index_problem', $err));
|
||||
}
|
||||
|
||||
my @disks = &list_disks_partitions();
|
||||
@disks = sort { $a->{'device'} cmp $b->{'device'} } @disks;
|
||||
if (@disks) {
|
||||
print &ui_columns_start([ $text{'index_dname'},
|
||||
$text{'index_dsize'},
|
||||
$text{'index_dmodel'},
|
||||
$text{'index_dparts'} ]);
|
||||
foreach my $d (@disks) {
|
||||
print &ui_columns_row([
|
||||
"<a href='edit_disk.cgi?device=".&urlize($d->{'device'}).
|
||||
"'>".&partition_description($d->{'device'})."</a>",
|
||||
&nice_size($d->{'size'}),
|
||||
$d->{'model'},
|
||||
scalar(@{$d->{'slices'}}),
|
||||
]);
|
||||
}
|
||||
print &ui_columns_end();
|
||||
}
|
||||
else {
|
||||
print "<b>$text{'index_none'}</b> <p>\n";
|
||||
}
|
||||
|
||||
&ui_print_footer("/", $text{'index'});
|
||||
#!/usr/local/bin/perl
|
||||
# Show a list of disks
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
no warnings 'uninitialized';
|
||||
require './bsdfdisk-lib.pl';
|
||||
our (%in, %text, %config, $module_name);
|
||||
|
||||
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
|
||||
&has_command('gpart') ? &help_search_link("gpart", "man") :
|
||||
&help_search_link("fdisk", "man"));
|
||||
|
||||
my $err = &check_fdisk();
|
||||
if ($err) {
|
||||
&ui_print_endpage(&text('index_problem', $err));
|
||||
}
|
||||
|
||||
my @disks = &list_disks_partitions();
|
||||
@disks = sort { $a->{'device'} cmp $b->{'device'} } @disks;
|
||||
if (@disks) {
|
||||
print &ui_columns_start([ $text{'index_dname'},
|
||||
$text{'index_dsize'},
|
||||
$text{'index_dmodel'},
|
||||
$text{'index_dparts'} ]);
|
||||
foreach my $d (@disks) {
|
||||
print &ui_columns_row([
|
||||
"<a href='edit_disk.cgi?device=".&urlize($d->{'device'}).
|
||||
"'>".&partition_description($d->{'device'})."</a>",
|
||||
&nice_size($d->{'size'}),
|
||||
$d->{'model'},
|
||||
scalar(@{$d->{'slices'}}),
|
||||
uc($d->{'type'}),
|
||||
]);
|
||||
}
|
||||
print &ui_columns_end();
|
||||
}
|
||||
else {
|
||||
print "<b>$text{'index_none'}</b> <p>\n";
|
||||
}
|
||||
|
||||
&ui_print_footer("/", $text{'index'});
|
||||
|
7
bsdfdisk/log_parser.pl
Executable file → Normal file
7
bsdfdisk/log_parser.pl
Executable file → Normal file
@ -8,10 +8,15 @@ do 'bsdfdisk-lib.pl';
|
||||
sub parse_webmin_log
|
||||
{
|
||||
my ($user, $script, $action, $type, $object, $p) = @_;
|
||||
if ($type eq "slice" || $type eq "part") {
|
||||
if ($type eq "slice" || $type eq "part" || $type eq "object") {
|
||||
return &text('log_'.$action.'_'.$type,
|
||||
"<tt>".&html_escape($object)."</tt>");
|
||||
}
|
||||
if ($type eq "disk") {
|
||||
return &text('log_'.$action.'_disk',
|
||||
"<tt>".&html_escape($object)."</tt>");
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
1;
|
||||
|
144
bsdfdisk/newfs.cgi
Executable file → Normal file
144
bsdfdisk/newfs.cgi
Executable file → Normal file
@ -1,72 +1,72 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Create a filesystem on a partition
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
no warnings 'uninitialized';
|
||||
require './bsdfdisk-lib.pl';
|
||||
our (%in, %text, $module_name);
|
||||
&ReadParse();
|
||||
&error_setup($text{'newfs_err'});
|
||||
|
||||
# Get the disk and slice
|
||||
my @disks = &list_disks_partitions();
|
||||
my ($disk) = grep { $_->{'device'} eq $in{'device'} } @disks;
|
||||
$disk || &error($text{'disk_egone'});
|
||||
my ($slice) = grep { $_->{'number'} eq $in{'slice'} } @{$disk->{'slices'}};
|
||||
$slice || &error($text{'slice_egone'});
|
||||
my ($object, $part);
|
||||
if ($in{'part'} ne '') {
|
||||
($part) = grep { $_->{'letter'} eq $in{'part'} }
|
||||
@{$slice->{'parts'}};
|
||||
$part || &error($text{'part_egone'});
|
||||
$object = $part;
|
||||
}
|
||||
else {
|
||||
$object = $slice;
|
||||
}
|
||||
|
||||
# Validate inputs
|
||||
my $newfs = { };
|
||||
$in{'free_def'} || $in{'free'} =~ /^\d+$/ && $in{'free'} <= 100 ||
|
||||
&error($text{'newfs_efree'});
|
||||
$newfs->{'free'} = $in{'free_def'} ? undef : $in{'free'};
|
||||
$newfs->{'trim'} = $in{'trim'};
|
||||
$in{'label_def'} || $in{'label'} =~ /^\S+$/ ||
|
||||
&error($text{'newfs_elabel'});
|
||||
$newfs->{'label'} = $in{'label_def'} ? undef : $in{'label'};
|
||||
|
||||
&ui_print_unbuffered_header($object->{'desc'}, $text{'newfs_title'}, "");
|
||||
|
||||
# Do the creation
|
||||
print &text('newfs_creating', "<tt>$object->{'device'}</tt>"),"<br>\n";
|
||||
print "<pre>\n";
|
||||
my $cmd = &get_create_filesystem_command($disk, $slice, $part, $newfs);
|
||||
&additional_log('exec', undef, $cmd);
|
||||
my $fh = "CMD";
|
||||
&open_execute_command($fh, $cmd, 2);
|
||||
while(<$fh>) {
|
||||
print &html_escape($_);
|
||||
}
|
||||
close($fh);
|
||||
print "</pre>";
|
||||
if ($?) {
|
||||
print $text{'newfs_failed'},"<p>\n";
|
||||
}
|
||||
else {
|
||||
print $text{'newfs_done'},"<p>\n";
|
||||
&webmin_log("newfs", $in{'part'} ne '' ? "part" : "object",
|
||||
$object->{'device'}, $object);
|
||||
}
|
||||
|
||||
if ($in{'part'} ne '') {
|
||||
&ui_print_footer("edit_part.cgi?device=$in{'device'}&".
|
||||
"slice=$in{'slice'}&part=$in{'part'}",
|
||||
$text{'part_return'});
|
||||
}
|
||||
else {
|
||||
&ui_print_footer("edit_slice.cgi?device=$in{'device'}&".
|
||||
"slice=$in{'slice'}",
|
||||
$text{'slice_return'});
|
||||
}
|
||||
#!/usr/local/bin/perl
|
||||
# Create a filesystem on a partition
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
no warnings 'uninitialized';
|
||||
require './bsdfdisk-lib.pl';
|
||||
our (%in, %text, $module_name);
|
||||
&ReadParse();
|
||||
&error_setup($text{'newfs_err'});
|
||||
|
||||
# Get the disk and slice
|
||||
my @disks = &list_disks_partitions();
|
||||
my ($disk) = grep { $_->{'device'} eq $in{'device'} } @disks;
|
||||
$disk || &error($text{'disk_egone'});
|
||||
my ($slice) = grep { $_->{'number'} eq $in{'slice'} } @{$disk->{'slices'}};
|
||||
$slice || &error($text{'slice_egone'});
|
||||
my $object = $slice;
|
||||
|
||||
# Handle partitions if specified
|
||||
my $part;
|
||||
if ($in{'part'} ne '') {
|
||||
($part) = grep { $_->{'letter'} eq $in{'part'} }
|
||||
@{$slice->{'parts'}};
|
||||
$part || &error($text{'part_egone'});
|
||||
$object = $part;
|
||||
}
|
||||
|
||||
# Validate inputs
|
||||
my $newfs = { };
|
||||
$in{'free_def'} || $in{'free'} =~ /^\d+$/ && $in{'free'} <= 100 ||
|
||||
&error($text{'newfs_efree'});
|
||||
$newfs->{'free'} = $in{'free_def'} ? undef : $in{'free'};
|
||||
$newfs->{'trim'} = $in{'trim'};
|
||||
$in{'label_def'} || $in{'label'} =~ /^\S+$/ ||
|
||||
&error($text{'newfs_elabel'});
|
||||
$newfs->{'label'} = $in{'label_def'} ? undef : $in{'label'};
|
||||
|
||||
&ui_print_unbuffered_header($object->{'desc'}, $text{'newfs_title'}, "");
|
||||
|
||||
# Create the filesystem
|
||||
print &text('newfs_creating', "<tt>$object->{'device'}</tt>"),"<br>\n";
|
||||
print "<pre>\n";
|
||||
my $cmd = &get_create_filesystem_command($disk, $slice, $part, $newfs);
|
||||
&additional_log('exec', undef, $cmd);
|
||||
my $fh = "CMD";
|
||||
&open_execute_command($fh, $cmd, 2);
|
||||
while(<$fh>) {
|
||||
print &html_escape($_);
|
||||
}
|
||||
close($fh);
|
||||
print "</pre>";
|
||||
if ($?) {
|
||||
print $text{'newfs_failed'},"<p>\n";
|
||||
}
|
||||
else {
|
||||
print $text{'newfs_done'},"<p>\n";
|
||||
&webmin_log("newfs", $in{'part'} ne '' ? "part" : "object",
|
||||
$object->{'device'}, $object);
|
||||
}
|
||||
|
||||
if ($in{'part'} ne '') {
|
||||
&ui_print_footer("edit_part.cgi?device=$in{'device'}&".
|
||||
"slice=$in{'slice'}&part=$in{'part'}",
|
||||
$text{'part_return'});
|
||||
}
|
||||
else {
|
||||
&ui_print_footer("edit_slice.cgi?device=$in{'device'}&".
|
||||
"slice=$in{'slice'}",
|
||||
$text{'slice_return'});
|
||||
}
|
||||
|
18
bsdfdisk/newfs_form.cgi
Executable file → Normal file
18
bsdfdisk/newfs_form.cgi
Executable file → Normal file
@ -9,22 +9,20 @@ require './bsdfdisk-lib.pl';
|
||||
our (%in, %text, $module_name);
|
||||
&ReadParse();
|
||||
|
||||
# Get the disk and slice
|
||||
# Get the disk and partition details
|
||||
my @disks = &list_disks_partitions();
|
||||
my ($disk) = grep { $_->{'device'} eq $in{'device'} } @disks;
|
||||
$disk || &error($text{'disk_egone'});
|
||||
my ($slice) = grep { $_->{'number'} eq $in{'slice'} } @{$disk->{'slices'}};
|
||||
$slice || &error($text{'slice_egone'});
|
||||
my $object;
|
||||
my $object = $slice;
|
||||
|
||||
if ($in{'part'} ne '') {
|
||||
my ($part) = grep { $_->{'letter'} eq $in{'part'} }
|
||||
@{$slice->{'parts'}};
|
||||
$part || &error($text{'part_egone'});
|
||||
$object = $part;
|
||||
}
|
||||
else {
|
||||
$object = $slice;
|
||||
}
|
||||
|
||||
&ui_print_header($object->{'desc'}, $text{'newfs_title'}, "");
|
||||
|
||||
@ -35,16 +33,20 @@ print &ui_hidden("part", $in{'part'});
|
||||
print &ui_table_start($text{'newfs_header'}, undef, 2);
|
||||
|
||||
print &ui_table_row($text{'part_device'},
|
||||
"<tt>$object->{'device'}</tt>");
|
||||
"<tt>$object->{'device'}</tt>") if ($object->{'device'});
|
||||
|
||||
# Free blocks percentage
|
||||
print &ui_table_row($text{'newfs_free'},
|
||||
&ui_opt_textbox("free", undef, 4, $text{'newfs_deffree'})."%");
|
||||
&ui_opt_textbox("free", undef, 4, $text{'newfs_free_def'},
|
||||
$text{'newfs_free_pc'})." %");
|
||||
|
||||
# Enable TRIM support
|
||||
print &ui_table_row($text{'newfs_trim'},
|
||||
&ui_yesno_radio("trim", 0));
|
||||
|
||||
# Filesystem label
|
||||
print &ui_table_row($text{'newfs_label'},
|
||||
&ui_opt_textbox("label", undef, 20, $text{'newfs_none'}));
|
||||
&ui_opt_textbox("label", undef, 20, $text{'newfs_label_def'}));
|
||||
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'newfs_create'} ] ]);
|
||||
|
12
bsdfdisk/part_form.cgi
Executable file → Normal file
12
bsdfdisk/part_form.cgi
Executable file → Normal file
@ -32,11 +32,11 @@ while($used{$l}) {
|
||||
print &ui_table_row($text{'npart_letter'},
|
||||
&ui_textbox("letter", $l, 4));
|
||||
|
||||
# Slice size in blocks
|
||||
# Available space in blocks
|
||||
print &ui_table_row($text{'npart_diskblocks'},
|
||||
$slice->{'blocks'});
|
||||
|
||||
# Start and end blocks (defaults to last part)
|
||||
# Start and end blocks calculation
|
||||
my ($start, $end) = (0, $slice->{'blocks'});
|
||||
foreach my $p (sort { $a->{'startblock'} cmp $b->{'startblock'} }
|
||||
@{$slice->{'parts'}}) {
|
||||
@ -47,11 +47,15 @@ print &ui_table_row($text{'nslice_start'},
|
||||
print &ui_table_row($text{'nslice_end'},
|
||||
&ui_textbox("end", $end, 10));
|
||||
|
||||
# Partition type
|
||||
# Partition type selection
|
||||
print &ui_table_row($text{'npart_type'},
|
||||
&ui_select("type", '4.2BSD',
|
||||
&ui_select("type", 'freebsd-ufs',
|
||||
[ &list_partition_types() ]));
|
||||
|
||||
# Partition label (optional)
|
||||
print &ui_table_row($text{'npart_label'},
|
||||
&ui_textbox("label", "", 20));
|
||||
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'create'} ] ]);
|
||||
|
||||
|
14
bsdfdisk/save_part.cgi
Executable file → Normal file
14
bsdfdisk/save_part.cgi
Executable file → Normal file
@ -26,9 +26,19 @@ if (@st && $st[2]) {
|
||||
&error(&text('part_esave', $use));
|
||||
}
|
||||
|
||||
# Make the change
|
||||
# Update partition properties
|
||||
$part->{'type'} = $in{'type'};
|
||||
my $err = &save_partition($disk, $slice, $part);
|
||||
my $err;
|
||||
if (defined($in{'label'})) {
|
||||
my $oldpart = { %$part };
|
||||
$part->{'label'} = $in{'label'} if defined($in{'label'});
|
||||
# Apply changes using gpart
|
||||
$err = &modify_partition($disk, $slice, $oldpart, $part);
|
||||
}
|
||||
else {
|
||||
$err = &save_partition($disk, $slice, $part);
|
||||
}
|
||||
|
||||
&error($err) if ($err);
|
||||
|
||||
&webmin_log("modify", "part", $part->{'device'}, $part);
|
||||
|
28
bsdfdisk/save_slice.cgi
Executable file → Normal file
28
bsdfdisk/save_slice.cgi
Executable file → Normal file
@ -8,7 +8,7 @@ no warnings 'uninitialized';
|
||||
require './bsdfdisk-lib.pl';
|
||||
our (%in, %text, $module_name);
|
||||
&ReadParse();
|
||||
&error_setup($text{'slice_err'});
|
||||
&error_setup($text{'save_err'});
|
||||
|
||||
# Get the disk and slice
|
||||
my @disks = &list_disks_partitions();
|
||||
@ -17,14 +17,24 @@ $disk || &error($text{'disk_egone'});
|
||||
my ($slice) = grep { $_->{'number'} eq $in{'slice'} } @{$disk->{'slices'}};
|
||||
$slice || &error($text{'slice_egone'});
|
||||
|
||||
# Apply changes
|
||||
my $oldslice = { %$slice };
|
||||
$slice->{'type'} = $in{'type'};
|
||||
if (!$slice->{'active'}) {
|
||||
$slice->{'active'} = $in{'active'};
|
||||
if ($in{'delete'}) {
|
||||
# Delete the slice
|
||||
my $err = &delete_slice($disk, $slice);
|
||||
&error($err) if ($err);
|
||||
&webmin_log("delete", "slice", $slice->{'device'}, $slice);
|
||||
}
|
||||
else {
|
||||
# Validate inputs
|
||||
$in{'type'} =~ /^\S+$/ || &error($text{'save_etype'});
|
||||
$in{'label'} =~ /^[a-zA-Z0-9._-]+$/ || &error($text{'save_elabel'});
|
||||
|
||||
# Update the slice
|
||||
my $oldslice = { %$slice };
|
||||
$slice->{'type'} = $in{'type'};
|
||||
$slice->{'label'} = $in{'label'};
|
||||
my $err = &modify_slice($disk, $oldslice, $slice);
|
||||
&error($err) if ($err);
|
||||
&webmin_log("modify", "slice", $slice->{'device'}, $slice);
|
||||
}
|
||||
my $err = &modify_slice($disk, $oldslice, $slice);
|
||||
&error($err) if ($err);
|
||||
|
||||
&webmin_log("modify", "slice", $slice->{'device'}, $slice);
|
||||
&redirect("edit_disk.cgi?device=$in{'device'}");
|
||||
|
18
bsdfdisk/slice_form.cgi
Executable file → Normal file
18
bsdfdisk/slice_form.cgi
Executable file → Normal file
@ -34,8 +34,8 @@ print &ui_table_row($text{'nslice_diskblocks'},
|
||||
$disk->{'blocks'});
|
||||
|
||||
# Start and end blocks (defaults to last slice+1)
|
||||
my ($start, $end) = (63, $disk->{'blocks'});
|
||||
foreach my $s (sort { $a->{'startblock'} cmp $b->{'startblock'} }
|
||||
my ($start, $end) = (2048, $disk->{'blocks'});
|
||||
foreach my $s (sort { $a->{'startblock'} <=> $b->{'startblock'} }
|
||||
@{$disk->{'slices'}}) {
|
||||
$start = $s->{'startblock'} + $s->{'blocks'} + 1;
|
||||
}
|
||||
@ -44,14 +44,16 @@ print &ui_table_row($text{'nslice_start'},
|
||||
print &ui_table_row($text{'nslice_end'},
|
||||
&ui_textbox("end", $end, 10));
|
||||
|
||||
# Slice type
|
||||
# GPT partition type
|
||||
print &ui_table_row($text{'nslice_type'},
|
||||
&ui_select("type", 'a5',
|
||||
[ sort { $a->[1] cmp $b->[1] }
|
||||
map { [ $_, &fdisk::tag_name($_) ] }
|
||||
&fdisk::list_tags() ]));
|
||||
&ui_select("type", 'freebsd-ufs',
|
||||
[ &list_partition_types() ]));
|
||||
|
||||
# Also create partition?
|
||||
# Partition label
|
||||
print &ui_table_row($text{'nslice_label'},
|
||||
&ui_textbox("label", "", 20));
|
||||
|
||||
# Create filesystem option
|
||||
print &ui_table_row($text{'nslice_makepart'},
|
||||
&ui_yesno_radio("makepart", 1));
|
||||
|
||||
|
Reference in New Issue
Block a user