Final Year Project:
Using Linux Filesystems Under Windows
Chris Bryden
BEng. Electronics and Software Engineering
School of Computer Science
University of Birmingham
37
5.9 Layer 0: The GetPartTable Function
This function is used to retrieve the partition table for a disk It reads the
information stored in the DiskInfo array and returns a much more convenient
form for the partition table on the disk. The data structure used for this is given
the type PARTTBL, it represents one entry in the partition table for the disk. An
array of four such structures is used to record the entire partition table. The
structure is shown below:
The meanings of the variables is as follows:
·
=uBoot - The bootable status of the partition.
·
=uStartHead, uStartSec, uStartCyl - The CHS reference for the start of the
partition
·
=uPartType - The hex value for the partition type, see section 2.2
·
=szPartType - A string indicating the partition type, this takes one of the
following values:
·
=DOS - For a primary DOS partition
·
=DOSEXT - For an Extended DOS partition
·
=LINUX - For a Linux filesystem partition
·
=LINUXSWP - For a Linux swapfile partition
·
=uENdHead, uEndSec, uEndCyl - The CHS reference for the end of the
partition.
·
=ulStartSec - The start sector of the partition, sectors numbered from 0.
·
=ulEndSec - The end sector of the partition, sectors numbered form 0.
The function accepts the PartTable array and the drive number as
arguments and simply reads the partition table values from the DiskInfo array
and calculates the ulStartSec and ulEndSec values, then fills the PartTable array
and returns.
typedef struct part_table {
unsigned uBoot;
unsigned uStartHead;
unsigned uStartSec;
unsigned uStartCyl;
unsigned uPartType;
char
szPartType[11];
unsigned uEndHead;
unsigned uEndSec;
unsigned uEndCyl;
unsigned long ulStartSec;
unsigned long ulNumSec;
}PARTTBL;