6 |
|
|
7 |
hdparm -t `block-devices` |
hdparm -t `block-devices` |
8 |
|
|
9 |
|
sfdisk -l `block-devices with-partitions` |
10 |
|
|
11 |
=cut |
=cut |
12 |
|
|
13 |
use warnings; |
use warnings; |
14 |
use strict; |
use strict; |
15 |
#use autodie; |
#use autodie; |
16 |
|
|
17 |
|
my $with_partitions = { true => 1 } if grep { m/with.?partitions/ } @ARGV; |
18 |
|
|
19 |
open(my $proc, '<', '/proc/partitions'); |
open(my $proc, '<', '/proc/partitions'); |
20 |
|
|
21 |
my @header; |
my @header; |
22 |
my $last_device; |
my $last_device = ''; |
23 |
|
|
24 |
my $name2col; |
my $name2col; |
25 |
sub col { |
sub col { |
41 |
next unless $_; |
next unless $_; |
42 |
|
|
43 |
my $device = col 'name', $_; |
my $device = col 'name', $_; |
44 |
if ( $last_device && substr( $device, 0, length($last_device) ) eq $last_device ) { |
my $device_like_last = substr( $device, 0, length($last_device) ); |
45 |
warn "# partition $device\n"; |
if ( $last_device && $device_like_last eq $last_device ) { |
46 |
|
if ( $with_partitions ) { |
47 |
|
print "/dev/$device_like_last\n" if ! $with_partitions->{ $device_like_last }++; |
48 |
|
} else { |
49 |
|
warn "# partition $device\n"; |
50 |
|
} |
51 |
} else { |
} else { |
52 |
print '/dev/', $last_device = $device, $/; |
print "/dev/$device\n" unless $with_partitions; |
53 |
|
$last_device = $device; |
54 |
} |
} |
55 |
} |
} |
56 |
|
|