Integrate hints into autogeneration scripts.
* docs/grub.texi (Filesystems): Add a hostdisk example. * Makefile.util.def (grub-mkdevicemap): Remove ofpath. (grub-probe): Add ofpath. * gentpl.py: Remove group nosparc64. * grub-core/commands/search.c (cache_entry): New struct. (cache): New var. (FUNC_NAME): Use and save cache. Fix handling of trailing comma. * grub-core/commands/search_wrap.c (options): Add platform-specific hint options. (grub_cmd_search): Handle platform-specific hints. (GRUB_MOD_INIT): Declare grub_cmd_search as accept_dash. * grub-core/kern/emu/hostdisk.c (map): New field device_map. (grub_util_biosdisk_data): Likewise. (grub_util_biosdisk_open): Set device_map. (read_device_map): Handle "" as indication of no map. Set device_map. (find_system_device): Add hostdisk/ prefix for autogenerated entries. (grub_util_biosdisk_get_compatibility_hint): New function. * grub-core/normal/main.c (features): Add feature_platform_search_hint. * include/grub/emu/hostdisk.h (grub_util_biosdisk_get_compatibility_hint): New proto. * util/grub-install.in: Don't call grub-mkdevicemap. Add platform-specific hint to load.cfg. * util/grub-mkconfig.in: Don't call grub-mkdevicemap. * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Add hints. Set root preliminary to compatibility hint, not to OS name. * util/grub-probe.c (PRINT_*): Add hints. (print): Make static. (escape_of_path): New function. (guess_bios_drive): Likewise. (guess_efi_drive): Likewise. (guess_baremetal_drive): Likewise. (print_full_name): Likewise. (probe): Handle hints. (main): Likewise. * util/ieee1275/devicemap.c: Removed. * util/ieee1275/ofpath.c (find_obppath): Allow to fail. All users updated. (grub_util_devname_to_ofpath): Return NULL on failure. * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev): Fix resource leak. * util/getroot.c (grub_util_pull_device): Fix memory leak. * po/POTFILES.in: Regenerated. Allow purely long options * grub-core/lib/arg.c (SHORT_ARG_HELP): Removed. (SHORT_ARG_USAGE): Likewise. (grub_arg_show_help): Compare opt with help_options. (parse_option): Receive opt as argument. If makes big simplificatons. All users updated
This commit is contained in:
commit
d3c13cbd62
19 changed files with 741 additions and 176 deletions
|
@ -25,14 +25,11 @@
|
|||
#include <grub/i18n.h>
|
||||
|
||||
/* Built-in parser for default options. */
|
||||
#define SHORT_ARG_HELP -100
|
||||
#define SHORT_ARG_USAGE -101
|
||||
|
||||
static const struct grub_arg_option help_options[] =
|
||||
{
|
||||
{"help", SHORT_ARG_HELP, 0,
|
||||
{"help", 0, 0,
|
||||
N_("Display this help and exit."), 0, ARG_TYPE_NONE},
|
||||
{"usage", SHORT_ARG_USAGE, 0,
|
||||
{"usage", 0, 0,
|
||||
N_("Display the usage of this command and exit."), 0, ARG_TYPE_NONE},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
@ -125,9 +122,9 @@ grub_arg_show_help (grub_extcmd_t cmd)
|
|||
|
||||
if (opt->shortarg && grub_isgraph (opt->shortarg))
|
||||
grub_printf ("-%c%c ", opt->shortarg, opt->longarg ? ',':' ');
|
||||
else if (opt->shortarg == SHORT_ARG_HELP && ! h_is_used)
|
||||
else if (opt == help_options && ! h_is_used)
|
||||
grub_printf ("-h, ");
|
||||
else if (opt->shortarg == SHORT_ARG_USAGE && ! u_is_used)
|
||||
else if (opt == help_options + 1 && ! u_is_used)
|
||||
grub_printf ("-u, ");
|
||||
else
|
||||
grub_printf (" ");
|
||||
|
@ -180,50 +177,34 @@ grub_arg_show_help (grub_extcmd_t cmd)
|
|||
|
||||
|
||||
static int
|
||||
parse_option (grub_extcmd_t cmd, int key, char *arg, struct grub_arg_list *usr)
|
||||
parse_option (grub_extcmd_t cmd, const struct grub_arg_option *opt,
|
||||
char *arg, struct grub_arg_list *usr)
|
||||
{
|
||||
switch (key)
|
||||
if (opt == help_options)
|
||||
{
|
||||
case SHORT_ARG_HELP:
|
||||
grub_arg_show_help (cmd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
case SHORT_ARG_USAGE:
|
||||
if (opt == help_options + 1)
|
||||
{
|
||||
show_usage (cmd);
|
||||
return -1;
|
||||
|
||||
default:
|
||||
{
|
||||
int found = -1;
|
||||
int i = 0;
|
||||
const struct grub_arg_option *opt = cmd->options;
|
||||
|
||||
while (opt->doc)
|
||||
{
|
||||
if (opt->shortarg && key == opt->shortarg)
|
||||
{
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
opt++;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (found == -1)
|
||||
return -1;
|
||||
|
||||
if (opt->flags & GRUB_ARG_OPTION_REPEATABLE)
|
||||
{
|
||||
usr[found].args[usr[found].set++] = arg;
|
||||
usr[found].args[usr[found].set] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
usr[found].set = 1;
|
||||
usr[found].arg = arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
int found = opt - cmd->options;
|
||||
|
||||
if (opt->flags & GRUB_ARG_OPTION_REPEATABLE)
|
||||
{
|
||||
usr[found].args[usr[found].set++] = arg;
|
||||
usr[found].args[usr[found].set] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
usr[found].set = 1;
|
||||
usr[found].arg = arg;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -307,7 +288,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
|
|||
it can have an argument value. */
|
||||
if (*curshort)
|
||||
{
|
||||
if (parse_option (cmd, opt->shortarg, 0, usr) || grub_errno)
|
||||
if (parse_option (cmd, opt, 0, usr) || grub_errno)
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
|
@ -411,7 +392,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
|
|||
/* XXX: Not implemented. */
|
||||
break;
|
||||
}
|
||||
if (parse_option (cmd, opt->shortarg, option, usr) || grub_errno)
|
||||
if (parse_option (cmd, opt, option, usr) || grub_errno)
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
|
@ -424,7 +405,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (parse_option (cmd, opt->shortarg, 0, usr) || grub_errno)
|
||||
if (parse_option (cmd, opt, 0, usr) || grub_errno)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue