nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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