blob: df671bc9d24c245c2abd4dc1ffb1df5be694d0a6 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001--- 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
21 arguments->dev_map = xstrdup (arg);
22 break;
23
24+ case 'r':
25+ if (arguments->root_dev)
26+ free (arguments->root_dev);
27+
28+ arguments->root_dev = xstrdup (arg);
29+ break;
30+
31 case 'f':
32 arguments->force = 1;
33 break;
34@@ -313,7 +323,7 @@ main (int argc, char *argv[])
35 GRUB_SETUP_FUNC (arguments.dir ? : DEFAULT_DIRECTORY,
36 arguments.boot_file ? : DEFAULT_BOOT_FILE,
37 arguments.core_file ? : DEFAULT_CORE_FILE,
38- dest_dev, arguments.force,
39+ arguments.root_dev, dest_dev, arguments.force,
40 arguments.fs_probe, arguments.allow_floppy,
41 arguments.add_rs_codes);
42
43--- a/util/setup.c
44+++ b/util/setup.c
45@@ -252,13 +252,12 @@ identify_partmap (grub_disk_t disk __att
46 void
47 SETUP (const char *dir,
48 const char *boot_file, const char *core_file,
49- const char *dest, int force,
50+ const char *root, const char *dest, int force,
51 int fs_probe, int allow_floppy,
52 int add_rs_codes __attribute__ ((unused))) /* unused on sparc64 */
53 {
54 char *core_path;
55 char *boot_img, *core_img, *boot_path;
56- char *root = 0;
57 size_t boot_size, core_size;
58 grub_uint16_t core_sectors;
59 grub_device_t root_dev = 0, dest_dev, core_dev;
60@@ -307,7 +306,10 @@ SETUP (const char *dir,
61
62 core_dev = dest_dev;
63
64- {
65+ if (root)
66+ root_dev = grub_device_open(root);
67+
68+ if (!root_dev) {
69 char **root_devices = grub_guess_root_devices (dir);
70 char **cur;
71 int found = 0;
72@@ -320,6 +322,8 @@ SETUP (const char *dir,
73 char *drive;
74 grub_device_t try_dev;
75
76+ if (root_dev)
77+ break;
78 drive = grub_util_get_grub_dev (*cur);
79 if (!drive)
80 continue;
81--- a/include/grub/util/install.h
82+++ b/include/grub/util/install.h
83@@ -191,13 +191,13 @@ grub_install_get_image_target (const cha
84 void
85 grub_util_bios_setup (const char *dir,
86 const char *boot_file, const char *core_file,
87- const char *dest, int force,
88+ const char *root, const char *dest, int force,
89 int fs_probe, int allow_floppy,
90 int add_rs_codes);
91 void
92 grub_util_sparc_setup (const char *dir,
93 const char *boot_file, const char *core_file,
94- const char *dest, int force,
95+ const char *root, const char *dest, int force,
96 int fs_probe, int allow_floppy,
97 int add_rs_codes);
98
99--- a/util/grub-install.c
100+++ b/util/grub-install.c
101@@ -1712,7 +1712,7 @@ main (int argc, char *argv[])
102 /* Now perform the installation. */
103 if (install_bootsector)
104 grub_util_bios_setup (platdir, "boot.img", "core.img",
105- install_drive, force,
106+ NULL, install_drive, force,
107 fs_probe, allow_floppy, add_rs_codes);
108 break;
109 }
110@@ -1738,7 +1738,7 @@ main (int argc, char *argv[])
111 /* Now perform the installation. */
112 if (install_bootsector)
113 grub_util_sparc_setup (platdir, "boot.img", "core.img",
114- install_drive, force,
115+ NULL, install_drive, force,
116 fs_probe, allow_floppy,
117 0 /* unused */ );
118 break;