[pve-devel] [PATCH] This function checks if the $volid reside on zfs.
Wolfgang Bumiller
w.bumiller at proxmox.com
Mon Mar 7 14:51:42 CET 2016
On Mon, Mar 07, 2016 at 12:49:20PM +0100, Wolfgang Link wrote:
> ---
> PVE/Storage.pm | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index 140f8ae..044e866 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -1270,4 +1270,24 @@ sub complete_volume {
> return $res;
> }
>
> +sub is_image_on_zfs {
> + my ($volid) = @_;
> +
> + my ($storeid, $volname) = parse_volume_id($volid);
> +
> + my $storecfg = config();
> + my $path = $storecfg->{ids}->{$storeid}->{path};
> + my $zfs = 0;
> +
> + my $is_zfs = sub{
> + my ($line) = shift @_;
> +
> + $zfs = 1 if ($line =~ m/ zfs /);
With `df --output=fstype` instead of '-T' you could do an exact match.
(Outputs *only* the type... and a line with the header string 'Type'.
Why 'df' has no parameter to omit that header line is beyond me...)
> + };
> +
> + PVE::Tools::run_command("df -T $path", 'timeout' => 5, 'outfunc' => $is_zfs);
Evil! Array variant please.
> +
> + return $zfs;
> +}
> +
> 1;
> --
> 2.1.4
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
More information about the pve-devel
mailing list