Root/package/grub2/patches/100-grub_setup_root.patch

1--- a/util/grub-setup.c
2+++ b/util/grub-setup.c
3@@ -141,12 +141,11 @@ write_rootdev (char *core_img, grub_devi
4 static void
5 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 {
11   char *boot_path, *core_path, *core_path_dev, *core_path_dev_full;
12   char *boot_img, *core_img;
13- char *root = 0;
14   size_t boot_size, core_size;
15   grub_uint16_t core_sectors;
16   grub_device_t root_dev = 0, dest_dev, core_dev;
17@@ -253,7 +252,10 @@ setup (const char *dir,
18 
19   core_dev = dest_dev;
20 
21- {
22+ if (root)
23+ root_dev = grub_device_open(root);
24+
25+ if (!root_dev) {
26     char **root_devices = grub_guess_root_devices (dir);
27     char **cur;
28     int found = 0;
29@@ -263,6 +265,8 @@ setup (const char *dir,
30     char *drive;
31     grub_device_t try_dev;
32 
33+ if (root_dev)
34+ break;
35     drive = grub_util_get_grub_dev (*cur);
36     if (!drive)
37       continue;
38@@ -956,6 +960,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@@ -993,6 +999,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@@ -1040,6 +1047,13 @@ argp_parser (int key, char *arg, struct
56         arguments->dev_map = xstrdup (arg);
57         break;
58 
59+ case 'r':
60+ if (arguments->root_dev)
61+ free (arguments->root_dev);
62+
63+ arguments->root_dev = xstrdup (arg);
64+ break;
65+
66       case 'f':
67         arguments->force = 1;
68         break;
69@@ -1172,7 +1186,7 @@ main (int argc, char *argv[])
70   setup (arguments.dir ? : DEFAULT_DIRECTORY,
71      arguments.boot_file ? : DEFAULT_BOOT_FILE,
72      arguments.core_file ? : DEFAULT_CORE_FILE,
73- dest_dev, arguments.force,
74+ arguments.root_dev, dest_dev, arguments.force,
75      arguments.fs_probe, arguments.allow_floppy);
76 
77   /* Free resources. */
78

Archive Download this file



interactive