Print this page
fixes + mirror


  46     {"hint-ieee1275",   0, GRUB_ARG_OPTION_REPEATABLE,
  47      N_("First try the device HINT if currently running on IEEE1275. "
  48         "If HINT ends in comma, also try subpartitions"),
  49      N_("HINT"), ARG_TYPE_STRING},
  50     {"hint-bios",   0, GRUB_ARG_OPTION_REPEATABLE,
  51      N_("First try the device HINT if currently running on BIOS. "
  52         "If HINT ends in comma, also try subpartitions"),
  53      N_("HINT"), ARG_TYPE_STRING},
  54     {"hint-baremetal",   0, GRUB_ARG_OPTION_REPEATABLE,
  55      N_("First try the device HINT if direct hardware access is supported. "
  56         "If HINT ends in comma, also try subpartitions"),
  57      N_("HINT"), ARG_TYPE_STRING},
  58     {"hint-efi",   0, GRUB_ARG_OPTION_REPEATABLE,
  59      N_("First try the device HINT if currently running on EFI. "
  60         "If HINT ends in comma, also try subpartitions"),
  61      N_("HINT"), ARG_TYPE_STRING},
  62     {"hint-arc",   0, GRUB_ARG_OPTION_REPEATABLE,
  63      N_("First try the device HINT if currently running on ARC."
  64         " If HINT ends in comma, also try subpartitions"),
  65      N_("HINT"), ARG_TYPE_STRING},

  66     {0, 0, 0, 0, 0, 0}
  67   };
  68 
  69 enum options
  70   {
  71     SEARCH_FILE,
  72     SEARCH_LABEL,
  73     SEARCH_FS_UUID,
  74     SEARCH_SET,
  75     SEARCH_NO_FLOPPY,
  76     SEARCH_HINT,
  77     SEARCH_HINT_IEEE1275,
  78     SEARCH_HINT_BIOS,
  79     SEARCH_HINT_BAREMETAL,
  80     SEARCH_HINT_EFI,
  81     SEARCH_HINT_ARC,

  82  };
  83 
  84 static grub_err_t
  85 grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
  86 {
  87   struct grub_arg_list *state = ctxt->state;
  88   const char *var = 0;
  89   const char *id = 0;
  90   int i = 0, j = 0, nhints = 0;
  91   char **hints = NULL;

  92 
  93   if (state[SEARCH_HINT].set)
  94     for (i = 0; state[SEARCH_HINT].args[i]; i++)
  95       nhints++;
  96 
  97 #ifdef GRUB_MACHINE_IEEE1275
  98   if (state[SEARCH_HINT_IEEE1275].set)
  99     for (i = 0; state[SEARCH_HINT_IEEE1275].args[i]; i++)
 100       nhints++;
 101 #endif
 102 
 103 #ifdef GRUB_MACHINE_EFI
 104   if (state[SEARCH_HINT_EFI].set)
 105     for (i = 0; state[SEARCH_HINT_EFI].args[i]; i++)
 106       nhints++;
 107 #endif
 108 
 109 #ifdef GRUB_MACHINE_PCBIOS
 110   if (state[SEARCH_HINT_BIOS].set)
 111     for (i = 0; state[SEARCH_HINT_BIOS].args[i]; i++)


 160       hints[j++] = state[SEARCH_HINT_BAREMETAL].args[i];
 161 
 162   /* Skip hints for future platforms.  */
 163   for (j = 0; j < argc; j++)
 164     if (grub_memcmp (args[j], "--hint-", sizeof ("--hint-") - 1) != 0)
 165       break;
 166 
 167   if (state[SEARCH_SET].set)
 168     var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root";
 169 
 170   if (argc != j)
 171     id = args[j];
 172   else if (state[SEARCH_SET].set && state[SEARCH_SET].arg)
 173     {
 174       id = state[SEARCH_SET].arg;
 175       var = "root";
 176     }
 177   else
 178     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
 179 



 180   if (state[SEARCH_LABEL].set)
 181     grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set, 
 182                        hints, nhints);
 183   else if (state[SEARCH_FS_UUID].set)
 184     grub_search_fs_uuid (id, var, state[SEARCH_NO_FLOPPY].set,
 185                          hints, nhints);
 186   else if (state[SEARCH_FILE].set)
 187     grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set, 
 188                          hints, nhints);
 189   else
 190     return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
 191 
 192   return grub_errno;
 193 }
 194 
 195 static grub_extcmd_t cmd;
 196 
 197 GRUB_MOD_INIT(search)
 198 {
 199   cmd =
 200     grub_register_extcmd ("search", grub_cmd_search,
 201                           GRUB_COMMAND_FLAG_EXTRACTOR | GRUB_COMMAND_ACCEPT_DASH,
 202                           N_("[-f|-l|-u|-s|-n] [--hint HINT [--hint HINT] ...]"
 203                              " NAME"),
 204                           N_("Search devices by file, filesystem label"
 205                              " or filesystem UUID."
 206                              " If --set is specified, the first device found is"
 207                              " set to a variable. If no variable name is"
 208                              " specified, `root' is used."),


  46     {"hint-ieee1275",   0, GRUB_ARG_OPTION_REPEATABLE,
  47      N_("First try the device HINT if currently running on IEEE1275. "
  48         "If HINT ends in comma, also try subpartitions"),
  49      N_("HINT"), ARG_TYPE_STRING},
  50     {"hint-bios",   0, GRUB_ARG_OPTION_REPEATABLE,
  51      N_("First try the device HINT if currently running on BIOS. "
  52         "If HINT ends in comma, also try subpartitions"),
  53      N_("HINT"), ARG_TYPE_STRING},
  54     {"hint-baremetal",   0, GRUB_ARG_OPTION_REPEATABLE,
  55      N_("First try the device HINT if direct hardware access is supported. "
  56         "If HINT ends in comma, also try subpartitions"),
  57      N_("HINT"), ARG_TYPE_STRING},
  58     {"hint-efi",   0, GRUB_ARG_OPTION_REPEATABLE,
  59      N_("First try the device HINT if currently running on EFI. "
  60         "If HINT ends in comma, also try subpartitions"),
  61      N_("HINT"), ARG_TYPE_STRING},
  62     {"hint-arc",   0, GRUB_ARG_OPTION_REPEATABLE,
  63      N_("First try the device HINT if currently running on ARC."
  64         " If HINT ends in comma, also try subpartitions"),
  65      N_("HINT"), ARG_TYPE_STRING},
  66     {"zfs-mirror", 'z', 0, N_("Handle zfs-mirror disk"), 0, 0},
  67     {0, 0, 0, 0, 0, 0}
  68   };
  69 
  70 enum options
  71   {
  72     SEARCH_FILE,
  73     SEARCH_LABEL,
  74     SEARCH_FS_UUID,
  75     SEARCH_SET,
  76     SEARCH_NO_FLOPPY,
  77     SEARCH_HINT,
  78     SEARCH_HINT_IEEE1275,
  79     SEARCH_HINT_BIOS,
  80     SEARCH_HINT_BAREMETAL,
  81     SEARCH_HINT_EFI,
  82     SEARCH_HINT_ARC,
  83     SEARCH_ZFS_MIRROR,
  84  };
  85 
  86 static grub_err_t
  87 grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
  88 {
  89   struct grub_arg_list *state = ctxt->state;
  90   const char *var = 0;
  91   const char *id = 0;
  92   int i = 0, j = 0, nhints = 0;
  93   char **hints = NULL;
  94   int mirror_mode = 0;
  95 
  96   if (state[SEARCH_HINT].set)
  97     for (i = 0; state[SEARCH_HINT].args[i]; i++)
  98       nhints++;
  99 
 100 #ifdef GRUB_MACHINE_IEEE1275
 101   if (state[SEARCH_HINT_IEEE1275].set)
 102     for (i = 0; state[SEARCH_HINT_IEEE1275].args[i]; i++)
 103       nhints++;
 104 #endif
 105 
 106 #ifdef GRUB_MACHINE_EFI
 107   if (state[SEARCH_HINT_EFI].set)
 108     for (i = 0; state[SEARCH_HINT_EFI].args[i]; i++)
 109       nhints++;
 110 #endif
 111 
 112 #ifdef GRUB_MACHINE_PCBIOS
 113   if (state[SEARCH_HINT_BIOS].set)
 114     for (i = 0; state[SEARCH_HINT_BIOS].args[i]; i++)


 163       hints[j++] = state[SEARCH_HINT_BAREMETAL].args[i];
 164 
 165   /* Skip hints for future platforms.  */
 166   for (j = 0; j < argc; j++)
 167     if (grub_memcmp (args[j], "--hint-", sizeof ("--hint-") - 1) != 0)
 168       break;
 169 
 170   if (state[SEARCH_SET].set)
 171     var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root";
 172 
 173   if (argc != j)
 174     id = args[j];
 175   else if (state[SEARCH_SET].set && state[SEARCH_SET].arg)
 176     {
 177       id = state[SEARCH_SET].arg;
 178       var = "root";
 179     }
 180   else
 181     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
 182 
 183   if (state[SEARCH_ZFS_MIRROR].set)
 184     mirror_mode = 1;
 185 
 186   if (state[SEARCH_LABEL].set)
 187     grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set, 
 188                        hints, nhints, mirror_mode);
 189   else if (state[SEARCH_FS_UUID].set)
 190     grub_search_fs_uuid (id, var, state[SEARCH_NO_FLOPPY].set,
 191                          hints, nhints, mirror_mode);
 192   else if (state[SEARCH_FILE].set)
 193     grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set, 
 194                          hints, nhints, mirror_mode);
 195   else
 196     return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
 197 
 198   return grub_errno;
 199 }
 200 
 201 static grub_extcmd_t cmd;
 202 
 203 GRUB_MOD_INIT(search)
 204 {
 205   cmd =
 206     grub_register_extcmd ("search", grub_cmd_search,
 207                           GRUB_COMMAND_FLAG_EXTRACTOR | GRUB_COMMAND_ACCEPT_DASH,
 208                           N_("[-f|-l|-u|-s|-n] [--hint HINT [--hint HINT] ...]"
 209                              " NAME"),
 210                           N_("Search devices by file, filesystem label"
 211                              " or filesystem UUID."
 212                              " If --set is specified, the first device found is"
 213                              " set to a variable. If no variable name is"
 214                              " specified, `root' is used."),