Reimport nestpart
This commit is contained in:
parent
bf7fcba2d7
commit
15cb7d433f
26 changed files with 561 additions and 720 deletions
|
@ -88,19 +88,15 @@ sun_partition_map_iterate (grub_disk_t disk,
|
|||
const grub_partition_t partition))
|
||||
{
|
||||
grub_partition_t p;
|
||||
struct grub_disk raw;
|
||||
struct grub_sun_block block;
|
||||
int partnum;
|
||||
|
||||
raw = *disk;
|
||||
raw.partition = 0;
|
||||
|
||||
p = (grub_partition_t) grub_zalloc (sizeof (struct grub_partition));
|
||||
if (! p)
|
||||
return grub_errno;
|
||||
|
||||
p->partmap = &grub_sun_partition_map;
|
||||
if (grub_disk_read (&raw, 0, 0, sizeof (struct grub_sun_block),
|
||||
if (grub_disk_read (disk, 0, 0, sizeof (struct grub_sun_block),
|
||||
&block) == GRUB_ERR_NONE)
|
||||
{
|
||||
if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.magic))
|
||||
|
@ -124,7 +120,7 @@ sun_partition_map_iterate (grub_disk_t disk,
|
|||
* grub_be_to_cpu16 (block.ntrks)
|
||||
* grub_be_to_cpu16 (block.nsect));
|
||||
p->len = grub_be_to_cpu32 (desc->num_sectors);
|
||||
p->index = partnum;
|
||||
p->number = p->index = partnum;
|
||||
if (p->len)
|
||||
{
|
||||
if (hook (disk, p))
|
||||
|
@ -138,62 +134,11 @@ sun_partition_map_iterate (grub_disk_t disk,
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_partition_t
|
||||
sun_partition_map_probe (grub_disk_t disk, const char *str)
|
||||
{
|
||||
grub_partition_t p = 0;
|
||||
int partnum = 0;
|
||||
char *s = (char *) str;
|
||||
|
||||
auto int find_func (grub_disk_t d, const grub_partition_t partition);
|
||||
|
||||
int find_func (grub_disk_t d __attribute__ ((unused)),
|
||||
const grub_partition_t partition)
|
||||
{
|
||||
if (partnum == partition->index)
|
||||
{
|
||||
p = (grub_partition_t) grub_malloc (sizeof (*p));
|
||||
if (p)
|
||||
grub_memcpy (p, partition, sizeof (*p));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
partnum = grub_strtoul (s, 0, 10) - 1;
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
{
|
||||
if (sun_partition_map_iterate (disk, find_func))
|
||||
{
|
||||
grub_free (p);
|
||||
p = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
|
||||
p = 0;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static char *
|
||||
sun_partition_map_get_name (const grub_partition_t p)
|
||||
{
|
||||
return grub_xasprintf ("%d", p->index + 1);
|
||||
}
|
||||
|
||||
/* Partition map type. */
|
||||
static struct grub_partition_map grub_sun_partition_map =
|
||||
{
|
||||
.name = "part_sun",
|
||||
.iterate = sun_partition_map_iterate,
|
||||
.probe = sun_partition_map_probe,
|
||||
.get_name = sun_partition_map_get_name
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(sun_partition_map)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue