2008-07-28 Robert Millan <rmh@aybabtu.com>
* partmap/apple.c (GRUB_APPLE_HEADER_MAGIC): New macro. (struct grub_apple_header): New struct. Describes the layout of the partmap header. (apple_partition_map_iterate): Check the header magic as well as the partition magic (which was already being checked).
This commit is contained in:
parent
cfd0b4e6fa
commit
41694fd019
2 changed files with 36 additions and 6 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2008-07-28 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
|
* partmap/apple.c (GRUB_APPLE_HEADER_MAGIC): New macro.
|
||||||
|
(struct grub_apple_header): New struct. Describes the layout of
|
||||||
|
the partmap header.
|
||||||
|
(apple_partition_map_iterate): Check the header magic as well as the
|
||||||
|
partition magic (which was already being checked).
|
||||||
|
|
||||||
2008-07-28 Pavel Roskin <proski@gnu.org>
|
2008-07-28 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* genmk.rb: Add a warning to the beginning of the output that
|
* genmk.rb: Add a warning to the beginning of the output that
|
||||||
|
|
|
@ -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,2006,2007 Free Software Foundation, Inc.
|
* Copyright (C) 2002,2004,2005,2006,2007,2008 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
|
||||||
|
@ -22,11 +22,19 @@
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/partition.h>
|
#include <grub/partition.h>
|
||||||
|
|
||||||
|
#define GRUB_APPLE_HEADER_MAGIC 0x4552
|
||||||
#define GRUB_APPLE_PART_MAGIC 0x504D
|
#define GRUB_APPLE_PART_MAGIC 0x504D
|
||||||
|
|
||||||
|
struct grub_apple_header
|
||||||
|
{
|
||||||
|
/* The magic number to identify the partition map, it should have
|
||||||
|
the value `0x4552'. */
|
||||||
|
grub_uint16_t magic;
|
||||||
|
};
|
||||||
|
|
||||||
struct grub_apple_part
|
struct grub_apple_part
|
||||||
{
|
{
|
||||||
/* The magic number to idenify this as a partition, it should have
|
/* The magic number to identify this as a partition, it should have
|
||||||
the value `0x504D'. */
|
the value `0x504D'. */
|
||||||
grub_uint16_t magic;
|
grub_uint16_t magic;
|
||||||
|
|
||||||
|
@ -98,6 +106,7 @@ apple_partition_map_iterate (grub_disk_t disk,
|
||||||
const grub_partition_t partition))
|
const grub_partition_t partition))
|
||||||
{
|
{
|
||||||
struct grub_partition part;
|
struct grub_partition part;
|
||||||
|
struct grub_apple_header aheader;
|
||||||
struct grub_apple_part apart;
|
struct grub_apple_part apart;
|
||||||
struct grub_disk raw;
|
struct grub_disk raw;
|
||||||
int partno = 0;
|
int partno = 0;
|
||||||
|
@ -109,6 +118,18 @@ apple_partition_map_iterate (grub_disk_t disk,
|
||||||
|
|
||||||
part.partmap = &grub_apple_partition_map;
|
part.partmap = &grub_apple_partition_map;
|
||||||
|
|
||||||
|
if (grub_disk_read (&raw, 0, 0, sizeof (aheader), (char *) &aheader))
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
if (grub_be_to_cpu16 (aheader.magic) != GRUB_APPLE_HEADER_MAGIC)
|
||||||
|
{
|
||||||
|
grub_dprintf ("partition",
|
||||||
|
"bad magic (found 0x%x; wanted 0x%x\n",
|
||||||
|
grub_be_to_cpu16 (aheader.magic),
|
||||||
|
GRUB_APPLE_HEADER_MAGIC);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (grub_disk_read (&raw, pos / GRUB_DISK_SECTOR_SIZE,
|
if (grub_disk_read (&raw, pos / GRUB_DISK_SECTOR_SIZE,
|
||||||
|
@ -147,11 +168,12 @@ apple_partition_map_iterate (grub_disk_t disk,
|
||||||
partno++;
|
partno++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos == GRUB_DISK_SECTOR_SIZE)
|
if (pos != GRUB_DISK_SECTOR_SIZE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
||||||
"Apple partition map not found.");
|
"Apple partition map not found.");
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue