From 3ed7a24053f0123d8d4e18ef313d83d23181de00 Mon Sep 17 00:00:00 2001 From: Niclas Berglind Date: Tue, 14 Oct 2014 22:25:18 +0200 Subject: [PATCH] Added try/catch when using /dev/disk/by-path Signed-off-by: Niclas Berglind --- gui/rpc/zfs.inc | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/gui/rpc/zfs.inc b/gui/rpc/zfs.inc index 881372a..9ab61a2 100644 --- a/gui/rpc/zfs.inc +++ b/gui/rpc/zfs.inc @@ -81,12 +81,16 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { $disks = preg_split("/[,;]/", $params['devices']); //Use /dev/disk/by-path as suggested in ZoL FAQ. if ($params['diskpath']) { - if (file_exists("/dev/disk/by-path/")) { - $tmp_disks = array(); - foreach ($disks as $disk) { - $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk); + try { + if (file_exists("/dev/disk/by-path/")) { + $tmp_disks = array(); + foreach ($disks as $disk) { + $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk); + } + $disks = $tmp_disks; } - $disks = $tmp_disks; + } catch (OMVModuleZFSException $e) { + //Do nothing if an excpetion is thrown } } @@ -581,12 +585,16 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { $disks = preg_split("/[,;]/", $params['devices']); //Use /dev/disk/by-path as suggested in ZoL FAQ. if ($params['diskpath']) { - if (file_exists("/dev/disk/by-path/")) { - $tmp_disks = array(); - foreach ($disks as $disk) { - $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk); + try { + if (file_exists("/dev/disk/by-path/")) { + $tmp_disks = array(); + foreach ($disks as $disk) { + $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk); + } + $disks = $tmp_disks; } - $disks = $tmp_disks; + } catch (OMVModuleZFSException $e) { + //Do nothing if an exception is thrown } } $vdev[] = new OMVModuleZFSVdev($params['name'], $pooltype, $disks); -- 2.39.5