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
47
ChangeLog
47
ChangeLog
|
@ -1,3 +1,50 @@
|
||||||
|
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.
|
||||||
|
|
||||||
2006-06-04 Yoshinori K. Okuji <okuji@enbug.org>
|
2006-06-04 Yoshinori K. Okuji <okuji@enbug.org>
|
||||||
|
|
||||||
Clean up the code to support 64-bit addressing in disks and
|
Clean up the code to support 64-bit addressing in disks and
|
||||||
|
|
5
NEWS
5
NEWS
|
@ -1,3 +1,8 @@
|
||||||
|
New in 1.95:
|
||||||
|
|
||||||
|
* Number partitions from 1 instead of 0. For instance, the first
|
||||||
|
partition of "hd0" is now "hd0,1" but not "hd0,0".
|
||||||
|
|
||||||
New in 1.94 - 2006-06-04:
|
New in 1.94 - 2006-06-04:
|
||||||
|
|
||||||
* Fix several serious bugs in HFS+.
|
* Fix several serious bugs in HFS+.
|
||||||
|
|
|
@ -236,7 +236,7 @@ grub_iso9660_mount (grub_disk_t disk)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grub_strncmp ((char *) data->voldesc.voldesc.magic, "CD001", 5) == 0)
|
if (grub_strncmp ((char *) data->voldesc.voldesc.magic, "CD001", 5) != 0)
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem");
|
grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -268,7 +268,7 @@ grub_iso9660_mount (grub_disk_t disk)
|
||||||
sua_size = rootdir.len - sua_pos;
|
sua_size = rootdir.len - sua_pos;
|
||||||
|
|
||||||
sua = grub_malloc (sua_size);
|
sua = grub_malloc (sua_size);
|
||||||
if (!sua)
|
if (! sua)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (grub_disk_read (disk, (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector)
|
if (grub_disk_read (disk, (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector)
|
||||||
|
@ -622,7 +622,7 @@ grub_iso9660_dir (grub_device_t device, const char *path,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data = grub_iso9660_mount (device->disk);
|
data = grub_iso9660_mount (device->disk);
|
||||||
if (!data)
|
if (! data)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
rootnode.data = data;
|
rootnode.data = data;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* GRUB -- GRand Unified Bootloader
|
* GRUB -- GRand Unified Bootloader
|
||||||
* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
* Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -64,7 +64,7 @@ make_install_device (void)
|
||||||
grub_boot_drive & 0x7f);
|
grub_boot_drive & 0x7f);
|
||||||
|
|
||||||
if (grub_install_dos_part >= 0)
|
if (grub_install_dos_part >= 0)
|
||||||
grub_sprintf (dev + grub_strlen (dev), ",%u", grub_install_dos_part);
|
grub_sprintf (dev + grub_strlen (dev), ",%u", grub_install_dos_part + 1);
|
||||||
|
|
||||||
if (grub_install_bsd_part >= 0)
|
if (grub_install_bsd_part >= 0)
|
||||||
grub_sprintf (dev + grub_strlen (dev), ",%c", grub_install_bsd_part + 'a');
|
grub_sprintf (dev + grub_strlen (dev), ",%c", grub_install_bsd_part + 'a');
|
||||||
|
|
|
@ -51,7 +51,7 @@ static struct grub_partition_map grub_acorn_partition_map;
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
acorn_partition_map_find (grub_disk_t disk, struct linux_part *m,
|
acorn_partition_map_find (grub_disk_t disk, struct linux_part *m,
|
||||||
unsigned int *sector)
|
grub_disk_addr_t *sector)
|
||||||
{
|
{
|
||||||
struct grub_acorn_boot_block boot;
|
struct grub_acorn_boot_block boot;
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
|
@ -61,8 +61,8 @@ acorn_partition_map_find (grub_disk_t disk, struct linux_part *m,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
err = grub_disk_read (disk, 0xC00 / GRUB_DISK_SECTOR_SIZE, 0,
|
err = grub_disk_read (disk, 0xC00 / GRUB_DISK_SECTOR_SIZE, 0,
|
||||||
sizeof (struct grub_acorn_boot_block),
|
sizeof (struct grub_acorn_boot_block),
|
||||||
(char *)&boot);
|
(char *) &boot);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ acorn_partition_map_find (grub_disk_t disk, struct linux_part *m,
|
||||||
|
|
||||||
return grub_disk_read (disk, *sector, 0,
|
return grub_disk_read (disk, *sector, 0,
|
||||||
sizeof (struct linux_part) * LINUX_MAP_ENTRIES,
|
sizeof (struct linux_part) * LINUX_MAP_ENTRIES,
|
||||||
(char *)m);
|
(char *) m);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
||||||
|
@ -100,7 +100,7 @@ acorn_partition_map_iterate (grub_disk_t disk,
|
||||||
struct grub_disk raw;
|
struct grub_disk raw;
|
||||||
struct linux_part map[LINUX_MAP_ENTRIES];
|
struct linux_part map[LINUX_MAP_ENTRIES];
|
||||||
int i;
|
int i;
|
||||||
unsigned int sector;
|
grub_disk_addr_t sector;
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
|
|
||||||
/* Enforce raw disk access. */
|
/* Enforce raw disk access. */
|
||||||
|
@ -119,7 +119,7 @@ acorn_partition_map_iterate (grub_disk_t disk,
|
||||||
&& map[i].magic != LINUX_SWAP_MAGIC)
|
&& map[i].magic != LINUX_SWAP_MAGIC)
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
|
|
||||||
part.start = (grub_disk_addr_t)sector + map[i].start;
|
part.start = sector + map[i].start;
|
||||||
part.len = map[i].size;
|
part.len = map[i].size;
|
||||||
part.offset = 6;
|
part.offset = 6;
|
||||||
part.index = i;
|
part.index = i;
|
||||||
|
@ -137,10 +137,11 @@ acorn_partition_map_probe (grub_disk_t disk, const char *str)
|
||||||
{
|
{
|
||||||
struct linux_part map[LINUX_MAP_ENTRIES];
|
struct linux_part map[LINUX_MAP_ENTRIES];
|
||||||
struct grub_disk raw = *disk;
|
struct grub_disk raw = *disk;
|
||||||
unsigned long partnum = grub_strtoul (str, 0, 10);
|
unsigned long partnum = grub_strtoul (str, 0, 10) - 1;
|
||||||
unsigned int sector;
|
grub_disk_addr_t sector;
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
|
grub_partition_t p;
|
||||||
|
|
||||||
/* Enforce raw disk access. */
|
/* Enforce raw disk access. */
|
||||||
raw.partition = 0;
|
raw.partition = 0;
|
||||||
|
|
||||||
|
@ -156,11 +157,11 @@ acorn_partition_map_probe (grub_disk_t disk, const char *str)
|
||||||
&& map[partnum].magic != LINUX_SWAP_MAGIC)
|
&& map[partnum].magic != LINUX_SWAP_MAGIC)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
grub_partition_t p = grub_malloc (sizeof (struct grub_partition));
|
p = grub_malloc (sizeof (struct grub_partition));
|
||||||
if (!p)
|
if (! p)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
p->start = (grub_disk_addr_t)sector + map[partnum].start;
|
p->start = sector + map[partnum].start;
|
||||||
p->len = map[partnum].size;
|
p->len = map[partnum].size;
|
||||||
p->offset = 6;
|
p->offset = 6;
|
||||||
p->index = partnum;
|
p->index = partnum;
|
||||||
|
@ -178,10 +179,10 @@ acorn_partition_map_get_name (const grub_partition_t p)
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
name = grub_malloc (13);
|
name = grub_malloc (13);
|
||||||
if (!name)
|
if (! name)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
grub_sprintf (name, "%d", p->index);
|
grub_sprintf (name, "%d", p->index + 1);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ amiga_partition_map_iterate (grub_disk_t disk,
|
||||||
struct grub_disk raw;
|
struct grub_disk raw;
|
||||||
int partno = 0;
|
int partno = 0;
|
||||||
int next = -1;
|
int next = -1;
|
||||||
int pos;
|
unsigned pos;
|
||||||
|
|
||||||
/* Enforce raw disk access. */
|
/* Enforce raw disk access. */
|
||||||
raw = *disk;
|
raw = *disk;
|
||||||
|
@ -94,8 +94,7 @@ amiga_partition_map_iterate (grub_disk_t disk,
|
||||||
for (pos = 0; pos < 15; pos++)
|
for (pos = 0; pos < 15; pos++)
|
||||||
{
|
{
|
||||||
/* Read the RDSK block which is a descriptor for the entire disk. */
|
/* Read the RDSK block which is a descriptor for the entire disk. */
|
||||||
if (grub_disk_read (&raw, pos, 0,
|
if (grub_disk_read (&raw, pos, 0, sizeof (rdsk), (char *) &rdsk))
|
||||||
sizeof (rdsk), (char *) &rdsk))
|
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
if (grub_strcmp ((char *) rdsk.magic, "RDSK") == 0)
|
if (grub_strcmp ((char *) rdsk.magic, "RDSK") == 0)
|
||||||
|
@ -116,8 +115,7 @@ amiga_partition_map_iterate (grub_disk_t disk,
|
||||||
struct grub_amiga_partition apart;
|
struct grub_amiga_partition apart;
|
||||||
|
|
||||||
/* Read the RDSK block which is a descriptor for the entire disk. */
|
/* Read the RDSK block which is a descriptor for the entire disk. */
|
||||||
if (grub_disk_read (&raw, next, 0,
|
if (grub_disk_read (&raw, next, 0, sizeof (apart), (char *) &apart))
|
||||||
sizeof (apart), (char *) &apart))
|
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
/* Calculate the first block and the size of the partition. */
|
/* Calculate the first block and the size of the partition. */
|
||||||
|
@ -129,7 +127,7 @@ amiga_partition_map_iterate (grub_disk_t disk,
|
||||||
* grub_be_to_cpu32 (apart.heads)
|
* grub_be_to_cpu32 (apart.heads)
|
||||||
* grub_be_to_cpu32 (apart.block_per_track));
|
* grub_be_to_cpu32 (apart.block_per_track));
|
||||||
|
|
||||||
part.offset = next * 512;
|
part.offset = (grub_off_t) next * 512;
|
||||||
part.index = partno;
|
part.index = partno;
|
||||||
part.partmap = &grub_amiga_partition_map;
|
part.partmap = &grub_amiga_partition_map;
|
||||||
|
|
||||||
|
@ -155,7 +153,7 @@ amiga_partition_map_probe (grub_disk_t disk, const char *str)
|
||||||
|
|
||||||
int find_func (grub_disk_t d __attribute__ ((unused)),
|
int find_func (grub_disk_t d __attribute__ ((unused)),
|
||||||
const grub_partition_t partition)
|
const grub_partition_t partition)
|
||||||
{
|
{
|
||||||
if (partnum == partition->index)
|
if (partnum == partition->index)
|
||||||
{
|
{
|
||||||
p = (grub_partition_t) grub_malloc (sizeof (*p));
|
p = (grub_partition_t) grub_malloc (sizeof (*p));
|
||||||
|
@ -170,7 +168,7 @@ amiga_partition_map_probe (grub_disk_t disk, const char *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the partition number. */
|
/* Get the partition number. */
|
||||||
partnum = grub_strtoul (s, 0, 10);
|
partnum = grub_strtoul (s, 0, 10) - 1;
|
||||||
if (grub_errno)
|
if (grub_errno)
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
|
grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
|
||||||
|
@ -197,7 +195,7 @@ amiga_partition_map_get_name (const grub_partition_t p)
|
||||||
if (! name)
|
if (! name)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
grub_sprintf (name, "%d", p->index);
|
grub_sprintf (name, "%d", p->index + 1);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* apple.c - Read macintosh partition tables. */
|
/* apple.c - Read macintosh partition tables. */
|
||||||
/*
|
/*
|
||||||
* GRUB -- GRand Unified Bootloader
|
* GRUB -- GRand Unified Bootloader
|
||||||
* Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
|
* Copyright (C) 2002,2004,2005,2006 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -102,7 +102,7 @@ apple_partition_map_iterate (grub_disk_t disk,
|
||||||
struct grub_apple_part apart;
|
struct grub_apple_part apart;
|
||||||
struct grub_disk raw;
|
struct grub_disk raw;
|
||||||
int partno = 0;
|
int partno = 0;
|
||||||
int pos = GRUB_DISK_SECTOR_SIZE;
|
unsigned pos = GRUB_DISK_SECTOR_SIZE;
|
||||||
|
|
||||||
/* Enforce raw disk access. */
|
/* Enforce raw disk access. */
|
||||||
raw = *disk;
|
raw = *disk;
|
||||||
|
@ -113,7 +113,7 @@ apple_partition_map_iterate (grub_disk_t disk,
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (grub_disk_read (&raw, pos / GRUB_DISK_SECTOR_SIZE,
|
if (grub_disk_read (&raw, pos / GRUB_DISK_SECTOR_SIZE,
|
||||||
pos % GRUB_DISK_SECTOR_SIZE,
|
pos % GRUB_DISK_SECTOR_SIZE,
|
||||||
sizeof (struct grub_apple_part), (char *) &apart))
|
sizeof (struct grub_apple_part), (char *) &apart))
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
|
@ -140,7 +140,8 @@ apple_partition_map_iterate (grub_disk_t disk,
|
||||||
if (hook (disk, &part))
|
if (hook (disk, &part))
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
if (grub_be_to_cpu32 (apart.first_phys_block) == GRUB_DISK_SECTOR_SIZE * 2)
|
if (grub_be_to_cpu32 (apart.first_phys_block)
|
||||||
|
== GRUB_DISK_SECTOR_SIZE * 2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pos += sizeof (struct grub_apple_part);
|
pos += sizeof (struct grub_apple_part);
|
||||||
|
@ -181,7 +182,7 @@ apple_partition_map_probe (grub_disk_t disk, const char *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the partition number. */
|
/* Get the partition number. */
|
||||||
partnum = grub_strtoul (s, 0, 10);
|
partnum = grub_strtoul (s, 0, 10) - 1;
|
||||||
if (grub_errno)
|
if (grub_errno)
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
|
grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
|
||||||
|
@ -208,7 +209,7 @@ apple_partition_map_get_name (const grub_partition_t p)
|
||||||
if (! name)
|
if (! name)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
grub_sprintf (name, "%d", p->index);
|
grub_sprintf (name, "%d", p->index + 1);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ gpt_partition_map_iterate (grub_disk_t disk,
|
||||||
struct grub_disk raw;
|
struct grub_disk raw;
|
||||||
struct grub_pc_partition_mbr mbr;
|
struct grub_pc_partition_mbr mbr;
|
||||||
grub_uint64_t entries;
|
grub_uint64_t entries;
|
||||||
int partno = 1;
|
int partno = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int last_offset = 0;
|
int last_offset = 0;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ gpt_partition_map_probe (grub_disk_t disk, const char *str)
|
||||||
|
|
||||||
int find_func (grub_disk_t d __attribute__ ((unused)),
|
int find_func (grub_disk_t d __attribute__ ((unused)),
|
||||||
const grub_partition_t partition)
|
const grub_partition_t partition)
|
||||||
{
|
{
|
||||||
if (partnum == partition->index)
|
if (partnum == partition->index)
|
||||||
{
|
{
|
||||||
p = (grub_partition_t) grub_malloc (sizeof (*p));
|
p = (grub_partition_t) grub_malloc (sizeof (*p));
|
||||||
|
@ -172,7 +172,7 @@ gpt_partition_map_probe (grub_disk_t disk, const char *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the partition number. */
|
/* Get the partition number. */
|
||||||
partnum = grub_strtoul (s, 0, 10);
|
partnum = grub_strtoul (s, 0, 10) - 1;
|
||||||
if (grub_errno)
|
if (grub_errno)
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
|
grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
|
||||||
|
@ -199,7 +199,7 @@ gpt_partition_map_get_name (const grub_partition_t p)
|
||||||
if (! name)
|
if (! name)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
grub_sprintf (name, "%d", p->index);
|
grub_sprintf (name, "%d", p->index + 1);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
partmap/pc.c
12
partmap/pc.c
|
@ -55,8 +55,9 @@ grub_partition_parse (const char *str)
|
||||||
/* Initialize some of the fields with invalid values. */
|
/* Initialize some of the fields with invalid values. */
|
||||||
pcdata->bsd_part = pcdata->dos_type = pcdata->bsd_type = p->index = -1;
|
pcdata->bsd_part = pcdata->dos_type = pcdata->bsd_type = p->index = -1;
|
||||||
|
|
||||||
/* Get the DOS partition number. */
|
/* Get the DOS partition number. The number is counted from one for
|
||||||
pcdata->dos_part = grub_strtoul (s, &s, 0);
|
the user interface, and from zero internally. */
|
||||||
|
pcdata->dos_part = grub_strtoul (s, &s, 0) - 1;
|
||||||
|
|
||||||
if (grub_errno)
|
if (grub_errno)
|
||||||
{
|
{
|
||||||
|
@ -237,6 +238,7 @@ pc_partition_map_probe (grub_disk_t disk, const char *str)
|
||||||
const grub_partition_t partition)
|
const grub_partition_t partition)
|
||||||
{
|
{
|
||||||
struct grub_pc_partition *partdata = partition->data;
|
struct grub_pc_partition *partdata = partition->data;
|
||||||
|
|
||||||
if ((pcdata->dos_part == partdata->dos_part || pcdata->dos_part == -1)
|
if ((pcdata->dos_part == partdata->dos_part || pcdata->dos_part == -1)
|
||||||
&& pcdata->bsd_part == partdata->bsd_part)
|
&& pcdata->bsd_part == partdata->bsd_part)
|
||||||
{
|
{
|
||||||
|
@ -283,9 +285,11 @@ pc_partition_map_get_name (const grub_partition_t p)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (pcdata->bsd_part < 0)
|
if (pcdata->bsd_part < 0)
|
||||||
grub_sprintf (name, "%d", pcdata->dos_part);
|
grub_sprintf (name, "%d", pcdata->dos_part + 1);
|
||||||
|
else if (pcdata->dos_part < 0)
|
||||||
|
grub_sprintf (name, "%c", pcdata->bsd_part + 'a');
|
||||||
else
|
else
|
||||||
grub_sprintf (name, "%d,%c", pcdata->dos_part, pcdata->bsd_part + 'a');
|
grub_sprintf (name, "%d,%c", pcdata->dos_part + 1, pcdata->bsd_part + 'a');
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* sun.c - Read SUN style partition tables. */
|
/* sun.c - Read SUN style partition tables. */
|
||||||
/*
|
/*
|
||||||
* GRUB -- GRand Unified Bootloader
|
* 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
|
* GRUB is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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 *pos;
|
||||||
grub_uint16_t sum = 0;
|
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;
|
sum ^= *pos;
|
||||||
return !sum;
|
|
||||||
|
return ! sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
|
@ -88,14 +92,16 @@ sun_partition_map_iterate (grub_disk_t disk,
|
||||||
int (*hook) (grub_disk_t disk,
|
int (*hook) (grub_disk_t disk,
|
||||||
const grub_partition_t partition))
|
const grub_partition_t partition))
|
||||||
{
|
{
|
||||||
struct grub_partition *p;
|
grub_partition_t p;
|
||||||
struct grub_disk raw;
|
struct grub_disk raw;
|
||||||
struct grub_sun_block block;
|
struct grub_sun_block block;
|
||||||
int partnum;
|
int partnum;
|
||||||
|
|
||||||
raw = *disk;
|
raw = *disk;
|
||||||
raw.partition = 0;
|
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;
|
return grub_errno;
|
||||||
|
|
||||||
p->offset = 0;
|
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))
|
if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.magic))
|
||||||
grub_error (GRUB_ERR_BAD_PART_TABLE, "not a sun partiton table");
|
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");
|
grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
|
||||||
|
|
||||||
/* Maybe another error value would be better, because partition
|
/* Maybe another error value would be better, because partition
|
||||||
table _is_ recognised but invalid. */
|
table _is_ recognised but invalid. */
|
||||||
for (partnum = 0; partnum < GRUB_PARTMAP_SUN_MAX_PARTS; partnum++)
|
for (partnum = 0; partnum < GRUB_PARTMAP_SUN_MAX_PARTS; partnum++)
|
||||||
{
|
{
|
||||||
if (block.infos[partnum].id == 0 ||
|
struct grub_sun_partition_descriptor *desc;
|
||||||
block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
|
|
||||||
|
if (block.infos[partnum].id == 0
|
||||||
|
|| block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
|
||||||
continue;
|
continue;
|
||||||
p->start = grub_be_to_cpu32
|
|
||||||
(block.partitions[partnum].start_cylinder)
|
desc = &block.partitions[partnum];
|
||||||
* grub_be_to_cpu16 (block.ntrks)
|
p->start = ((grub_uint64_t) grub_be_to_cpu32 (desc->start_cylinder)
|
||||||
* grub_be_to_cpu16 (block.nsect);
|
* grub_be_to_cpu16 (block.ntrks)
|
||||||
p->len = grub_be_to_cpu32 (block.partitions[partnum].num_sectors);
|
* grub_be_to_cpu16 (block.nsect));
|
||||||
|
p->len = grub_be_to_cpu32 (desc->num_sectors);
|
||||||
p->index = partnum;
|
p->index = partnum;
|
||||||
if (p->len)
|
if (p->len)
|
||||||
{
|
{
|
||||||
|
@ -128,6 +139,7 @@ sun_partition_map_iterate (grub_disk_t disk,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_free (p);
|
grub_free (p);
|
||||||
|
|
||||||
return grub_errno;
|
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));
|
p = (grub_partition_t) grub_malloc (sizeof (*p));
|
||||||
if (p)
|
if (p)
|
||||||
grub_memcpy (p, partition, sizeof (*p));
|
grub_memcpy (p, partition, sizeof (*p));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
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 (grub_errno == GRUB_ERR_NONE)
|
||||||
{
|
{
|
||||||
if (sun_partition_map_iterate (disk, find_func))
|
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");
|
grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
|
||||||
p = 0;
|
p = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,9 +192,11 @@ static char *
|
||||||
sun_partition_map_get_name (const grub_partition_t p)
|
sun_partition_map_get_name (const grub_partition_t p)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
name = grub_malloc (13);
|
name = grub_malloc (13);
|
||||||
if (name)
|
if (name)
|
||||||
grub_sprintf (name, "%d", p->index);
|
grub_sprintf (name, "%d", p->index + 1);
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue