- $xpath = "//system/fstab/mntent[fsname=" . $pooluuid . "]";
- $object = $xmlConfig->get($xpath);
- if(is_null($object)) {
- $uuid = OMVUtil::uuid();
- $ds = new OMVModuleZFSDataset($name);
- $dir = $ds->getMountPoint();
- $object = array(
- "uuid" => $uuid,
- "fsname" => $pooluuid,
- "dir" => $dir,
- "type" => "zfs",
- "opts" => "rw,relatime,xattr",
- "freq" => "0",
- "passno" => "2"
- );
- $xmlConfig->set("//system/fstab",array("mntent" => $object));
- $dispatcher = &OMVNotifyDispatcher::getInstance();
- $dispatcher->notify(OMV_NOTIFY_CREATE,"org.openmediavault.system.fstab.mntent", $object);
+ if (isset($pooluuid)) {
+ $pooluuid = "UUID=" . $pooluuid;
+ $xpath = "//system/fstab/mntent";
+ $object = $xmlConfig->get($xpath);
+ $uuidexists = false;
+ foreach ($object as $obj) {
+ if (strcmp($pooluuid, $obj['fsname']) === 0) {
+ $uuidexists = true;
+ break;
+ }
+ }
+ if (!$uuidexists) {
+ $uuid = OMVUtil::uuid();
+ $ds = new OMVModuleZFSDataset($name);
+ $dir = $ds->getMountPoint();
+ $object = array(
+ "uuid" => $uuid,
+ "fsname" => $pooluuid,
+ "dir" => $dir,
+ "type" => "zfs",
+ "opts" => "rw,relatime,xattr",
+ "freq" => "0",
+ "passno" => "2"
+ );
+ $xmlConfig->set("//system/fstab",array("mntent" => $object));
+ $dispatcher = &OMVNotifyDispatcher::getInstance();
+ $dispatcher->notify(OMV_NOTIFY_CREATE,"org.openmediavault.system.fstab.mntent", $object);
+ }