From cc6e6edbf80008ea35979a3470fd8ed9567274b3 Mon Sep 17 00:00:00 2001 From: Niclas Berglind Date: Wed, 12 Mar 2014 20:34:19 +0100 Subject: [PATCH] Removed mountpoint attribute from Zvol. Signed-off-by: Niclas Berglind --- src/Zvol.php | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/Zvol.php b/src/Zvol.php index e6fba7b..82569d4 100644 --- a/src/Zvol.php +++ b/src/Zvol.php @@ -1,4 +1,6 @@ updateAllProperties(); - $this->mountPoint = $this->properties["mountpoint"]["value"]; - $this->size = $this->properties["size"]["value"]; + $this->size = $this->properties["volsize"]["value"]; continue; } } @@ -78,16 +71,6 @@ class OMVModuleZFSZvol { return $this->name; } - /** - * Get the mountpoint of the Zvol - * - * @return string $mountPoint - * @access public - */ - public function getMountPoint() { - return $this->mountPoint; - } - /** * Get a single property value associated with the Zvol * @@ -111,7 +94,6 @@ class OMVModuleZFSZvol { return $this->properties; } - /** * XXX * @@ -149,6 +131,26 @@ class OMVModuleZFSZvol { } } + /** + * Create a Zvol on commandline. Optionally provide a number of properties to set. + * + * @param string $size Size of the Zvol that should be created + * @param array $properties Properties to set when creating the dataset. + * @return void + * @access public + */ + public function create($size, array $properties = null, bool $sparse = null) { + $cmd = "zfs create -p "; + if (isset($sparse) && $sparse == true) { + $cmd .= "-s "; + } + $cmd .= "-V " . $size . " " . $this->name . " 2>&1"; + $this->exec($cmd,$out,$res); + $this->updateAllProperties(); + $this->setProperties($properties); + $this->size = $this->properties["volsize"]["value"]; + } + /** * Helper function to execute a command and throw an exception on error * (requires stderr redirected to stdout for proper exception message). @@ -167,7 +169,6 @@ class OMVModuleZFSZvol { } return $tmp; } - } ?> -- 2.39.2