Reimport nestpart
This commit is contained in:
parent
bf7fcba2d7
commit
15cb7d433f
26 changed files with 561 additions and 720 deletions
|
@ -82,13 +82,16 @@ grub_refresh (void)
|
|||
static void
|
||||
probe_partmap (grub_disk_t disk)
|
||||
{
|
||||
grub_partition_t part;
|
||||
|
||||
if (disk->partition == NULL)
|
||||
{
|
||||
grub_util_info ("no partition map found for %s", disk->name);
|
||||
return;
|
||||
}
|
||||
|
||||
printf ("%s\n", disk->partition->partmap->name);
|
||||
for (part = disk->partition; part; part = part->parent)
|
||||
printf ("%s\n", part->partmap->name);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -334,10 +334,13 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
|||
{
|
||||
int is_partition = 0;
|
||||
char dev[PATH_MAX];
|
||||
grub_disk_addr_t part_start = 0;
|
||||
|
||||
part_start = grub_partition_get_start (disk->partition);
|
||||
|
||||
strcpy (dev, map[disk->id].device);
|
||||
if (disk->partition && strncmp (map[disk->id].device, "/dev/", 5) == 0)
|
||||
is_partition = linux_find_partition (dev, disk->partition->start);
|
||||
is_partition = linux_find_partition (dev, part_start);
|
||||
|
||||
/* Open the partition. */
|
||||
grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev);
|
||||
|
@ -353,7 +356,7 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
|||
ioctl (fd, BLKFLSBUF, 0);
|
||||
|
||||
if (is_partition)
|
||||
sector -= disk->partition->start;
|
||||
sector -= part_start;
|
||||
}
|
||||
#else /* ! __linux__ */
|
||||
#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
|
@ -952,39 +955,25 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
int find_partition (grub_disk_t disk __attribute__ ((unused)),
|
||||
const grub_partition_t partition)
|
||||
{
|
||||
struct grub_msdos_partition *pcdata = NULL;
|
||||
grub_disk_addr_t part_start = 0;
|
||||
grub_util_info ("Partition %d starts from %lu",
|
||||
partition->number, partition->start);
|
||||
|
||||
if (strcmp (partition->partmap->name, "part_msdos") == 0)
|
||||
pcdata = partition->data;
|
||||
part_start = grub_partition_get_start (partition);
|
||||
|
||||
if (pcdata)
|
||||
if (hdg.start == part_start)
|
||||
{
|
||||
if (pcdata->bsd_part < 0)
|
||||
grub_util_info ("DOS partition %d starts from %lu",
|
||||
pcdata->dos_part, partition->start);
|
||||
else
|
||||
grub_util_info ("BSD partition %d,%c starts from %lu",
|
||||
pcdata->dos_part, pcdata->bsd_part + 'a',
|
||||
partition->start);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_util_info ("Partition %d starts from %lu",
|
||||
partition->index, partition->start);
|
||||
}
|
||||
|
||||
if (hdg.start == partition->start)
|
||||
{
|
||||
if (pcdata)
|
||||
if (partition->parent)
|
||||
{
|
||||
dos_part = pcdata->dos_part;
|
||||
bsd_part = pcdata->bsd_part;
|
||||
dos_part = partition->parent->number;
|
||||
bsd_part = partition->number;
|
||||
}
|
||||
else
|
||||
{
|
||||
dos_part = partition->index;
|
||||
dos_part = partition->number;
|
||||
bsd_part = -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,15 +116,10 @@ setup (const char *dir,
|
|||
int NESTED_FUNC_ATTR find_usable_region_msdos (grub_disk_t disk __attribute__ ((unused)),
|
||||
const grub_partition_t p)
|
||||
{
|
||||
struct grub_msdos_partition *pcdata = p->data;
|
||||
|
||||
/* There's always an embed region, and it starts right after the MBR. */
|
||||
embed_region.start = 1;
|
||||
|
||||
/* For its end offset, include as many dummy partitions as we can. */
|
||||
if (! grub_msdos_partition_is_empty (pcdata->dos_type)
|
||||
&& ! grub_msdos_partition_is_bsd (pcdata->dos_type)
|
||||
&& embed_region.end > p->start)
|
||||
if (embed_region.end > p->start)
|
||||
embed_region.end = p->start;
|
||||
|
||||
return 0;
|
||||
|
@ -289,22 +284,19 @@ setup (const char *dir,
|
|||
/* Embed information about the installed location. */
|
||||
if (root_dev->disk->partition)
|
||||
{
|
||||
if (strcmp (root_dev->disk->partition->partmap->name,
|
||||
"part_msdos") == 0)
|
||||
{
|
||||
struct grub_msdos_partition *pcdata =
|
||||
root_dev->disk->partition->data;
|
||||
dos_part = pcdata->dos_part;
|
||||
bsd_part = pcdata->bsd_part;
|
||||
}
|
||||
else if (strcmp (root_dev->disk->partition->partmap->name,
|
||||
"part_gpt") == 0)
|
||||
{
|
||||
dos_part = root_dev->disk->partition->index;
|
||||
bsd_part = -1;
|
||||
}
|
||||
if (root_dev->disk->partition->parent)
|
||||
{
|
||||
if (root_dev->disk->partition->parent->parent)
|
||||
grub_util_error ("Installing on doubly nested partitions is "
|
||||
"not supported");
|
||||
dos_part = root_dev->disk->partition->parent->number;
|
||||
bsd_part = root_dev->disk->partition->number;
|
||||
}
|
||||
else
|
||||
grub_util_error (_("no DOS-style partitions found"));
|
||||
{
|
||||
dos_part = root_dev->disk->partition->number;
|
||||
bsd_part = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
dos_part = bsd_part = -1;
|
||||
|
@ -337,6 +329,8 @@ setup (const char *dir,
|
|||
int NESTED_FUNC_ATTR identify_partmap (grub_disk_t disk __attribute__ ((unused)),
|
||||
const grub_partition_t p)
|
||||
{
|
||||
if (p->parent)
|
||||
return 0;
|
||||
dest_partmap = p->partmap->name;
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue