From e078be88378149c73ba149af46cf6d595866c5c5 Mon Sep 17 00:00:00 2001 From: Niclas Berglind Date: Mon, 14 Apr 2014 20:48:59 +0200 Subject: [PATCH] Added methods to Dataset to get it's origin if it's a clone. Signed-off-by: Niclas Berglind --- src/Dataset.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Dataset.php b/src/Dataset.php index f61baa1..253909c 100644 --- a/src/Dataset.php +++ b/src/Dataset.php @@ -293,6 +293,35 @@ class OMVModuleZFSDataset { unset($this->snapshots[$snap_name]); } + /** + * Check if the Dataset is a clone or not. + * + * @return bool + * @access public + */ + public function isClone() { + $origin = $this->getProperty("origin"); + if (strlen($origin) > 0) { + return true; + } else { + return false; + } + } + + /** + * Get the origin of the Dataset if it's a clone. + * + * @return string The name of the origin if it exists. Otherwise an empty string. + * @access public + */ + public function getOrigin() { + if ($this->isClone()) { + return $this->getProperty("origin"); + } else { + return ""; + } + } + /** * Helper function to execute a command and throw an exception on error * (requires stderr redirected to stdout for proper exception message). -- 2.39.2