grub2/grub2-btrfs-07-subvol-fallback.patch
Andrei Borzenkov 79b1983d8c Accepting request 403817 from home:michael-chang:branches:Base:System
- Fix grub2-editenv error on encrypted lvm installation (bsc#981621) 
  * modified grub2-btrfs-workaround-grub2-once.patch
- Add missing closing bracket in 'grub2-snapper-plugin.sh'.
- Fix snapshot booting on s390x (bsc#955115)
  * modified grub2-snapper-plugin.sh 
- Fallback to old subvol name scheme to support old snapshot config
  (bsc#953538)
  * added grub2-btrfs-07-subvol-fallback.patch

OBS-URL: https://build.opensuse.org/request/show/403817
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=221
2016-06-21 16:44:17 +00:00

47 lines
1.4 KiB
Diff

Index: grub-2.02~beta3/grub-core/fs/btrfs.c
===================================================================
--- grub-2.02~beta3.orig/grub-core/fs/btrfs.c
+++ grub-2.02~beta3/grub-core/fs/btrfs.c
@@ -925,10 +925,40 @@ lookup_root_by_name(struct grub_btrfs_da
}
static grub_err_t
+lookup_root_by_name_fallback(struct grub_btrfs_data *data, const char *path)
+{
+ grub_err_t err;
+ grub_uint64_t tree = 0;
+ grub_uint8_t type;
+ struct grub_btrfs_key key;
+
+ err = find_path (data, path, &key, &tree, &type);
+ if (err)
+ return grub_error(GRUB_ERR_FILE_NOT_FOUND, "couldn't locate %s\n", path);
+
+ if (key.object_id != grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK) || tree == 0)
+ return grub_error(GRUB_ERR_BAD_FILE_TYPE, "%s: not a subvolume\n", path);
+
+ data->fs_tree = tree;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
btrfs_handle_subvol(struct grub_btrfs_data *data __attribute__ ((unused)))
{
if (btrfs_default_subvol)
- return lookup_root_by_name(data, btrfs_default_subvol);
+ {
+ grub_err_t err;
+ err = lookup_root_by_name(data, btrfs_default_subvol);
+
+ /* Fallback to old schemes */
+ if (err == GRUB_ERR_FILE_NOT_FOUND)
+ {
+ err = GRUB_ERR_NONE;
+ return lookup_root_by_name_fallback(data, btrfs_default_subvol);
+ }
+ return err;
+ }
if (btrfs_default_subvolid)
return lookup_root_by_id(data, btrfs_default_subvolid);