fdisk_partition.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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"
/*
* Fdisk partition class implementation file
*/
/*
* System include files
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include <string.h>
/*
* Private data and procedure declarations
*/
#include "partition_private.h"
/*
* Forward declarations of private methods
*/
static partition_result_t
static int is_dos_drive(uchar_t);
/*
* Methods that implement abstract methods
* declared in the parent partition class
*/
static partition_methods_t partition_methods =
/*
* Definition of the public read_partition() method that
* identifies the partition type and sets its attributes
*/
{
/*
* Check to see if there is an fdisk partition table in
* the partition. If so, searche the fdisk partition
* table for partitions that aren't empty and aren't
* extended DOS partitions. If such a partition exists,
* create an empty child partition object and link it to
* the parent fdisk partition. Set the child partition's
* offset on the medium and call read_partition(), passing
* it the child object's handle.
*
* Next, search the fdisk partition table for extended
* DOS partitions. If one exists, create an empty child
* partition object and link it to the fdisk partition.
* Set the child partition's offset on the medium and call
* read_partition(), passing it the child object's handle.
*
* NOTE: This method is recursive. It can call itself
* and call other read_partition() methods that
* can call it.
*/
struct mboot *master_boot_recordp;
int partition_index;
struct ipart *partition_table_entryp;
struct ipart *partition_tablep;
int read_length;
unsigned char systid;
int solaris_offset;
if (partition_privatep->primary_part_idx != 0) {
/*
* There should be no fdisk partition in the primary
* fdisk partition.
*/
goto dun;
}
goto dun;
}
}
if (partition_result == PARTITION_SUCCESS) {
}
}
if (partition_result == PARTITION_SUCCESS) {
}
}
if (partition_result == PARTITION_SUCCESS) {
(void *)master_boot_recordp,
sizeof (struct mboot));
if (read_length != sizeof (struct mboot)) {
}
}
if (partition_result == PARTITION_SUCCESS) {
} else {
(void) memcpy((void *)partition_tablep,
(const void *)master_boot_recordp->parts,
}
}
solaris_offset = -1;
#ifdef _FIRMWARE_NEEDS_FDISK
if (primary_partition) {
/*
* Solaris partition cannot exist in extended DOS partition.
*/
partition_index = 0;
while ((partition_result == PARTITION_SUCCESS) &&
(partition_index < FD_NUMPART)) {
unsigned char bootid;
/*
* see sd.c on how scsi driver picks the solaris
* partition.
*/
}
}
}
}
#endif
partition_index = 0;
while ((partition_result == PARTITION_SUCCESS) &&
(partition_index < FD_NUMPART)) {
systid != 0 &&
partition_table_entryp->relsect != 0) {
&new_childp);
if (partition_result == PARTITION_SUCCESS) {
(PC_SECSIZE *
if (partition_index != solaris_offset) {
= TRUE;
}
if (primary_partition) {
(char)partition_index + 1;
} else {
-((char)partition_index + 1);
}
(is_dos_drive(systid) == 0);
}
}
}
partition_index = 0;
while ((partition_result == PARTITION_SUCCESS) &&
(partition_index < FD_NUMPART)) {
partition_table_entryp->relsect != 0) {
&new_childp);
if (partition_result != PARTITION_SUCCESS)
break;
seek_off = (PC_SECSIZE *
if (primary_partition) {
/*
* This is the primary record, calc the
* base offset of the extended partition
* record.
*/
child_privatep->offset = 0;
} else {
/* This is an extended partition record */
}
/*
* There should be no solaris partition in
* the extended partition.
*/
/*
* There is only one extended partition should exist
* in this record.
*/
break;
}
}
if (master_boot_recordp != NULL) {
}
if (partition_tablep != NULL) {
}
dun:
return (partition_result);
}
/*
* Definitions of private methods
*/
static partition_result_t
{
/*
* An fdisk partition has no vnodes of its own, because
* it's not represented in the external structures of
* file systems. It simply appropriates the vnodes of
* the medium, by way of any parent fdisk partitions
* that may exist on the medium.
*/
if (parent_privatep != NULL) {
/*
* The partition has a parent fdisk partition.
* It's pathnames and vvnodes are the same
* as those of its parent.
*/
} else {
}
}
} else {
/*
* The partition is the top partition on
* the medium. It's pathnames and vvnodes
* are the same as those of the medium.
*/
} else {
}
}
}
/*
* Create vnodes for the partitions described in the fdisk
* partition table.
*/
}
return (partition_result);
}
static int
{
}