Merge pull request #1839 from SimonFair/VM-ZFS-Fixes

ZFS fixes
This commit is contained in:
tom mortensen
2024-08-29 11:58:12 -07:00
committed by GitHub
4 changed files with 9 additions and 6 deletions

View File

@@ -2003,8 +2003,10 @@
if (is_file($disk)) unlink($disk);
if (is_file($cfg)) unlink($cfg);
if (is_file($xml)) unlink($xml);
#if (is_dir($dir) && $this->is_dir_empty($dir)) rmdir($dir);
if (is_dir($dir) && $this->is_dir_empty($dir)) my_rmdir($dir);
if (is_dir($dir) && $this->is_dir_empty($dir)) {
$error = my_rmdir($dir);
qemu_log("$domain","delete empty $dir $error");
}
}
return true;

View File

@@ -2845,7 +2845,7 @@ function check_zfs_name($zfsname, $storage="default") {
$storage=transpose_user_path($storage);
$fstype = trim(shell_exec(" stat -f -c '%T' $storage"));
#Check if ZFS.
$allowed_chars = "/^[A-Za-z0-9\-_.:]+$/";
$allowed_chars = "/^[A-Za-z0-9][A-Za-z0-9\-_.: ]*$/";
if ($fstype == "zfs" && !preg_match($allowed_chars, $zfsname)) {
return false;
} else {

View File

@@ -2015,7 +2015,7 @@ function checkName(name) {
/* Declare variables at the function scope */
var isValidName
$('#zfs-name').hide();
isValidName = /^[A-Za-z0-9][A-Za-z0-9\-_.:]*$/.test(name);
isValidName = /^[A-Za-z0-9][A-Za-z0-9\-_.: ]*$/.test(name);
if (isValidName) {
$('#btnSubmit').prop("disabled", false);
} else {

View File

@@ -356,8 +356,9 @@ function my_rmdir($dirname) {
$rtncode = false;
switch ($fstype) {
case "zfs":
$zfsdataset = trim(shell_exec("zfs list -H -o name $dirname")) ;
$rtncode=exec("zfs destroy \"$zfsdataset\"");
$zfsoutput = array();
$zfsdataset = trim(shell_exec("zfs list -H -o name \"$dirname\"")) ;
exec("zfs destroy \"$zfsdataset\"",$zfsoutput,$rtncode);
break;
case "btrfs":
default: