aboutsummaryrefslogtreecommitdiffstats
path: root/com32/gpllib/disk
diff options
context:
space:
mode:
Diffstat (limited to 'com32/gpllib/disk')
-rw-r--r--com32/gpllib/disk/ata.c38
-rw-r--r--com32/gpllib/disk/bootloaders.c34
-rw-r--r--com32/gpllib/disk/error.c4
-rw-r--r--com32/gpllib/disk/geom.c213
-rw-r--r--com32/gpllib/disk/labels.c772
-rw-r--r--com32/gpllib/disk/mbrs.c145
-rw-r--r--com32/gpllib/disk/msdos.c175
-rw-r--r--com32/gpllib/disk/read.c130
-rw-r--r--com32/gpllib/disk/swsusp.c22
-rw-r--r--com32/gpllib/disk/util.c23
-rw-r--r--com32/gpllib/disk/write.c127
11 files changed, 1057 insertions, 626 deletions
diff --git a/com32/gpllib/disk/ata.c b/com32/gpllib/disk/ata.c
index 8694470d..b0c2b63c 100644
--- a/com32/gpllib/disk/ata.c
+++ b/com32/gpllib/disk/ata.c
@@ -16,22 +16,22 @@
* caller.
*/
void ata_id_string(const uint16_t * id, unsigned char *s,
- unsigned int ofs, unsigned int len)
+ unsigned int ofs, unsigned int len)
{
- unsigned int c;
+ unsigned int c;
- while (len > 0) {
- c = id[ofs] >> 8;
- *s = c;
- s++;
+ while (len > 0) {
+ c = id[ofs] >> 8;
+ *s = c;
+ s++;
- c = id[ofs] & 0xff;
- *s = c;
- s++;
+ c = id[ofs] & 0xff;
+ *s = c;
+ s++;
- ofs++;
- len -= 2;
- }
+ ofs++;
+ len -= 2;
+ }
}
/**
@@ -49,14 +49,14 @@ void ata_id_string(const uint16_t * id, unsigned char *s,
* caller.
*/
void ata_id_c_string(const uint16_t * id, unsigned char *s,
- unsigned int ofs, unsigned int len)
+ unsigned int ofs, unsigned int len)
{
- unsigned char *p;
+ unsigned char *p;
- ata_id_string(id, s, ofs, len - 1);
+ ata_id_string(id, s, ofs, len - 1);
- p = s + strnlen(s, len - 1);
- while (p > s && p[-1] == ' ')
- p--;
- *p = '\0';
+ p = s + strnlen(s, len - 1);
+ while (p > s && p[-1] == ' ')
+ p--;
+ *p = '\0';
}
diff --git a/com32/gpllib/disk/bootloaders.c b/com32/gpllib/disk/bootloaders.c
index 4b3962ae..29aecbd4 100644
--- a/com32/gpllib/disk/bootloaders.c
+++ b/com32/gpllib/disk/bootloaders.c
@@ -23,24 +23,24 @@
* @buffer_size: @buffer size
**/
int get_bootloader_string(const struct driveinfo *d, const struct part_entry *p,
- char* buffer, const int buffer_size)
+ char *buffer, const int buffer_size)
{
- char boot_sector[SECTOR * sizeof(char)];
+ char boot_sector[SECTOR * sizeof(char)];
- if (read_sectors(d, &boot_sector, p->start_lba, 1) == -1)
- return -1;
- else {
- if (!strncmp(boot_sector + 3, "SYSLINUX", 8))
- strncpy(buffer, "SYSLINUX", buffer_size - 1);
- else if (!strncmp(boot_sector + 3, "EXTLINUX", 8))
- strncpy(buffer, "EXTLINUX", buffer_size - 1);
- else if (!strncmp(boot_sector + 3, "MSWIN4.1", 8))
- strncpy(buffer, "MSWIN4.1", buffer_size - 1);
- else
- return -1;
- /* Add more... */
+ if (read_sectors(d, &boot_sector, p->start_lba, 1) == -1)
+ return -1;
+ else {
+ if (!strncmp(boot_sector + 3, "SYSLINUX", 8))
+ strncpy(buffer, "SYSLINUX", buffer_size - 1);
+ else if (!strncmp(boot_sector + 3, "EXTLINUX", 8))
+ strncpy(buffer, "EXTLINUX", buffer_size - 1);
+ else if (!strncmp(boot_sector + 3, "MSWIN4.1", 8))
+ strncpy(buffer, "MSWIN4.1", buffer_size - 1);
+ else
+ return -1;
+ /* Add more... */
- buffer[buffer_size - 1] = '\0';
- return 0;
- }
+ buffer[buffer_size - 1] = '\0';
+ return 0;
+ }
}
diff --git a/com32/gpllib/disk/error.c b/com32/gpllib/disk/error.c
index b3fb6ce1..fe4722e1 100644
--- a/com32/gpllib/disk/error.c
+++ b/com32/gpllib/disk/error.c
@@ -17,7 +17,7 @@
*
* Fill @buffer_ptr with the last errno_disk
**/
-void get_error(const char* s)
+void get_error(const char *s)
{
- fprintf(stderr, "%s: error %d\n", s, errno_disk);
+ fprintf(stderr, "%s: error %d\n", s, errno_disk);
}
diff --git a/com32/gpllib/disk/geom.c b/com32/gpllib/disk/geom.c
index 2305ed16..9e673ed4 100644
--- a/com32/gpllib/disk/geom.c
+++ b/com32/gpllib/disk/geom.c
@@ -22,25 +22,25 @@
/**
* lba_to_chs - split given lba into cylinders/heads/sectors
**/
-void lba_to_chs(const struct driveinfo* drive_info, const int lba,
- unsigned int* cylinder, unsigned int* head,
- unsigned int* sector)
+void lba_to_chs(const struct driveinfo *drive_info, const int lba,
+ unsigned int *cylinder, unsigned int *head,
+ unsigned int *sector)
{
- unsigned int track;
-
- /* Use EDD, if valid */
- if (drive_info->edd_params.sectors_per_track > 0 &&
- drive_info->edd_params.heads > 0) {
- *cylinder = (lba % drive_info->edd_params.sectors_per_track) + 1;
- track = lba / drive_info->edd_params.sectors_per_track;
- *head = track % drive_info->edd_params.heads;
- *sector = track / drive_info->edd_params.heads;
- } else if (drive_info->cbios) {
- *cylinder = (lba % drive_info->legacy_sectors_per_track) + 1;
- track = lba / drive_info->legacy_sectors_per_track;
- *head = track % (drive_info->legacy_max_head + 1);
- *sector = track / (drive_info->legacy_max_head + 1);
- }
+ unsigned int track;
+
+ /* Use EDD, if valid */
+ if (drive_info->edd_params.sectors_per_track > 0 &&
+ drive_info->edd_params.heads > 0) {
+ *cylinder = (lba % drive_info->edd_params.sectors_per_track) + 1;
+ track = lba / drive_info->edd_params.sectors_per_track;
+ *head = track % drive_info->edd_params.heads;
+ *sector = track / drive_info->edd_params.heads;
+ } else if (drive_info->cbios) {
+ *cylinder = (lba % drive_info->legacy_sectors_per_track) + 1;
+ track = lba / drive_info->legacy_sectors_per_track;
+ *head = track % (drive_info->legacy_max_head + 1);
+ *sector = track / (drive_info->legacy_max_head + 1);
+ }
}
/**
@@ -76,28 +76,27 @@ void lba_to_chs(const struct driveinfo* drive_info, const int lba,
* extended drive parameter table is valid (see #00273,#00278)
* 3-15 reserved (0)
**/
-static int detect_extensions(struct driveinfo* drive_info)
+static int detect_extensions(struct driveinfo *drive_info)
{
- com32sys_t getebios, ebios;
-
- memset(&getebios, 0, sizeof getebios);
- memset(&ebios, 0, sizeof ebios);
-
- getebios.eflags.b[0] = 0x3; /* CF set */
- getebios.ebx.w[0] = 0x55aa;
- getebios.edx.b[0] = drive_info->disk;
- getebios.eax.b[1] = 0x41;
-
- __intcall(0x13, &getebios, &ebios);
-
- if ( !(ebios.eflags.l & EFLAGS_CF) &&
- ebios.ebx.w[0] == 0xaa55 ) {
- drive_info->ebios = 1;
- drive_info->edd_version = ebios.eax.b[1];
- drive_info->edd_functionality_subset = ebios.ecx.w[0];
- return 0;
- } else
- return -1; /* Drive does not exist? */
+ com32sys_t getebios, ebios;
+
+ memset(&getebios, 0, sizeof getebios);
+ memset(&ebios, 0, sizeof ebios);
+
+ getebios.eflags.b[0] = 0x3; /* CF set */
+ getebios.ebx.w[0] = 0x55aa;
+ getebios.edx.b[0] = drive_info->disk;
+ getebios.eax.b[1] = 0x41;
+
+ __intcall(0x13, &getebios, &ebios);
+
+ if (!(ebios.eflags.l & EFLAGS_CF) && ebios.ebx.w[0] == 0xaa55) {
+ drive_info->ebios = 1;
+ drive_info->edd_version = ebios.eax.b[1];
+ drive_info->edd_functionality_subset = ebios.ecx.w[0];
+ return 0;
+ } else
+ return -1; /* Drive does not exist? */
}
/**
@@ -118,39 +117,39 @@ static int detect_extensions(struct driveinfo* drive_info)
* numbers, stopping as soon as the number of valid drives encountered
* equals the value in 0040h:0075h
**/
-static int get_drive_parameters_with_extensions(struct driveinfo* drive_info)
+static int get_drive_parameters_with_extensions(struct driveinfo *drive_info)
{
- com32sys_t inreg, outreg;
- struct edd_device_parameters *dp = __com32.cs_bounce;
+ com32sys_t inreg, outreg;
+ struct edd_device_parameters *dp = __com32.cs_bounce;
- memset(&inreg, 0, sizeof inreg);
+ memset(&inreg, 0, sizeof inreg);
- /*
- * The caller shall set this value to the maximum Result Buffer
- * length, in bytes. If the length of this buffer is less than 30
- * bytes, this function shall not return the pointer to Drive Parameter
- * Table (DPT) extension. If the buffer length is 30 or greater on
- * entry, it shall be set to 30 on exit. If the buffer length is
- * between 26 and 29, it shall be set to 26 on exit.
- * If the buffer length is less than 26 on entry an error shall be
- * returned.
- */
- dp->len = sizeof(struct edd_device_parameters);
+ /*
+ * The caller shall set this value to the maximum Result Buffer
+ * length, in bytes. If the length of this buffer is less than 30
+ * bytes, this function shall not return the pointer to Drive Parameter
+ * Table (DPT) extension. If the buffer length is 30 or greater on
+ * entry, it shall be set to 30 on exit. If the buffer length is
+ * between 26 and 29, it shall be set to 26 on exit.
+ * If the buffer length is less than 26 on entry an error shall be
+ * returned.
+ */
+ dp->len = sizeof(struct edd_device_parameters);
- inreg.esi.w[0] = OFFS(dp);
- inreg.ds = SEG(dp);
- inreg.edx.b[0] = drive_info->disk;
- inreg.eax.b[1] = 0x48;
+ inreg.esi.w[0] = OFFS(dp);
+ inreg.ds = SEG(dp);
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.eax.b[1] = 0x48;
- __intcall(0x13, &inreg, &outreg);
+ __intcall(0x13, &inreg, &outreg);
- /* CF set on error */
- if ( outreg.eflags.l & EFLAGS_CF )
- return outreg.eax.b[1];
+ /* CF set on error */
+ if (outreg.eflags.l & EFLAGS_CF)
+ return outreg.eax.b[1];
- memcpy(&drive_info->edd_params, dp, sizeof drive_info->edd_params);
+ memcpy(&drive_info->edd_params, dp, sizeof drive_info->edd_params);
- return 0;
+ return 0;
}
/**
@@ -201,53 +200,53 @@ static int get_drive_parameters_with_extensions(struct driveinfo* drive_info)
* SeeAlso: AH=06h"Adaptec",AH=13h"SyQuest",AH=48h,AH=15h,INT 1E
* SeeAlso: INT 41"HARD DISK 0"
**/
-static int get_drive_parameters_without_extensions(struct driveinfo* drive_info)
+static int get_drive_parameters_without_extensions(struct driveinfo *drive_info)
{
- com32sys_t getparm, parm;
+ com32sys_t getparm, parm;
- memset(&getparm, 0, sizeof getparm);
- memset(&parm, 0, sizeof parm);
+ memset(&getparm, 0, sizeof getparm);
+ memset(&parm, 0, sizeof parm);
- /* Ralf Brown recommends setting ES:DI to 0:0 */
- getparm.esi.w[0] = 0;
- getparm.ds = 0;
- getparm.edx.b[0] = drive_info->disk;
- getparm.eax.b[1] = 0x08;
+ /* Ralf Brown recommends setting ES:DI to 0:0 */
+ getparm.esi.w[0] = 0;
+ getparm.ds = 0;
+ getparm.edx.b[0] = drive_info->disk;
+ getparm.eax.b[1] = 0x08;
- __intcall(0x13, &getparm, &parm);
+ __intcall(0x13, &getparm, &parm);
- /* CF set on error */
- if ( parm.eflags.l & EFLAGS_CF )
- return parm.eax.b[1];
+ /* CF set on error */
+ if (parm.eflags.l & EFLAGS_CF)
+ return parm.eax.b[1];
- /* DL contains the maximum drive number (it starts at 0) */
- drive_info->legacy_max_drive = parm.edx.b[0];
+ /* DL contains the maximum drive number (it starts at 0) */
+ drive_info->legacy_max_drive = parm.edx.b[0];
- // XXX broken
- /* Drive specified greater than the bumber of attached drives */
- //if (drive_info->disk > drive_info->drives)
- // return -1;
+ // XXX broken
+ /* Drive specified greater than the bumber of attached drives */
+ //if (drive_info->disk > drive_info->drives)
+ // return -1;
- drive_info->legacy_type = parm.ebx.b[0];
+ drive_info->legacy_type = parm.ebx.b[0];
- /* DH contains the maximum head number (it starts at 0) */
- drive_info->legacy_max_head = parm.edx.b[1];
+ /* DH contains the maximum head number (it starts at 0) */
+ drive_info->legacy_max_head = parm.edx.b[1];
- /* Maximum sector number (bits 5-0) per track */
- drive_info->legacy_sectors_per_track = parm.ecx.b[0] & 0x3f;
+ /* Maximum sector number (bits 5-0) per track */
+ drive_info->legacy_sectors_per_track = parm.ecx.b[0] & 0x3f;
- /*
- * Maximum cylinder number:
- * CH = low eight bits of maximum cylinder number
- * CL = high two bits of maximum cylinder number (bits 7-6)
- */
- drive_info->legacy_max_cylinder = parm.ecx.b[1] +
- ((parm.ecx.b[0] & 0xc0) << 2);
+ /*
+ * Maximum cylinder number:
+ * CH = low eight bits of maximum cylinder number
+ * CL = high two bits of maximum cylinder number (bits 7-6)
+ */
+ drive_info->legacy_max_cylinder = parm.ecx.b[1] +
+ ((parm.ecx.b[0] & 0xc0) << 2);
- if ( drive_info->legacy_sectors_per_track > 0 )
- drive_info->cbios = 1; /* Valid geometry */
+ if (drive_info->legacy_sectors_per_track > 0)
+ drive_info->cbios = 1; /* Valid geometry */
- return 0;
+ return 0;
}
/**
@@ -256,17 +255,17 @@ static int get_drive_parameters_without_extensions(struct driveinfo* drive_info)
**/
int get_drive_parameters(struct driveinfo *drive_info)
{
- int return_code;
+ int return_code;
- if (detect_extensions(drive_info))
- return -1;
+ if (detect_extensions(drive_info))
+ return -1;
- return_code = get_drive_parameters_without_extensions(drive_info);
+ return_code = get_drive_parameters_without_extensions(drive_info);
- /* If geometry isn't valid, no need to try to get more info about the drive*/
- /* Looks like in can confuse some optical drives */
- if (drive_info->ebios && drive_info->cbios)
- get_drive_parameters_with_extensions(drive_info);
+ /* If geometry isn't valid, no need to try to get more info about the drive */
+ /* Looks like in can confuse some optical drives */
+ if (drive_info->ebios && drive_info->cbios)
+ get_drive_parameters_with_extensions(drive_info);
- return return_code;
+ return return_code;
}
diff --git a/com32/gpllib/disk/labels.c b/com32/gpllib/disk/labels.c
index 7efe1ad1..8017d48a 100644
--- a/com32/gpllib/disk/labels.c
+++ b/com32/gpllib/disk/labels.c
@@ -10,245 +10,645 @@
#include <stdlib.h>
#include <string.h>
-void get_label(int label, char** buffer_label)
+void get_label(int label, char **buffer_label)
{
- int buffer_size = (80 * sizeof(char));
- char* buffer = malloc(buffer_size);
- *buffer_label = buffer;
+ int buffer_size = (80 * sizeof(char));
+ char *buffer = malloc(buffer_size);
+ *buffer_label = buffer;
- switch (label) {
- case 0x01: strncpy(buffer, "DOS 12-bit fat", buffer_size); break;
- case 0x02: strncpy(buffer, "XENIX root", buffer_size); break;
- case 0x03: strncpy(buffer, "XENIX /usr", buffer_size); break;
- case 0x04: strncpy(buffer, "DOS 3.0+ 16-bit FAT (up to 32M)", buffer_size); break;
- case 0x05: strncpy(buffer, "DOS 3.3+ Extended Partition", buffer_size); break;
- case 0x06: strncpy(buffer, "DOS 3.31+ 16-bit FAT (over 32M)", buffer_size); break;
- case 0x07: strncpy(buffer, "OS/2 IFS (e.g., HPFS)", buffer_size); break;
+ switch (label) {
+ case 0x01:
+ strncpy(buffer, "DOS 12-bit fat", buffer_size);
+ break;
+ case 0x02:
+ strncpy(buffer, "XENIX root", buffer_size);
+ break;
+ case 0x03:
+ strncpy(buffer, "XENIX /usr", buffer_size);
+ break;
+ case 0x04:
+ strncpy(buffer, "DOS 3.0+ 16-bit FAT (up to 32M)", buffer_size);
+ break;
+ case 0x05:
+ strncpy(buffer, "DOS 3.3+ Extended Partition", buffer_size);
+ break;
+ case 0x06:
+ strncpy(buffer, "DOS 3.31+ 16-bit FAT (over 32M)", buffer_size);
+ break;
+ case 0x07:
+ strncpy(buffer, "OS/2 IFS (e.g., HPFS)", buffer_size);
+ break;
//case 0x07: strncpy(buffer, "Advanced Unix", buffer_size); break;
//case 0x07: strncpy(buffer, "Windows NT NTFS", buffer_size); break;
//case 0x07: strncpy(buffer, "QNX2.x (pre-1988)", buffer_size); break;
- case 0x08: strncpy(buffer, "OS/2 (v1.0-1.3 only)", buffer_size); break;
+ case 0x08:
+ strncpy(buffer, "OS/2 (v1.0-1.3 only)", buffer_size);
+ break;
//case 0x08: strncpy(buffer, "AIX boot partition", buffer_size); break;
//case 0x08: strncpy(buffer, "SplitDrive", buffer_size); break;
//case 0x08: strncpy(buffer, "DELL partition spanning multiple drives", buffer_size); break;
//case 0x08: strncpy(buffer, "Commodore DOS", buffer_size); break;
//case 0x08: strncpy(buffer, "QNX 1.x and 2.x ("qny")", buffer_size); break;
- case 0x09: strncpy(buffer, "AIX data partition", buffer_size); break;
+ case 0x09:
+ strncpy(buffer, "AIX data partition", buffer_size);
+ break;
//case 0x09: strncpy(buffer, "Coherent filesystem", buffer_size); break;
//case 0x09: strncpy(buffer, "QNX 1.x and 2.x ("qnz")", buffer_size); break;
- case 0x0a: strncpy(buffer, "OS/2 Boot Manager", buffer_size); break;
+ case 0x0a:
+ strncpy(buffer, "OS/2 Boot Manager", buffer_size);
+ break;
//case 0x0a: strncpy(buffer, "Coherent swap partition", buffer_size); break;
//case 0x0a: strncpy(buffer, "OPUS", buffer_size); break;
- case 0x0b: strncpy(buffer, "WIN95 OSR2 32-bit FAT", buffer_size); break;
- case 0x0c: strncpy(buffer, "WIN95 OSR2 32-bit FAT, LBA-mapped", buffer_size); break;
- case 0x0e: strncpy(buffer, "WIN95: DOS 16-bit FAT, LBA-mapped", buffer_size); break;
- case 0x0f: strncpy(buffer, "WIN95: Extended partition, LBA-mapped", buffer_size); break;
- case 0x10: strncpy(buffer, "OPUS (?)", buffer_size); break;
- case 0x11: strncpy(buffer, "Hidden DOS 12-bit FAT", buffer_size); break;
- case 0x12: strncpy(buffer, "Compaq config partition", buffer_size); break;
- case 0x14: strncpy(buffer, "Hidden DOS 16-bit FAT <32M", buffer_size); break;
- case 0x16: strncpy(buffer, "Hidden DOS 16-bit FAT >=32M", buffer_size); break;
- case 0x17: strncpy(buffer, "Hidden IFS (e.g., HPFS)", buffer_size); break;
- case 0x18: strncpy(buffer, "AST SmartSleep Partition", buffer_size); break;
- case 0x19: strncpy(buffer, "Unused (Claimed for Willowtech Photon COS)", buffer_size); break;
- case 0x1b: strncpy(buffer, "Hidden WIN95 OSR2 32-bit FAT", buffer_size); break;
- case 0x1c: strncpy(buffer, "Hidden WIN95 OSR2 32-bit FAT, LBA-mapped", buffer_size); break;
- case 0x1e: strncpy(buffer, "Hidden WIN95 16-bit FAT, LBA-mapped", buffer_size); break;
- case 0x20: strncpy(buffer, "Unused", buffer_size); break;
- case 0x21: strncpy(buffer, "Reserved", buffer_size); break;
+ case 0x0b:
+ strncpy(buffer, "WIN95 OSR2 32-bit FAT", buffer_size);
+ break;
+ case 0x0c:
+ strncpy(buffer, "WIN95 OSR2 32-bit FAT, LBA-mapped", buffer_size);
+ break;
+ case 0x0e:
+ strncpy(buffer, "WIN95: DOS 16-bit FAT, LBA-mapped", buffer_size);
+ break;
+ case 0x0f:
+ strncpy(buffer, "WIN95: Extended partition, LBA-mapped", buffer_size);
+ break;
+ case 0x10:
+ strncpy(buffer, "OPUS (?)", buffer_size);
+ break;
+ case 0x11:
+ strncpy(buffer, "Hidden DOS 12-bit FAT", buffer_size);
+ break;
+ case 0x12:
+ strncpy(buffer, "Compaq config partition", buffer_size);
+ break;
+ case 0x14:
+ strncpy(buffer, "Hidden DOS 16-bit FAT <32M", buffer_size);
+ break;
+ case 0x16:
+ strncpy(buffer, "Hidden DOS 16-bit FAT >=32M", buffer_size);
+ break;
+ case 0x17:
+ strncpy(buffer, "Hidden IFS (e.g., HPFS)", buffer_size);
+ break;
+ case 0x18:
+ strncpy(buffer, "AST SmartSleep Partition", buffer_size);
+ break;
+ case 0x19:
+ strncpy(buffer, "Unused (Claimed for Willowtech Photon COS)",
+ buffer_size);
+ break;
+ case 0x1b:
+ strncpy(buffer, "Hidden WIN95 OSR2 32-bit FAT", buffer_size);
+ break;
+ case 0x1c:
+ strncpy(buffer, "Hidden WIN95 OSR2 32-bit FAT, LBA-mapped",
+ buffer_size);
+ break;
+ case 0x1e:
+ strncpy(buffer, "Hidden WIN95 16-bit FAT, LBA-mapped", buffer_size);
+ break;
+ case 0x20:
+ strncpy(buffer, "Unused", buffer_size);
+ break;
+ case 0x21:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
//case 0x21: strncpy(buffer, "Unused", buffer_size); break;
- case 0x22: strncpy(buffer, "Unused", buffer_size); break;
- case 0x23: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x24: strncpy(buffer, "NEC DOS 3.x", buffer_size); break;
- case 0x26: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x31: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x32: strncpy(buffer, "NOS", buffer_size); break;
- case 0x33: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x34: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x35: strncpy(buffer, "JFS on OS/2 or eCS", buffer_size); break;
- case 0x36: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x38: strncpy(buffer, "THEOS ver 3.2 2gb partition", buffer_size); break;
- case 0x39: strncpy(buffer, "Plan 9 partition", buffer_size); break;
+ case 0x22:
+ strncpy(buffer, "Unused", buffer_size);
+ break;
+ case 0x23:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x24:
+ strncpy(buffer, "NEC DOS 3.x", buffer_size);
+ break;
+ case 0x26:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x31:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x32:
+ strncpy(buffer, "NOS", buffer_size);
+ break;
+ case 0x33:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x34:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x35:
+ strncpy(buffer, "JFS on OS/2 or eCS", buffer_size);
+ break;
+ case 0x36:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x38:
+ strncpy(buffer, "THEOS ver 3.2 2gb partition", buffer_size);
+ break;
+ case 0x39:
+ strncpy(buffer, "Plan 9 partition", buffer_size);
+ break;
//case 0x39: strncpy(buffer, "THEOS ver 4 spanned partition", buffer_size); break;
- case 0x3a: strncpy(buffer, "THEOS ver 4 4gb partition", buffer_size); break;
- case 0x3b: strncpy(buffer, "THEOS ver 4 extended partition", buffer_size); break;
- case 0x3c: strncpy(buffer, "PartitionMagic recovery partition", buffer_size); break;
- case 0x3d: strncpy(buffer, "Hidden NetWare", buffer_size); break;
- case 0x40: strncpy(buffer, "Venix 80286", buffer_size); break;
- case 0x41: strncpy(buffer, "Linux/MINIX (sharing disk with DRDOS)", buffer_size); break;
+ case 0x3a:
+ strncpy(buffer, "THEOS ver 4 4gb partition", buffer_size);
+ break;
+ case 0x3b:
+ strncpy(buffer, "THEOS ver 4 extended partition", buffer_size);
+ break;
+ case 0x3c:
+ strncpy(buffer, "PartitionMagic recovery partition", buffer_size);
+ break;
+ case 0x3d:
+ strncpy(buffer, "Hidden NetWare", buffer_size);
+ break;
+ case 0x40:
+ strncpy(buffer, "Venix 80286", buffer_size);
+ break;
+ case 0x41:
+ strncpy(buffer, "Linux/MINIX (sharing disk with DRDOS)", buffer_size);
+ break;
//case 0x41: strncpy(buffer, "Personal RISC Boot", buffer_size); break;
//case 0x41: strncpy(buffer, "PPC PReP (Power PC Reference Platform) Boot", buffer_size); break;
- case 0x42: strncpy(buffer, "Linux swap (sharing disk with DRDOS)", buffer_size); break;
+ case 0x42:
+ strncpy(buffer, "Linux swap (sharing disk with DRDOS)", buffer_size);
+ break;
//case 0x42: strncpy(buffer, "SFS (Secure Filesystem)", buffer_size); break;
//case 0x42: strncpy(buffer, "Windows 2000 marker", buffer_size); break;
- case 0x43: strncpy(buffer, "Linux native (sharing disk with DRDOS)", buffer_size); break;
- case 0x44: strncpy(buffer, "GoBack partition", buffer_size); break;
- case 0x45: strncpy(buffer, "Boot-US boot manager", buffer_size); break;
+ case 0x43:
+ strncpy(buffer, "Linux native (sharing disk with DRDOS)", buffer_size);
+ break;
+ case 0x44:
+ strncpy(buffer, "GoBack partition", buffer_size);
+ break;
+ case 0x45:
+ strncpy(buffer, "Boot-US boot manager", buffer_size);
+ break;
//case 0x45: strncpy(buffer, "Priam", buffer_size); break;
//case 0x45: strncpy(buffer, "EUMEL/Elan", buffer_size); break;
- case 0x46: strncpy(buffer, "EUMEL/Elan", buffer_size); break;
- case 0x47: strncpy(buffer, "EUMEL/Elan", buffer_size); break;
- case 0x48: strncpy(buffer, "EUMEL/Elan", buffer_size); break;
- case 0x4a: strncpy(buffer, "AdaOS Aquila (Default)", buffer_size); break;
+ case 0x46:
+ strncpy(buffer, "EUMEL/Elan", buffer_size);
+ break;
+ case 0x47:
+ strncpy(buffer, "EUMEL/Elan", buffer_size);
+ break;
+ case 0x48:
+ strncpy(buffer, "EUMEL/Elan", buffer_size);
+ break;
+ case 0x4a:
+ strncpy(buffer, "AdaOS Aquila (Default)", buffer_size);
+ break;
//case 0x4a: strncpy(buffer, "ALFS/THIN lightweight filesystem for DOS", buffer_size); break;
- case 0x4c: strncpy(buffer, "Oberon partition", buffer_size); break;
- case 0x4d: strncpy(buffer, "QNX4.x", buffer_size); break;
- case 0x4e: strncpy(buffer, "QNX4.x 2nd part", buffer_size); break;
- case 0x4f: strncpy(buffer, "QNX4.x 3rd part", buffer_size); break;
+ case 0x4c:
+ strncpy(buffer, "Oberon partition", buffer_size);
+ break;
+ case 0x4d:
+ strncpy(buffer, "QNX4.x", buffer_size);
+ break;
+ case 0x4e:
+ strncpy(buffer, "QNX4.x 2nd part", buffer_size);
+ break;
+ case 0x4f:
+ strncpy(buffer, "QNX4.x 3rd part", buffer_size);
+ break;
//case 0x4f: strncpy(buffer, "Oberon partition", buffer_size); break;
- case 0x50: strncpy(buffer, "OnTrack Disk Manager (older versions) RO", buffer_size); break;
+ case 0x50:
+ strncpy(buffer, "OnTrack Disk Manager (older versions) RO",
+ buffer_size);
+ break;
//case 0x50: strncpy(buffer, "Lynx RTOS", buffer_size); break;
//case 0x50: strncpy(buffer, "Native Oberon (alt)", buffer_size); break;
- case 0x51: strncpy(buffer, "OnTrack Disk Manager RW (DM6 Aux1)", buffer_size); break;
+ case 0x51:
+ strncpy(buffer, "OnTrack Disk Manager RW (DM6 Aux1)", buffer_size);
+ break;
//case 0x51: strncpy(buffer, "Novell", buffer_size); break;
- case 0x52: strncpy(buffer, "CP/M", buffer_size); break;
+ case 0x52:
+ strncpy(buffer, "CP/M", buffer_size);
+ break;
//case 0x52: strncpy(buffer, "Microport SysV/AT", buffer_size); break;
- case 0x53: strncpy(buffer, "Disk Manager 6.0 Aux3", buffer_size); break;
- case 0x54: strncpy(buffer, "Disk Manager 6.0 Dynamic Drive Overlay", buffer_size); break;
- case 0x55: strncpy(buffer, "EZ-Drive", buffer_size); break;
- case 0x56: strncpy(buffer, "Golden Bow VFeature Partitioned Volume.", buffer_size); break;
+ case 0x53:
+ strncpy(buffer, "Disk Manager 6.0 Aux3", buffer_size);
+ break;
+ case 0x54:
+ strncpy(buffer, "Disk Manager 6.0 Dynamic Drive Overlay", buffer_size);
+ break;
+ case 0x55:
+ strncpy(buffer, "EZ-Drive", buffer_size);
+ break;
+ case 0x56:
+ strncpy(buffer, "Golden Bow VFeature Partitioned Volume.", buffer_size);
+ break;
//case 0x56: strncpy(buffer, "DM converted to EZ-BIOS", buffer_size); break;
- case 0x57: strncpy(buffer, "DrivePro", buffer_size); break;
+ case 0x57:
+ strncpy(buffer, "DrivePro", buffer_size);
+ break;
//case 0x57: strncpy(buffer, "VNDI Partition", buffer_size); break;
- case 0x5c: strncpy(buffer, "Priam EDisk", buffer_size); break;
- case 0x61: strncpy(buffer, "SpeedStor", buffer_size); break;
- case 0x63: strncpy(buffer, "Unix System V (SCO, ISC Unix, UnixWare, ...), Mach, GNU Hurd", buffer_size); break;
- case 0x64: strncpy(buffer, "PC-ARMOUR protected partition", buffer_size); break;
+ case 0x5c:
+ strncpy(buffer, "Priam EDisk", buffer_size);
+ break;
+ case 0x61:
+ strncpy(buffer, "SpeedStor", buffer_size);
+ break;
+ case 0x63:
+ strncpy(buffer,
+ "Unix System V (SCO, ISC Unix, UnixWare, ...), Mach, GNU Hurd",
+ buffer_size);
+ break;
+ case 0x64:
+ strncpy(buffer, "PC-ARMOUR protected partition", buffer_size);
+ break;
//case 0x64: strncpy(buffer, "Novell Netware 286, 2.xx", buffer_size); break;
- case 0x65: strncpy(buffer, "Novell Netware 386, 3.xx or 4.xx", buffer_size); break;
- case 0x66: strncpy(buffer, "Novell Netware SMS Partition", buffer_size); break;
- case 0x67: strncpy(buffer, "Novell", buffer_size); break;
- case 0x68: strncpy(buffer, "Novell", buffer_size); break;
- case 0x69: strncpy(buffer, "Novell Netware 5+, Novell Netware NSS Partition", buffer_size); break;
- case 0x70: strncpy(buffer, "DiskSecure Multi-Boot", buffer_size); break;
- case 0x71: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x73: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x74: strncpy(buffer, "Reserved", buffer_size); break;
+ case 0x65:
+ strncpy(buffer, "Novell Netware 386, 3.xx or 4.xx", buffer_size);
+ break;
+ case 0x66:
+ strncpy(buffer, "Novell Netware SMS Partition", buffer_size);
+ break;
+ case 0x67:
+ strncpy(buffer, "Novell", buffer_size);
+ break;
+ case 0x68:
+ strncpy(buffer, "Novell", buffer_size);
+ break;
+ case 0x69:
+ strncpy(buffer, "Novell Netware 5+, Novell Netware NSS Partition",
+ buffer_size);
+ break;
+ case 0x70:
+ strncpy(buffer, "DiskSecure Multi-Boot", buffer_size);
+ break;
+ case 0x71:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x73:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x74:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
//case 0x74: strncpy(buffer, "Scramdisk partition", buffer_size); break;
- case 0x75: strncpy(buffer, "IBM PC/IX", buffer_size); break;
- case 0x76: strncpy(buffer, "Reserved", buffer_size); break;
- case 0x77: strncpy(buffer, "M2FS/M2CS partition", buffer_size); break;
+ case 0x75:
+ strncpy(buffer, "IBM PC/IX", buffer_size);
+ break;
+ case 0x76:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0x77:
+ strncpy(buffer, "M2FS/M2CS partition", buffer_size);
+ break;
//case 0x77: strncpy(buffer, "VNDI Partition", buffer_size); break;
- case 0x78: strncpy(buffer, "XOSL FS", buffer_size); break;
- case 0x7E: strncpy(buffer, " ", buffer_size); break;
- case 0x80: strncpy(buffer, "MINIX until 1.4a", buffer_size); break;
- case 0x81: strncpy(buffer, "MINIX since 1.4b, early Linux", buffer_size); break;
+ case 0x78:
+ strncpy(buffer, "XOSL FS", buffer_size);
+ break;
+ case 0x7E:
+ strncpy(buffer, " ", buffer_size);
+ break;
+ case 0x80:
+ strncpy(buffer, "MINIX until 1.4a", buffer_size);
+ break;
+ case 0x81:
+ strncpy(buffer, "MINIX since 1.4b, early Linux", buffer_size);
+ break;
//case 0x81: strncpy(buffer, "Mitac disk manager", buffer_size); break;
//case 0x82: strncpy(buffer, "Prime", buffer_size); break;
//case 0x82: strncpy(buffer, "Solaris x86", buffer_size); break;
- case 0x82: strncpy(buffer, "Linux swap", buffer_size); break;
- case 0x83: strncpy(buffer, "Linux native (usually ext2fs)", buffer_size); break;
- case 0x84: strncpy(buffer, "OS/2 hidden C: drive", buffer_size); break;
+ case 0x82:
+ strncpy(buffer, "Linux swap", buffer_size);
+ break;
+ case 0x83:
+ strncpy(buffer, "Linux native (usually ext2fs)", buffer_size);
+ break;
+ case 0x84:
+ strncpy(buffer, "OS/2 hidden C: drive", buffer_size);
+ break;
//case 0x84: strncpy(buffer, "Hibernation partition", buffer_size); break;
- case 0x85: strncpy(buffer, "Linux extended partition", buffer_size); break;
+ case 0x85:
+ strncpy(buffer, "Linux extended partition", buffer_size);
+ break;
//case 0x86: strncpy(buffer, "Old Linux RAID partition superblock", buffer_size); break;
- case 0x86: strncpy(buffer, "NTFS volume set", buffer_size); break;
- case 0x87: strncpy(buffer, "NTFS volume set", buffer_size); break;
- case 0x8a: strncpy(buffer, "Linux Kernel Partition (used by AiR-BOOT)", buffer_size); break;
- case 0x8b: strncpy(buffer, "Legacy Fault Tolerant FAT32 volume", buffer_size); break;
- case 0x8c: strncpy(buffer, "Legacy Fault Tolerant FAT32 volume using BIOS extd INT 13h", buffer_size); break;
- case 0x8d: strncpy(buffer, "Free FDISK hidden Primary DOS FAT12 partitition", buffer_size); break;
- case 0x8e: strncpy(buffer, "Linux Logical Volume Manager partition", buffer_size); break;
- case 0x90: strncpy(buffer, "Free FDISK hidden Primary DOS FAT16 partitition", buffer_size); break;
- case 0x91: strncpy(buffer, "Free FDISK hidden DOS extended partitition", buffer_size); break;
- case 0x92: strncpy(buffer, "Free FDISK hidden Primary DOS large FAT16 partitition", buffer_size); break;
- case 0x93: strncpy(buffer, "Hidden Linux native partition", buffer_size); break;
+ case 0x86:
+ strncpy(buffer, "NTFS volume set", buffer_size);
+ break;
+ case 0x87:
+ strncpy(buffer, "NTFS volume set", buffer_size);
+ break;
+ case 0x8a:
+ strncpy(buffer, "Linux Kernel Partition (used by AiR-BOOT)",
+ buffer_size);
+ break;
+ case 0x8b:
+ strncpy(buffer, "Legacy Fault Tolerant FAT32 volume", buffer_size);
+ break;
+ case 0x8c:
+ strncpy(buffer,
+ "Legacy Fault Tolerant FAT32 volume using BIOS extd INT 13h",
+ buffer_size);
+ break;
+ case 0x8d:
+ strncpy(buffer, "Free FDISK hidden Primary DOS FAT12 partitition",
+ buffer_size);
+ break;
+ case 0x8e:
+ strncpy(buffer, "Linux Logical Volume Manager partition", buffer_size);
+ break;
+ case 0x90:
+ strncpy(buffer, "Free FDISK hidden Primary DOS FAT16 partitition",
+ buffer_size);
+ break;
+ case 0x91:
+ strncpy(buffer, "Free FDISK hidden DOS extended partitition",
+ buffer_size);
+ break;
+ case 0x92:
+ strncpy(buffer, "Free FDISK hidden Primary DOS large FAT16 partitition",
+ buffer_size);
+ break;
+ case 0x93:
+ strncpy(buffer, "Hidden Linux native partition", buffer_size);
+ break;
//case 0x93: strncpy(buffer, "Amoeba", buffer_size); break;
- case 0x94: strncpy(buffer, "Amoeba bad block table", buffer_size); break;
- case 0x95: strncpy(buffer, "MIT EXOPC native partitions", buffer_size); break;
- case 0x97: strncpy(buffer, "Free FDISK hidden Primary DOS FAT32 partitition", buffer_size); break;
- case 0x98: strncpy(buffer, "Free FDISK hidden Primary DOS FAT32 partitition (LBA)", buffer_size); break;
- case 0x99: strncpy(buffer, "DCE376 logical drive", buffer_size); break;
- case 0x9a: strncpy(buffer, "Free FDISK hidden Primary DOS FAT16 partitition (LBA)", buffer_size); break;
- case 0x9b: strncpy(buffer, "Free FDISK hidden DOS extended partitition (LBA)", buffer_size); break;
- case 0x9f: strncpy(buffer, "BSD/OS", buffer_size); break;
- case 0xa0: strncpy(buffer, "Laptop hibernation partition", buffer_size); break;
- case 0xa1: strncpy(buffer, "Laptop hibernation partition", buffer_size); break;
+ case 0x94:
+ strncpy(buffer, "Amoeba bad block table", buffer_size);
+ break;
+ case 0x95:
+ strncpy(buffer, "MIT EXOPC native partitions", buffer_size);
+ break;
+ case 0x97:
+ strncpy(buffer, "Free FDISK hidden Primary DOS FAT32 partitition",
+ buffer_size);
+ break;
+ case 0x98:
+ strncpy(buffer, "Free FDISK hidden Primary DOS FAT32 partitition (LBA)",
+ buffer_size);
+ break;
+ case 0x99:
+ strncpy(buffer, "DCE376 logical drive", buffer_size);
+ break;
+ case 0x9a:
+ strncpy(buffer, "Free FDISK hidden Primary DOS FAT16 partitition (LBA)",
+ buffer_size);
+ break;
+ case 0x9b:
+ strncpy(buffer, "Free FDISK hidden DOS extended partitition (LBA)",
+ buffer_size);
+ break;
+ case 0x9f:
+ strncpy(buffer, "BSD/OS", buffer_size);
+ break;
+ case 0xa0:
+ strncpy(buffer, "Laptop hibernation partition", buffer_size);
+ break;
+ case 0xa1:
+ strncpy(buffer, "Laptop hibernation partition", buffer_size);
+ break;
//case 0xa1: strncpy(buffer, "HP Volume Expansion (SpeedStor variant)", buffer_size); break;
- case 0xa3: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xa4: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xa5: strncpy(buffer, "BSD/386, 386BSD, NetBSD, FreeBSD", buffer_size); break;
- case 0xa6: strncpy(buffer, "OpenBSD", buffer_size); break;
- case 0xa7: strncpy(buffer, "NEXTSTEP", buffer_size); break;
- case 0xa8: strncpy(buffer, "Mac OS-X", buffer_size); break;
- case 0xa9: strncpy(buffer, "NetBSD", buffer_size); break;
- case 0xaa: strncpy(buffer, "Olivetti Fat 12 1.44Mb Service Partition", buffer_size); break;
- case 0xab: strncpy(buffer, "Mac OS-X Boot partition", buffer_size); break;
+ case 0xa3:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xa4:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xa5:
+ strncpy(buffer, "BSD/386, 386BSD, NetBSD, FreeBSD", buffer_size);
+ break;
+ case 0xa6:
+ strncpy(buffer, "OpenBSD", buffer_size);
+ break;
+ case 0xa7:
+ strncpy(buffer, "NEXTSTEP", buffer_size);
+ break;
+ case 0xa8:
+ strncpy(buffer, "Mac OS-X", buffer_size);
+ break;
+ case 0xa9:
+ strncpy(buffer, "NetBSD", buffer_size);
+ break;
+ case 0xaa:
+ strncpy(buffer, "Olivetti Fat 12 1.44Mb Service Partition",
+ buffer_size);
+ break;
+ case 0xab:
+ strncpy(buffer, "Mac OS-X Boot partition", buffer_size);
+ break;
//case 0xab: strncpy(buffer, "GO! partition", buffer_size); break;
- case 0xae: strncpy(buffer, "ShagOS filesystem", buffer_size); break;
- case 0xaf: strncpy(buffer, "ShagOS swap partition", buffer_size); break;
- case 0xb0: strncpy(buffer, "BootStar Dummy", buffer_size); break;
- case 0xb1: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xb3: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xb4: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xb6: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xb7: strncpy(buffer, "BSDI BSD/386 filesystem", buffer_size); break;
- case 0xb8: strncpy(buffer, "BSDI BSD/386 swap partition", buffer_size); break;
- case 0xbb: strncpy(buffer, "Boot Wizard hidden", buffer_size); break;
- case 0xbe: strncpy(buffer, "Solaris 8 boot partition", buffer_size); break;
- case 0xc0: strncpy(buffer, "CTOS", buffer_size); break;
+ case 0xae:
+ strncpy(buffer, "ShagOS filesystem", buffer_size);
+ break;
+ case 0xaf:
+ strncpy(buffer, "ShagOS swap partition", buffer_size);
+ break;
+ case 0xb0:
+ strncpy(buffer, "BootStar Dummy", buffer_size);
+ break;
+ case 0xb1:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xb3:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xb4:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xb6:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xb7:
+ strncpy(buffer, "BSDI BSD/386 filesystem", buffer_size);
+ break;
+ case 0xb8:
+ strncpy(buffer, "BSDI BSD/386 swap partition", buffer_size);
+ break;
+ case 0xbb:
+ strncpy(buffer, "Boot Wizard hidden", buffer_size);
+ break;
+ case 0xbe:
+ strncpy(buffer, "Solaris 8 boot partition", buffer_size);
+ break;
+ case 0xc0:
+ strncpy(buffer, "CTOS", buffer_size);
+ break;
//case 0xc0: strncpy(buffer, "REAL/32 secure small partition", buffer_size); break;
//case 0xc0: strncpy(buffer, "NTFT Partition", buffer_size); break;
- case 0xc1: strncpy(buffer, "DRDOS/secured (FAT-12)", buffer_size); break;
- case 0xc2: strncpy(buffer, "Reserved for DR-DOS 7+", buffer_size); break;
+ case 0xc1:
+ strncpy(buffer, "DRDOS/secured (FAT-12)", buffer_size);
+ break;
+ case 0xc2:
+ strncpy(buffer, "Reserved for DR-DOS 7+", buffer_size);
+ break;
//case 0xc2: strncpy(buffer, "Hidden Linux", buffer_size); break;
- case 0xc3: strncpy(buffer, "Hidden Linux swap", buffer_size); break;
- case 0xc4: strncpy(buffer, "DRDOS/secured (FAT-16, < 32M)", buffer_size); break;
- case 0xc5: strncpy(buffer, "DRDOS/secured (extended)", buffer_size); break;
- case 0xc6: strncpy(buffer, "DRDOS/secured (FAT-16, >= 32M)", buffer_size); break;
+ case 0xc3:
+ strncpy(buffer, "Hidden Linux swap", buffer_size);
+ break;
+ case 0xc4:
+ strncpy(buffer, "DRDOS/secured (FAT-16, < 32M)", buffer_size);
+ break;
+ case 0xc5:
+ strncpy(buffer, "DRDOS/secured (extended)", buffer_size);
+ break;
+ case 0xc6:
+ strncpy(buffer, "DRDOS/secured (FAT-16, >= 32M)", buffer_size);
+ break;
//case 0xc6: strncpy(buffer, "Windows NT corrupted FAT16 volume/stripe set", buffer_size); break;
- case 0xc7: strncpy(buffer, "Windows NT corrupted NTFS volume/stripe set", buffer_size); break;
+ case 0xc7:
+ strncpy(buffer, "Windows NT corrupted NTFS volume/stripe set",
+ buffer_size);
+ break;
//case 0xc7: strncpy(buffer, "Syrinx boot", buffer_size); break;
- case 0xc8: strncpy(buffer, "(See also ID c2.)", buffer_size); break;
- case 0xc9: strncpy(buffer, "(See also ID c2.)", buffer_size); break;
- case 0xca: strncpy(buffer, "(See also ID c2.)", buffer_size); break;
- case 0xcb: strncpy(buffer, "reserved for DRDOS/secured (FAT32)", buffer_size); break;
- case 0xcc: strncpy(buffer, "reserved for DRDOS/secured (FAT32, LBA)", buffer_size); break;
- case 0xcd: strncpy(buffer, "CTOS Memdump?", buffer_size); break;
- case 0xce: strncpy(buffer, "reserved for DRDOS/secured (FAT16, LBA)", buffer_size); break;
- case 0xd0: strncpy(buffer, "REAL/32 secure big partition", buffer_size); break;
- case 0xd1: strncpy(buffer, "Old Multiuser DOS secured FAT12", buffer_size); break;
- case 0xd4: strncpy(buffer, "Old Multiuser DOS secured FAT16 <32M", buffer_size); break;
- case 0xd5: strncpy(buffer, "Old Multiuser DOS secured extended partition", buffer_size); break;
- case 0xd6: strncpy(buffer, "Old Multiuser DOS secured FAT16 >=32M", buffer_size); break;
- case 0xd8: strncpy(buffer, "CP/M-86", buffer_size); break;
- case 0xda: strncpy(buffer, "Non-FS Data", buffer_size); break;
- case 0xdb: strncpy(buffer, "Digital Research CP/M, Concurrent CP/M, Concurrent DOS", buffer_size); break;
+ case 0xc8:
+ strncpy(buffer, "(See also ID c2.)", buffer_size);
+ break;
+ case 0xc9:
+ strncpy(buffer, "(See also ID c2.)", buffer_size);
+ break;
+ case 0xca:
+ strncpy(buffer, "(See also ID c2.)", buffer_size);
+ break;
+ case 0xcb:
+ strncpy(buffer, "reserved for DRDOS/secured (FAT32)", buffer_size);
+ break;
+ case 0xcc:
+ strncpy(buffer, "reserved for DRDOS/secured (FAT32, LBA)", buffer_size);
+ break;
+ case 0xcd:
+ strncpy(buffer, "CTOS Memdump?", buffer_size);
+ break;
+ case 0xce:
+ strncpy(buffer, "reserved for DRDOS/secured (FAT16, LBA)", buffer_size);
+ break;
+ case 0xd0:
+ strncpy(buffer, "REAL/32 secure big partition", buffer_size);
+ break;
+ case 0xd1:
+ strncpy(buffer, "Old Multiuser DOS secured FAT12", buffer_size);
+ break;
+ case 0xd4:
+ strncpy(buffer, "Old Multiuser DOS secured FAT16 <32M", buffer_size);
+ break;
+ case 0xd5:
+ strncpy(buffer, "Old Multiuser DOS secured extended partition",
+ buffer_size);
+ break;
+ case 0xd6:
+ strncpy(buffer, "Old Multiuser DOS secured FAT16 >=32M", buffer_size);
+ break;
+ case 0xd8:
+ strncpy(buffer, "CP/M-86", buffer_size);
+ break;
+ case 0xda:
+ strncpy(buffer, "Non-FS Data", buffer_size);
+ break;
+ case 0xdb:
+ strncpy(buffer,
+ "Digital Research CP/M, Concurrent CP/M, Concurrent DOS",
+ buffer_size);
+ break;
//case 0xdb: strncpy(buffer, "CTOS (Convergent Technologies OS -Unisys)", buffer_size); break;
//case 0xdb: strncpy(buffer, "KDG Telemetry SCPU boot", buffer_size); break;
- case 0xdd: strncpy(buffer, "Hidden CTOS Memdump?", buffer_size); break;
- case 0xde: strncpy(buffer, "Dell PowerEdge Server utilities (FAT fs)", buffer_size); break;
- case 0xdf: strncpy(buffer, "DG/UX virtual disk manager partition", buffer_size); break;
+ case 0xdd:
+ strncpy(buffer, "Hidden CTOS Memdump?", buffer_size);
+ break;
+ case 0xde:
+ strncpy(buffer, "Dell PowerEdge Server utilities (FAT fs)",
+ buffer_size);
+ break;
+ case 0xdf:
+ strncpy(buffer, "DG/UX virtual disk manager partition", buffer_size);
+ break;
//case 0xdf: strncpy(buffer, "BootIt EMBRM", buffer_size); break;
- case 0xe0: strncpy(buffer, "Reserved by STMicroelectronics for a filesystem called ST AVFS.", buffer_size); break;
- case 0xe1: strncpy(buffer, "DOS access or SpeedStor 12-bit FAT extended partition", buffer_size); break;
- case 0xe3: strncpy(buffer, "DOS R/O or SpeedStor", buffer_size); break;
- case 0xe4: strncpy(buffer, "SpeedStor 16-bit FAT extended partition < 1024 cyl.", buffer_size); break;
- case 0xe5: strncpy(buffer, "Tandy DOS with logical sectored FAT (According to Powerquest.)", buffer_size); break;
+ case 0xe0:
+ strncpy(buffer,
+ "Reserved by STMicroelectronics for a filesystem called ST AVFS.",
+ buffer_size);
+ break;
+ case 0xe1:
+ strncpy(buffer, "DOS access or SpeedStor 12-bit FAT extended partition",
+ buffer_size);
+ break;
+ case 0xe3:
+ strncpy(buffer, "DOS R/O or SpeedStor", buffer_size);
+ break;
+ case 0xe4:
+ strncpy(buffer, "SpeedStor 16-bit FAT extended partition < 1024 cyl.",
+ buffer_size);
+ break;
+ case 0xe5:
+ strncpy(buffer,
+ "Tandy DOS with logical sectored FAT (According to Powerquest.)",
+ buffer_size);
+ break;
//case 0xe5: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xe6: strncpy(buffer, "Reserved", buffer_size); break;
- case 0xeb: strncpy(buffer, "BFS (aka BeFS)", buffer_size); break;
- case 0xed: strncpy(buffer, "Reserved for Matthias Paul's Sprytix", buffer_size); break;
- case 0xee: strncpy(buffer, "Indication that this legacy MBR is followed by an EFI header", buffer_size); break;
- case 0xef: strncpy(buffer, "Partition that contains an EFI file system", buffer_size); break;
- case 0xf0: strncpy(buffer, "Linux/PA-RISC boot loader", buffer_size); break;
- case 0xf1: strncpy(buffer, "SpeedStor", buffer_size); break;
- case 0xf2: strncpy(buffer, "DOS 3.3+ secondary partition (Powerquest writes: Unisys DOS with logical sectored FAT.)", buffer_size); break;
- case 0xf3: strncpy(buffer, "Reserved (Powerquest writes: Storage Dimensions SpeedStor.)", buffer_size); break;
- case 0xf4: strncpy(buffer, "SpeedStor large partition", buffer_size); break;
+ case 0xe6:
+ strncpy(buffer, "Reserved", buffer_size);
+ break;
+ case 0xeb:
+ strncpy(buffer, "BFS (aka BeFS)", buffer_size);
+ break;
+ case 0xed:
+ strncpy(buffer, "Reserved for Matthias Paul's Sprytix", buffer_size);
+ break;
+ case 0xee:
+ strncpy(buffer,
+ "Indication that this legacy MBR is followed by an EFI header",
+ buffer_size);
+ break;
+ case 0xef:
+ strncpy(buffer, "Partition that contains an EFI file system",
+ buffer_size);
+ break;
+ case 0xf0:
+ strncpy(buffer, "Linux/PA-RISC boot loader", buffer_size);
+ break;
+ case 0xf1:
+ strncpy(buffer, "SpeedStor", buffer_size);
+ break;
+ case 0xf2:
+ strncpy(buffer,
+ "DOS 3.3+ secondary partition (Powerquest writes: Unisys DOS with logical sectored FAT.)",
+ buffer_size);
+ break;
+ case 0xf3:
+ strncpy(buffer,
+ "Reserved (Powerquest writes: Storage Dimensions SpeedStor.)",
+ buffer_size);
+ break;
+ case 0xf4:
+ strncpy(buffer, "SpeedStor large partition", buffer_size);
+ break;
//case 0xf4: strncpy(buffer, "Prologue single-volume partition", buffer_size); break;
- case 0xf5: strncpy(buffer, "Prologue multi-volume partition", buffer_size); break;
- case 0xf6: strncpy(buffer, "Reserved (Powerquest writes: Storage Dimensions SpeedStor. )", buffer_size); break;
- case 0xfa: strncpy(buffer, "Bochs", buffer_size); break;
- case 0xfb: strncpy(buffer, "VMware File System partition", buffer_size); break;
- case 0xfc: strncpy(buffer, "VMware Swap partition", buffer_size); break;
- case 0xfd: strncpy(buffer, "Linux raid partition with autodetect using persistent superblock (Powerquest writes: Reserved for FreeDOS. )", buffer_size); break;
- case 0xfe: strncpy(buffer, "SpeedStor > 1024 cyl.", buffer_size); break;
+ case 0xf5:
+ strncpy(buffer, "Prologue multi-volume partition", buffer_size);
+ break;
+ case 0xf6:
+ strncpy(buffer,
+ "Reserved (Powerquest writes: Storage Dimensions SpeedStor. )",
+ buffer_size);
+ break;
+ case 0xfa:
+ strncpy(buffer, "Bochs", buffer_size);
+ break;
+ case 0xfb:
+ strncpy(buffer, "VMware File System partition", buffer_size);
+ break;
+ case 0xfc:
+ strncpy(buffer, "VMware Swap partition", buffer_size);
+ break;
+ case 0xfd:
+ strncpy(buffer,
+ "Linux raid partition with autodetect using persistent superblock (Powerquest writes: Reserved for FreeDOS. )",
+ buffer_size);
+ break;
+ case 0xfe:
+ strncpy(buffer, "SpeedStor > 1024 cyl.", buffer_size);
+ break;
//case 0xfe: strncpy(buffer, "LANstep", buffer_size); break;
//case 0xfe: strncpy(buffer, "IBM PS/2 IML (Initial Microcode Load) partition, located at the end of the disk.", buffer_size); break;
//case 0xfe: strncpy(buffer, "Windows NT Disk Administrator hidden partition", buffer_size); break;
//case 0xfe: strncpy(buffer, "Linux Logical Volume Manager partition (old)", buffer_size); break;
- case 0xff: strncpy(buffer, "Xenix Bad Block Table ", buffer_size); break;
- default: strncpy(buffer, "Unknown", buffer_size); break;
- }
+ case 0xff:
+ strncpy(buffer, "Xenix Bad Block Table ", buffer_size);
+ break;
+ default:
+ strncpy(buffer, "Unknown", buffer_size);
+ break;
+ }
}
diff --git a/com32/gpllib/disk/mbrs.c b/com32/gpllib/disk/mbrs.c
index 5bf96050..b468f791 100644
--- a/com32/gpllib/disk/mbrs.c
+++ b/com32/gpllib/disk/mbrs.c
@@ -20,54 +20,87 @@
* @buffer: pre-allocated buffer
* @buffer_size: @buffer size
**/
-void get_mbr_string(const uint32_t label, char* buffer, const int buffer_size)
+void get_mbr_string(const uint32_t label, char *buffer, const int buffer_size)
{
- /* 2 bytes are usually enough to identify the MBR */
- uint16_t s_label = label >> 16;
+ /* 2 bytes are usually enough to identify the MBR */
+ uint16_t s_label = label >> 16;
- switch (s_label) {
- case 0x0000:
- case 0xfa33:
- case 0xfab8:
- case 0xfabe:
- strncpy(buffer, "No bootloader", buffer_size - 1); break;
- case 0x0ebe: strncpy(buffer, "ThinkPad", buffer_size - 1); break;
- case 0x31c0: strncpy(buffer, "Acer 3", buffer_size - 1); break;
- case 0x33c0: strncpy(buffer, "Windows", buffer_size - 1); break;
- case 0x33ff: strncpy(buffer, "HP/Gateway", buffer_size - 1); break;
- case 0xb800: strncpy(buffer, "PloP", buffer_size - 1); break;
- case 0xea05: strncpy(buffer, "XOSL", buffer_size - 1); break;
- case 0xea1e: strncpy(buffer, "Truecrypt Boot Loader", buffer_size - 1); break;
- case 0xeb04: strncpy(buffer, "Solaris", buffer_size - 1); break;
- case 0xeb48: strncpy(buffer, "Grub", buffer_size - 1); break;
- case 0xeb4c: strncpy(buffer, "Grub2 (v1.96)", buffer_size - 1); break;
- case 0xeb63: strncpy(buffer, "Grub2 (v1.97)", buffer_size - 1); break;
+ switch (s_label) {
+ case 0x0000:
+ case 0xfa33:
+ case 0xfab8:
+ case 0xfabe:
+ strncpy(buffer, "No bootloader", buffer_size - 1);
+ break;
+ case 0x0ebe:
+ strncpy(buffer, "ThinkPad", buffer_size - 1);
+ break;
+ case 0x31c0:
+ strncpy(buffer, "Acer 3", buffer_size - 1);
+ break;
+ case 0x33c0:
+ strncpy(buffer, "Windows", buffer_size - 1);
+ break;
+ case 0x33ff:
+ strncpy(buffer, "HP/Gateway", buffer_size - 1);
+ break;
+ case 0xb800:
+ strncpy(buffer, "PloP", buffer_size - 1);
+ break;
+ case 0xea05:
+ strncpy(buffer, "XOSL", buffer_size - 1);
+ break;
+ case 0xea1e:
+ strncpy(buffer, "Truecrypt Boot Loader", buffer_size - 1);
+ break;
+ case 0xeb04:
+ strncpy(buffer, "Solaris", buffer_size - 1);
+ break;
+ case 0xeb48:
+ strncpy(buffer, "Grub", buffer_size - 1);
+ break;
+ case 0xeb4c:
+ strncpy(buffer, "Grub2 (v1.96)", buffer_size - 1);
+ break;
+ case 0xeb63:
+ strncpy(buffer, "Grub2 (v1.97)", buffer_size - 1);
+ break;
case 0xeb5e:
- /* We need more than 2 bytes */
- if (((label >> 8) & 0xff) == 0x00)
- strncpy(buffer, "fbinst", buffer_size - 1);
- else if (((label >> 8) & 0xff) == 0x80)
- strncpy(buffer, "Grub4Dos", buffer_size - 1);
- else
- strncpy(buffer, "Unknown mbr", buffer_size - 1);
- break;
- case 0xfa31:
- /* We need more than 2 bytes */
- if (((label >> 8) & 0xff) == 0xc9)
- strncpy(buffer, "Master Boot LoaDeR", buffer_size - 1);
- else if (((label >> 8) & 0xff) == 0xc0)
- strncpy(buffer, "Syslinux", buffer_size - 1);
- else
- strncpy(buffer, "Unknown mbr", buffer_size - 1);
- break;
- case 0xfaeb: strncpy(buffer, "Lilo", buffer_size - 1); break;
- case 0xfc31: strncpy(buffer, "Testdisk", buffer_size - 1); break;
- case 0xfc33: strncpy(buffer, "GAG", buffer_size - 1); break;
- case 0xfceb: strncpy(buffer, "BootIT NG", buffer_size - 1); break;
- default: strncpy(buffer, "Unknown mbr", buffer_size - 1); break;
- }
+ /* We need more than 2 bytes */
+ if (((label >> 8) & 0xff) == 0x00)
+ strncpy(buffer, "fbinst", buffer_size - 1);
+ else if (((label >> 8) & 0xff) == 0x80)
+ strncpy(buffer, "Grub4Dos", buffer_size - 1);
+ else
+ strncpy(buffer, "Unknown mbr", buffer_size - 1);
+ break;
+ case 0xfa31:
+ /* We need more than 2 bytes */
+ if (((label >> 8) & 0xff) == 0xc9)
+ strncpy(buffer, "Master Boot LoaDeR", buffer_size - 1);
+ else if (((label >> 8) & 0xff) == 0xc0)
+ strncpy(buffer, "Syslinux", buffer_size - 1);
+ else
+ strncpy(buffer, "Unknown mbr", buffer_size - 1);
+ break;
+ case 0xfaeb:
+ strncpy(buffer, "Lilo", buffer_size - 1);
+ break;
+ case 0xfc31:
+ strncpy(buffer, "Testdisk", buffer_size - 1);
+ break;
+ case 0xfc33:
+ strncpy(buffer, "GAG", buffer_size - 1);
+ break;
+ case 0xfceb:
+ strncpy(buffer, "BootIT NG", buffer_size - 1);
+ break;
+ default:
+ strncpy(buffer, "Unknown mbr", buffer_size - 1);
+ break;
+ }
- buffer[buffer_size - 1] = '\0';
+ buffer[buffer_size - 1] = '\0';
}
/**
@@ -76,17 +109,17 @@ void get_mbr_string(const uint32_t label, char* buffer, const int buffer_size)
**/
uint32_t get_mbr_id(const struct driveinfo *d)
{
- char mbr[SECTOR * sizeof(char)];
+ char mbr[SECTOR * sizeof(char)];
- if (read_mbr(d->disk, &mbr) == -1)
- return -1;
- else {
- uint32_t mbr_id;
- /* Reverse the opcodes */
- mbr_id = (*(uint8_t *) (mbr + 3));
- mbr_id += (*(uint8_t *) (mbr + 2) << 8);
- mbr_id += (*(uint8_t *) (mbr + 1) << 16);
- mbr_id += (*(uint8_t *) mbr) << 24;
- return mbr_id;
- }
+ if (read_mbr(d->disk, &mbr) == -1)
+ return -1;
+ else {
+ uint32_t mbr_id;
+ /* Reverse the opcodes */
+ mbr_id = (*(uint8_t *) (mbr + 3));
+ mbr_id += (*(uint8_t *) (mbr + 2) << 8);
+ mbr_id += (*(uint8_t *) (mbr + 1) << 16);
+ mbr_id += (*(uint8_t *) mbr) << 24;
+ return mbr_id;
+ }
}
diff --git a/com32/gpllib/disk/msdos.c b/com32/gpllib/disk/msdos.c
index 1d1ef4df..affec43b 100644
--- a/com32/gpllib/disk/msdos.c
+++ b/com32/gpllib/disk/msdos.c
@@ -22,13 +22,13 @@
static inline int is_extended_partition(struct part_entry *ptab)
{
- return (ptab->ostype == 0x05 ||
- ptab->ostype == 0x0f ||
- ptab->ostype == 0x85);
+ return (ptab->ostype == 0x05 ||
+ ptab->ostype == 0x0f || ptab->ostype == 0x85);
}
+
static inline int msdos_magic_present(const char *ptab)
{
- return ( *(uint16_t *)(ptab + 0x1fe) == 0xaa55 );
+ return (*(uint16_t *) (ptab + 0x1fe) == 0xaa55);
}
/**
@@ -44,65 +44,63 @@ static inline int msdos_magic_present(const char *ptab)
static int process_extended_partition(struct driveinfo *drive_info,
const int partition_offset,
const int ebr_offset,
- p_callback callback,
- int nb_part_seen)
+ p_callback callback, int nb_part_seen)
{
- int status = 0;
- /* The ebr is located at the first sector of the extended partition */
- char* ebr = malloc(SECTOR * sizeof(char));
-
- if (read_sectors(drive_info, ebr, partition_offset + ebr_offset, 1) == -1)
- goto abort;
-
- /* Check msdos magic signature */
- if (!msdos_magic_present(ebr))
- goto abort;
-
- struct part_entry *ptab = (struct part_entry *)(ebr + PARTITION_TABLES_OFFSET);
-
- for (int i = 0; i < 4; i++) {
- if (status == -1)
- goto abort;
-
- if (!is_extended_partition(&ptab[i])) {
- /*
- * This EBR partition table entry points to the
- * logical partition associated to that EBR
- */
- int logical_partition_start = ebr_offset + ptab[i].start_lba;
-
- /* Last EBR in the extended partition? */
- if (!logical_partition_start)
- continue;
-
- /*
- * Check for garbage:
- * 3rd and 4th entries in an EBR should be zero
- * Some (malformed) partitioning software still add some
- * data partitions there.
- */
- if (ptab[i].start_lba <= 0 || ptab[i].length <= 0)
- continue;
-
- nb_part_seen++;
- callback(drive_info,
- &ptab[i],
- partition_offset + logical_partition_start,
- nb_part_seen);
- } else
- status = process_extended_partition(drive_info,
- partition_offset,
- ptab[i].start_lba,
- callback,
- nb_part_seen);
- }
-
- free(ebr);
- return 0;
+ int status = 0;
+ /* The ebr is located at the first sector of the extended partition */
+ char *ebr = malloc(SECTOR * sizeof(char));
+
+ if (read_sectors(drive_info, ebr, partition_offset + ebr_offset, 1) == -1)
+ goto abort;
+
+ /* Check msdos magic signature */
+ if (!msdos_magic_present(ebr))
+ goto abort;
+
+ struct part_entry *ptab =
+ (struct part_entry *)(ebr + PARTITION_TABLES_OFFSET);
+
+ for (int i = 0; i < 4; i++) {
+ if (status == -1)
+ goto abort;
+
+ if (!is_extended_partition(&ptab[i])) {
+ /*
+ * This EBR partition table entry points to the
+ * logical partition associated to that EBR
+ */
+ int logical_partition_start = ebr_offset + ptab[i].start_lba;
+
+ /* Last EBR in the extended partition? */
+ if (!logical_partition_start)
+ continue;
+
+ /*
+ * Check for garbage:
+ * 3rd and 4th entries in an EBR should be zero
+ * Some (malformed) partitioning software still add some
+ * data partitions there.
+ */
+ if (ptab[i].start_lba <= 0 || ptab[i].length <= 0)
+ continue;
+
+ nb_part_seen++;
+ callback(drive_info,
+ &ptab[i],
+ partition_offset + logical_partition_start, nb_part_seen);
+ } else
+ status = process_extended_partition(drive_info,
+ partition_offset,
+ ptab[i].start_lba,
+ callback, nb_part_seen);
+ }
+
+ free(ebr);
+ return 0;
abort:
- free(ebr);
- return -1;
+ free(ebr);
+ return -1;
}
/**
@@ -114,28 +112,24 @@ abort:
static int process_mbr(struct driveinfo *drive_info, struct part_entry *ptab,
p_callback callback)
{
- int status = 0;
-
- for (int i = 0; i < 4; i++) {
- if (status == -1)
- return -1;
-
- if (ptab[i].start_sect > 0) {
- if (is_extended_partition(&ptab[i])) {
- callback(drive_info,
- &ptab[i],
- ptab[i].start_lba,
- i+1);
- status = process_extended_partition(drive_info, ptab[i].start_lba, 0, callback, 4);
- } else
- callback(drive_info,
- &ptab[i],
- ptab[i].start_lba,
- i+1);
- }
+ int status = 0;
+
+ for (int i = 0; i < 4; i++) {
+ if (status == -1)
+ return -1;
+
+ if (ptab[i].start_sect > 0) {
+ if (is_extended_partition(&ptab[i])) {
+ callback(drive_info, &ptab[i], ptab[i].start_lba, i + 1);
+ status =
+ process_extended_partition(drive_info, ptab[i].start_lba, 0,
+ callback, 4);
+ } else
+ callback(drive_info, &ptab[i], ptab[i].start_lba, i + 1);
}
+ }
- return 0;
+ return 0;
}
/**
@@ -152,16 +146,17 @@ static int process_mbr(struct driveinfo *drive_info, struct part_entry *ptab,
**/
int parse_partition_table(struct driveinfo *d, p_callback callback)
{
- char *mbr = malloc(SECTOR * sizeof(char));
+ char *mbr = malloc(SECTOR * sizeof(char));
- if (read_mbr(d->disk, mbr) == -1)
- return -1;
- else {
- /* Check msdos magic signature */
- if (!msdos_magic_present(mbr))
- return -1;
+ if (read_mbr(d->disk, mbr) == -1)
+ return -1;
+ else {
+ /* Check msdos magic signature */
+ if (!msdos_magic_present(mbr))
+ return -1;
- struct part_entry *ptab = (struct part_entry *)(mbr + PARTITION_TABLES_OFFSET);
- return process_mbr(d, ptab, callback);
- }
+ struct part_entry *ptab =
+ (struct part_entry *)(mbr + PARTITION_TABLES_OFFSET);
+ return process_mbr(d, ptab, callback);
+ }
}
diff --git a/com32/gpllib/disk/read.c b/com32/gpllib/disk/read.c
index 74840829..7a6cc430 100644
--- a/com32/gpllib/disk/read.c
+++ b/com32/gpllib/disk/read.c
@@ -36,11 +36,11 @@
**/
int read_mbr(int drive, void *buf)
{
- struct driveinfo drive_info;
- drive_info.disk = drive;
+ struct driveinfo drive_info;
+ drive_info.disk = drive;
- /* MBR: lba = 0, 1 sector */
- return read_sectors(&drive_info, buf, 0, 1);
+ /* MBR: lba = 0, 1 sector */
+ return read_sectors(&drive_info, buf, 0, 1);
}
/**
@@ -54,12 +54,12 @@ int read_mbr(int drive, void *buf)
* Return the number of sectors read on success or -1 on failure.
* errno_disk contains the error number.
**/
-int dev_read(int drive, void * buf, unsigned int lba, int sectors)
+int dev_read(int drive, void *buf, unsigned int lba, int sectors)
{
- struct driveinfo drive_info;
- drive_info.disk = drive;
+ struct driveinfo drive_info;
+ drive_info.disk = drive;
- return read_sectors(&drive_info, buf, lba, sectors);
+ return read_sectors(&drive_info, buf, lba, sectors);
}
/**
@@ -72,62 +72,64 @@ int dev_read(int drive, void * buf, unsigned int lba, int sectors)
* Return the number of sectors read on success or -1 on failure.
* errno_disk contains the error number.
**/
-int read_sectors(struct driveinfo* drive_info, void *data,
+int read_sectors(struct driveinfo *drive_info, void *data,
const unsigned int lba, const int sectors)
{
- com32sys_t inreg, outreg;
- struct ebios_dapa *dapa = __com32.cs_bounce;
- void *buf = (char *)__com32.cs_bounce + sectors * SECTOR;
- char *bufp = data;
-
- if (get_drive_parameters(drive_info) == -1)
- return -1;
-
- memset(&inreg, 0, sizeof inreg);
-
- if (drive_info->ebios) {
- dapa->len = sizeof(*dapa);
- dapa->count = sectors;
- dapa->off = OFFS(buf);
- dapa->seg = SEG(buf);
- dapa->lba = lba;
-
- inreg.esi.w[0] = OFFS(dapa);
- inreg.ds = SEG(dapa);
- inreg.edx.b[0] = drive_info->disk;
- inreg.eax.b[1] = 0x42; /* Extended read */
- } else {
- unsigned int c, h, s;
-
- if (!drive_info->cbios) { // XXX errno
- /* We failed to get the geometry */
- if (lba)
- return -1; /* Can only read MBR */
-
- s = 1; h = 0; c = 0;
- } else
- lba_to_chs(drive_info, lba, &s, &h, &c);
-
- // XXX errno
- if ( s > 63 || h > 256 || c > 1023 )
- return -1;
-
- inreg.eax.w[0] = 0x0201; /* Read one sector */
- inreg.ecx.b[1] = c & 0xff;
- inreg.ecx.b[0] = s + (c >> 6);
- inreg.edx.b[1] = h;
- inreg.edx.b[0] = drive_info->disk;
- inreg.ebx.w[0] = OFFS(buf);
- inreg.es = SEG(buf);
- }
-
- /* Perform the read */
- if (int13_retry(&inreg, &outreg)) {
- errno_disk = outreg.eax.b[1];
- return -1; /* Give up */
- }
-
- memcpy(bufp, buf, sectors * SECTOR);
-
- return sectors;
+ com32sys_t inreg, outreg;
+ struct ebios_dapa *dapa = __com32.cs_bounce;
+ void *buf = (char *)__com32.cs_bounce + sectors * SECTOR;
+ char *bufp = data;
+
+ if (get_drive_parameters(drive_info) == -1)
+ return -1;
+
+ memset(&inreg, 0, sizeof inreg);
+
+ if (drive_info->ebios) {
+ dapa->len = sizeof(*dapa);
+ dapa->count = sectors;
+ dapa->off = OFFS(buf);
+ dapa->seg = SEG(buf);
+ dapa->lba = lba;
+
+ inreg.esi.w[0] = OFFS(dapa);
+ inreg.ds = SEG(dapa);
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.eax.b[1] = 0x42; /* Extended read */
+ } else {
+ unsigned int c, h, s;
+
+ if (!drive_info->cbios) { // XXX errno
+ /* We failed to get the geometry */
+ if (lba)
+ return -1; /* Can only read MBR */
+
+ s = 1;
+ h = 0;
+ c = 0;
+ } else
+ lba_to_chs(drive_info, lba, &s, &h, &c);
+
+ // XXX errno
+ if (s > 63 || h > 256 || c > 1023)
+ return -1;
+
+ inreg.eax.w[0] = 0x0201; /* Read one sector */
+ inreg.ecx.b[1] = c & 0xff;
+ inreg.ecx.b[0] = s + (c >> 6);
+ inreg.edx.b[1] = h;
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.ebx.w[0] = OFFS(buf);
+ inreg.es = SEG(buf);
+ }
+
+ /* Perform the read */
+ if (int13_retry(&inreg, &outreg)) {
+ errno_disk = outreg.eax.b[1];
+ return -1; /* Give up */
+ }
+
+ memcpy(bufp, buf, sectors * SECTOR);
+
+ return sectors;
}
diff --git a/com32/gpllib/disk/swsusp.c b/com32/gpllib/disk/swsusp.c
index ac9724aa..ef782fd5 100644
--- a/com32/gpllib/disk/swsusp.c
+++ b/com32/gpllib/disk/swsusp.c
@@ -12,16 +12,16 @@
**/
int swsusp_check(struct driveinfo *drive_info, struct part_entry *ptab)
{
- struct swsusp_header header_p;
- int offset;
- int found;
+ struct swsusp_header header_p;
+ int offset;
+ int found;
- /* Read first page of the swap device */
- offset = ptab->start_lba;
- if (read_sectors(drive_info, &header_p, offset, PAGE_SIZE/SECTOR) == -1) {
- return -1;
- } else {
- found = !memcmp(SWSUSP_SIG, header_p.sig, 10);
- return found;
- }
+ /* Read first page of the swap device */
+ offset = ptab->start_lba;
+ if (read_sectors(drive_info, &header_p, offset, PAGE_SIZE / SECTOR) == -1) {
+ return -1;
+ } else {
+ found = !memcmp(SWSUSP_SIG, header_p.sig, 10);
+ return found;
+ }
}
diff --git a/com32/gpllib/disk/util.c b/com32/gpllib/disk/util.c
index 6faac399..59c0328f 100644
--- a/com32/gpllib/disk/util.c
+++ b/com32/gpllib/disk/util.c
@@ -26,19 +26,20 @@
*
* Call int 13h, but with retry on failure. Especially floppies need this.
**/
-int int13_retry(const com32sys_t *inreg, com32sys_t *outreg)
+int int13_retry(const com32sys_t * inreg, com32sys_t * outreg)
{
- int retry = MAX_NB_RETRIES; /* Number of retries */
- com32sys_t tmpregs;
+ int retry = MAX_NB_RETRIES; /* Number of retries */
+ com32sys_t tmpregs;
- if ( !outreg ) outreg = &tmpregs;
+ if (!outreg)
+ outreg = &tmpregs;
- while ( retry-- ) {
- __intcall(0x13, inreg, outreg);
- if ( !(outreg->eflags.l & EFLAGS_CF) )
- return 0; /* CF=0 => OK */
- }
+ while (retry--) {
+ __intcall(0x13, inreg, outreg);
+ if (!(outreg->eflags.l & EFLAGS_CF))
+ return 0; /* CF=0 => OK */
+ }
- /* If we get here: error */
- return -1;
+ /* If we get here: error */
+ return -1;
}
diff --git a/com32/gpllib/disk/write.c b/com32/gpllib/disk/write.c
index a236f37d..89e530d9 100644
--- a/com32/gpllib/disk/write.c
+++ b/com32/gpllib/disk/write.c
@@ -32,58 +32,60 @@
* Return the number of sectors write on success or -1 on failure.
* errno_disk contains the error number.
**/
-int write_sectors(const struct driveinfo* drive_info, const unsigned int lba,
+int write_sectors(const struct driveinfo *drive_info, const unsigned int lba,
const void *data, const int size)
{
- com32sys_t inreg, outreg;
- struct ebios_dapa *dapa = __com32.cs_bounce;
- void *buf = (char *)__com32.cs_bounce + size;
-
- memcpy(buf, data, size);
- memset(&inreg, 0, sizeof inreg);
-
- if (drive_info->ebios) {
- dapa->len = sizeof(*dapa);
- dapa->count = size;
- dapa->off = OFFS(buf);
- dapa->seg = SEG(buf);
- dapa->lba = lba;
-
- inreg.esi.w[0] = OFFS(dapa);
- inreg.ds = SEG(dapa);
- inreg.edx.b[0] = drive_info->disk;
- inreg.eax.w[0] = 0x4300; /* Extended write */
- } else {
- unsigned int c, h, s;
-
- if (!drive_info->cbios) { // XXX errno
- /* We failed to get the geometry */
- if (lba)
- return -1; /* Can only write MBR */
-
- s = 1; h = 0; c = 0;
- } else
- lba_to_chs(drive_info, lba, &s, &h, &c);
-
- // XXX errno
- if ( s > 63 || h > 256 || c > 1023 )
- return -1;
-
- inreg.eax.w[0] = 0x0301; /* Write one sector */
- inreg.ecx.b[1] = c & 0xff;
- inreg.ecx.b[0] = s + (c >> 6);
- inreg.edx.b[1] = h;
- inreg.edx.b[0] = drive_info->disk;
- inreg.ebx.w[0] = OFFS(buf);
- inreg.es = SEG(buf);
- }
-
- /* Perform the write */
- if (int13_retry(&inreg, &outreg)) {
- errno_disk = outreg.eax.b[1];
- return -1; /* Give up */
+ com32sys_t inreg, outreg;
+ struct ebios_dapa *dapa = __com32.cs_bounce;
+ void *buf = (char *)__com32.cs_bounce + size;
+
+ memcpy(buf, data, size);
+ memset(&inreg, 0, sizeof inreg);
+
+ if (drive_info->ebios) {
+ dapa->len = sizeof(*dapa);
+ dapa->count = size;
+ dapa->off = OFFS(buf);
+ dapa->seg = SEG(buf);
+ dapa->lba = lba;
+
+ inreg.esi.w[0] = OFFS(dapa);
+ inreg.ds = SEG(dapa);
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.eax.w[0] = 0x4300; /* Extended write */
+ } else {
+ unsigned int c, h, s;
+
+ if (!drive_info->cbios) { // XXX errno
+ /* We failed to get the geometry */
+ if (lba)
+ return -1; /* Can only write MBR */
+
+ s = 1;
+ h = 0;
+ c = 0;
} else
- return size;
+ lba_to_chs(drive_info, lba, &s, &h, &c);
+
+ // XXX errno
+ if (s > 63 || h > 256 || c > 1023)
+ return -1;
+
+ inreg.eax.w[0] = 0x0301; /* Write one sector */
+ inreg.ecx.b[1] = c & 0xff;
+ inreg.ecx.b[0] = s + (c >> 6);
+ inreg.edx.b[1] = h;
+ inreg.edx.b[0] = drive_info->disk;
+ inreg.ebx.w[0] = OFFS(buf);
+ inreg.es = SEG(buf);
+ }
+
+ /* Perform the write */
+ if (int13_retry(&inreg, &outreg)) {
+ errno_disk = outreg.eax.b[1];
+ return -1; /* Give up */
+ } else
+ return size;
}
/**
@@ -92,11 +94,10 @@ int write_sectors(const struct driveinfo* drive_info, const unsigned int lba,
* @lba: Position to write
* @data: Buffer to write
**/
-int write_verify_sector(struct driveinfo* drive_info,
- const unsigned int lba,
- const void *data)
+int write_verify_sector(struct driveinfo *drive_info,
+ const unsigned int lba, const void *data)
{
- return write_verify_sectors(drive_info, lba, data, SECTOR);
+ return write_verify_sectors(drive_info, lba, data, SECTOR);
}
/**
@@ -106,20 +107,20 @@ int write_verify_sector(struct driveinfo* drive_info,
* @data: Buffer to write
* @size: Size of the buffer (number of sectors)
**/
-int write_verify_sectors(struct driveinfo* drive_info,
+int write_verify_sectors(struct driveinfo *drive_info,
const unsigned int lba,
const void *data, const int size)
{
- char *rb = malloc(SECTOR * size * sizeof(char));
- int status;
+ char *rb = malloc(SECTOR * size * sizeof(char));
+ int status;
- if (write_sectors(drive_info, lba, data, size) == -1)
- return -1; /* Write failure */
+ if (write_sectors(drive_info, lba, data, size) == -1)
+ return -1; /* Write failure */
- if (read_sectors(drive_info, rb, lba, size) == -1)
- return -1; /* Readback failure */
+ if (read_sectors(drive_info, rb, lba, size) == -1)
+ return -1; /* Readback failure */
- status = memcmp(data, rb, SECTOR * size);
- free(rb);
- return status ? -1 : 0;
+ status = memcmp(data, rb, SECTOR * size);
+ free(rb);
+ return status ? -1 : 0;
}