Support net-/openbsd labels inside logical partitions
This commit is contained in:
parent
43de930c20
commit
4b98e0d7c7
3 changed files with 45 additions and 21 deletions
|
@ -145,32 +145,49 @@ netopenbsdlabel_partition_map_iterate (grub_disk_t disk, grub_uint8_t type,
|
||||||
int (*hook) (grub_disk_t disk,
|
int (*hook) (grub_disk_t disk,
|
||||||
const grub_partition_t partition))
|
const grub_partition_t partition))
|
||||||
{
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
auto int check_msdos (grub_disk_t dsk,
|
||||||
|
const grub_partition_t partition);
|
||||||
|
|
||||||
|
int check_msdos (grub_disk_t dsk,
|
||||||
|
const grub_partition_t partition)
|
||||||
|
{
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
|
|
||||||
|
if (partition->msdostype != type)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err = iterate_real (dsk, partition->start
|
||||||
|
+ GRUB_PC_PARTITION_BSD_LABEL_SECTOR, 0, pmap, hook);
|
||||||
|
if (err == GRUB_ERR_NONE)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (err == GRUB_ERR_BAD_PART_TABLE)
|
||||||
|
{
|
||||||
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
grub_print_error ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (disk->partition && grub_strcmp (disk->partition->partmap->name, "msdos")
|
if (disk->partition && grub_strcmp (disk->partition->partmap->name, "msdos")
|
||||||
== 0)
|
== 0)
|
||||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no embedding supported");
|
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no embedding supported");
|
||||||
|
|
||||||
{
|
{
|
||||||
struct grub_msdos_partition_mbr mbr;
|
grub_err_t err;
|
||||||
unsigned i;
|
err = grub_partition_msdos_iterate (disk, check_msdos);
|
||||||
|
|
||||||
err = grub_disk_read (disk, 0, 0, sizeof (mbr), &mbr);
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
if (!count)
|
||||||
for (i = 0; i < ARRAY_SIZE (mbr.entries); i++)
|
|
||||||
if (mbr.entries[i].type == type)
|
|
||||||
{
|
|
||||||
err = iterate_real (disk, mbr.entries[i].start
|
|
||||||
+ GRUB_PC_PARTITION_BSD_LABEL_SECTOR, 0, pmap,
|
|
||||||
hook);
|
|
||||||
if (err != GRUB_ERR_BAD_PART_TABLE)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no bsdlabel found");
|
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no bsdlabel found");
|
||||||
|
}
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
static struct grub_partition_map grub_msdos_partition_map;
|
static struct grub_partition_map grub_msdos_partition_map;
|
||||||
|
|
||||||
|
|
||||||
static grub_err_t
|
grub_err_t
|
||||||
pc_partition_map_iterate (grub_disk_t disk,
|
grub_partition_msdos_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))
|
||||||
{
|
{
|
||||||
|
@ -148,7 +148,7 @@ pc_partition_map_iterate (grub_disk_t disk,
|
||||||
static struct grub_partition_map grub_msdos_partition_map =
|
static struct grub_partition_map grub_msdos_partition_map =
|
||||||
{
|
{
|
||||||
.name = "msdos",
|
.name = "msdos",
|
||||||
.iterate = pc_partition_map_iterate,
|
.iterate = grub_partition_msdos_iterate,
|
||||||
};
|
};
|
||||||
|
|
||||||
GRUB_MOD_INIT(part_msdos)
|
GRUB_MOD_INIT(part_msdos)
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
|
#include <grub/disk.h>
|
||||||
|
#include <grub/partition.h>
|
||||||
|
|
||||||
/* The signature. */
|
/* The signature. */
|
||||||
#define GRUB_PC_PARTITION_SIGNATURE 0xaa55
|
#define GRUB_PC_PARTITION_SIGNATURE 0xaa55
|
||||||
|
@ -114,4 +116,9 @@ grub_msdos_partition_is_extended (int type)
|
||||||
|| type == GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED);
|
|| type == GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_err_t
|
||||||
|
grub_partition_msdos_iterate (grub_disk_t disk,
|
||||||
|
int (*hook) (grub_disk_t disk,
|
||||||
|
const grub_partition_t partition));
|
||||||
|
|
||||||
#endif /* ! GRUB_PC_PARTITION_HEADER */
|
#endif /* ! GRUB_PC_PARTITION_HEADER */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue