dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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