Fix missing byte order conversion in get_btrfs_fs_prefix function
PATCH 1/1 Fix missing byte order conversion in get_btrfs_fs_prefix function
Since btrfs on-disk format uses little-endian, the searched item types (ROOT_REF, INODE_REF) need converting the byte order in order to function properly on big-endian systems.
--- grub-core/osdep/linux/getroot.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
grub-core/osdep/linux/getroot.c +3 -3
@@ -316,9 +316,9 @@ get_btrfs_fs_prefix (const char *mount_path) 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 {
@@ -345,7 +345,7 @@ get_btrfs_fs_prefix (const char *mount_path) 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 );
Signature · 1 line
1.7.3.4
Andrei Borzenkov
AppliedВ Mon, 22 Jun 2015 16:45:27 +0800
Michael Chang <[email protected]> пишет:
Quoted 3 lines
Since btrfs on-disk format uses little-endian, the searched item types (
ROOT_REF,INODE_REF) need converting the byte order in order to function properly on big-endian systems.
Applied. Thanks!
Quoted 29 lines
--- grub-core/osdep/linux/getroot.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)grub-core/osdep/linux/getroot.c +3
-3@@ -316,9 +316,9 @@ get_btrfs_fs_prefix (const char *mount_path) 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 {@@ -345,7 +345,7 @@ get_btrfs_fs_prefix (const char *mount_path) 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 );