Merge mainline into plan9
This commit is contained in:
commit
4e01c8c165
595 changed files with 52570 additions and 11831 deletions
|
@ -23,6 +23,8 @@
|
|||
#include <grub/partition.h>
|
||||
#include <grub/acorn_filecore.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define LINUX_NATIVE_MAGIC grub_cpu_to_le32 (0xdeafa1de)
|
||||
#define LINUX_SWAP_MAGIC grub_cpu_to_le32 (0xdeafab1e)
|
||||
#define LINUX_MAP_ENTRIES (512 / 12)
|
||||
|
@ -32,11 +34,18 @@
|
|||
|
||||
struct grub_acorn_boot_block
|
||||
{
|
||||
grub_uint8_t misc[0x1C0];
|
||||
struct grub_filecore_disc_record disc_record;
|
||||
grub_uint8_t flags;
|
||||
grub_uint16_t start_cylinder;
|
||||
grub_uint8_t checksum;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
grub_uint8_t misc[0x1C0];
|
||||
struct grub_filecore_disc_record disc_record;
|
||||
grub_uint8_t flags;
|
||||
grub_uint16_t start_cylinder;
|
||||
grub_uint8_t checksum;
|
||||
} __attribute__ ((packed, aligned));
|
||||
grub_uint8_t bin[0x200];
|
||||
};
|
||||
} __attribute__ ((packed, aligned));
|
||||
|
||||
struct linux_part
|
||||
|
@ -69,7 +78,7 @@ acorn_partition_map_find (grub_disk_t disk, struct linux_part *m,
|
|||
goto fail;
|
||||
|
||||
for (i = 0; i != 0x1ff; ++i)
|
||||
checksum = (checksum & 0xff) + (checksum >> 8) + boot.misc[i];
|
||||
checksum = ((checksum & 0xff) + (checksum >> 8) + boot.bin[i]);
|
||||
|
||||
if ((grub_uint8_t) checksum != boot.checksum)
|
||||
goto fail;
|
||||
|
|
|
@ -23,10 +23,13 @@
|
|||
#include <grub/partition.h>
|
||||
#include <grub/dl.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
struct grub_amiga_rdsk
|
||||
{
|
||||
/* "RDSK". */
|
||||
grub_uint8_t magic[4];
|
||||
#define GRUB_AMIGA_RDSK_MAGIC "RDSK"
|
||||
grub_uint32_t size;
|
||||
grub_int32_t checksum;
|
||||
grub_uint32_t scsihost;
|
||||
|
@ -36,13 +39,14 @@ struct grub_amiga_rdsk
|
|||
grub_uint32_t partitionlst;
|
||||
grub_uint32_t fslst;
|
||||
|
||||
/* The other information is not important for us. */
|
||||
grub_uint32_t unused[128 - 9];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct grub_amiga_partition
|
||||
{
|
||||
/* "PART". */
|
||||
grub_uint8_t magic[4];
|
||||
#define GRUB_AMIGA_PART_MAGIC "PART"
|
||||
grub_int32_t size;
|
||||
grub_int32_t checksum;
|
||||
grub_uint32_t scsihost;
|
||||
|
@ -63,12 +67,24 @@ struct grub_amiga_partition
|
|||
grub_uint32_t highcyl;
|
||||
|
||||
grub_uint32_t firstcyl;
|
||||
grub_uint32_t unused[128 - 44];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static struct grub_partition_map grub_amiga_partition_map;
|
||||
|
||||
|
||||
|
||||
static grub_uint32_t
|
||||
amiga_partition_map_checksum (void *buf, grub_size_t sz)
|
||||
{
|
||||
grub_uint32_t *ptr = buf;
|
||||
grub_uint32_t r = 0;
|
||||
sz /= sizeof (grub_uint32_t);
|
||||
for (; sz; sz--, ptr++)
|
||||
r += grub_be_to_cpu32 (*ptr);
|
||||
return r;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
amiga_partition_map_iterate (grub_disk_t disk,
|
||||
int (*hook) (grub_disk_t disk,
|
||||
|
@ -87,7 +103,9 @@ amiga_partition_map_iterate (grub_disk_t disk,
|
|||
if (grub_disk_read (disk, pos, 0, sizeof (rdsk), &rdsk))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_strcmp ((char *) rdsk.magic, "RDSK") == 0)
|
||||
if (grub_memcmp (rdsk.magic, GRUB_AMIGA_RDSK_MAGIC,
|
||||
sizeof (rdsk.magic)) == 0
|
||||
&& amiga_partition_map_checksum (&rdsk, sizeof (rdsk)) == 0)
|
||||
{
|
||||
/* Found the first PART block. */
|
||||
next = grub_be_to_cpu32 (rdsk.partitionlst);
|
||||
|
@ -108,6 +126,11 @@ amiga_partition_map_iterate (grub_disk_t disk,
|
|||
if (grub_disk_read (disk, next, 0, sizeof (apart), &apart))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_memcmp (apart.magic, GRUB_AMIGA_PART_MAGIC,
|
||||
sizeof (apart.magic)) != 0
|
||||
|| amiga_partition_map_checksum (&apart, sizeof (apart)) != 0)
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
||||
"invalid Amiga partition map");
|
||||
/* Calculate the first block and the size of the partition. */
|
||||
part.start = (grub_be_to_cpu32 (apart.lowcyl)
|
||||
* grub_be_to_cpu32 (apart.heads)
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include <grub/mm.h>
|
||||
#include <grub/partition.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define GRUB_APPLE_HEADER_MAGIC 0x4552
|
||||
#define GRUB_APPLE_PART_MAGIC 0x504D
|
||||
|
||||
|
|
|
@ -24,9 +24,12 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/msdos_partition.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/emu/misc.h>
|
||||
#endif
|
||||
|
||||
static struct grub_partition_map grub_bsdlabel_partition_map;
|
||||
|
@ -101,8 +104,9 @@ iterate_real (grub_disk_t disk, grub_disk_addr_t sector, int freebsd,
|
|||
#ifdef GRUB_UTIL
|
||||
char *partname;
|
||||
/* disk->partition != NULL as 0 < delta */
|
||||
partname = grub_partition_get_name (disk->partition);
|
||||
grub_util_warn ("Discarding improperly nested partition (%s,%s,%s%d)",
|
||||
partname = disk->partition ? grub_partition_get_name (disk->partition)
|
||||
: "";
|
||||
grub_util_warn (_("Discarding improperly nested partition (%s,%s,%s%d)"),
|
||||
disk->name, partname, p.partmap->name, p.number + 1);
|
||||
grub_free (partname);
|
||||
#endif
|
||||
|
|
124
grub-core/partmap/dvh.c
Normal file
124
grub-core/partmap/dvh.c
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2005,2006,2007,2011 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/partition.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define DVH_MAGIC 0x0be5a941
|
||||
|
||||
struct grub_dvh_partition_descriptor
|
||||
{
|
||||
grub_uint32_t length;
|
||||
grub_uint32_t start;
|
||||
grub_uint32_t type;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct grub_dvh_block
|
||||
{
|
||||
grub_uint32_t magic;
|
||||
grub_uint8_t unused[308];
|
||||
struct grub_dvh_partition_descriptor parts[16];
|
||||
grub_uint32_t checksum;
|
||||
grub_uint32_t unused2;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static struct grub_partition_map grub_dvh_partition_map;
|
||||
|
||||
/* Verify checksum (true=ok). */
|
||||
static int
|
||||
grub_dvh_is_valid (struct grub_dvh_block *label)
|
||||
{
|
||||
grub_uint32_t *pos;
|
||||
grub_uint32_t sum = 0;
|
||||
|
||||
for (pos = (grub_uint32_t *) label;
|
||||
pos < (grub_uint32_t *) (label + 1);
|
||||
pos++)
|
||||
sum += *pos;
|
||||
|
||||
return ! sum;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
dvh_partition_map_iterate (grub_disk_t disk,
|
||||
int (*hook) (grub_disk_t disk,
|
||||
const grub_partition_t partition))
|
||||
{
|
||||
struct grub_partition p;
|
||||
struct grub_dvh_block block;
|
||||
unsigned partnum;
|
||||
grub_err_t err;
|
||||
|
||||
p.partmap = &grub_dvh_partition_map;
|
||||
err = grub_disk_read (disk, 0, 0, sizeof (struct grub_dvh_block),
|
||||
&block);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (DVH_MAGIC != grub_be_to_cpu32 (block.magic))
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "not a dvh partition table");
|
||||
|
||||
if (! grub_dvh_is_valid (&block))
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
|
||||
|
||||
/* Maybe another error value would be better, because partition
|
||||
table _is_ recognized but invalid. */
|
||||
for (partnum = 0; partnum < ARRAY_SIZE (block.parts); partnum++)
|
||||
{
|
||||
if (block.parts[partnum].length == 0)
|
||||
continue;
|
||||
|
||||
if (partnum == 10)
|
||||
continue;
|
||||
|
||||
p.start = grub_be_to_cpu32 (block.parts[partnum].start);
|
||||
p.len = grub_be_to_cpu32 (block.parts[partnum].length);
|
||||
p.number = p.index = partnum;
|
||||
if (hook (disk, &p))
|
||||
break;
|
||||
}
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
/* Partition map type. */
|
||||
static struct grub_partition_map grub_dvh_partition_map =
|
||||
{
|
||||
.name = "dvh",
|
||||
.iterate = dvh_partition_map_iterate,
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(part_dvh)
|
||||
{
|
||||
grub_partition_map_register (&grub_dvh_partition_map);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(part_dvh)
|
||||
{
|
||||
grub_partition_map_unregister (&grub_dvh_partition_map);
|
||||
}
|
||||
|
|
@ -25,6 +25,8 @@
|
|||
#include <grub/msdos_partition.h>
|
||||
#include <grub/gpt_partition.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static grub_uint8_t grub_gpt_magic[8] =
|
||||
{
|
||||
0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
|
||||
|
@ -138,11 +140,17 @@ gpt_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
|
|||
const grub_partition_t p)
|
||||
{
|
||||
struct grub_gpt_partentry gptdata;
|
||||
grub_partition_t p2;
|
||||
|
||||
p2 = disk->partition;
|
||||
disk->partition = p->parent;
|
||||
if (grub_disk_read (disk, p->offset, p->index,
|
||||
sizeof (gptdata), &gptdata))
|
||||
return 0;
|
||||
{
|
||||
disk->partition = p2;
|
||||
return 0;
|
||||
}
|
||||
disk->partition = p2;
|
||||
|
||||
/* If there's an embed region, it is in a dedicated partition. */
|
||||
if (! grub_memcmp (&gptdata.type, &grub_gpt_partition_type_bios_boot, 16))
|
||||
|
@ -157,7 +165,7 @@ gpt_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
|
|||
|
||||
if (embed_type != GRUB_EMBED_PCBIOS)
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"GPT curently supports only PC-BIOS embedding");
|
||||
"GPT currently supports only PC-BIOS embedding");
|
||||
|
||||
err = gpt_partition_map_iterate (disk, find_usable_region);
|
||||
if (err)
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/dl.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static struct grub_partition_map grub_msdos_partition_map;
|
||||
|
||||
|
||||
|
@ -90,8 +92,11 @@ grub_partition_msdos_iterate (grub_disk_t disk,
|
|||
{
|
||||
e = mbr.entries + p.index;
|
||||
|
||||
p.start = p.offset + grub_le_to_cpu32 (e->start) - delta;
|
||||
p.len = grub_le_to_cpu32 (e->length);
|
||||
p.start = p.offset
|
||||
+ (grub_le_to_cpu32 (e->start)
|
||||
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)) - delta;
|
||||
p.len = grub_le_to_cpu32 (e->length)
|
||||
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
|
||||
p.msdostype = e->type;
|
||||
|
||||
grub_dprintf ("partition",
|
||||
|
@ -126,7 +131,9 @@ grub_partition_msdos_iterate (grub_disk_t disk,
|
|||
|
||||
if (grub_msdos_partition_is_extended (e->type))
|
||||
{
|
||||
p.offset = ext_offset + grub_le_to_cpu32 (e->start);
|
||||
p.offset = ext_offset
|
||||
+ (grub_le_to_cpu32 (e->start)
|
||||
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
|
||||
if (! ext_offset)
|
||||
ext_offset = p.offset;
|
||||
|
||||
|
@ -204,8 +211,11 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
|
|||
e = mbr.entries + i;
|
||||
|
||||
if (!grub_msdos_partition_is_empty (e->type)
|
||||
&& end > offset + grub_le_to_cpu32 (e->start))
|
||||
end = offset + grub_le_to_cpu32 (e->start);
|
||||
&& end > offset
|
||||
+ (grub_le_to_cpu32 (e->start)
|
||||
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)))
|
||||
end = offset + (grub_le_to_cpu32 (e->start)
|
||||
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
|
||||
|
||||
/* If this is a GPT partition, this MBR is just a dummy. */
|
||||
if (e->type == GRUB_PC_PARTITION_TYPE_GPT_DISK && i == 0)
|
||||
|
@ -219,7 +229,9 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
|
|||
|
||||
if (grub_msdos_partition_is_extended (e->type))
|
||||
{
|
||||
offset = ext_offset + grub_le_to_cpu32 (e->start);
|
||||
offset = ext_offset
|
||||
+ (grub_le_to_cpu32 (e->start)
|
||||
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
|
||||
if (! ext_offset)
|
||||
ext_offset = offset;
|
||||
|
||||
|
@ -232,10 +244,10 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
|
|||
break;
|
||||
}
|
||||
|
||||
if (end >= *nsectors + 1)
|
||||
if (end >= *nsectors + 2)
|
||||
{
|
||||
int i;
|
||||
*nsectors = end - 1;
|
||||
unsigned i;
|
||||
*nsectors = end - 2;
|
||||
*sectors = grub_malloc (*nsectors * sizeof (**sectors));
|
||||
if (!*sectors)
|
||||
return grub_errno;
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define GRUB_PARTMAP_SUN_MAGIC 0xDABE
|
||||
#define GRUB_PARTMAP_SUN_MAX_PARTS 8
|
||||
#define GRUB_PARTMAP_SUN_WHOLE_DISK_ID 0x05
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define GRUB_PARTMAP_SUN_PC_MAGIC 0xDABE
|
||||
#define GRUB_PARTMAP_SUN_PC_MAX_PARTS 16
|
||||
#define GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID 0x05
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue