diff --git a/plugins/dynamix.vm.manager/scripts/qemu.php b/plugins/dynamix.vm.manager/scripts/qemu.php index 8da524e46..1ee5390fe 100755 --- a/plugins/dynamix.vm.manager/scripts/qemu.php +++ b/plugins/dynamix.vm.manager/scripts/qemu.php @@ -14,12 +14,10 @@ function detect_user_share(&$arg) { $arg = preg_replace_callback('|(/mnt/user/[^,]+\.[^,\s]*)|', function($match) { if (is_file($match[0])) { // resolve the actual disk or cache backing device for this user share path - $realdisk = trim(shell_exec("getfattr --absolute-names -n user.LOCATIONS ".escapeshellarg($match[0])." 2>/dev/null|grep -Po '^user.LOCATIONS=\"\K[^\\\"]+'")); + $realdisk = trim(shell_exec("getfattr --absolute-names --only-values -n user.LOCATION ".escapeshellarg($match[0])." 2>/dev/null")); if (!empty($realdisk)) { - // there may be several disks participating in this path (e.g. disk1,2,3) so - // only return the first disk and replace 'user' with say 'cache' or 'disk1' - $replacement = str_replace('/mnt/user/', '/mnt/'.strtok($realdisk.',', ',').'/', $match[0]); + $replacement = str_replace('/mnt/user/', "/mnt/$realdisk/", $match[0]); if (is_file($replacement)) { // the replacement path (e.g. /mnt/disk1/domains/vmname/vdisk1.img) checks out so use it @@ -40,4 +38,4 @@ foreach ($argv as $arg) { $whole_cmd .= escapeshellarg($arg).' '; } -echo trim($whole_cmd); \ No newline at end of file +echo trim($whole_cmd); diff --git a/plugins/dynamix/Browse.page b/plugins/dynamix/Browse.page index a1c8e9550..cf11d5d9a 100644 --- a/plugins/dynamix/Browse.page +++ b/plugins/dynamix/Browse.page @@ -23,13 +23,9 @@ function sort_by($field, $opt, $show_disk) { // read directory contents into 'list' array global $docroot,$dir; $path = $docroot.preg_replace('/([\'" &()[\]\\\\])/','\\\\$1',$dir).'/*'; - $file = array(); $disk = array(); $list = array(); + $file = array(); $list = array(); $i = 0; exec("shopt -s dotglob ; stat -L -c'%F|%n|%s|%Y' $path 2>/dev/null", $file); - if ($show_disk) - exec("shopt -s dotglob ; getfattr --absolute-names -n user.LOCATIONS $path 2>/dev/null|grep -Po '^user.LOCATIONS=\"\K[^\\\"]+'", $disk); - else - $disk = array_fill(0, max(count($file),1), ''); foreach ($file as $entry) { $attr = explode('|', $entry); $info = pathinfo($attr[1]); @@ -39,7 +35,7 @@ function sort_by($field, $opt, $show_disk) { 'fext' => strtolower($info['extension']), 'size' => $attr[2], 'time' => $attr[3], - 'disk' => my_disk($disk[$i++])); + 'disk' => $show_disk?my_disk(exec("shopt -s dotglob ; getfattr --absolute-names --only-values -n user.LOCATIONS '$attr[1]'")):''); } // sort by input 'field' if ($field=='name') { @@ -125,7 +121,7 @@ $disk_order=($column=='disk'?$order:'A');
> > diff --git a/plugins/dynamix/include/Helpers.php b/plugins/dynamix/include/Helpers.php index 138562e9d..a7307706b 100644 --- a/plugins/dynamix/include/Helpers.php +++ b/plugins/dynamix/include/Helpers.php @@ -221,12 +221,9 @@ function autov($file) { } function transpose_user_path($path) { if (strpos($path, '/mnt/user/') === 0 && file_exists($path)) { - $realdisk = trim(shell_exec("getfattr --absolute-names -n user.LOCATIONS ".escapeshellarg($path)." 2>/dev/null|grep -Po '^user.LOCATIONS=\"\K[^\\\"]+'")); - if (!empty($realdisk)) { - // there may be several disks participating in this path (e.g. disk1,2,3) so - // only return the first disk and replace 'user' with say 'cache' or 'disk1' - $path = str_replace('/mnt/user/', '/mnt/'.strtok($realdisk.',', ',').'/', $path); - } + $realdisk = trim(shell_exec("getfattr --absolute-names --only-values -n user.LOCATION ".escapeshellarg($path)." 2>/dev/null")); + if (!empty($realdisk)) + $path = str_replace('/mnt/user/', "/mnt/$realdisk/", $path); } return $path; }