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

« back to all changes in this revision

Viewing changes to util/grub-probe.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:
19
19
 
20
20
#include <config.h>
21
21
#include <grub/types.h>
 
22
#include <grub/emu/misc.h>
22
23
#include <grub/util/misc.h>
23
24
#include <grub/util/misc.h>
24
25
#include <grub/device.h>
34
35
#include <grub/raid.h>
35
36
#include <grub/i18n.h>
36
37
 
37
 
#include <grub_probe_init.h>
38
 
 
39
38
#include <stdio.h>
40
39
#include <unistd.h>
41
40
#include <string.h>
60
59
int print = PRINT_FS;
61
60
static unsigned int argument_is_device = 0;
62
61
 
63
 
void 
64
 
grub_xputs_real (const char *str)
65
 
{
66
 
  fputs (str, stdout);
67
 
}
68
 
 
69
 
void (*grub_xputs) (const char *str) = grub_xputs_real;
70
 
 
71
 
int
72
 
grub_getkey (void)
73
 
{
74
 
  return -1;
75
 
}
76
 
 
77
 
void
78
 
grub_refresh (void)
79
 
{
80
 
  fflush (stdout);
81
 
}
82
 
 
83
62
static void
84
63
probe_partmap (grub_disk_t disk)
85
64
{
196
175
            printf ("raid5rec ");
197
176
          if (is_raid6)
198
177
            printf ("raid6rec ");
199
 
          printf ("mdraid ");
 
178
          if (dev->disk->dev->raidname)
 
179
            printf ("%s ", dev->disk->dev->raidname (dev->disk));
200
180
        }
201
181
 
202
182
      if (is_lvm)
247
227
 
248
228
  if (print == PRINT_FS)
249
229
    {
250
 
      if (path)
251
 
        {
252
 
          struct stat st;
253
 
 
254
 
          stat (path, &st);
255
 
 
256
 
          if (S_ISREG (st.st_mode))
257
 
            {
258
 
              /* Regular file.  Verify that we can read it properly.  */
259
 
 
260
 
              grub_file_t file;
261
 
              char *rel_path;
262
 
              grub_util_info ("reading %s via OS facilities", path);
263
 
              filebuf_via_sys = grub_util_read_image (path);
264
 
 
265
 
              rel_path = grub_make_system_path_relative_to_its_root (path);
266
 
              grub_path = xasprintf ("(%s)%s", drive_name, rel_path);
267
 
              free (rel_path);
268
 
              grub_util_info ("reading %s via GRUB facilities", grub_path);
269
 
              file = grub_file_open (grub_path);
270
 
              if (! file)
271
 
                grub_util_error ("cannot open %s via GRUB facilities", grub_path);
272
 
              filebuf_via_grub = xmalloc (file->size);
273
 
              grub_file_read (file, filebuf_via_grub, file->size);
274
 
 
275
 
              grub_util_info ("comparing");
276
 
 
277
 
              if (memcmp (filebuf_via_grub, filebuf_via_sys, file->size))
278
 
                grub_util_error ("files differ");
279
 
            }
280
 
        }
281
 
 
282
230
      printf ("%s\n", fs->name);
283
231
    }
284
 
 
285
 
  if (print == PRINT_FS_UUID)
 
232
  else if (print == PRINT_FS_UUID)
286
233
    {
287
234
      char *uuid;
288
235
      if (! fs->uuid)
289
236
        grub_util_error ("%s does not support UUIDs", fs->name);
290
237
 
291
 
      fs->uuid (dev, &uuid);
 
238
      if (fs->uuid (dev, &uuid) != GRUB_ERR_NONE)
 
239
        grub_util_error ("%s", grub_errmsg);
292
240
 
293
241
      printf ("%s\n", uuid);
294
242
    }
298
246
      if (! fs->label)
299
247
        grub_util_error ("%s does not support labels", fs->name);
300
248
 
301
 
      fs->label (dev, &label);
 
249
      if (fs->label (dev, &label) != GRUB_ERR_NONE)
 
250
        grub_util_error ("%s", grub_errmsg);
302
251
 
303
252
      printf ("%s\n", label);
304
253
    }
442
391
  /* Initialize all modules. */
443
392
  grub_init_all ();
444
393
 
 
394
  grub_lvm_fini ();
 
395
  grub_mdraid09_fini ();
 
396
  grub_mdraid1x_fini ();
 
397
  grub_raid_fini ();
 
398
  grub_raid_init ();
 
399
  grub_mdraid09_init ();
 
400
  grub_mdraid1x_init ();
 
401
  grub_lvm_init ();
 
402
 
445
403
  /* Do it.  */
446
404
  if (argument_is_device)
447
405
    probe (NULL, argument);