SHA256
1
0
forked from pool/grub2

Accepting request 312487 from home:michael-chang:grub2-BE-fix

- Fix btrfs subvol detection on BigEndian systems (bsc#933541)
  * modified grub2-btrfs-06-subvol-mount.patch
- Fix grub2-mkrelpath outputs wrong path on BigEndian system
  * added grub2-getroot-fix-get-btrfs-fs-prefix-big-endian.patch

OBS-URL: https://build.opensuse.org/request/show/312487
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=169
This commit is contained in:
Andrei Borzenkov 2015-06-18 18:53:54 +00:00 committed by Git OBS Bridge
parent eae0d17794
commit edf621776c
4 changed files with 48 additions and 9 deletions

View File

@ -283,7 +283,7 @@ Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c
struct btrfs_ioctl_search_args {
struct btrfs_ioctl_search_key key;
grub_uint64_t buf[(4096 - sizeof(struct btrfs_ioctl_search_key))
@@ -366,6 +374,105 @@ get_btrfs_fs_prefix (const char *mount_p
@@ -366,6 +374,109 @@ get_btrfs_fs_prefix (const char *mount_p
int use_relative_path_on_btrfs = 0;
@ -314,6 +314,8 @@ Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c
+ struct grub_btrfs_root_backref *br;
+ struct btrfs_ioctl_search_header *search_header;
+ char *old;
+ grub_uint16_t len;
+ grub_uint64_t inode_id;
+
+ memset (&sargs, 0, sizeof(sargs));
+
@ -339,20 +341,22 @@ Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c
+ search_header = (struct btrfs_ioctl_search_header *)sargs.buf;
+ br = (struct grub_btrfs_root_backref *) (search_header + 1);
+
+ len = grub_le_to_cpu16 (br->n);
+ inode_id = grub_le_to_cpu64 (br->inode_id);
+ tree_id = search_header->offset;
+
+ old = ret;
+ ret = malloc (br->n + 1);
+ memcpy (ret, br->name, br->n);
+ ret[br->n] = '\0';
+ ret = malloc (len + 1);
+ memcpy (ret, br->name, len);
+ ret[len] = '\0';
+
+ if (br->inode_id != GRUB_BTRFS_TREE_ROOT_OBJECTID)
+ if (inode_id != GRUB_BTRFS_TREE_ROOT_OBJECTID)
+ {
+ char *s;
+
+ memset(&args, 0, sizeof(args));
+ args.treeid = search_header->offset;
+ args.objectid = br->inode_id;
+ args.objectid = inode_id;
+
+ if (ioctl (fd, BTRFS_IOC_INO_LOOKUP, &args) < 0)
+ goto error;
@ -389,7 +393,7 @@ Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c
char **
grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
{
@@ -502,12 +609,15 @@ grub_find_root_devices_from_mountinfo (c
@@ -502,12 +613,15 @@ grub_find_root_devices_from_mountinfo (c
else if (grub_strcmp (entries[i].fstype, "btrfs") == 0)
{
ret = grub_find_root_devices_from_btrfs (dir);
@ -408,7 +412,7 @@ Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c
}
}
if (!ret)
@@ -1094,6 +1204,34 @@ grub_util_get_grub_dev_os (const char *o
@@ -1094,6 +1208,34 @@ grub_util_get_grub_dev_os (const char *o
return grub_dev;
}

View File

@ -0,0 +1,25 @@
Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/osdep/linux/getroot.c
+++ grub-2.02~beta2/grub-core/osdep/linux/getroot.c
@@ -324,9 +324,9 @@ get_btrfs_fs_prefix (const char *mount_p
tree_id = sargs.buf[2];
br = (struct grub_btrfs_root_backref *) (sargs.buf + 4);
- inode_id = br->inode_id;
+ inode_id = grub_le_to_cpu64 (br->inode_id);
name = br->name;
- namelen = br->n;
+ namelen = grub_le_to_cpu16 (br->n);
}
else
{
@@ -353,7 +353,7 @@ get_btrfs_fs_prefix (const char *mount_p
ir = (struct grub_btrfs_inode_ref *) (sargs.buf + 4);
name = ir->name;
- namelen = ir->n;
+ namelen = grub_le_to_cpu16 (ir->n);
}
old = ret;
ret = xmalloc (namelen + (old ? strlen (old) : 0) + 2);

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Jun 18 08:43:07 UTC 2015 - mchang@suse.com
- Fix btrfs subvol detection on BigEndian systems (bsc#933541)
* modified grub2-btrfs-06-subvol-mount.patch
- Fix grub2-mkrelpath outputs wrong path on BigEndian system
* added grub2-getroot-fix-get-btrfs-fs-prefix-big-endian.patch
-------------------------------------------------------------------
Fri Jun 12 07:20:00 UTC 2015 - mchang@suse.com

View File

@ -1,7 +1,7 @@
#
# spec file for package grub2
#
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -199,6 +199,7 @@ Patch65: grub2-mkconfig-aarch64.patch
Patch66: grub2-glibc-2.20.patch
Patch67: grub2-Initialized-initrd_ctx-so-we-don-t-free-a-random-poi.patch
Patch68: grub2-btrfs-fix-get_root-key-comparison-failures-due-to-en.patch
Patch69: grub2-getroot-fix-get-btrfs-fs-prefix-big-endian.patch
# Btrfs snapshot booting related patches
Patch101: grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
Patch102: grub2-btrfs-02-export-subvolume-envvars.patch
@ -445,6 +446,7 @@ mv po/grub.pot po/%{name}.pot
%patch66 -p1
%patch67 -p1
%patch68 -p1
%patch69 -p1
%patch101 -p1
%patch102 -p1
%patch103 -p1