Show un-used partitions too

This commit is contained in:
Jamie Cameron
2012-10-09 21:01:01 -07:00
parent a207a2b372
commit 7bdb656dff
3 changed files with 12 additions and 9 deletions

View File

@@ -224,12 +224,12 @@ my $out = &backquote_logged("$cmd 2>&1");
return $? ? $out : undef;
}
# get_connection_users(&conn)
# get_connection_users(&conn, [include-unused])
# Returns a list of partitions in the device for some connection, and their
# users (like raid, mount, lvm)
sub get_connection_users
{
my ($conn) = @_;
my ($conn, $unused) = @_;
return ( ) if (!$conn->{'device'});
my @users;
my @disks = &fdisk::list_disks_partitions();
@@ -237,7 +237,7 @@ my ($disk) = grep { $_->{'device'} eq $conn->{'device'} } @disks;
next if (!$disk);
foreach my $part (@{$disk->{'parts'}}) {
my @st = &fdisk::device_status($part->{'device'});
if (@st) {
if (@st || $unused) {
push(@users, [ $conn, $part, @st ]);
}
}

View File

@@ -148,6 +148,7 @@ dconns_part=Partition
dconns_use=Used by
dconns_size=Partition size
dconns_confirm=Remove Connections
dconns_unused=Unused
vconn_title=iSCSI Connection
vconn_egone=Selected connection no longer exists!

View File

@@ -59,19 +59,21 @@ if ($conn->{'device'}) {
&nice_size($disk->{'size'}));
}
my @users = &get_connection_users($conn);
my @users = &get_connection_users($conn, 1);
if (@users) {
my $utable = &ui_columns_start([
$text{'dconns_part'},
$text{'dconns_size'},
$text{'dconns_use'},
], undef, 0, [ "", "nowrap", "" ]);
], 100, 0, [ "nowrap", "nowrap", "nowrap" ]);
foreach my $u (@users) {
$utable .= &ui_columns_row([
&mount::device_name($u->[1]->{'device'}),
&nice_size($u->[1]->{'size'}),
&lvm::device_message($u->[2], $u->[3], $u->[4]),
], "50");
&mount::device_name($u->[1]->{'device'}),
&nice_size($u->[1]->{'size'}),
$u->[2] ?
&lvm::device_message($u->[2], $u->[3], $u->[4])
: "<i>$text{'dconns_unused'}</i>",
], "50");
}
$utable .= &ui_columns_end();
print &ui_table_row($text{'vconn_users'}, $utable);