nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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