2005-08-18 Yoshinori K. Okuji <okuji@enbug.org>
* normal/misc.c: New file. * DISTLIST: Added normal/misc.c. * partmap/amiga.c (amiga_partition_map_iterate): Add an argument DISK to HOOK. Call HOOK with DISK. * partmap/apple.c (apple_partition_map_iterate): Likewise. * partmap/pc.c (pc_partition_map_iterate): Likewise. * partmap/sun.c (sun_partition_map_iterate): Likewise. * normal/menu_entry.c (struct screen): Added a new member "completion_shown". (completion_buffer): New global variable. (make_screen): Set SCREEN->COMPLETION_SHOWN to zero. (store_completion): New function. (complete): Likewise. (clear_completions): Likewise. (grub_menu_entry_run): If SCREEN->COMPLETION_SHOWN is non-zero, call clear_completions and reset SCREEN->COMPLETION_SHOWN. If C is a tab, call complete. * normal/completion.c (disk_dev): Removed. (print_simple_completion): Likewise. (print_partition_completion): Likewise. (print_func): New global variable. (add_completion): Do not take the arguments WHAT or PRINT any longer. Added a new argument TYPE. Instead of printing directly, call PRINT_FUNC if not NULL. All callers changed. (complete_device): Use a local variable DEV instead of DISK_DEV. Do not move CURRENT_WORD to the end of a device name. (grub_normal_do_completion): Take a new argument HOOK. Do not initialize DISK_DEV. Initialize PRINT_FUNC to HOOK. If RET is an empty string, return NULL instead. All callers changed. * normal/cmdline.c (print_completion): New function. * kern/partition.c (grub_partition_iterate): Add an argument DISK to HOOK. All callers changed. * kern/disk.c (grub_print_partinfo): Removed. * include/grub/partition.h (struct grub_partition_map): Add a new argument DISK into HOOK of ITERATE. (grub_partition_iterate): Add a new argument DISK to HOOK. * include/grub/normal.h (enum grub_completion_type): New enum. (grub_completion_type_t): New type. (GRUB_COMPLETION_TYPE_COMMAND): New constant. (GRUB_COMPLETION_TYPE_DEVICE): Likewise. (GRUB_COMPLETION_TYPE_PARTITION): Likewise. (GRUB_COMPLETION_TYPE_FILE): Likewise. (grub_normal_do_completion): Added a new argument HOOK. (grub_normal_print_device_info): New prototype. * include/grub/disk.h (grub_print_partinfo): Removed. * conf/i386-pc.rmk (grub_emu_SOURCES): Added normal/misc.c. (normal_mod_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. (normal_mod_SOURCES): Likewise. * commands/ls.c (grub_ls_list_disks): Use grub_normal_print_device_info instead of grub_print_partinfo. Free PNAME. (grub_ls_list_files): Use grub_normal_print_device_info instead of duplicating the code.
This commit is contained in:
parent
0bd41162dd
commit
992ffbbebb
23 changed files with 570 additions and 196 deletions
|
@ -71,10 +71,13 @@ static struct grub_partition_map grub_amiga_partition_map;
|
|||
#ifndef GRUB_UTIL
|
||||
static grub_dl_t my_mod;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static grub_err_t
|
||||
amiga_partition_map_iterate (grub_disk_t disk,
|
||||
int (*hook) (const grub_partition_t partition))
|
||||
int (*hook) (grub_disk_t disk,
|
||||
const grub_partition_t partition))
|
||||
{
|
||||
struct grub_partition part;
|
||||
struct grub_amiga_rdsk rdsk;
|
||||
|
@ -130,7 +133,7 @@ amiga_partition_map_iterate (grub_disk_t disk,
|
|||
part.index = partno;
|
||||
part.partmap = &grub_amiga_partition_map;
|
||||
|
||||
if (hook (&part))
|
||||
if (hook (disk, &part))
|
||||
return grub_errno;
|
||||
|
||||
next = grub_be_to_cpu32 (apart.next);
|
||||
|
@ -148,9 +151,10 @@ amiga_partition_map_probe (grub_disk_t disk, const char *str)
|
|||
int partnum = 0;
|
||||
char *s = (char *) str;
|
||||
|
||||
auto int find_func (const grub_partition_t partition);
|
||||
auto int find_func (grub_disk_t d, const grub_partition_t partition);
|
||||
|
||||
int find_func (const grub_partition_t partition)
|
||||
int find_func (grub_disk_t d __attribute__ ((unused)),
|
||||
const grub_partition_t partition)
|
||||
{
|
||||
if (partnum == partition->index)
|
||||
{
|
||||
|
|
|
@ -95,7 +95,8 @@ static grub_dl_t my_mod;
|
|||
|
||||
static grub_err_t
|
||||
apple_partition_map_iterate (grub_disk_t disk,
|
||||
int (*hook) (const grub_partition_t partition))
|
||||
int (*hook) (grub_disk_t disk,
|
||||
const grub_partition_t partition))
|
||||
{
|
||||
struct grub_partition part;
|
||||
struct grub_apple_part apart;
|
||||
|
@ -134,7 +135,7 @@ apple_partition_map_iterate (grub_disk_t disk,
|
|||
partno, apart.partname, apart.parttype,
|
||||
apart.first_phys_block, apart.blockcnt);
|
||||
|
||||
if (hook (&part))
|
||||
if (hook (disk, &part))
|
||||
return grub_errno;
|
||||
|
||||
if (apart.first_phys_block == GRUB_DISK_SECTOR_SIZE * 2)
|
||||
|
@ -159,9 +160,10 @@ apple_partition_map_probe (grub_disk_t disk, const char *str)
|
|||
int partnum = 0;
|
||||
char *s = (char *) str;
|
||||
|
||||
auto int find_func (const grub_partition_t partition);
|
||||
auto int find_func (grub_disk_t d, const grub_partition_t partition);
|
||||
|
||||
int find_func (const grub_partition_t partition)
|
||||
int find_func (grub_disk_t d __attribute__ ((unused)),
|
||||
const grub_partition_t partition)
|
||||
{
|
||||
if (partnum == partition->index)
|
||||
{
|
||||
|
|
12
partmap/pc.c
12
partmap/pc.c
|
@ -93,7 +93,8 @@ grub_partition_parse (const char *str)
|
|||
|
||||
static grub_err_t
|
||||
pc_partition_map_iterate (grub_disk_t disk,
|
||||
int (*hook) (const grub_partition_t partition))
|
||||
int (*hook) (grub_disk_t disk,
|
||||
const grub_partition_t partition))
|
||||
{
|
||||
struct grub_partition p;
|
||||
struct grub_pc_partition pcdata;
|
||||
|
@ -145,7 +146,7 @@ pc_partition_map_iterate (grub_disk_t disk,
|
|||
{
|
||||
pcdata.dos_part++;
|
||||
|
||||
if (hook (&p))
|
||||
if (hook (disk, &p))
|
||||
goto finish;
|
||||
|
||||
/* Check if this is a BSD partition. */
|
||||
|
@ -183,7 +184,7 @@ pc_partition_map_iterate (grub_disk_t disk,
|
|||
pcdata.bsd_type = be->fs_type;
|
||||
|
||||
if (be->fs_type != GRUB_PC_PARTITION_BSD_TYPE_UNUSED)
|
||||
if (hook (&p))
|
||||
if (hook (disk, &p))
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
@ -225,9 +226,10 @@ pc_partition_map_probe (grub_disk_t disk, const char *str)
|
|||
grub_partition_t p;
|
||||
struct grub_pc_partition *pcdata;
|
||||
|
||||
auto int find_func (const grub_partition_t partition);
|
||||
auto int find_func (grub_disk_t d, const grub_partition_t partition);
|
||||
|
||||
int find_func (const grub_partition_t partition)
|
||||
int find_func (grub_disk_t d __attribute__ ((unused)),
|
||||
const grub_partition_t partition)
|
||||
{
|
||||
struct grub_pc_partition *partdata = partition->data;
|
||||
if ((pcdata->dos_part == partdata->dos_part || pcdata->dos_part == -1)
|
||||
|
|
|
@ -85,7 +85,8 @@ grub_sun_is_valid (struct grub_sun_block *label)
|
|||
|
||||
static grub_err_t
|
||||
sun_partition_map_iterate (grub_disk_t disk,
|
||||
int (*hook) (const grub_partition_t partition))
|
||||
int (*hook) (grub_disk_t disk,
|
||||
const grub_partition_t partition))
|
||||
{
|
||||
struct grub_partition *p;
|
||||
struct grub_disk raw;
|
||||
|
@ -122,7 +123,7 @@ sun_partition_map_iterate (grub_disk_t disk,
|
|||
p->index = partnum;
|
||||
if (p->len)
|
||||
{
|
||||
if (hook (p))
|
||||
if (hook (disk, p))
|
||||
partnum = GRUB_PARTMAP_SUN_MAX_PARTS;
|
||||
}
|
||||
}
|
||||
|
@ -139,14 +140,16 @@ sun_partition_map_probe (grub_disk_t disk, const char *str)
|
|||
int partnum = 0;
|
||||
char *s = (char *) str;
|
||||
|
||||
auto int find_func (const grub_partition_t partition);
|
||||
int find_func (const grub_partition_t partition)
|
||||
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));
|
||||
grub_memcpy (p, partition, sizeof (*p));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue