]> git.proxmox.com Git - pve-storage.git/blame - PVE/Storage/ZFSDirPlugin.pm
ZFSDirPlugin: new plugin for local zfs storage
[pve-storage.git] / PVE / Storage / ZFSDirPlugin.pm
CommitLineData
5bb8e010
DM
1package PVE::Storage::ZFSDirPlugin;
2
3use strict;
4use warnings;
5use IO::File;
6use POSIX;
7use PVE::Tools qw(run_command);
8use PVE::Storage::Plugin;
9
10
11use base qw(PVE::Storage::Plugin);
12
13sub zfs_parse_size {
14 my ($text) = @_;
15
16 return 0 if !$text;
17
18 if ($text =~ m/^(\d+(\.\d+)?)([TGMK])?$/) {
19 my ($size, $reminder, $unit) = ($1, $2, $3);
20 return $size if !$unit;
21 if ($unit eq 'K') {
22 $size *= 1024;
23 } elsif ($unit eq 'M') {
24 $size *= 1024*1024;
25 } elsif ($unit eq 'G') {
26 $size *= 1024*1024*1024;
27 } elsif ($unit eq 'T') {
28 $size *= 1024*1024*1024*1024;
29 }
30
31 if ($reminder) {
32 $size = ceil($size);
33 }
34 return $size;
35 } else {
36 return 0;
37 }
38}
39
40sub type {
41 return 'zfsdir';
42}
43
44sub plugindata {
45 return {
46 content => [ { images => 1, rootdir => 1, vztmpl => 1, iso => 1, backup => 1},
47 { images => 1 }],
48 };
49}
50
51sub options {
52 return {
53 path => { fixed => 1 },
54 nodes => { optional => 1 },
55 disable => { optional => 1 },
56 maxfiles => { optional => 1 },
57 content => { optional => 1 },
58 };
59}
60
61# fixme: implement me
62
631;