Jiri Slaby
618ccb4258
- add new patches for booting btrfs snapshot (fate#316522) (fate#316232) * 0001-btrfs-rename-skip_default-to-follow_default.patch * 0002-btrfs-add-ability-to-boot-from-subvolumes.patch * 0003-cmdline-add-envvar-loader_cmdline_append.patch * 0004-btrfs-export-subvolume-envvars.patch OBS-URL: https://build.opensuse.org/request/show/211329 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=60
67 lines
1.7 KiB
Diff
67 lines
1.7 KiB
Diff
From: Michael Chang <mchang@suse.com>
|
|
Subject: add loader_cmdline_append environment variable
|
|
|
|
Add loader_cmdline_append environment variable that appends it's
|
|
value to the loader's command line. We can use this variable to
|
|
assign values determined at run time. It will take effect on any
|
|
subsidiary configs loaded using configfile as well.
|
|
|
|
By means of this variable, we can, for example, set rootflags=
|
|
according to the selected btrfs snapshots and tell linux kernel's
|
|
btrfs module to mount the snapshot by the subvolume name or id.
|
|
|
|
Signed-off-by: Michael Chang <mchang@suse.com>
|
|
---
|
|
grub-core/lib/cmdline.c | 21 +++++++++++++++++++++
|
|
1 file changed, 21 insertions(+)
|
|
|
|
diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c
|
|
index a702e64..c5be945 100644
|
|
--- a/grub-core/lib/cmdline.c
|
|
+++ b/grub-core/lib/cmdline.c
|
|
@@ -19,6 +19,8 @@
|
|
|
|
#include <grub/lib/cmdline.h>
|
|
#include <grub/misc.h>
|
|
+#include <grub/mm.h>
|
|
+#include <grub/env.h>
|
|
|
|
static unsigned int check_arg (char *c, int *has_space)
|
|
{
|
|
@@ -65,6 +67,8 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf,
|
|
int i, space;
|
|
unsigned int arg_size;
|
|
char *c;
|
|
+ const char *append = NULL;
|
|
+ grub_size_t append_size = 0;
|
|
|
|
for (i = 0; i < argc; i++)
|
|
{
|
|
@@ -95,6 +99,23 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf,
|
|
*buf++ = ' ';
|
|
}
|
|
|
|
+ append = grub_env_get ("loader_cmdline_append");
|
|
+
|
|
+ if (append)
|
|
+ append_size = grub_strlen (append);
|
|
+
|
|
+ if (append_size)
|
|
+ {
|
|
+ append_size++;
|
|
+ if (size >= append_size)
|
|
+ {
|
|
+ grub_strcpy (buf, append);
|
|
+ buf += append_size;
|
|
+ size -= append_size;
|
|
+ i++;
|
|
+ }
|
|
+ }
|
|
+
|
|
/* Replace last space with null. */
|
|
if (i)
|
|
buf--;
|
|
--
|
|
1.8.1.4
|
|
|