+ /**
+ * Manages relocation of ZFS filesystem mountpoints in the OMV backend.
+ * Needed when the user changes mountpoint of a filesystem in the GUI.
+ *
+ */
+ public static function relocateFilesystem($name) {
+ global $xmlConfig;
+ $poolname = OMVModuleZFSUtil::getPoolname($name);
+ $pooluuid = OMVModuleZFSUtil::getUUIDbyName($poolname);
+ $ds = new OMVModuleZFSDataset($name);
+ $dir = $ds->getMountPoint();
+ $xpath = "//system/fstab/mntent[fsname='" . $pooluuid . "' and dir='" . $dir . "' and type='zfs']";
+ $object = $xmlConfig->get($xpath);
+ $object['dir'] = $property['value'];
+ $xmlConfig->replace($xpath, $object);
+ return null;
+ }
+
+ /**
+ * Clears all ZFS labels on specified devices.
+ * Needed for blkid to display proper data.
+ *
+ */
+ public static function clearZFSLabel($disks) {
+ foreach ($disks as $disk) {
+ $cmd = "zpool labelclear /dev/" . $disk . "1";
+ OMVModuleZFSUtil::exec($cmd,$out,$res);
+ }
+ return null;
+ }
+
+ /**
+ * Return all disks in /dev/sdXX used by the pool
+ *
+ * @return array An array with all the disks
+ */
+ public static function getDevDisksByPool($name) {
+ $pool = new OMVModuleZFSZpool($name);
+ $disks = array();
+ $vdevs = $pool->getVdevs();
+ foreach ($vdevs as $vdev) {
+ $vdisks = $vdev->getDisks();
+ foreach ($vdisks as $vdisk) {
+ if (preg_match('/^[a-z0-9]+$/', $vdisk)) {
+ $disks[] = $vdisk;
+ continue;
+ }
+ $cmd = "ls -la /dev/disk/by-path/" . $vdisk;
+ unset($out);
+ OMVModuleZFSUtil::exec($cmd,$out,$res);
+ if (count($out) === 1) {
+ if (preg_match('/^.*\/([a-z0-9]+)$/', $out[0], $match)) {
+ $disks[] = $match[1];
+ }
+ }
+ }
+ }
+ return($disks);
+ }
+