100-grub_setup_root.patch 3.7 KB

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