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

« back to all changes in this revision

Viewing changes to normal/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2010-01-11 11:12:55 UTC
  • mfrom: (17.3.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100111111255-lr8ebkqw5x41gq6j
Tags: 1.98~20100101-1ubuntu1
* Resynchronise with Debian. 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.
  - Conflict with grub (<< 0.97-54) as well as grub-legacy.
  - 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.
  - If the environment variable "quiet" is set to something other than 0,
    suppress progress messages as the kernel and initrd load. Set this for
    non-recovery kernel menu entries.
  - Add GRUB_DEFAULT=saved, as well as grub-set-default and grub-reboot
    utilities. Provides functionality essentially equivalent to GRUB
    Legacy's savedefault.
  - Keep the loopback file open so that subsequent changes to the "root"
    environment variable don't affect it.
  - 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.
  - Handle RAID devices containing virtio components.
* Update savedefault patch from current Bazaar branch, fixing grub-reboot
  to have distinct behaviour from grub-set-default (LP: #497326).
* Fix grub-mkisofs compilation error with FORTIFY_SOURCE.
* Convert recordfail boilerplate in each menu entry to use a function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
385
385
void
386
386
grub_normal_init_page (void)
387
387
{
388
 
  grub_uint8_t width, margin;
389
 
 
390
 
#define TITLE ("GNU GRUB  version " PACKAGE_VERSION)
391
 
 
392
 
  width = grub_getwh () >> 8;
393
 
  margin = (width - (sizeof(TITLE) + 7)) / 2;
394
 
 
 
388
  int msg_len;
 
389
  int posx;
 
390
  const char *msg = _("GNU GRUB  version %s");
 
391
 
 
392
  char *msg_formatted = grub_malloc (grub_strlen(msg) +
 
393
                                     grub_strlen(PACKAGE_VERSION));
 
394
 
395
395
  grub_cls ();
396
 
  grub_putchar ('\n');
397
 
 
398
 
  while (margin--)
399
 
    grub_putchar (' ');
400
 
 
401
 
  grub_printf ("%s\n\n", TITLE);
402
 
 
403
 
#undef TITLE
 
396
 
 
397
  grub_sprintf (msg_formatted, msg, PACKAGE_VERSION);
 
398
 
 
399
  grub_uint32_t *unicode_msg;
 
400
  grub_uint32_t *last_position;
 
401
 
 
402
  msg_len = grub_utf8_to_ucs4_alloc (msg_formatted,
 
403
                                     &unicode_msg, &last_position);
 
404
 
 
405
  if (msg_len < 0)
 
406
    {
 
407
      return;
 
408
    }
 
409
 
 
410
  posx = grub_getstringwidth (unicode_msg, last_position);
 
411
  posx = (GRUB_TERM_WIDTH - posx) / 2;
 
412
  grub_gotoxy (posx, 1);
 
413
 
 
414
  grub_print_ucs4 (unicode_msg, last_position);
 
415
  grub_printf("\n\n");
 
416
  grub_free (unicode_msg);
404
417
}
405
418
 
406
419
static int reader_nested;
509
522
  grub_normal_init_page ();
510
523
  grub_setcursor (1);
511
524
 
512
 
  grub_printf (_("\
513
 
 [ Minimal BASH-like line editing is supported. For the first word, TAB\n\
514
 
   lists possible command completions. Anywhere else TAB lists possible\n\
515
 
   device/file completions.%s ]\n\n"),
516
 
               reader_nested ? " ESC at any time exits." : "");
517
 
 
 
525
  const char *msg = _("Minimal BASH-like line editing is supported. For "
 
526
                      "the first word, TAB lists possible command completions. Anywhere "
 
527
                      "else TAB lists possible device or file completions. %s");
 
528
 
 
529
  const char *msg_esc = _("ESC at any time exits.");
 
530
 
 
531
  char *msg_formatted = grub_malloc (sizeof (char) * (grub_strlen (msg) +
 
532
                grub_strlen(msg_esc) + 1));
 
533
 
 
534
  grub_sprintf (msg_formatted, msg, reader_nested ? msg_esc : "");
 
535
  grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN);
 
536
  grub_puts ("\n");
 
537
 
 
538
  grub_free (msg_formatted);
 
539
 
518
540
  return 0;
519
541
}
520
542
 
524
546
grub_normal_read_line (char **line, int cont)
525
547
{
526
548
  grub_parser_t parser = grub_parser_get_current ();
527
 
  char prompt[sizeof("> ") + grub_strlen (parser->name)];
 
549
  char prompt[sizeof(">") + grub_strlen (parser->name)];
528
550
 
529
 
  grub_sprintf (prompt, "%s> ", parser->name);
 
551
  grub_sprintf (prompt, "%s>", parser->name);
530
552
 
531
553
  while (1)
532
554
    {
576
598
 
577
599
  /* Register a command "normal" for the rescue mode.  */
578
600
  grub_register_command_prio ("normal", grub_cmd_normal,
579
 
                              0, "Enter normal mode", 0);
 
601
                              0, "Enter normal mode.", 0);
580
602
 
581
603
  /* Reload terminal colors when these variables are written to.  */
582
604
  grub_register_variable_hook ("color_normal", NULL, grub_env_write_color_normal);