|
|
@ -8,6 +8,7 @@ closedir($dh); |
|
|
|
my $json; |
|
|
|
my $json; |
|
|
|
foreach my $block (@blocks){ |
|
|
|
foreach my $block (@blocks){ |
|
|
|
my $removable = 0; |
|
|
|
my $removable = 0; |
|
|
|
|
|
|
|
my $size = 1; |
|
|
|
if ( -e "/sys/block/$block/removable"){ |
|
|
|
if ( -e "/sys/block/$block/removable"){ |
|
|
|
open REMOVABLE, "/sys/block/$block/removable"; |
|
|
|
open REMOVABLE, "/sys/block/$block/removable"; |
|
|
|
$removable = join "", <REMOVABLE>; |
|
|
|
$removable = join "", <REMOVABLE>; |
|
|
@ -15,8 +16,15 @@ foreach my $block (@blocks){ |
|
|
|
chomp($removable); |
|
|
|
chomp($removable); |
|
|
|
next if ($removable eq '1'); |
|
|
|
next if ($removable eq '1'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ( -e "/sys/block/$block/size"){ |
|
|
|
|
|
|
|
open SIZE, "/sys/block/$block/size"; |
|
|
|
|
|
|
|
$size = join "", <SIZE>; |
|
|
|
|
|
|
|
close SIZE; |
|
|
|
|
|
|
|
chomp($size); |
|
|
|
|
|
|
|
next if ($size eq '0'); |
|
|
|
|
|
|
|
} |
|
|
|
my $dev = '/dev/' . $block; |
|
|
|
my $dev = '/dev/' . $block; |
|
|
|
push @{$json->{data}}, { "{#BLOCKDEVICE}" => $dev }; |
|
|
|
push @{$json->{data}}, { "{#BLOCKDEVICE}" => $dev, "{#BLOCKSIZE}" => $size }; |
|
|
|
} |
|
|
|
} |
|
|
|
print to_json($json); |
|
|
|
print to_json($json); |
|
|
|
exit(0); |
|
|
|
exit(0); |
|
|
|