|
|
8e15ce |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8e15ce |
From: Andrei Borzenkov <arvidjaar@gmail.com>
|
|
|
8e15ce |
Date: Tue, 21 Jun 2016 16:44:17 +0000
|
|
|
8e15ce |
Subject: [PATCH] Fallback to old subvol name scheme to support old snapshot
|
|
|
8e15ce |
config
|
|
|
8e15ce |
|
|
|
8e15ce |
Ref: bsc#953538
|
|
|
8e15ce |
---
|
|
|
8e15ce |
grub-core/fs/btrfs.c | 32 +++++++++++++++++++++++++++++++-
|
|
|
8e15ce |
1 file changed, 31 insertions(+), 1 deletion(-)
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
|
|
|
8e15ce |
index d323746ecfa..673ded03522 100644
|
|
|
8e15ce |
--- a/grub-core/fs/btrfs.c
|
|
|
8e15ce |
+++ b/grub-core/fs/btrfs.c
|
|
|
8e15ce |
@@ -1260,11 +1260,41 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path)
|
|
|
8e15ce |
return GRUB_ERR_NONE;
|
|
|
8e15ce |
}
|
|
|
8e15ce |
|
|
|
8e15ce |
+static grub_err_t
|
|
|
8e15ce |
+lookup_root_by_name_fallback(struct grub_btrfs_data *data, const char *path)
|
|
|
8e15ce |
+{
|
|
|
8e15ce |
+ grub_err_t err;
|
|
|
8e15ce |
+ grub_uint64_t tree = 0;
|
|
|
8e15ce |
+ grub_uint8_t type;
|
|
|
8e15ce |
+ struct grub_btrfs_key key;
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+ err = find_path (data, path, &key, &tree, &type);
|
|
|
8e15ce |
+ if (err)
|
|
|
8e15ce |
+ return grub_error(GRUB_ERR_FILE_NOT_FOUND, "couldn't locate %s\n", path);
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+ if (key.object_id != grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK) || tree == 0)
|
|
|
8e15ce |
+ return grub_error(GRUB_ERR_BAD_FILE_TYPE, "%s: not a subvolume\n", path);
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+ data->fs_tree = tree;
|
|
|
8e15ce |
+ return GRUB_ERR_NONE;
|
|
|
8e15ce |
+}
|
|
|
8e15ce |
+
|
|
|
8e15ce |
static grub_err_t
|
|
|
8e15ce |
btrfs_handle_subvol(struct grub_btrfs_data *data __attribute__ ((unused)))
|
|
|
8e15ce |
{
|
|
|
8e15ce |
if (btrfs_default_subvol)
|
|
|
8e15ce |
- return lookup_root_by_name(data, btrfs_default_subvol);
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ grub_err_t err;
|
|
|
8e15ce |
+ err = lookup_root_by_name(data, btrfs_default_subvol);
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+ /* Fallback to old schemes */
|
|
|
8e15ce |
+ if (err == GRUB_ERR_FILE_NOT_FOUND)
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ err = GRUB_ERR_NONE;
|
|
|
8e15ce |
+ return lookup_root_by_name_fallback(data, btrfs_default_subvol);
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
+ return err;
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
|
|
|
8e15ce |
if (btrfs_default_subvolid)
|
|
|
8e15ce |
return lookup_root_by_id(data, btrfs_default_subvolid);
|