/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* This file contains functions that operate on partition tables.
*/
#include <string.h>
#include <stdlib.h>
#include "global.h"
#include "partition.h"
#include "misc.h"
#include "menu_command.h"
#include "menu_partition.h"
/*
* Default vtoc information for non-SVr4 partitions
*/
{ V_ROOT, 0 }, /* a - 0 */
{ V_UNASSIGNED, 0 }, /* d - 3 */
{ V_UNASSIGNED, 0 }, /* e - 4 */
{ V_UNASSIGNED, 0 }, /* f - 5 */
{ V_USR, 0 }, /* g - 6 */
{ V_UNASSIGNED, 0 }, /* h - 7 */
#if defined(_SUNOS_VTOC_16)
#if defined(i386)
{ V_ALTSCTR, 0 }, /* j - 9 */
#else
#endif /* defined(i386) */
{ V_UNASSIGNED, 0 }, /* k - 10 */
{ V_UNASSIGNED, 0 }, /* l - 11 */
{ V_UNASSIGNED, 0 }, /* m - 12 */
{ V_UNASSIGNED, 0 }, /* n - 13 */
{ V_UNASSIGNED, 0 }, /* o - 14 */
{ V_UNASSIGNED, 0 }, /* p - 15 */
#endif /* defined(_SUNOS_VTOC_16) */
};
/*
* This routine finds the last usable sector in the partition table.
* It skips the BACKUP partition.
*/
static uint64_t
{
int i;
sec_no[0] = 0;
}
sec_no[1] = 0;
}
if (i == 0) {
}
} else {
}
}
if (max == 0)
max = 34;
return (max);
}
/*
* This routine allows the user to change the boundaries of the given
* partition in the current partition map.
*/
void
{
uint_t i;
uint_t j;
int deflt;
int tag;
int flag;
/*
* check if there exists a partition table for the disk.
*/
err_print("Current Disk has no partition table.\n");
return;
}
if (cur_label == L_TYPE_EFI) {
err_print("Invalid partition for EFI label\n");
return;
}
fmt_print("\n");
/*
* Prompt for p_tag and p_flag values for this partition
*/
if (deflt == V_UNASSIGNED) {
}
}
(int *)&efi_deflt, DATA_INPUT);
(int *)&efi_deflt, DATA_INPUT);
if (j64 == 0) {
tag = V_UNASSIGNED;
i64 = 0;
}
/*
* We are now done with EFI part, so return now
*/
return;
}
/*
* getting into.
*/
fmt_print("\n");
/*
* Prompt for p_tag and p_flag values for this partition.
*/
/*
* Ask for the new values. The old values are the defaults, and
* strict bounds checking is done on the values given.
*/
#if defined(i386)
/*
* Determine cyl offset for boot and alternate partitions.
* Assuming that the alternate sectors partition (slice)
* physical location immediately follows the boot
* partition and partition sizes are expressed in multiples
* of cylinder size.
*/
}
}
}
#endif /* defined(i386) */
&deflt, DATA_INPUT);
/* fill in defaults for the current partition */
/* call input, passing p_deflt's address, typecast to (int *) */
(int *)&p_deflt, DATA_INPUT);
/*
* If the current partition has a size of zero change the
* tag to Unassigned and the starting cylinder to zero
*/
if (j == 0) {
tag = V_UNASSIGNED;
i = 0;
}
#if defined(i386)
/*
* Check if it's the boot or alternates slice and warn
* accordingly
*/
fmt_print("\nWarning: Partition overlaps boot ");
fmt_print("partition. Specify different start cyl.\n");
return;
}
/*
* Cyl offset for alternates partition was calculated before
*/
if (i < cyl_offset) {
fmt_print("\nWarning: Partition overlaps alternates ");
fmt_print("partition. Specify different start cyl.\n");
return;
}
}
#endif /* defined(i386) */
/*
* If user has entered a V_BACKUP tag then the partition
* size should specify full disk capacity else
* return an Error.
*/
if (fullsz != j) {
/*
* V_BACKUP Tag Partition != full disk capacity.
* print useful messages.
*/
fmt_print("\nWarning: Partition with V_BACKUP tag should ");
fmt_print("specify full disk capacity. \n");
return;
}
}
/*
* If the current partition is named, we can't change it.
* We create a new current partition map instead.
*/
/*
* Change the values.
*/
#if defined(_SUNOS_VTOC_16)
#endif /* defined(_SUNOS_VTOC_16) */
/*
* Install the p_tag and p_flag values for this partition
*/
}
/*
* This routine picks to closest partition table which matches the
* selected disk type. It is called each time the disk type is
* changed. If no match is found, it uses the first element
* of the partition table. If no table exists, a dummy is
* created.
*/
int
{
/*
* If there are no pre-defined maps for this disk type, it's
* an error.
*/
err_print("No defined partition tables.\n");
return (-1);
}
/*
* Loop through the pre-defined maps searching for one which match
* disk type. If found copy it into unmamed partition.
*/
if (cur_dtype->dtype_asciilabel) {
cur_dtype->dtype_asciilabel) == 0) {
/*
* Set current partition and name it.
*/
return (0);
}
}
}
/*
* If we couldn't find a match, take the first one.
* Set current partition and name it.
*/
return (0);
}
/*
* This routine creates a new partition map and sets it current. If there
* was a current map, the new map starts out identical to it. Otherwise
* the new map starts out all zeroes.
*/
void
{
int i;
/*
* Lock out interrupts so the lists don't get mangled.
*/
/*
* Get space for for the new map and link it into the list
* of maps for the current disk type.
*/
} else {
}
}
/*
* If there was a current map, copy its values.
*/
if (cur_label == L_TYPE_EFI) {
int nparts;
int size;
return;
}
for (i = 0; i < NDKMAP; i++) {
}
} else {
/*
* Otherwise set initial default vtoc values
*/
}
/*
* Make the new one current.
*/
}
/*
* This routine deletes a partition map from the list of maps for
* the given disk type.
*/
void
{
/*
* If there isn't a current map, it's an error.
*/
err_print("Error: unexpected null partition list.\n");
fullabort();
}
/*
* Remove the map from the list.
*/
else {
;
}
/*
* Free the space it was using.
*/
destroy_data((char *)parts);
}
/*
* Set all partition vtoc fields to defaults
*/
void
{
int i;
for (i = 0; i < NDKMAP; i++) {
}
}