#!/usr/local/bin/perl # Show details of a disk, and slices on it use strict; use warnings; no warnings 'redefine'; no warnings 'uninitialized'; require './bsdfdisk-lib.pl'; our ( %in, %text, $module_name ); &ReadParse(); my $extwidth = 100; # Get the disk my @disks = &list_disks_partitions(); # Validate input parameters $in{'device'} =~ /^[a-zA-Z0-9_\/.-]+$/ or &error( $text{'disk_edevice'} ); $in{'device'} !~ /\.\./ or &error( $text{'disk_edevice'} ); my ($disk) = grep { $_->{'device'} eq $in{'device'} } @disks; $disk || &error( $text{'disk_egone'} ); # Cache commonly used values my $device = $disk->{'device'}; my $device_url = &urlize($device); my $desc = $disk->{'desc'}; # Prefer total blocks from gpart header when available my $base_device = $disk->{'device'}; $base_device =~ s{^/dev/}{}; my $disk_structure = &get_disk_structure($base_device); my $disk_blocks = ( $disk_structure && $disk_structure->{'total_blocks'} ) ? $disk_structure->{'total_blocks'} : ( $disk->{'blocks'} || 1000000 ); # Precompute a scale factor for extent image widths my $scale = $extwidth / ( $disk_blocks || 1 ); &ui_print_header( $disk->{'desc'}, $text{'disk_title'}, "" ); # Debug toggle bar print "
Command: "
. &html_escape($cmd)
. "\nOutput:\n"
. &html_escape($out)
. "\n";
print "Disk Structure:\n";
foreach my $key ( sort keys %$disk_structure ) {
if ( $key eq 'entries' ) {
print "entries: [\n";
foreach my $entry ( @{ $disk_structure->{'entries'} } ) {
print " {\n";
foreach my $k ( sort keys %$entry ) {
print " $k: " . &html_escape( $entry->{$k} ) . "\n";
}
print " },\n";
}
print "]\n";
}
else {
print "$key: " . &html_escape( $disk_structure->{$key} ) . "\n";
}
}
print "";
print "Raw GEOM output:\n";
print &html_escape(
&backquote_command(
"geom disk list " . "e_path($device) . " 2>/dev/null"
)
);
print "";
print "";
my $cmd = "zpool status 2>&1";
my $out = &backquote_command($cmd);
print "Command: "
. &html_escape($cmd)
. "\nOutput:\n"
. &html_escape($out) . "\n";
print "";
print "Partition Details Mapping:\n";
foreach my $pnum ( sort { $a <=> $b } keys %part_details ) {
print " $pnum: {\n";
foreach my $k ( sort keys %{ $part_details{$pnum} } ) {
print " $k: "
. &html_escape( $part_details{$pnum}->{$k} ) . "\n";
}
print " },\n";
}
print "";
print "$text{'disk_none'}
\n"; } } print &ui_links_row( \@links ); # Show SMART status link if available if ( &has_command("smartctl") ) { print &ui_hr(); print &ui_buttons_start(); print &ui_buttons_row( "smart.cgi", $text{'disk_smart'}, $text{'disk_smartdesc'}, &ui_hidden( "device", $device ) ); print &ui_buttons_end(); } # Debug: ZFS cache detail if ( $in{'debug'} ) { print "Pools: " . join( ", ", keys %$zfs_pools ) . "\n\nDevices:\n";
foreach my $device_id ( sort keys %$zfs_devices ) {
next if $device_id =~ /^_debug_/;
my $device_info = $zfs_devices->{$device_id};
print
"$device_id => Pool: $device_info->{'pool'}, Type: $device_info->{'vdev_type'}, Mirrored: "
. ( $device_info->{'is_mirrored'} ? "Yes" : "No" )
. ", RAIDZ: "
. ( $device_info->{'is_raidz'}
? "Yes (Level: $device_info->{'raidz_level'})"
: "No" )
. ", Single: "
. ( $device_info->{'is_single'} ? "Yes" : "No" )
. ", Striped: "
. ( $device_info->{'is_striped'} ? "Yes" : "No" ) . "\n";
}
print "";
print "