- /**
- * XXX
- *
- * @return int XXX
- * @access public
- */
- public function getSize() {
- trigger_error('Not Implemented!', E_USER_WARNING);
- }
+ /**
+ * Constructor
+ *
+ * @param string $name Name of the new Dataset
+ * @param array $features An array of features to set when creating the Dataset
+ *
+ */
+ public function __construct($name, array $features = null) {
+ $cmd = "zfs create ";
+ if (isset($features)) {
+ $cmd .= "-o " . implode(",", $features) . " ";
+ }
+ $cmd .= $name . " 2>&1";
+ exec($cmd,$out,$res);
+ if ($res == 1) {
+ throw new OMVModuleZFSException(implode("\n", $out));
+ }
+ unset($res);
+ $this->name = $name;
+ if (isset($features)) {
+ $this->features = $features;
+ foreach ($features as $feature) {
+ if (preg_match('/^mountpoint\=(.*)$/', $feature, $res)) {
+ $this->mountPoint = $res[1];
+ continue;
+ }
+ }
+ } else {
+ $this->features = array();
+ $this->mountPoint = "/" . $name;
+ }
+ }