X-Git-Url: http://git.datanom.net/omvzfs.git/blobdiff_plain/4163f889aa50c1ee7f66ff9392ba600048221edb..e20fe312a03771aeb3233e1ef640a3c9b8d9c737:/src/Utils.php diff --git a/src/Utils.php b/src/Utils.php index cc0814b..4d577f8 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -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. *