Menu="Device:1" Title="$name _(Settings)_" Tag="hdd-o" Cond="array_key_exists($name, $disks) || array_key_exists($name, $devs)" --- 0 ? $sheets[$i - 1] : $sheets[$end]; $next = $i < $end ? $sheets[$i + 1] : $sheets[0]; $textErase = isPool($name) ? _('This will ERASE content of ALL devices in the pool') : _('This will ERASE ALL device content'); $textDelete = _('This will unassign all devices from the pool but will NOT modify any device contents'); function disabled_if($condition) { if ($condition !== false) { echo ' disabled'; } } function sanitize(&$val) { $data = explode('.', str_replace([' ',','], ['','.'], $val)); $last = array_pop($data); $val = count($data) ? implode($data).".$last" : $last; $val = preg_replace('/[^0-9.]/', '', $val); } function presetSpace($val) { global $disk,$display; if (!$val or strcasecmp($val, 'NaN') == 0) { return; } sanitize($val); $size = _var($disk, 'fsSize', 0); $size = $size > 0 ? round(100 * $val / $size, 1) : 0; $units = ['KB','MB','GB','TB','PB','EB','ZB','YB']; $base = $val > 0 ? floor(log($val, 1000)) : 0; $size = round($val / pow(1000, $base), 1); $unit = _var($units, $base); [$dot,$comma] = str_split(_var($display, 'number', '.,')); return $size > 0 ? number_format($size, $size - floor($size) ? 1 : 0, $dot, $comma).' '.$unit : ''; } function fsSize() { global $disks,$pools; $fsSize = []; foreach ($pools as $pool) { $fsSize[] = '"'.$pool.'":"'._var($disks[$pool], 'fsSize', 0).'"'; } return implode(',', $fsSize); } function fsType($type) { global $disk; return strpos(_var($disk, 'fsType'), $type) !== false; } function diskStatus($status) { global $disk; return strpos(_var($disk, 'status'), $status) !== false; } function diskType(...$types) { global $disk; $pass = false; foreach ($types as $type) { $pass |= _var($disk, 'type') == $type; } return $pass; } function makeList($list) { return implode(',', array_map('escapestring', $list)); } function sharename($share) { return basename($share, '.cfg'); } function makeTemp(&$disk, $zone) { global $display; switch ($zone) { case 'hot': $nvme = 'wctemp'; break; case 'max': $nvme = 'cctemp'; break; } return _var($disk, 'transport') == 'nvme' ? get_nvme_info(_var($disk, 'device'), $nvme) : (_var($disk, 'rotational', 1) == 0 && $display["{$zone}ssd"] >= 0 ? $display["{$zone}ssd"] : $display[$zone]); } function maintenance_mode() { global $var; return _var($var, 'fsState') == "Started" && _var($var, 'startMode') == "Maintenance" && _var($disk, 'luksState', 0) <= 1; } function isPool($name) { global $pools; return in_array($name, $pools); } /* Check to see if a pool has already been upgraded. */ function is_upgraded_ZFS_pool($pool_name) { /* See if the pool is aready upgraded. */ $upgrade = trim(shell_exec("/usr/sbin/zpool status ".escapeshellarg($pool_name)." | /usr/bin/grep 'Enable all features using.'") ?? ""); return ($upgrade ? false : true); } ?>