label.c revision 91e1058474884b4b6f1d3665a96ddeb9a30cd489
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/dditypes.h>
#include "i2o_bs.h"
static int dsklbl_chk(struct dk_label *, unsigned short *);
char *partition_type(unsigned char);
struct dk_geom *, int);
void dsklbl_mprint(struct partition *);
struct cb_ops *);
#ifdef DLBL_DEBUG
int label_debug = 1;
#else
#endif
static int
{
short *sp;
short count;
unsigned short sum;
/*
* Check magic number of the label
*/
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
/*
* Check the checksum of the label
*/
sum = 0;
while (count--) {
}
if (sum)
return (DDI_FAILURE);
return (DDI_SUCCESS);
}
/*
* We have this wonderful scenario where there exists two different kind
* (read broken) that it justifies having two completely different preplb
* routines.
*/
static void
{
long disksize;
int rval;
int s2size;
#if defined(_SUNOS_VTOC_16)
"nsect = %d)\n",
#elif defined(_SUNOS_VTOC_8)
#endif
/* or can use the size saved in ata_data (consider generic case */
/*
* Set up the p0 partition
*/
/* NEEDS WORK add support for SPARC for CD */
/*
* If CD-ROM, special-case:
* - add full disk as slices 0 and 2 to the label
*/
/*
* Not heads * sectors * cyls, but the whole thing
* This applies later, to s2, as well.
*/
/* NEEDS WORK get it from IOP probably not SD uses it too */
#if defined(_SUNOS_VTOC_16)
#elif defined(_SUNOS_VTOC_8)
/* Add full disk slice as slice 2 to the disk */
#else
#endif
} else {
/* NONE CD case */
/* Add boot disk slice as slice 8 to the disk */
/*
* There is a number of cases we have to worry about:
*
* 1) There is an fdisk partition but no Solaris partition.
* In this case the s2 slice size is zero since a valid
* Solaris partition must be present for us to decide the
* the size of the Solaris partition.
*
* 2) There is an fdisk parition and a Solaris partition.
* We got here because the Solaris partition was not labeled
* or the label has been corrupted, declare the entire Solaris
* parition as the s2 slice
*
* 3) There is no fdisk partition.
* We have to declare the entire disk as the s2 slice,
* with some room for the fdisk partition (I think)
*/
if (lblp->fdiskpresent) {
s2size = 0;
} else { /* FDISK + Solaris (2 above) */
}
} else { /* No FDISK (3 above) */
}
#if defined(_SUNOS_VTOC_16)
/*
*/
/* Add full disk slice as slice 2 to the disk */
/* For now this is not a requirenment */
/* Add Alternates disk slice as slice 9 to the disk */
"DEFAULT cyl %d alt %d hd %d sec %d",
#elif defined(_SUNOS_VTOC_8)
/* Add full disk slice as slice 2 to the disk */
"DEFAULT cyl %d alt %d hd %d sec %d",
#else
#endif
}
/*
* now that an on disk label is manufactured, convert so
* that we start using right away
* is this the right thing to do, we also need a mutex
* to protext it.
*
* dsklbl_convert_lbl_to_pmap(&lblp->ondsklbl, lblp);
*
*/
}
static void
{
int i;
#if defined(_SUNOS_VTOC_16)
#elif defined(_SUNOS_VTOC_8)
for (i = 0; i < NDKMAP; i++) {
}
#else
#endif
for (i = 0; i < NDKMAP; i++) {
}
}
static void
{
/*
* save the disk label in memory
*/
#ifdef DLBL_DEBUG
#endif
}
static int
{
unsigned short sum;
/*
* read the label
*/
/*
* check label
*/
"?label does not have a valid checksum\n"));
return (DDI_FAILURE);
}
/*
* record label information
*/
return (DDI_SUCCESS);
}
struct {
unsigned char id;
char *name;
} partitionname[] = {
{ 0x01, "DOS 12-bit FAT" },
{ 0x02, "XENIX /" },
{ 0x03, "XENIX /usr" },
{ 0x04, "DOS 16-bit FAT <32M" },
{ 0x05, "DOS Extended Partition" },
{ 0x06, "DOS 16-bit FAT >=32M" },
{ 0x07, "OS/2 IFS (e.g., HPFS) or NTFS or QNX2.x or Advanced UNIX" },
{ 0x08, "AIX boot or SplitDrive" },
{ 0x09, "AIX data or Coherent" },
{ 0x0a, "OS/2 Boot Manager" },
{ 0x0e, "DOS 16-bit FAT, CHS-mapped" },
{ 0x0f, "Extended partition, CHS-mapped" },
{ 0x10, "OPUS" },
{ 0x11, "OS/2 BM: Hidden DOS 12-bit FAT" },
{ 0x12, "Compaq config partition" },
{ 0x14, "OS/2 BM: Hidden DOS 16-bit FAT <32M" },
{ 0x16, "OS/2 BM: Hidden DOS 16-bit FAT >=32M" },
{ 0x17, "OS/2 BM: Hidden IFS (e.g., HPFS)" },
{ 0x18, "AST Windows swapfile" },
{ 0x24, "NEC DOS" },
{ 0x3c, "PartitionMagic recovery partition" },
{ 0x40, "Venix 80286" },
{ 0x42, "Linux swap (sharing disk with DRDOS) or SFS" },
{ 0x43, "Linux native (sharing disk with DRDOS)" },
{ 0x50, "OnTrack DM RO" },
{ 0x51, "OnTrack DM RW (DM6 Aux1) or Novell" },
{ 0x53, "DM6 Aux3" },
{ 0x54, "DM6" },
{ 0x55, "EZ-Drive" },
{ 0x56, "Golden Bow VFeature Partitioned Volume." },
{ 0x5C, "Priam EDisk" },
{ 0x61, "SpeedStor" },
{ 0x63, "Unix System V (SCO, ISC UNIX, UnixWare, ...)" },
{ 0x64, "Novell Netware 2.xx" },
{ 0x65, "Novell Netware 3.xx or 4.xx" },
{ 0x70, "DiskSecure Multi-Boot" },
{ 0x77, "QNX4.x" },
{ 0x78, "QNX4.x 2nd part" },
{ 0x79, "QNX4.x 3rd part" },
{ 0x80, "MINIX until 1.4a" },
{ 0x81, "MINIX since 1.4b, early Linux, Mitac dmgr" },
{ 0x82, "Solaris" },
{ 0x83, "Linux native" },
{ 0x84, "OS/2 hidden C: drive" },
{ 0x85, "Linux extended partition" },
{ 0x86, "NTFS volume set??" },
{ 0x87, "NTFS volume set??" },
{ 0x93, "Amoeba" },
{ 0x94, "Amoeba bad track table" },
{ 0xa0, "IBM Thinkpad hibernation partition" },
{ 0xa5, "BSD/386, 386BSD, NetBSD, FreeBSD" },
{ 0xa7, "NEXTSTEP" },
{ 0xb7, "BSDI fs" },
{ 0xb8, "BSDI swap" },
{ 0xc7, "Syrinx" },
{ 0xdb, "Concurrent CP/M or Concurrent DOS or CTOS" },
{ 0xe1, "DOS access or SpeedStor 12-bit FAT extended partition" },
{ 0xe3, "DOS R/O or SpeedStor" },
{ 0xe4, "SpeedStor 16-bit FAT extended partition < 1024 cyl." },
{ 0xf1, "SpeedStor" },
{ 0xf2, "DOS 3.3+ secondary" },
{ 0xf4, "SpeedStor large partition" },
{ 0xfe, "SpeedStor >1024 cyl. or LANstep" },
{ 0xff, "Xenix Bad Block Table" }
};
char *
partition_type(unsigned char systid)
{
int i;
for (i = 0; i < sizeof (partitionname)/sizeof (partitionname[0]); i++)
return (partitionname[i].name);
return ("Unknown");
}
int
{
int i, uidx;
/*
* The whole disk is represented here (this is the p0 partition.)
*/
"?lbl 0x%x does not have an fdisk table.\n",
#ifdef DLBL_DEBUG
if (mbp)
"expteced magic: 0x%x got 0x%x\n",
#endif
"parse_label: b_edev %x "
"b_dev = %x\n",
lblp->fdiskpresent = 0;
}
return (DDI_SUCCESS);
}
/*
* The fdisk table does not begin on a 4-byte boundary within
* the master boot record; so, we need to recopy its contents to
* another data structure to avoid an alignment exception.
* This is not necessary for x86, but it avoids ifdefs
*/
"?---------------------- Partition Table -----------------\n"));
"?------- ------- ------- -----------------------------\n"));
continue;
}
if (uidx == 0)
uidx = i;
uidx = i;
}
}
}
return (DDI_SUCCESS);
}
void
{
/*
* read the label
*/
}
#ifdef DLBL_DEBUG
void
{
int i;
}
}
}
#endif
int
{
int status;
int backup_block;
int count;
/*
* Data is originated from vtoc. One copy of the data is stored in
* lblp->ondsklbl. This is what we think of as the copy of the lable
* on this held in memory. The other copy (to the lbp) is to be
* written out to the disk.
*/
/*
* check label
*/
else
return (status);
/*
* DO backup copies of vtoc
*/
backup_block += 2;
}
return (0);
}
void
{
#if defined(_SUNOS_VTOC_16)
sizeof (*vtocp));
#elif defined(_SUNOS_VTOC_8)
int i;
long nblks;
/*
* Data is originated from vtoc. One copy of the data is stored in
* lblp->ondsklbl. This is what we think of as the copy of the label
* on the disk held in memory. The other copy (to the lbp) is to be
* written out to the disk.
*/
/*
* Put appropriate vtoc structure fields into the disk label
*
*/
/* For now may want to add the sectorsz field to the generic structur */
/*
* Note the conversion from starting sector number
* to starting cylinder number.
*/
lmap++;
lpart++;
vpart++;
}
#else
#endif
}
void
{
#if defined(_SUNOS_VTOC_16)
sizeof (*vtocp));
#elif defined(_SUNOS_VTOC_8)
/*
* Put appropriate vtoc structure fields into the disk label
*
*/
int i;
long nblks;
/*
* Data is originated from vtoc. One copy of the data is stored in
* lblp->ondsklbl. This is what we think of as the copy of the label
* on this disk held in memory. The other copy (to the lbp) is to be
* written out to the disk.
*/
sizeof (vtocp->v_bootinfo));
sizeof (vtocp->v_reserved));
/*
* Note the conversion from starting sector number
* to starting cylinder number.
*/
lmap++;
lpart++;
vpart++;
}
#else
#endif
}
void
{
#if !defined(__sparc)
#endif
}
void
{
#if !defined(__sparc)
#endif
}