|
|
8e15ce |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8e15ce |
From: Michael Chang <mchang@suse.com>
|
|
|
8e15ce |
Date: Thu, 21 Aug 2014 03:39:11 +0000
|
|
|
8e15ce |
Subject: [PATCH] grub2-btrfs-04-grub2-install
|
|
|
8e15ce |
|
|
|
8e15ce |
---
|
|
|
8e15ce |
grub-core/osdep/linux/getroot.c | 7 +++++++
|
|
|
8e15ce |
grub-core/osdep/unix/config.c | 17 +++++++++++++++--
|
|
|
8e15ce |
util/config.c | 10 ++++++++++
|
|
|
8e15ce |
util/grub-install.c | 15 +++++++++++++++
|
|
|
8e15ce |
util/grub-mkrelpath.c | 6 ++++++
|
|
|
8e15ce |
include/grub/emu/config.h | 1 +
|
|
|
8e15ce |
6 files changed, 54 insertions(+), 2 deletions(-)
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
|
|
|
8e15ce |
index 001b818fe58..caf9b1ccd3f 100644
|
|
|
8e15ce |
--- a/grub-core/osdep/linux/getroot.c
|
|
|
8e15ce |
+++ b/grub-core/osdep/linux/getroot.c
|
|
|
8e15ce |
@@ -376,6 +376,7 @@ get_btrfs_fs_prefix (const char *mount_path)
|
|
|
8e15ce |
return NULL;
|
|
|
8e15ce |
}
|
|
|
8e15ce |
|
|
|
8e15ce |
+int use_relative_path_on_btrfs = 0;
|
|
|
8e15ce |
|
|
|
8e15ce |
char **
|
|
|
8e15ce |
grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
|
|
|
8e15ce |
@@ -519,6 +520,12 @@ again:
|
|
|
8e15ce |
{
|
|
|
8e15ce |
ret = grub_find_root_devices_from_btrfs (dir);
|
|
|
8e15ce |
fs_prefix = get_btrfs_fs_prefix (entries[i].enc_path);
|
|
|
8e15ce |
+ if (use_relative_path_on_btrfs)
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ if (fs_prefix)
|
|
|
8e15ce |
+ free (fs_prefix);
|
|
|
8e15ce |
+ fs_prefix = xstrdup ("/");
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
}
|
|
|
8e15ce |
else if (!retry && grub_strcmp (entries[i].fstype, "autofs") == 0)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c
|
|
|
8e15ce |
index 7d6325138ce..46a881530c0 100644
|
|
|
8e15ce |
--- a/grub-core/osdep/unix/config.c
|
|
|
8e15ce |
+++ b/grub-core/osdep/unix/config.c
|
|
|
8e15ce |
@@ -82,6 +82,19 @@ grub_util_load_config (struct grub_util_config *cfg)
|
|
|
8e15ce |
if (v)
|
|
|
8e15ce |
cfg->grub_distributor = xstrdup (v);
|
|
|
8e15ce |
|
|
|
8e15ce |
+ v = getenv ("SUSE_BTRFS_SNAPSHOT_BOOTING");
|
|
|
8e15ce |
+ if (v)
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ if (grub_strncmp(v, "true", sizeof ("true") - 1) == 0)
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ cfg->is_suse_btrfs_snapshot_enabled = 1;
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
+ else
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ cfg->is_suse_btrfs_snapshot_enabled = 0;
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
+
|
|
|
8e15ce |
cfgfile = grub_util_get_config_filename ();
|
|
|
8e15ce |
if (!grub_util_is_regular (cfgfile))
|
|
|
8e15ce |
return;
|
|
|
8e15ce |
@@ -105,8 +118,8 @@ grub_util_load_config (struct grub_util_config *cfg)
|
|
|
8e15ce |
*ptr++ = *iptr;
|
|
|
8e15ce |
}
|
|
|
8e15ce |
|
|
|
8e15ce |
- strcpy (ptr, "'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\n\" "
|
|
|
8e15ce |
- "\"$GRUB_ENABLE_CRYPTODISK\" \"$GRUB_DISTRIBUTOR\"");
|
|
|
8e15ce |
+ strcpy (ptr, "'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\nSUSE_BTRFS_SNAPSHOT_BOOTING=%s\\n\" "
|
|
|
8e15ce |
+ "\"$GRUB_ENABLE_CRYPTODISK\" \"$GRUB_DISTRIBUTOR\" \"$SUSE_BTRFS_SNAPSHOT_BOOTING\"");
|
|
|
8e15ce |
|
|
|
8e15ce |
argv[2] = script;
|
|
|
8e15ce |
argv[3] = '\0';
|
|
|
8e15ce |
diff --git a/util/config.c b/util/config.c
|
|
|
8e15ce |
index ebcdd8f5e22..f044a880a76 100644
|
|
|
8e15ce |
--- a/util/config.c
|
|
|
8e15ce |
+++ b/util/config.c
|
|
|
8e15ce |
@@ -42,6 +42,16 @@ grub_util_parse_config (FILE *f, struct grub_util_config *cfg, int simple)
|
|
|
8e15ce |
cfg->is_cryptodisk_enabled = 1;
|
|
|
8e15ce |
continue;
|
|
|
8e15ce |
}
|
|
|
8e15ce |
+ if (grub_strncmp (ptr, "SUSE_BTRFS_SNAPSHOT_BOOTING=",
|
|
|
8e15ce |
+ sizeof ("SUSE_BTRFS_SNAPSHOT_BOOTING=") - 1) == 0)
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ ptr += sizeof ("SUSE_BTRFS_SNAPSHOT_BOOTING=") - 1;
|
|
|
8e15ce |
+ if (*ptr == '"' || *ptr == '\'')
|
|
|
8e15ce |
+ ptr++;
|
|
|
8e15ce |
+ if (grub_strncmp(ptr, "true", sizeof ("true") - 1) == 0)
|
|
|
8e15ce |
+ cfg->is_suse_btrfs_snapshot_enabled = 1;
|
|
|
8e15ce |
+ continue;
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
if (grub_strncmp (ptr, "GRUB_DISTRIBUTOR=",
|
|
|
8e15ce |
sizeof ("GRUB_DISTRIBUTOR=") - 1) == 0)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
diff --git a/util/grub-install.c b/util/grub-install.c
|
|
|
8e15ce |
index 0fbe7f78c6d..0f66f36d23a 100644
|
|
|
8e15ce |
--- a/util/grub-install.c
|
|
|
8e15ce |
+++ b/util/grub-install.c
|
|
|
8e15ce |
@@ -827,6 +827,8 @@ fill_core_services (const char *core_services)
|
|
|
8e15ce |
free (sysv_plist);
|
|
|
8e15ce |
}
|
|
|
8e15ce |
|
|
|
8e15ce |
+extern int use_relative_path_on_btrfs;
|
|
|
8e15ce |
+
|
|
|
8e15ce |
int
|
|
|
8e15ce |
main (int argc, char *argv[])
|
|
|
8e15ce |
{
|
|
|
8e15ce |
@@ -860,6 +862,9 @@ main (int argc, char *argv[])
|
|
|
8e15ce |
|
|
|
8e15ce |
grub_util_load_config (&config);
|
|
|
8e15ce |
|
|
|
8e15ce |
+ if (config.is_suse_btrfs_snapshot_enabled)
|
|
|
8e15ce |
+ use_relative_path_on_btrfs = 1;
|
|
|
8e15ce |
+
|
|
|
8e15ce |
if (!bootloader_id && config.grub_distributor)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
char *ptr;
|
|
|
8e15ce |
@@ -1352,6 +1357,16 @@ main (int argc, char *argv[])
|
|
|
8e15ce |
fprintf (load_cfg_f, "set debug='%s'\n",
|
|
|
8e15ce |
debug_image);
|
|
|
8e15ce |
}
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+ if (config.is_suse_btrfs_snapshot_enabled
|
|
|
8e15ce |
+ && grub_strncmp(grub_fs->name, "btrfs", sizeof ("btrfs") - 1) == 0)
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ if (!load_cfg_f)
|
|
|
8e15ce |
+ load_cfg_f = grub_util_fopen (load_cfg, "wb");
|
|
|
8e15ce |
+ have_load_cfg = 1;
|
|
|
8e15ce |
+ fprintf (load_cfg_f, "set btrfs_relative_path='y'\n");
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
+
|
|
|
8e15ce |
char *prefix_drive = NULL;
|
|
|
8e15ce |
char *install_drive = NULL;
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/util/grub-mkrelpath.c b/util/grub-mkrelpath.c
|
|
|
8e15ce |
index 47a241a391b..5db7a9a7d97 100644
|
|
|
8e15ce |
--- a/util/grub-mkrelpath.c
|
|
|
8e15ce |
+++ b/util/grub-mkrelpath.c
|
|
|
8e15ce |
@@ -40,9 +40,12 @@ struct arguments
|
|
|
8e15ce |
};
|
|
|
8e15ce |
|
|
|
8e15ce |
static struct argp_option options[] = {
|
|
|
8e15ce |
+ {"relative", 'r', 0, 0, "use relative path on btrfs", 0},
|
|
|
8e15ce |
{ 0, 0, 0, 0, 0, 0 }
|
|
|
8e15ce |
};
|
|
|
8e15ce |
|
|
|
8e15ce |
+extern int use_relative_path_on_btrfs;
|
|
|
8e15ce |
+
|
|
|
8e15ce |
static error_t
|
|
|
8e15ce |
argp_parser (int key, char *arg, struct argp_state *state)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
@@ -52,6 +55,9 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
|
|
8e15ce |
|
|
|
8e15ce |
switch (key)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
+ case 'r':
|
|
|
8e15ce |
+ use_relative_path_on_btrfs = 1;
|
|
|
8e15ce |
+ break;
|
|
|
8e15ce |
case ARGP_KEY_ARG:
|
|
|
8e15ce |
if (state->arg_num == 0)
|
|
|
8e15ce |
arguments->pathname = xstrdup (arg);
|
|
|
8e15ce |
diff --git a/include/grub/emu/config.h b/include/grub/emu/config.h
|
|
|
8e15ce |
index 875d5896ce1..c9a7e5f4ade 100644
|
|
|
8e15ce |
--- a/include/grub/emu/config.h
|
|
|
8e15ce |
+++ b/include/grub/emu/config.h
|
|
|
8e15ce |
@@ -37,6 +37,7 @@ struct grub_util_config
|
|
|
8e15ce |
{
|
|
|
8e15ce |
int is_cryptodisk_enabled;
|
|
|
8e15ce |
char *grub_distributor;
|
|
|
8e15ce |
+ int is_suse_btrfs_snapshot_enabled;
|
|
|
8e15ce |
};
|
|
|
8e15ce |
|
|
|
8e15ce |
void
|