[pve-devel] applied: [PATCH storage v2] fix #1912: find the partition instead of guessing it

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Sep 14 11:42:46 CEST 2018


On 9/14/18 11:13 AM, Dominik Csapak wrote:
> instead of using '$dev1' as partition,
> get the information from /sys/block/$dev
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> changes from v1:
> * use regex with word markers instead of string interpolation
>  PVE/API2/Disks/Directory.pm | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/API2/Disks/Directory.pm b/PVE/API2/Disks/Directory.pm
> index 8e6118a..9d27762 100644
> --- a/PVE/API2/Disks/Directory.pm
> +++ b/PVE/API2/Disks/Directory.pm
> @@ -220,7 +220,12 @@ __PACKAGE__->register_method ({
>  		print "# ", join(' ', @$cmd), "\n";
>  		run_command($cmd);
>  
> -		my $part = "${dev}1";
> +		my ($devname) = $dev =~ m|^/dev/(.*)$|;
> +		my $part = "/dev/";
> +		dir_glob_foreach("/sys/block/$devname", qr/\Q$devname\E.+/, sub {
> +		    my ($partition) = @_;
> +		    $part .= $partition;
> +		});
>  
>  		# create filesystem
>  		$cmd = [$MKFS, '-t', $type, $part];
> 

applied, thanks




More information about the pve-devel mailing list