mirror of
https://github.com/webmin/webmin.git
synced 2025-07-20 16:48:46 +00:00
Work on partition editing page
This commit is contained in:
@ -10,6 +10,7 @@ BEGIN { push(@INC, ".."); };
|
||||
use WebminCore;
|
||||
&init_config();
|
||||
&foreign_require("mount");
|
||||
&foreign_require("fdisk");
|
||||
|
||||
sub check_fdisk
|
||||
{
|
||||
|
79
bsdfdisk/edit_disk.cgi
Normal file
79
bsdfdisk/edit_disk.cgi
Normal file
@ -0,0 +1,79 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Show partitions on one disk
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
require './bsdfdisk-lib.pl';
|
||||
our (%in, %text, $module_name);
|
||||
&ReadParse();
|
||||
my $extwidth = 300;
|
||||
|
||||
# Get the disk
|
||||
my @disks = &list_disks_partitions();
|
||||
my ($disk) = grep { $_->{'device'} eq $in{'device'} } @disks;
|
||||
$disk || &error($text{'disk_egone'});
|
||||
|
||||
&ui_print_header($disk->{'device'}, $text{'disk_title'}, "");
|
||||
|
||||
# Show disk details
|
||||
my @info = ( );
|
||||
push(@info, &text('disk_dsize', &nice_size($d->{'size'}));
|
||||
if ($d->{'model'}) {
|
||||
push(@info, &text('disk_model', $d->{'model'}));
|
||||
}
|
||||
push(@info, &text('disk_cylinders', $d->{'cylinders'}));
|
||||
print &ui_links_row(\@info),"<p>\n";
|
||||
|
||||
# Show partitions table
|
||||
my @links = ( "<a href='edit_part.cgi?device=".&urlize($disk->{'device'}).
|
||||
"&new=1'>".$text{'disk_add'}."</a>" );
|
||||
if (@{$disk->{'parts'}}) {
|
||||
print &ui_links_row(\@links);
|
||||
print &ui_columns_start([
|
||||
$text{'disk_no'},
|
||||
$text{'disk_type'},
|
||||
$text{'disk_extent'},
|
||||
$text{'disk_size'},
|
||||
$text{'disk_start'},
|
||||
$text{'disk_end'},
|
||||
$text{'disk_use'},
|
||||
]);
|
||||
foreach my $p (@{$disk->{'parts'}}) {
|
||||
# Create images for the extent
|
||||
my $ext = "";
|
||||
$ext .= sprintf "<img src=images/gap.gif height=10 width=%d>",
|
||||
$extwidth*($p->{'start'} - 1) /
|
||||
$disk->{'cylinders'};
|
||||
$ext .= sprintf "<img src=images/%s.gif height=10 width=%d>",
|
||||
$p->{'extended'} ? "ext" : "use",
|
||||
$extwidth*($p->{'end'} - $p->{'start'}) /
|
||||
$disk->{'cylinders'};
|
||||
$ext .= sprintf "<img src=images/gap.gif height=10 width=%d>",
|
||||
$extwidth*($disk->{'cylinders'} - ($p->{'end'} - 1)) /
|
||||
$disk->{'cylinders'};
|
||||
|
||||
# Create usage description
|
||||
my @stat = &fdisk::device_status($p->{'device'});
|
||||
my $stat = &device_status_link(@stat);
|
||||
|
||||
# Add row for the partition
|
||||
my $url = "edit_part.cgi?device=".&urlize($disk->{'device'}).
|
||||
"&part=".$p->{'number'};
|
||||
print &ui_columns_row([
|
||||
"<a href='$url'>$p->{'number'}</a>",
|
||||
"<a href='$url'>".&fdisk::tag_name($p->{'type'})."</a>",
|
||||
$ext,
|
||||
&nice_size($p->{'size'}),
|
||||
$p->{'start'},
|
||||
$p->{'end'},
|
||||
$stat,
|
||||
]);
|
||||
}
|
||||
print &ui_columns_end();
|
||||
}
|
||||
else {
|
||||
print "<b>$text{'disk_none'}</b><p>\n";
|
||||
}
|
||||
print &ui_links_row(\@links);
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
BIN
bsdfdisk/images/ext.gif
Normal file
BIN
bsdfdisk/images/ext.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 B |
BIN
bsdfdisk/images/gap.gif
Normal file
BIN
bsdfdisk/images/gap.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 B |
BIN
bsdfdisk/images/use.gif
Normal file
BIN
bsdfdisk/images/use.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 B |
@ -22,7 +22,7 @@ if (@disks) {
|
||||
$text{'index_dparts'} ]);
|
||||
foreach my $d (@disks) {
|
||||
print &ui_columns_row([
|
||||
"<a href='edit_disk.cgi?dev=".&urlize($d->{'device'}).
|
||||
"<a href='edit_disk.cgi?device=".&urlize($d->{'device'}).
|
||||
"'>".&html_escape($d->{'device'})."</a>",
|
||||
&nice_size($d->{'size'}),
|
||||
$d->{'model'},
|
||||
|
@ -6,3 +6,25 @@ index_dname=Disk name
|
||||
index_dsize=Total size
|
||||
index_dmodel=Make and model
|
||||
index_dparts=Partitions
|
||||
index_return=list of disks
|
||||
|
||||
disk_title=Edit Disk Partitions
|
||||
disk_egone=Disk no longer exists!
|
||||
disk_no=Number
|
||||
disk_type=Type
|
||||
disk_extent=Extent
|
||||
disk_start=Start
|
||||
disk_end=End
|
||||
disk_use=Used by
|
||||
disk_free=Free space
|
||||
disk_vm=Virtual memory
|
||||
disk_iscsi=iSCSI shared device $1
|
||||
disk_none=This disk has no partitions yet.
|
||||
disk_size=Size
|
||||
disk_dsize=<b>Disk size:</b> $1
|
||||
disk_model=<b>Make and model:</b> $1
|
||||
disk_cylinders=<b>Cylinders:</b> $1
|
||||
disk_table=<b>Partition format:</b> $1
|
||||
disk_return=list of partitions
|
||||
disk_add=Add primary partition.
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
desc=Partitions on Local Disks
|
||||
os_support=freebsd
|
||||
category=hardware
|
||||
depends=mount
|
||||
depends=mount fdisk
|
||||
desc_de=Partitionen auf lokalen Festplatten
|
||||
|
@ -88,40 +88,7 @@ if (@parts) {
|
||||
|
||||
# Work out usage
|
||||
@stat = &device_status($p->{'device'});
|
||||
$stat = "";
|
||||
$statdesc = $stat[0] =~ /^swap/ ? "<i>$text{'disk_vm'}</i>"
|
||||
: "<tt>$stat[0]</tt>";
|
||||
if ($stat[1] eq 'raid') {
|
||||
$stat = $statdesc;
|
||||
}
|
||||
elsif ($stat[1] eq 'lvm') {
|
||||
if (&foreign_available("lvm")) {
|
||||
$stat = "<a href='../lvm/'>".
|
||||
"LVM VG $statdesc</a>";
|
||||
}
|
||||
else {
|
||||
$stat = "LVM VG $statdesc";
|
||||
}
|
||||
}
|
||||
elsif ($stat[1] eq 'iscsi') {
|
||||
$stat = &text('disk_iscsi', $stat[0]);
|
||||
if (&foreign_available("iscsi-server")) {
|
||||
$stat = "<a href='../$stat[3]/'>$stat</a>";
|
||||
}
|
||||
}
|
||||
elsif ($stat[0] && !&foreign_available("mount")) {
|
||||
$stat = $statdesc;
|
||||
}
|
||||
elsif ($stat[0] && $stat[3] == -1) {
|
||||
$stat = "<a href='../mount/edit_mount.cgi?".
|
||||
"index=$stat[4]&temp=1&return=/$module_name/'>".
|
||||
"$statdesc</a>";
|
||||
}
|
||||
elsif ($stat[0]) {
|
||||
$stat = "<a href='../mount/edit_mount.cgi?".
|
||||
"index=$stat[3]&return=/$module_name/'>".
|
||||
"$statdesc</a>";
|
||||
}
|
||||
$stat = &device_status_link(@stat);
|
||||
|
||||
print &ui_columns_row([
|
||||
"<a href='$url'>$p->{'number'}</a>",
|
||||
|
@ -1162,6 +1162,48 @@ if ($iscsi_target_module) {
|
||||
return ();
|
||||
}
|
||||
|
||||
# device_status_link(directory, type, mounted, module)
|
||||
# Converts the list returned by device_status to a link
|
||||
sub device_status_link
|
||||
{
|
||||
my @stat = @_;
|
||||
my $stat = "";
|
||||
my $statdesc = $stat[0] =~ /^swap/ ? "<i>$text{'disk_vm'}</i>"
|
||||
: "<tt>$stat[0]</tt>";
|
||||
if ($stat[1] eq 'raid') {
|
||||
$stat = $statdesc;
|
||||
}
|
||||
elsif ($stat[1] eq 'lvm') {
|
||||
if (&foreign_available("lvm")) {
|
||||
$stat = "<a href='../lvm/'>".
|
||||
"LVM VG $statdesc</a>";
|
||||
}
|
||||
else {
|
||||
$stat = "LVM VG $statdesc";
|
||||
}
|
||||
}
|
||||
elsif ($stat[1] eq 'iscsi') {
|
||||
$stat = &text('disk_iscsi', $stat[0]);
|
||||
if (&foreign_available("iscsi-server")) {
|
||||
$stat = "<a href='../$stat[3]/'>$stat</a>";
|
||||
}
|
||||
}
|
||||
elsif ($stat[0] && !&foreign_available("mount")) {
|
||||
$stat = $statdesc;
|
||||
}
|
||||
elsif ($stat[0] && $stat[3] == -1) {
|
||||
$stat = "<a href='../mount/edit_mount.cgi?".
|
||||
"index=$stat[4]&temp=1&return=/$module_name/'>".
|
||||
"$statdesc</a>";
|
||||
}
|
||||
elsif ($stat[0]) {
|
||||
$stat = "<a href='../mount/edit_mount.cgi?".
|
||||
"index=$stat[3]&return=/$module_name/'>".
|
||||
"$statdesc</a>";
|
||||
}
|
||||
return $stat;
|
||||
}
|
||||
|
||||
# can_fsck(type)
|
||||
# Returns 1 if some filesystem type can fsck'd
|
||||
sub can_fsck
|
||||
|
Reference in New Issue
Block a user