Blame SOURCES/0168-xfs-Convert-inode-numbers-to-cpu-endianity-immediate.patch

d41074
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
a85e8e
From: Jan Kara <jack@suse.cz>
a85e8e
Date: Mon, 14 Jul 2014 17:21:30 +0200
d41074
Subject: [PATCH] xfs: Convert inode numbers to cpu endianity immediately after
d41074
 reading
a85e8e
a85e8e
Currently XFS driver converted inode numbers to native endianity only
a85e8e
when using them to compute inode position. Although this works, it is
a85e8e
somewhat confusing. So convert inode numbers when reading them from disk
a85e8e
structures as every other field.
a85e8e
a85e8e
Signed-off-by: Jan Kara <jack@suse.cz>
a85e8e
---
a85e8e
 grub-core/fs/xfs.c | 13 ++++++-------
a85e8e
 1 file changed, 6 insertions(+), 7 deletions(-)
a85e8e
a85e8e
diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
d41074
index 4bd52d1e081..0d704e9a4d4 100644
a85e8e
--- a/grub-core/fs/xfs.c
a85e8e
+++ b/grub-core/fs/xfs.c
a85e8e
@@ -180,14 +180,14 @@ static inline grub_uint64_t
a85e8e
 GRUB_XFS_INO_INOINAG (struct grub_xfs_data *data,
a85e8e
 		      grub_uint64_t ino)
a85e8e
 {
a85e8e
-  return (grub_be_to_cpu64 (ino) & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1));
a85e8e
+  return (ino & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1));
a85e8e
 }
a85e8e
 
a85e8e
 static inline grub_uint64_t
a85e8e
 GRUB_XFS_INO_AG (struct grub_xfs_data *data,
a85e8e
 		 grub_uint64_t ino)
a85e8e
 {
a85e8e
-  return (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data));
a85e8e
+  return (ino >> GRUB_XFS_INO_AGBITS (data));
a85e8e
 }
a85e8e
 
a85e8e
 static inline grub_disk_addr_t
a85e8e
@@ -506,13 +506,12 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
a85e8e
 	if (smallino)
a85e8e
 	  {
a85e8e
 	    parent = grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4);
a85e8e
-	    parent = grub_cpu_to_be64 (parent);
a85e8e
 	    /* The header is a bit smaller than usual.  */
a85e8e
 	    de = (struct grub_xfs_dir_entry *) ((char *) de - 4);
a85e8e
 	  }
a85e8e
 	else
a85e8e
 	  {
a85e8e
-	    parent = diro->inode.data.dir.dirhead.parent.i8;
a85e8e
+	    parent = grub_be_to_cpu64(diro->inode.data.dir.dirhead.parent.i8);
a85e8e
 	  }
a85e8e
 
a85e8e
 	/* Synthesize the direntries for `.' and `..'.  */
a85e8e
@@ -545,7 +544,6 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
a85e8e
 		| (((grub_uint64_t) inopos[5]) << 16)
a85e8e
 		| (((grub_uint64_t) inopos[6]) << 8)
a85e8e
 		| (((grub_uint64_t) inopos[7]) << 0);
a85e8e
-	    ino = grub_cpu_to_be64 (ino);
a85e8e
 
a85e8e
 	    c = de->name[de->len];
a85e8e
 	    de->name[de->len] = '\0';
a85e8e
@@ -627,7 +625,8 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
a85e8e
 		   is not used by GRUB.  So it can be overwritten.  */
a85e8e
 		filename[direntry->len] = '\0';
a85e8e
 
a85e8e
-		if (iterate_dir_call_hook (direntry->inode, filename, &ctx))
a85e8e
+		if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode), 
a85e8e
+					   filename, &ctx))
a85e8e
 		  {
a85e8e
 		    grub_free (dirblock);
a85e8e
 		    return 1;
a85e8e
@@ -689,7 +688,7 @@ grub_xfs_mount (grub_disk_t disk)
a85e8e
     goto fail;
a85e8e
 
a85e8e
   data->diropen.data = data;
a85e8e
-  data->diropen.ino = data->sblock.rootino;
a85e8e
+  data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino);
a85e8e
   data->diropen.inode_read = 1;
a85e8e
   data->bsize = grub_be_to_cpu32 (data->sblock.bsize);
a85e8e
   data->agsize = grub_be_to_cpu32 (data->sblock.agsize);