]> git.datanom.net - omvzfs.git/blobdiff - src/Utils.php
Use /dev/disk/by-path as default for new pools as suggested by ZoL FAQ.
[omvzfs.git] / src / Utils.php
index cc0814bdbc474f2383a9d7569c5ef2b88939cfb0..4d577f8d26c3039e7caf91ebadd192722cc85f56 100644 (file)
@@ -8,6 +8,22 @@ require_once("Dataset.php");
  */
 class OMVModuleZFSUtil {
 
+       /**
+        * Get /dev/disk/by-path from /dev/sdX
+        *
+        * @return string Disk identifier
+        */
+       public static function getDiskPath($disk) {
+               preg_match("/^.*\/([A-Za-z0-9]+)$/", $disk, $identifier);
+               $cmd = "ls -la /dev/disk/by-path | grep '$identifier[1]$'";
+               OMVModuleZFSUtil::exec($cmd, $out, $res);
+               if (is_array($out)) {
+                       $cols = preg_split('/[\s]+/', $out[0]);
+                       return($cols[count($cols)-3]);
+               }
+       }
+
+
        /**
         * Get poolname from name of dataset/volume etc.
         *
This page took 0.195979 seconds and 5 git commands to generate.