+static void
+add_root_to_options(CHAR16 *options, CHAR16 *root, CHAR16 *vmcode)
+{
+ CHAR16 *o, ko[CMDLINE_MAXLEN];
+
+ if (vmcode[0]) {
+ for (o = options; *o; o++) {
+ if (*o == '-' && *(o+1) == '-')
+ break;
+ }
+ if (! *o) {
+ /* no separator found, add one */
+ StrCpy(o, L" -- ");
+ o++;
+ }
+
+ /* advance past separator and whitespace */
+ o += 2;
+ while (*o == ' ') o++;
+ } else {
+ o = options;
+ }
+
+ /* insert root param at this point */
+ StrCpy(ko, o);
+ StrCpy(o, L"root=");
+ StrCat(o, root);
+ StrCat(o, L" ");
+ StrCat(o, ko);
+}
+