function get_all_device($a_extent, $uuid) { $a = array(); $a[''] = gettext("Must choose one"); foreach (get_conf_all_disks_list_filtered() as $diskv) { $file = $diskv['devicespecialfile']; $size = $diskv['size']; $name = $diskv['name']; $desc = $diskv['desc']; if (strcmp($size, "NA") == 0) { continue; } if (disks_exists($file) == 1) { continue; } $index = array_search_ex($file, $a_extent, "path"); if (FALSE !== $index) { if (!isset($uuid)) { continue; } if ($a_extent[$index]['uuid'] != $uuid) { continue; } } if (disks_ismounted_ex($file, "devicespecialfile")) { continue; } $a[$file] = htmlspecialchars("{$name}: {$size} ({$desc})"); } return $a; }
function ismounted_or_dataset($path) { if (disks_ismounted_ex($path, "mp")) { return true; } mwexec2("/sbin/zfs list -H -o mountpoint", $rawdata); foreach ($rawdata as $line) { $mp = trim($line); if ($mp == "-") { conitnue; } if ($path == $mp) { return true; } } return false; }
updatenotify_delete("raid_gvinum"); } header("Location: disks_raid_gvinum.php"); exit; } } if (!is_array($config['gvinum']['vdisk'])) { $config['gvinum']['vdisk'] = array(); } array_sort_key($config['gvinum']['vdisk'], "name"); $a_raid =& $config['gvinum']['vdisk']; if ($_GET['act'] === "del") { unset($errormsg); if ($a_raid[$_GET['id']]) { // Check if disk is mounted. if (0 == disks_ismounted_ex($a_raid[$_GET['id']]['devicespecialfile'], "devicespecialfile")) { updatenotify_set("raid_gvinum", UPDATENOTIFY_MODE_DIRTY, $a_raid[$_GET['id']]['uuid']); header("Location: disks_raid_gvinum.php"); exit; } else { $errormsg = sprintf(gettext("The RAID volume is currently mounted! Remove the <a href='%s'>mount point</a> first before proceeding."), "disks_mount.php"); } } } function gvinum_process_updatenotification($mode, $data) { global $config; $retval = 0; switch ($mode) { case UPDATENOTIFY_MODE_NEW: $retval |= disks_raid_gvinum_configure($data);
if ($_POST['passphrase'] !== $_POST['passphraseconf']) { $input_errors[] = gettext("Passphrase don't match."); } if (0 != mwexec("/sbin/kldstat -q -m aesni")) { mwexec("/sbin/kldload -q aesni.ko"); } if (empty($input_errors)) { $pconfig['do_action'] = true; $pconfig['init'] = isset($_POST['init']) ? true : false; $pconfig['name'] = $a_alldisk[$_POST['disk']]['name']; // e.g. da2 $pconfig['devicespecialfile'] = $a_alldisk[$_POST['disk']]['devicespecialfile']; // e.g. /dev/da2 $pconfig['aalgo'] = "none"; // Check whether disk is mounted. if (disks_ismounted_ex($pconfig['devicespecialfile'], "devicespecialfile")) { $errormsg = sprintf(gettext("The disk is currently mounted! <a href='%s'>Unmount</a> this disk first before proceeding."), "disks_mount_tools.php?disk={$pconfig['devicespecialfile']}&action=umount"); $pconfig['do_action'] = false; } if ($pconfig['do_action']) { // Set new file system type attribute ('fstype') in configuration. set_conf_disk_fstype($pconfig['devicespecialfile'], "geli"); // Get disk information. $diskinfo = disks_get_diskinfo($pconfig['devicespecialfile']); $geli = array(); $geli['uuid'] = uuid(); $geli['name'] = $pconfig['name']; $geli['device'] = $pconfig['devicespecialfile']; $geli['devicespecialfile'] = "{$geli['device']}.eli"; $geli['desc'] = "Encrypted disk"; $geli['size'] = "{$diskinfo['mediasize_mbytes']}MB";
foreach ($volumelabels as $volumelabel) { $reqdfields = explode(" ", "volumelabel"); $reqdfieldsn = array(gettext("Volume label")); $reqdfieldst = explode(" ", "alias"); do_input_validation_type(array('volumelabel' => $volumelabel), $reqdfields, $reqdfieldsn, $reqdfieldst, $input_errors); } if (count($volumelabels) > 1 && count($volumelabels) > count($disks)) { $input_errors[] = gettext("Wrong number of argument for Volume label"); } if (empty($input_errors)) { $do_format = array(); if (count($disks) > 0) { foreach ($disks as $key => $disk) { $do_format[$key] = true; // Check whether disk is mounted. if (disks_ismounted_ex($disk, "devicespecialfile")) { $errormsg = sprintf(gettext("The disk is currently mounted! <a href='%s'>Unmount</a> this disk first before proceeding."), "disks_mount_tools.php?disk={$disk}&action=umount"); $do_format[$key] = false; } // Check if user tries to format the OS disk. if (preg_match("/" . preg_quote($disk, "/") . "\\D+/", $cfdevice)) { $input_errors[] = gettext("Can't format the OS origin disk!"); $do_format[$key] = false; } if ($do_format[$key]) { // Set new file system type attribute ('fstype') in configuration. $opt = array(); $opt['zfsgpt'] = $zfsgpt ? "p1" : ""; set_conf_disk_fstype($disk, $type, $opt); if (count($volumelabels) == 1 && count($disks) > 1) { for ($i = 0; $i < count($disks); $i++) {
unset($input_errors); // Input validation. $reqdfields = explode(" ", "disk action"); $reqdfieldsn = array(gettext("Disk"), gettext("Command")); if (isset($_POST['action']) && $_POST['action'] === "attach") { $reqdfields = array_merge($reqdfields, explode(" ", "passphrase")); $reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Passphrase"))); } do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); if (0 != mwexec("/sbin/kldstat -q -m aesni")) { mwexec("/sbin/kldload -q aesni.ko"); } if (empty($input_errors)) { $pconfig['do_action'] = true; // Action = 'detach' => Check if device is mounted if ($_POST['action'] === "detach" && 1 == disks_ismounted_ex($_POST['disk'], "devicespecialfile")) { $errormsg = sprintf(gettext("The encrypted device is currently mounted! <a href='%s'>Unmount</a> this disk first before proceeding."), "disks_mount_tools.php?disk={$_POST['disk']}&action=umount"); $pconfig['do_action'] = false; } $pconfig['action'] = $_POST['action']; $pconfig['disk'] = $_POST['disk']; $pconfig['oldpassphrase'] = $_POST['oldpassphrase']; $pconfig['passphrase'] = $_POST['passphrase']; // Get configuration. $id = array_search_ex($pconfig['disk'], $a_geli, "devicespecialfile"); $geli = $a_geli[$id]; } } if (!isset($pconfig['action'])) { $pconfig['do_action'] = false; $pconfig['action'] = "";
foreach ($a_mount as $mount) { ?> <?php $notificationmode = updatenotify_get_mode("mountpoint", $mount['uuid']); switch ($notificationmode) { case UPDATENOTIFY_MODE_NEW: $status = gettext("Initializing"); break; case UPDATENOTIFY_MODE_MODIFIED: $status = gettext("Modifying"); break; case UPDATENOTIFY_MODE_DIRTY: $status = gettext("Deleting"); break; default: if (disks_ismounted_ex($mount['sharename'], "sharename")) { $status = gettext("OK"); } else { $status = gettext("Error") . " - <a href=\"disks_mount.php?act=retry&uuid={$mount['uuid']}\">" . gettext("Retry") . "</a>"; } break; } ?> <tr> <?php if ("disk" === $mount['type']) { ?> <td class="listlr"><?php echo htmlspecialchars($mount['devicespecialfile']); ?> </td>