mirror of
https://github.com/schoebel/mars
synced 2024-12-11 09:15:48 +00:00
marsadm: allow devices as size argument
This commit is contained in:
parent
f4f9ba93e2
commit
08c776fc36
@ -1095,6 +1095,14 @@ sub try_to_avoid_splitbrain {
|
||||
sub get_size {
|
||||
my $arg = shift;
|
||||
my $orig_arg = $arg;
|
||||
# Do what I mean: when given a device, take its actual size.
|
||||
if (-b $arg) {
|
||||
my $mangled = $arg;
|
||||
$mangled =~ s:/dev/::;
|
||||
$mangled =~ s:/:!:g;
|
||||
my $path = "/sys/block/$mangled/size";
|
||||
$arg = `cat $path` * 512 if -r $path;
|
||||
}
|
||||
if ($arg !~ m/^([0-9]+(?:\.[0-9]*)?)([kmgtp]?)$/i) {
|
||||
ldie "Size argument '$arg' must be a number, optionally followed by a suffix [kKmMgGtTpP]. Lowercase = multiples of 1000, Uppercase = multiples of 1024.\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user