2006-06-05 Yoshinori K. Okuji <okuji@enbug.org>
Count partitions from 1 instead of 0 in the string representation of partitions. Still use 0-based internally. * partmap/sun.c (grub_sun_is_valid): A cosmetic change. (sun_partition_map_iterate): Use grub_partition_t instead of struct grub_partition *. Cast DESC->START_CYLINDER to grub_uint64_t after converting the endian. (sun_partition_map_probe): Subtract 1 for PARTNUM. (sun_partition_map_get_name): Add 1 to P->INDEX. * partmap/pc.c (grub_partition_parse): Subtract 1 for PCDATA->DOS_PART. (pc_partition_map_get_name): Add 1 into PCDATA->DOS_PART. * partmap/gpt.c (gpt_partition_map_iterate): Initialize PARTNO to zero instead of one. (gpt_partition_map_probe): Subtract 1 for PARTNUM. (gpt_partition_map_get_name): Add 1 into P->INDEX. * partmap/apple.c (apple_partition_map_iterate): Change the type of POS to unsigned. (apple_partition_map_probe): Subtract 1 for PARTNUM. (apple_partition_map_get_name): Add 1 into P->INDEX. * partmap/amiga.c (amiga_partition_map_iterate): Change the type of POS to unsigned. (amiga_partition_map_iterate): Cast NEXT to grub_off_t to calculate the offset of a partition. (amiga_partition_map_probe): Subtract 1 for PARTNUM. (amiga_partition_map_get_name): Add 1 into P->INDEX. * partmap/acorn.c (acorn_partition_map_find): Change the type of SECTOR to grub_disk_addr_t. (acorn_partition_map_iterate): Likewise. (acorn_partition_map_probe): Subtract 1 for PARTNUM. Change the type of SECTOR to grub_disk_addr_t. Declare P on the top. (acorn_partition_map_get_name): Add 1 into P->INDEX. * kern/i386/pc/init.c (make_install_device): Add 1 into GRUB_INSTALL_DOS_PART. * fs/iso9660.c (grub_iso9660_mount): Fixed a reversed conditional.
This commit is contained in:
parent
524a1e6a40
commit
deae281bfe
10 changed files with 131 additions and 58 deletions
|
@ -1,7 +1,7 @@
|
|||
/* sun.c - Read SUN style partition tables. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2002,2005,2006 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -78,9 +78,13 @@ grub_sun_is_valid (struct grub_sun_block *label)
|
|||
{
|
||||
grub_uint16_t *pos;
|
||||
grub_uint16_t sum = 0;
|
||||
for (pos = (grub_uint16_t *) label; pos < (grub_uint16_t *) (label + 1); pos++)
|
||||
|
||||
for (pos = (grub_uint16_t *) label;
|
||||
pos < (grub_uint16_t *) (label + 1);
|
||||
pos++)
|
||||
sum ^= *pos;
|
||||
return !sum;
|
||||
|
||||
return ! sum;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
@ -88,14 +92,16 @@ sun_partition_map_iterate (grub_disk_t disk,
|
|||
int (*hook) (grub_disk_t disk,
|
||||
const grub_partition_t partition))
|
||||
{
|
||||
struct grub_partition *p;
|
||||
grub_partition_t p;
|
||||
struct grub_disk raw;
|
||||
struct grub_sun_block block;
|
||||
int partnum;
|
||||
|
||||
raw = *disk;
|
||||
raw.partition = 0;
|
||||
p = (struct grub_partition *) grub_malloc (sizeof (struct grub_partition));
|
||||
if (!p)
|
||||
|
||||
p = (grub_partition_t) grub_malloc (sizeof (struct grub_partition));
|
||||
if (! p)
|
||||
return grub_errno;
|
||||
|
||||
p->offset = 0;
|
||||
|
@ -106,20 +112,25 @@ sun_partition_map_iterate (grub_disk_t disk,
|
|||
{
|
||||
if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.magic))
|
||||
grub_error (GRUB_ERR_BAD_PART_TABLE, "not a sun partiton table");
|
||||
if (!grub_sun_is_valid (&block))
|
||||
|
||||
if (! grub_sun_is_valid (&block))
|
||||
grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
|
||||
|
||||
/* Maybe another error value would be better, because partition
|
||||
table _is_ recognised but invalid. */
|
||||
for (partnum = 0; partnum < GRUB_PARTMAP_SUN_MAX_PARTS; partnum++)
|
||||
{
|
||||
if (block.infos[partnum].id == 0 ||
|
||||
block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
|
||||
struct grub_sun_partition_descriptor *desc;
|
||||
|
||||
if (block.infos[partnum].id == 0
|
||||
|| block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
|
||||
continue;
|
||||
p->start = grub_be_to_cpu32
|
||||
(block.partitions[partnum].start_cylinder)
|
||||
* grub_be_to_cpu16 (block.ntrks)
|
||||
* grub_be_to_cpu16 (block.nsect);
|
||||
p->len = grub_be_to_cpu32 (block.partitions[partnum].num_sectors);
|
||||
|
||||
desc = &block.partitions[partnum];
|
||||
p->start = ((grub_uint64_t) grub_be_to_cpu32 (desc->start_cylinder)
|
||||
* grub_be_to_cpu16 (block.ntrks)
|
||||
* grub_be_to_cpu16 (block.nsect));
|
||||
p->len = grub_be_to_cpu32 (desc->num_sectors);
|
||||
p->index = partnum;
|
||||
if (p->len)
|
||||
{
|
||||
|
@ -128,6 +139,7 @@ sun_partition_map_iterate (grub_disk_t disk,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
grub_free (p);
|
||||
|
||||
return grub_errno;
|
||||
|
@ -150,13 +162,15 @@ sun_partition_map_probe (grub_disk_t disk, const char *str)
|
|||
p = (grub_partition_t) grub_malloc (sizeof (*p));
|
||||
if (p)
|
||||
grub_memcpy (p, partition, sizeof (*p));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
partnum = grub_strtoul (s, 0, 10);
|
||||
partnum = grub_strtoul (s, 0, 10) - 1;
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
{
|
||||
if (sun_partition_map_iterate (disk, find_func))
|
||||
|
@ -170,6 +184,7 @@ sun_partition_map_probe (grub_disk_t disk, const char *str)
|
|||
grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
|
||||
p = 0;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -177,9 +192,11 @@ static char *
|
|||
sun_partition_map_get_name (const grub_partition_t p)
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = grub_malloc (13);
|
||||
if (name)
|
||||
grub_sprintf (name, "%d", p->index);
|
||||
grub_sprintf (name, "%d", p->index + 1);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue