1
0

100-grub_setup_root.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. --- a/util/grub-setup.c
  2. +++ b/util/grub-setup.c
  3. @@ -87,6 +87,8 @@ static struct argp_option options[] = {
  4. N_("install even if problems are detected"), 0},
  5. {"skip-fs-probe",'s',0, 0,
  6. N_("do not probe for filesystems in DEVICE"), 0},
  7. + {"root-device", 'r', N_("DEVICE"), 0,
  8. + N_("use DEVICE as the root device"), 0},
  9. {"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
  10. {"allow-floppy", 'a', 0, 0,
  11. /* TRANSLATORS: The potential breakage isn't limited to floppies but it's
  12. @@ -130,6 +132,7 @@ struct arguments
  13. char *core_file;
  14. char *dir;
  15. char *dev_map;
  16. + char *root_dev;
  17. int force;
  18. int fs_probe;
  19. int allow_floppy;
  20. @@ -178,6 +181,13 @@ argp_parser (int key, char *arg, struct argp_state *state)
  21. arguments->dev_map = xstrdup (arg);
  22. break;
  23. + case 'r':
  24. + if (arguments->root_dev)
  25. + free (arguments->root_dev);
  26. +
  27. + arguments->root_dev = xstrdup (arg);
  28. + break;
  29. +
  30. case 'f':
  31. arguments->force = 1;
  32. break;
  33. @@ -313,7 +323,7 @@ main (int argc, char *argv[])
  34. GRUB_SETUP_FUNC (arguments.dir ? : DEFAULT_DIRECTORY,
  35. arguments.boot_file ? : DEFAULT_BOOT_FILE,
  36. arguments.core_file ? : DEFAULT_CORE_FILE,
  37. - dest_dev, arguments.force,
  38. + arguments.root_dev, dest_dev, arguments.force,
  39. arguments.fs_probe, arguments.allow_floppy,
  40. arguments.add_rs_codes);
  41. --- a/util/setup.c
  42. +++ b/util/setup.c
  43. @@ -247,13 +247,12 @@ identify_partmap (grub_disk_t disk __attribute__ ((unused)),
  44. void
  45. SETUP (const char *dir,
  46. const char *boot_file, const char *core_file,
  47. - const char *dest, int force,
  48. + const char *root, const char *dest, int force,
  49. int fs_probe, int allow_floppy,
  50. int add_rs_codes __attribute__ ((unused))) /* unused on sparc64 */
  51. {
  52. char *core_path;
  53. char *boot_img, *core_img, *boot_path;
  54. - char *root = 0;
  55. size_t boot_size, core_size;
  56. #ifdef GRUB_SETUP_BIOS
  57. grub_uint16_t core_sectors;
  58. @@ -307,7 +306,10 @@ SETUP (const char *dir,
  59. core_dev = dest_dev;
  60. - {
  61. + if (root)
  62. + root_dev = grub_device_open(root);
  63. +
  64. + if (!root_dev) {
  65. char **root_devices = grub_guess_root_devices (dir);
  66. char **cur;
  67. int found = 0;
  68. @@ -320,6 +322,8 @@ SETUP (const char *dir,
  69. char *drive;
  70. grub_device_t try_dev;
  71. + if (root_dev)
  72. + break;
  73. drive = grub_util_get_grub_dev (*cur);
  74. if (!drive)
  75. continue;
  76. --- a/include/grub/util/install.h
  77. +++ b/include/grub/util/install.h
  78. @@ -184,13 +184,13 @@ grub_install_get_image_target (const char *arg);
  79. void
  80. grub_util_bios_setup (const char *dir,
  81. const char *boot_file, const char *core_file,
  82. - const char *dest, int force,
  83. + const char *root, const char *dest, int force,
  84. int fs_probe, int allow_floppy,
  85. int add_rs_codes);
  86. void
  87. grub_util_sparc_setup (const char *dir,
  88. const char *boot_file, const char *core_file,
  89. - const char *dest, int force,
  90. + const char *root, const char *dest, int force,
  91. int fs_probe, int allow_floppy,
  92. int add_rs_codes);
  93. --- a/util/grub-install.c
  94. +++ b/util/grub-install.c
  95. @@ -1673,7 +1673,7 @@ main (int argc, char *argv[])
  96. /* Now perform the installation. */
  97. if (install_bootsector)
  98. grub_util_bios_setup (platdir, "boot.img", "core.img",
  99. - install_drive, force,
  100. + NULL, install_drive, force,
  101. fs_probe, allow_floppy, add_rs_codes);
  102. break;
  103. }
  104. @@ -1699,7 +1699,7 @@ main (int argc, char *argv[])
  105. /* Now perform the installation. */
  106. if (install_bootsector)
  107. grub_util_sparc_setup (platdir, "boot.img", "core.img",
  108. - install_drive, force,
  109. + NULL, install_drive, force,
  110. fs_probe, allow_floppy,
  111. 0 /* unused */ );
  112. break;