~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to grub-core/commands/search_wrap.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Robert Millan, Updated translations
  • Date: 2010-11-22 12:24:56 UTC
  • mfrom: (1.26.4 upstream) (17.3.36 sid)
  • mto: (17.3.43 sid)
  • mto: This revision was merged to the branch mainline in revision 89.
  • Revision ID: james.westby@ubuntu.com-20101122122456-y82z3sfb7k4zfdcc
Tags: 1.99~20101122-1
[ Colin Watson ]
* New Bazaar snapshot.  Too many changes to list in full, but some of the
  more user-visible ones are as follows:
  - GRUB script:
    + Function parameters, "break", "continue", "shift", "setparams",
      "return", and "!".
    + "export" command supports multiple variable names.
    + Multi-line quoted strings support.
    + Wildcard expansion.
  - sendkey support.
  - USB hotunplugging and USB serial support.
  - Rename CD-ROM to cd on BIOS.
  - Add new --boot-directory option to grub-install, grub-reboot, and
    grub-set-default; the old --root-directory option is still accepted
    but was often confusing.
  - Basic btrfs detection/UUID support (but no file reading yet).
  - bash-completion for utilities.
  - If a device is listed in device.map, always assume that it is
    BIOS-visible rather than using extra layers such as LVM or RAID.
  - Add grub-mknetdir script (closes: #550658).
  - Remove deprecated "root" command.
  - Handle RAID devices containing virtio components.
  - GRUB Legacy configuration file support (via grub-menulst2cfg).
  - Keyboard layout support (via grub-mklayout and grub-kbdcomp).
  - Check generated grub.cfg for syntax errors before saving.
  - Pause execution for at most ten seconds if any errors are displayed,
    so that the user has a chance to see them.
  - Support submenus.
  - Write embedding zone using Reed-Solomon, so that it's robust against
    being partially overwritten (closes: #550702, #591416, #593347).
  - GRUB_DISABLE_LINUX_RECOVERY and GRUB_DISABLE_NETBSD_RECOVERY merged
    into a single GRUB_DISABLE_RECOVERY variable.
  - Fix loader memory allocation failure (closes: #551627).
  - Don't call savedefault on recovery entries (closes: #589325).
  - Support triple-indirect blocks on ext2 (closes: #543924).
  - Recognise DDF1 fake RAID (closes: #603354).

[ Robert Millan ]
* Use dpkg architecture wildcards.

[ Updated translations ]
* Slovenian (Vanja Cvelbar).  Closes: #604003
* Dzongkha (dawa pemo via Tenzin Dendup).  Closes: #604102

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* search.c - search devices based on a file or a filesystem label */
 
2
/*
 
3
 *  GRUB  --  GRand Unified Bootloader
 
4
 *  Copyright (C) 2005,2007,2008,2009  Free Software Foundation, Inc.
 
5
 *
 
6
 *  GRUB is free software: you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation, either version 3 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  GRUB is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include <grub/types.h>
 
21
#include <grub/misc.h>
 
22
#include <grub/mm.h>
 
23
#include <grub/err.h>
 
24
#include <grub/dl.h>
 
25
#include <grub/env.h>
 
26
#include <grub/extcmd.h>
 
27
#include <grub/search.h>
 
28
#include <grub/i18n.h>
 
29
 
 
30
static const struct grub_arg_option options[] =
 
31
  {
 
32
    {"file",            'f', 0, N_("Search devices by a file."), 0, 0},
 
33
    {"label",           'l', 0, N_("Search devices by a filesystem label."),
 
34
     0, 0},
 
35
    {"fs-uuid",         'u', 0, N_("Search devices by a filesystem UUID."),
 
36
     0, 0},
 
37
    {"set",             's', GRUB_ARG_OPTION_OPTIONAL,
 
38
     N_("Set a variable to the first device found."), "VAR", ARG_TYPE_STRING},
 
39
    {"no-floppy",       'n', 0, N_("Do not probe any floppy drive."), 0, 0},
 
40
    {"hint",            'h', GRUB_ARG_OPTION_REPEATABLE,
 
41
     N_("First try the device HINT. If HINT ends in comma, "
 
42
        "also try subpartitions"), N_("HINT"), ARG_TYPE_STRING},
 
43
    {0, 0, 0, 0, 0, 0}
 
44
  };
 
45
 
 
46
enum options
 
47
  {
 
48
    SEARCH_FILE,
 
49
    SEARCH_LABEL,
 
50
    SEARCH_FS_UUID,
 
51
    SEARCH_SET,
 
52
    SEARCH_NO_FLOPPY,
 
53
    SEARCH_HINT
 
54
 };
 
55
 
 
56
static grub_err_t
 
57
grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
 
58
{
 
59
  struct grub_arg_list *state = ctxt->state;
 
60
  const char *var = 0;
 
61
  int nhints = 0;
 
62
 
 
63
  if (state[SEARCH_HINT].set)
 
64
    while (state[SEARCH_HINT].args[nhints])
 
65
      nhints++;
 
66
 
 
67
  if (argc == 0)
 
68
    return grub_error (GRUB_ERR_BAD_ARGUMENT, "no argument specified");
 
69
 
 
70
  if (state[SEARCH_SET].set)
 
71
    var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root";
 
72
 
 
73
  if (state[SEARCH_LABEL].set)
 
74
    grub_search_label (args[0], var, state[SEARCH_NO_FLOPPY].set, 
 
75
                       state[SEARCH_HINT].args, nhints);
 
76
  else if (state[SEARCH_FS_UUID].set)
 
77
    grub_search_fs_uuid (args[0], var, state[SEARCH_NO_FLOPPY].set,
 
78
                         state[SEARCH_HINT].args, nhints);
 
79
  else if (state[SEARCH_FILE].set)
 
80
    grub_search_fs_file (args[0], var, state[SEARCH_NO_FLOPPY].set, 
 
81
                         state[SEARCH_HINT].args, nhints);
 
82
  else
 
83
    return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
 
84
 
 
85
  return grub_errno;
 
86
}
 
87
 
 
88
static grub_extcmd_t cmd;
 
89
 
 
90
GRUB_MOD_INIT(search)
 
91
{
 
92
  cmd =
 
93
    grub_register_extcmd ("search", grub_cmd_search, GRUB_COMMAND_FLAG_EXTRACTOR,
 
94
                          N_("[-f|-l|-u|-s|-n] [--hint HINT [--hint HINT] ...]"
 
95
                             " NAME"),
 
96
                          N_("Search devices by file, filesystem label"
 
97
                             " or filesystem UUID."
 
98
                             " If --set is specified, the first device found is"
 
99
                             " set to a variable. If no variable name is"
 
100
                             " specified, \"root\" is used."),
 
101
                          options);
 
102
}
 
103
 
 
104
GRUB_MOD_FINI(search)
 
105
{
 
106
  grub_unregister_extcmd (cmd);
 
107
}