<< Previous | Next >>

mbr_CreatePartition

int mbr_CreatePartition( mbr_drive *drive, int pnum, char type );

Description

Creates or modifies the partition specified. The partition being modified must not be mounted, and should be released by filesystem use (that is, its fs_part pointer must be null). The new partition values should be placed in the appropriate partition structure within the drive structure. For example,

drive.part[partnum].bootflag = 0;
drive.part[partnum].starthead = 0xfe;
drive.part[partnum].startseccyl = 0;
drive.part[partnum].parttype = 0xda;
drive.part[partnum].endhead = 0xfe;
drive.part[partnum].endseccyl = 0;
drive.part[partnum].startsector = start;
drive.part[partnum].partsecsize = ((PART_SZ) / 512) + 1;
mbr_CreatePartition(&drive, partnum, 0xda);

For more information on the partition structure (mbr_part) look in part_defs.lib.

The type parameter should match the type as it currently exists on the drive, unless this is unused. Some values for the type parameter are already in use. A list of known partition types is at:

www.win.tue.nl/~aeb/partitions/partition_types-1.html
NOTE Starting with Dynamic C 9.01, this function BLOCKS!

Parameters

drive
Pointer to a MBR drive structure

pnum
Partition number to be created or modified

type
Type that exists on the physical drive partition now

Return value

0 for success
-EIO for Error trying to read drive/device or structures.
-EINVAL if drive structure, pnum or type is invalid.
-EPERM if the partition has not been enumerated or is currently mounted.
-EUNFORMAT if the drive is accessible, but not formatted.
-EBUSY if the device is busy. (Valid prior to Dynamic C 9.01)

Library

PART.LIB


Dynamic C Functions << Previous | Next >> rabbit.com