From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1X6i4e-0003OP-Jk for mharc-grub-devel@gnu.org; Mon, 14 Jul 2014 11:21:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6i4W-0003If-7Z for grub-devel@gnu.org; Mon, 14 Jul 2014 11:21:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6i4P-00085z-9v for grub-devel@gnu.org; Mon, 14 Jul 2014 11:21:44 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44316 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6i4P-00084V-3G for grub-devel@gnu.org; Mon, 14 Jul 2014 11:21:37 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id ED365AC47 for ; Mon, 14 Jul 2014 15:21:34 +0000 (UTC) Received: by quack.suse.cz (Postfix, from userid 1000) id 7647C81EDD; Mon, 14 Jul 2014 17:21:33 +0200 (CEST) From: Jan Kara To: grub-devel@gnu.org Subject: [PATCH 3/4] xfs: Convert inode numbers to cpu endianity immediately after reading Date: Mon, 14 Jul 2014 17:21:30 +0200 Message-Id: <1405351291-24767-4-git-send-email-jack@suse.cz> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1405351291-24767-1-git-send-email-jack@suse.cz> References: <1405351291-24767-1-git-send-email-jack@suse.cz> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Cc: Jan Kara X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jul 2014 15:21:51 -0000 Currently XFS driver converted inode numbers to native endianity only when using them to compute inode position. Although this works, it is somewhat confusing. So convert inode numbers when reading them from disk structures as every other field. Signed-off-by: Jan Kara --- grub-core/fs/xfs.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index ef3bc787e968..7e247a32df5c 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -180,14 +180,14 @@ static inline grub_uint64_t GRUB_XFS_INO_INOINAG (struct grub_xfs_data *data, grub_uint64_t ino) { - return (grub_be_to_cpu64 (ino) & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1)); + return (ino & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1)); } static inline grub_uint64_t GRUB_XFS_INO_AG (struct grub_xfs_data *data, grub_uint64_t ino) { - return (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data)); + return (ino >> GRUB_XFS_INO_AGBITS (data)); } static inline grub_disk_addr_t @@ -511,13 +511,12 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, if (smallino) { parent = grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4); - parent = grub_cpu_to_be64 (parent); /* The header is a bit smaller than usual. */ de = (struct grub_xfs_dir_entry *) ((char *) de - 4); } else { - parent = diro->inode.data.dir.dirhead.parent.i8; + parent = grub_be_to_cpu64(diro->inode.data.dir.dirhead.parent.i8); } /* Synthesize the direntries for `.' and `..'. */ @@ -550,7 +549,6 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, | (((grub_uint64_t) inopos[5]) << 16) | (((grub_uint64_t) inopos[6]) << 8) | (((grub_uint64_t) inopos[7]) << 0); - ino = grub_cpu_to_be64 (ino); c = de->name[de->len]; de->name[de->len] = '\0'; @@ -632,7 +630,8 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, is not used by GRUB. So it can be overwritten. */ filename[direntry->len] = '\0'; - if (iterate_dir_call_hook (direntry->inode, filename, &ctx)) + if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode), + filename, &ctx)) { grub_free (dirblock); return 1; @@ -694,7 +693,7 @@ grub_xfs_mount (grub_disk_t disk) goto fail; data->diropen.data = data; - data->diropen.ino = data->sblock.rootino; + data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino); data->diropen.inode_read = 1; data->bsize = grub_be_to_cpu32 (data->sblock.bsize); data->agsize = grub_be_to_cpu32 (data->sblock.agsize); -- 1.8.1.4