[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Set a bootdrive environment variable.
From: |
Mathieu Trudel-Lapierre |
Subject: |
[PATCH] Set a bootdrive environment variable. |
Date: |
Tue, 26 May 2015 12:46:08 -0400 |
---
grub-core/kern/main.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
index 9cad0c4..8352b6e 100644
--- a/grub-core/kern/main.c
+++ b/grub-core/kern/main.c
@@ -130,6 +130,8 @@ grub_set_prefix_and_root (void)
if (fwdevice)
{
char *cmdpath;
+ char *bootdrive = NULL;
+ char *cptr;
cmdpath = grub_xasprintf ("(%s)%s", fwdevice, fwpath ? : "");
if (cmdpath)
@@ -138,6 +140,19 @@ grub_set_prefix_and_root (void)
grub_env_export ("cmdpath");
grub_free (cmdpath);
}
+
+ cptr = grub_strrchr (fwdevice, ',');
+ if (cptr)
+ {
+ bootdrive = grub_strndup (fwdevice, cptr - fwdevice);
+ cptr++;
+ }
+ if (bootdrive)
+ {
+ grub_env_set ("bootdrive", bootdrive);
+ grub_env_export ("bootdrive");
+ grub_free (bootdrive);
+ }
}
if (prefix)
--
2.1.4