summaryrefslogtreecommitdiff
path: root/disk/part_dos.c
diff options
context:
space:
mode:
Diffstat (limited to 'disk/part_dos.c')
-rw-r--r--disk/part_dos.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 4d778ec5b24..0bc8ba72043 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -36,28 +36,28 @@
#include "part_dos.h"
#if (defined(CONFIG_CMD_IDE) || \
- defined(CONFIG_CMD_SATA) || \
- defined(CONFIG_CMD_SCSI) || \
- defined(CONFIG_CMD_USB) || \
- defined(CONFIG_MMC) || \
- defined(CONFIG_SYSTEMACE) ) && defined(CONFIG_DOS_PARTITION)
+ defined(CONFIG_CMD_SATA) || \
+ defined(CONFIG_CMD_SCSI) || \
+ defined(CONFIG_CMD_USB) || \
+ defined(CONFIG_MMC) || \
+ defined(CONFIG_SYSTEMACE) ) && defined(CONFIG_DOS_PARTITION)
/* Convert char[4] in little endian format to the host format integer
*/
static inline int le32_to_int(unsigned char *le32)
{
- return ((le32[3] << 24) +
- (le32[2] << 16) +
- (le32[1] << 8) +
- le32[0]
+ return ((le32[3] << 24) +
+ (le32[2] << 16) +
+ (le32[1] << 8) +
+ le32[0]
);
}
static inline int is_extended(int part_type)
{
- return (part_type == 0x5 ||
- part_type == 0xf ||
- part_type == 0x85);
+ return (part_type == 0x5 ||
+ part_type == 0xf ||
+ part_type == 0x85);
}
static void print_one_part (dos_partition_t *p, int ext_part_sector, int part_num)
@@ -73,12 +73,12 @@ static void print_one_part (dos_partition_t *p, int ext_part_sector, int part_nu
static int test_block_type(unsigned char *buffer)
{
if((buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
- (buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
+ (buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
return (-1);
} /* no DOS Signature at all */
if(strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],"FAT",3)==0)
return DOS_PBR; /* is PBR */
- return DOS_MBR; /* Is MBR */
+ return DOS_MBR; /* Is MBR */
}
@@ -87,14 +87,14 @@ int test_part_dos (block_dev_desc_t *dev_desc)
unsigned char buffer[DEFAULT_SECTOR_SIZE];
if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) buffer) != 1) ||
- (buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
- (buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
+ (buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
+ (buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
return (-1);
}
return (0);
}
-/* Print a partition that is relative to its Extended partition table
+/* Print a partition that is relative to its Extended partition table
*/
static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_sector, int relative,
int part_num)
@@ -116,7 +116,7 @@ static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_s
return;
}
if(i==DOS_PBR) {
- printf (" 1\t\t 0\t%10ld\t%2x\n",
+ printf (" 1\t\t 0\t%10ld\t%2x\n",
dev_desc->lba, buffer[DOS_PBR_MEDIA_TYPE_OFFSET]);
return;
}
@@ -129,13 +129,13 @@ static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_s
*/
if ((pt->sys_ind != 0) &&
- (ext_part_sector == 0 || !is_extended (pt->sys_ind)) ) {
+ (ext_part_sector == 0 || !is_extended (pt->sys_ind)) ) {
print_one_part (pt, ext_part_sector, part_num);
}
/* Reverse engr the fdisk part# assignment rule! */
if ((ext_part_sector == 0) ||
- (pt->sys_ind != 0 && !is_extended (pt->sys_ind)) ) {
+ (pt->sys_ind != 0 && !is_extended (pt->sys_ind)) ) {
part_num++;
}
}
@@ -147,7 +147,7 @@ static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_s
int lba_start = le32_to_int (pt->start4) + relative;
print_partition_extended (dev_desc, lba_start,
- ext_part_sector == 0 ? lba_start
+ ext_part_sector == 0 ? lba_start
: relative,
part_num);
}
@@ -157,7 +157,7 @@ static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_s
}
-/* Print a partition that is relative to its Extended partition table
+/* Print a partition that is relative to its Extended partition table
*/
static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part_sector,
int relative, int part_num,
@@ -180,6 +180,9 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
return -1;
}
+ if (((buffer[0] == 0xEB) && (buffer[2] == 0x90)) || (buffer[0] == 0xE9))
+ return(-1);
+
/* Print all primary/logical partitions */
pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
for (i = 0; i < 4; i++, pt++) {
@@ -188,11 +191,11 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
* are not in the MBR
*/
if ((pt->sys_ind != 0) &&
- (part_num == which_part) &&
- (is_extended(pt->sys_ind) == 0)) {
+ (part_num == which_part) &&
+ (is_extended(pt->sys_ind) == 0)) {
info->blksz = 512;
info->start = ext_part_sector + le32_to_int (pt->start4);
- info->size = le32_to_int (pt->size4);
+ info->size = le32_to_int (pt->size4);
switch(dev_desc->if_type) {
case IF_TYPE_IDE:
case IF_TYPE_SATA:
@@ -219,7 +222,7 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
/* Reverse engr the fdisk part# assignment rule! */
if ((ext_part_sector == 0) ||
- (pt->sys_ind != 0 && !is_extended (pt->sys_ind)) ) {
+ (pt->sys_ind != 0 && !is_extended (pt->sys_ind)) ) {
part_num++;
}
}
@@ -240,7 +243,7 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
void print_part_dos (block_dev_desc_t *dev_desc)
{
- printf ("Partition Start Sector Num Sectors Type\n");
+ printf ("Partition Start Sector Num Sectors Type\n");
print_partition_extended (dev_desc, 0, 0, 1);
}