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