]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/grub-0.90-append.patch
Add some patches to grub.
[ipfire-2.x.git] / src / patches / grub-0.90-append.patch
1 --- grub-0.90/stage2/stage2.c.append Thu Dec 20 08:20:48 2001
2 +++ grub-0.90/stage2/stage2.c Thu Dec 20 17:01:20 2001
3 @@ -500,7 +500,8 @@
4 if (config_entries)
5 printf ("\
6 Press enter to boot the selected OS, \'e\' to edit the\n\
7 - commands before booting, or \'c\' for a command-line.");
8 + commands before booting, \'a\' to modify the kernel arguments\n\
9 + before booting, or \'c\' for a command-line.");
10 else
11 printf ("\
12 Press \'b\' to boot, \'e\' to edit the selected command in the\n\
13 @@ -787,6 +788,98 @@
14 enter_cmdline (heap, 0);
15 goto restart;
16 }
17 + if (config_entries && c == 'a')
18 + {
19 + int new_num_entries = 0, i = 0, j;
20 + int needs_padding, amount;
21 + char *new_heap;
22 + char * entries;
23 + char * entry_copy;
24 + char * append_line;
25 + char * start;
26 +
27 + entry_copy = new_heap = heap;
28 + cur_entry = get_entry (config_entries, first_entry + entryno,
29 + 1);
30 +
31 + do
32 + {
33 + while ((*(new_heap++) = cur_entry[i++]) != 0);
34 + new_num_entries++;
35 + }
36 + while (config_entries && cur_entry[i]);
37 +
38 + /* this only needs to be done if config_entries is non-NULL,
39 + but it doesn't hurt to do it always */
40 + *(new_heap++) = 0;
41 +
42 + new_heap = heap + NEW_HEAPSIZE + 1;
43 +
44 + entries = entry_copy;
45 + while (*entries)
46 + {
47 + if ((strstr(entries, "kernel") == entries) &&
48 + isspace(entries[6]))
49 + break;
50 +
51 + while (*entries) entries++;
52 + entries++;
53 + }
54 +
55 + if (!*entries)
56 + goto restart;
57 +
58 + start = entries + 6;
59 +
60 + /* skip the white space */
61 + while (*start && isspace(*start)) start++;
62 + /* skip the kernel name */
63 + while (*start && !isspace(*start)) start++;
64 +
65 + /* skip the white space */
66 + needs_padding = (!*start || !isspace(*start));
67 + while (*start && isspace(*start)) start++;
68 +
69 + append_line = new_heap;
70 + grub_strcpy(append_line, start);
71 +
72 + cls();
73 + print_cmdline_message (CMDLINE_EDIT_MODE);
74 +
75 + if (get_cmdline(PACKAGE " append> ",
76 + append_line, NEW_HEAPSIZE + 1,
77 + 0, 1))
78 + goto restart;
79 +
80 + /* have new args; append_line points to the
81 + new args and start points to the old
82 + args */
83 +
84 + i = grub_strlen(start);
85 + j = grub_strlen(append_line);
86 +
87 + if (i > (j + needs_padding))
88 + amount = i;
89 + else
90 + amount = j + needs_padding;
91 +
92 + /* align rest of commands properly */
93 + memmove (start + j + needs_padding, start + i,
94 + ((int) append_line) - ((int) start) - (amount));
95 +
96 + if (needs_padding)
97 + *start = ' ';
98 +
99 + /* copy command to correct area */
100 + memmove (start + needs_padding, append_line, j);
101 +
102 + /* set up this entry to boot */
103 + config_entries = NULL;
104 + cur_entry = entry_copy;
105 + heap = new_heap;
106 +
107 + break;
108 + }
109 #ifdef GRUB_UTIL
110 if (c == 'q')
111 {