~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to kern/corecmd.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Evan Broder, Mario Limonciello
  • Date: 2010-11-24 13:59:55 UTC
  • mfrom: (1.17.6 upstream) (17.6.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20101124135955-r6ii5sepayr7jt53
Tags: 1.99~20101124-1ubuntu1
[ Colin Watson ]
* Resynchronise with Debian experimental.  Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
    recovery mode, quiet option, tweak how memtest86+ is displayed, and
    use UUIDs where appropriate.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel= options if kdump and makedumpfile are available.
  - If other operating systems are installed, then automatically unhide
    the menu.  Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus
    if available to check whether Shift is pressed.  If it is, show the
    menu, otherwise boot immediately.  If keystatus is not available, then
    fall back to a short delay interruptible with Escape.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Don't display introductory message about line editing unless we're
    actually offering a shell prompt.  Don't clear the screen just before
    booting if we never drew the menu in the first place.
  - Remove some verbose messages printed before reading the configuration
    file.
  - Suppress progress messages as the kernel and initrd load for
    non-recovery kernel menu entries.
  - Change prepare_grub_to_access_device to handle filesystems
    loop-mounted on file images.
  - Ignore devices loop-mounted from files in 10_linux.
  - Show the boot menu if the previous boot failed, that is if it failed
    to get to the end of one of the normal runlevels.
  - Don't generate /boot/grub/device.map during grub-install or
    grub-mkconfig by default.
  - Adjust upgrade version checks for Ubuntu.
  - Don't display "GRUB loading" unless Shift is held down.
  - Adjust versions of grub-doc and grub-legacy-doc conflicts to tolerate
    our backport of the grub-doc split.
  - Fix LVM/RAID probing in the absence of /boot/grub/device.map.
  - Look for .mo files in /usr/share/locale-langpack as well, in
    preference.
  - Make sure GRUB_TIMEOUT isn't quoted unnecessarily.
  - Probe all devices in 'grub-probe --target=drive' if
    /boot/grub/device.map is missing.
  - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
  - Use qemu rather than qemu-system-i386.
  - Program vesafb on BIOS systems rather than efifb.
  - Add a grub-rescue-efi-amd64 package containing a rescue CD-ROM image
    for EFI-AMD64.
  - On Wubi, don't ask for an install device, but just update wubildr
    using the diverted grub-install.
  - When embedding the core image in a post-MBR gap, check for and avoid
    sectors matching any of a list of known signatures.
  - Disable video_bochs and video_cirrus on PC BIOS systems, as probing
    PCI space seems to break on some systems.
* Downgrade "ACPI shutdown failed" error to a debug message, since it can
  cause spurious test failures.

[ Evan Broder ]
* Enable lua from grub-extras.
* Incorporate the bitop library into lua.
* Add enum_pci function to grub module in lua.
* Switch back to gfxpayload=keep by default, unless the video hardware
  is known to not support it.

[ Mario Limonciello ]
* Built part_msdos and vfat into bootx64.efi (LP: #677758)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* corecmd.c - critical commands which are registered in kernel */
2
 
/*
3
 
 *  GRUB  --  GRand Unified Bootloader
4
 
 *  Copyright (C) 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/mm.h>
21
 
#include <grub/dl.h>
22
 
#include <grub/err.h>
23
 
#include <grub/env.h>
24
 
#include <grub/misc.h>
25
 
#include <grub/term.h>
26
 
#include <grub/file.h>
27
 
#include <grub/device.h>
28
 
#include <grub/command.h>
29
 
#include <grub/i18n.h>
30
 
 
31
 
/* set ENVVAR=VALUE */
32
 
static grub_err_t
33
 
grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
34
 
                   int argc, char *argv[])
35
 
{
36
 
  char *var;
37
 
  char *val;
38
 
 
39
 
  auto int print_env (struct grub_env_var *env);
40
 
 
41
 
  int print_env (struct grub_env_var *env)
42
 
    {
43
 
      grub_printf ("%s=%s\n", env->name, env->value);
44
 
      return 0;
45
 
    }
46
 
 
47
 
  if (argc < 1)
48
 
    {
49
 
      grub_env_iterate (print_env);
50
 
      return 0;
51
 
    }
52
 
 
53
 
  var = argv[0];
54
 
  val = grub_strchr (var, '=');
55
 
  if (! val)
56
 
    return grub_error (GRUB_ERR_BAD_ARGUMENT, "not an assignment");
57
 
 
58
 
  val[0] = 0;
59
 
  grub_env_set (var, val + 1);
60
 
  val[0] = '=';
61
 
 
62
 
  return 0;
63
 
}
64
 
 
65
 
static grub_err_t
66
 
grub_core_cmd_unset (struct grub_command *cmd __attribute__ ((unused)),
67
 
                     int argc, char *argv[])
68
 
{
69
 
  if (argc < 1)
70
 
    return grub_error (GRUB_ERR_BAD_ARGUMENT,
71
 
                       "no environment variable specified");
72
 
 
73
 
  grub_env_unset (argv[0]);
74
 
  return 0;
75
 
}
76
 
 
77
 
/* insmod MODULE */
78
 
static grub_err_t
79
 
grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)),
80
 
                      int argc, char *argv[])
81
 
{
82
 
  char *p;
83
 
  grub_dl_t mod;
84
 
 
85
 
  if (argc == 0)
86
 
    return grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified");
87
 
 
88
 
  p = grub_strchr (argv[0], '/');
89
 
  if (! p)
90
 
    mod = grub_dl_load (argv[0]);
91
 
  else
92
 
    mod = grub_dl_load_file (argv[0]);
93
 
 
94
 
  if (mod)
95
 
    grub_dl_ref (mod);
96
 
 
97
 
  return 0;
98
 
}
99
 
 
100
 
static int
101
 
grub_mini_print_devices (const char *name)
102
 
{
103
 
  grub_printf ("(%s) ", name);
104
 
 
105
 
  return 0;
106
 
}
107
 
 
108
 
static int
109
 
grub_mini_print_files (const char *filename,
110
 
                       const struct grub_dirhook_info *info)
111
 
{
112
 
  grub_printf ("%s%s ", filename, info->dir ? "/" : "");
113
 
 
114
 
  return 0;
115
 
}
116
 
 
117
 
/* ls [ARG] */
118
 
static grub_err_t
119
 
grub_core_cmd_ls (struct grub_command *cmd __attribute__ ((unused)),
120
 
                  int argc, char *argv[])
121
 
{
122
 
  if (argc < 1)
123
 
    {
124
 
      grub_device_iterate (grub_mini_print_devices);
125
 
      grub_xputs ("\n");
126
 
      grub_refresh ();
127
 
    }
128
 
  else
129
 
    {
130
 
      char *device_name;
131
 
      grub_device_t dev;
132
 
      grub_fs_t fs;
133
 
      char *path;
134
 
 
135
 
      device_name = grub_file_get_device_name (argv[0]);
136
 
      dev = grub_device_open (device_name);
137
 
      if (! dev)
138
 
        goto fail;
139
 
 
140
 
      fs = grub_fs_probe (dev);
141
 
      path = grub_strchr (argv[0], ')');
142
 
      if (! path)
143
 
        path = argv[0];
144
 
      else
145
 
        path++;
146
 
 
147
 
      if (! path && ! device_name)
148
 
        {
149
 
          grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
150
 
          goto fail;
151
 
        }
152
 
 
153
 
      if (! path)
154
 
        {
155
 
          if (grub_errno == GRUB_ERR_UNKNOWN_FS)
156
 
            grub_errno = GRUB_ERR_NONE;
157
 
 
158
 
          grub_printf ("(%s): Filesystem is %s.\n",
159
 
                       device_name, fs ? fs->name : "unknown");
160
 
        }
161
 
      else if (fs)
162
 
        {
163
 
          (fs->dir) (dev, path, grub_mini_print_files);
164
 
          grub_xputs ("\n");
165
 
          grub_refresh ();
166
 
        }
167
 
 
168
 
    fail:
169
 
      if (dev)
170
 
        grub_device_close (dev);
171
 
 
172
 
      grub_free (device_name);
173
 
    }
174
 
 
175
 
  return grub_errno;
176
 
}
177
 
 
178
 
void
179
 
grub_register_core_commands (void)
180
 
{
181
 
  grub_register_command ("set", grub_core_cmd_set,
182
 
                         N_("[ENVVAR=VALUE]"),
183
 
                         N_("Set an environment variable."));
184
 
  grub_register_command ("unset", grub_core_cmd_unset,
185
 
                         N_("ENVVAR"),
186
 
                         N_("Remove an environment variable."));
187
 
  grub_register_command ("ls", grub_core_cmd_ls,
188
 
                         N_("[ARG]"), N_("List devices or files."));
189
 
  grub_register_command ("insmod", grub_core_cmd_insmod,
190
 
                         N_("MODULE"), N_("Insert a module."));
191
 
}