function strip_exists($device, &$a_vdevice) { if (false !== array_search_ex($diskv['devicespecialfile'], $a_vdevice, "device")) { return true; } foreach ($a_vdevice as $vdevs) { foreach ($vdevs['device'] as $dev) { // label $tmp = disks_label_to_device($dev); if (strcmp($tmp, $device) == 0) { return true; } // label+partition $tmp = strip_partition($tmp); if (strcmp($tmp, $device) == 0) { return true; } // partition $tmp = strip_partition($dev); if (strcmp($tmp, $device) == 0) { return true; } } } return false; }
} $zfs['pools']['pool'][$pool]['hastpool'] = $hastpool; $cfg['zfs']['pools']['pool'][] = $zfs['pools']['pool'][$pool]; } foreach ($_POST['vdev'] as $vdev) { $import |= true; $cfg['zfs']['vdevices']['vdevice'][] = $zfs['vdevices']['vdevice'][$vdev]; } if ($import) { $cfg['disks'] = $config['disks']; $cfg['geli'] = $config['geli']; $disks = get_physical_disks_list(); foreach ($cfg['zfs']['vdevices']['vdevice'] as $vdev) { foreach ($vdev['device'] as $device) { $encrypted = false; $device = disks_label_to_device($device); if (preg_match("/^(.+)\\.eli\$/", $device, $m)) { $device = $m[1]; $encrypted = true; } if (preg_match("/^(.*)p\\d+\$/", $device, $m)) { $device = $m[1]; } $index = false; if (!empty($cfg['disks']['disk'])) { $index = array_search_ex($device, $cfg['disks']['disk'], 'devicespecialfile'); } if ($index === false && isset($_POST['import_disks'])) { $disk = array_search_ex($device, $disks, 'devicespecialfile'); $disk = $disks[$disk]; $cfg['disks']['disk'][] = array('uuid' => uuid(), 'name' => $disk['name'], 'devicespecialfile' => $disk['devicespecialfile'], 'harddiskstandby' => 0, 'acoustic' => 0, 'fstype' => $encrypted ? 'geli' : 'zfs', 'apm' => 0, 'transfermode' => 'auto', 'type' => $disk['type'], 'desc' => $disk['desc'], 'size' => $disk['size'], 'serial' => $disk['serial'], 'smart' => false);