]> TLD Linux GIT Repositories - packages/grub2.git/blob - grub2-xfs-Convert-inode-numbers-to-cpu-endianity-immediate.patch
- partial PLD merge
[packages/grub2.git] / grub2-xfs-Convert-inode-numbers-to-cpu-endianity-immediate.patch
1 From 57ae4073cc28fa74014a62aca397a40ce1f73763 Mon Sep 17 00:00:00 2001
2 From: Jan Kara <jack@suse.cz>
3 Date: Thu, 12 Jun 2014 11:01:11 +0200
4 Subject: [PATCH 3/4] xfs: Convert inode numbers to cpu endianity immediately
5  after reading
6
7 Currently XFS driver converted inode numbers to native endianity only
8 when using them to compute inode position. Although this works, it is
9 somewhat confusing. So convert inode numbers when reading them from disk
10 structures as every other field.
11
12 Signed-off-by: Jan Kara <jack@suse.cz>
13 ---
14  grub-core/fs/xfs.c | 13 ++++++-------
15  1 file changed, 6 insertions(+), 7 deletions(-)
16
17 diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
18 index ef3bc787e968..7e247a32df5c 100644
19 --- a/grub-core/fs/xfs.c
20 +++ b/grub-core/fs/xfs.c
21 @@ -180,14 +180,14 @@ static inline grub_uint64_t
22  GRUB_XFS_INO_INOINAG (struct grub_xfs_data *data,
23                       grub_uint64_t ino)
24  {
25 -  return (grub_be_to_cpu64 (ino) & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1));
26 +  return (ino & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1));
27  }
28  
29  static inline grub_uint64_t
30  GRUB_XFS_INO_AG (struct grub_xfs_data *data,
31                  grub_uint64_t ino)
32  {
33 -  return (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data));
34 +  return (ino >> GRUB_XFS_INO_AGBITS (data));
35  }
36  
37  static inline grub_disk_addr_t
38 @@ -511,13 +511,12 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
39         if (smallino)
40           {
41             parent = grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4);
42 -           parent = grub_cpu_to_be64 (parent);
43             /* The header is a bit smaller than usual.  */
44             de = (struct grub_xfs_dir_entry *) ((char *) de - 4);
45           }
46         else
47           {
48 -           parent = diro->inode.data.dir.dirhead.parent.i8;
49 +           parent = grub_be_to_cpu64(diro->inode.data.dir.dirhead.parent.i8);
50           }
51  
52         /* Synthesize the direntries for `.' and `..'.  */
53 @@ -550,7 +549,6 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
54                 | (((grub_uint64_t) inopos[5]) << 16)
55                 | (((grub_uint64_t) inopos[6]) << 8)
56                 | (((grub_uint64_t) inopos[7]) << 0);
57 -           ino = grub_cpu_to_be64 (ino);
58  
59             c = de->name[de->len];
60             de->name[de->len] = '\0';
61 @@ -632,7 +630,8 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
62                    is not used by GRUB.  So it can be overwritten.  */
63                 filename[direntry->len] = '\0';
64  
65 -               if (iterate_dir_call_hook (direntry->inode, filename, &ctx))
66 +               if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode), 
67 +                                          filename, &ctx))
68                   {
69                     grub_free (dirblock);
70                     return 1;
71 @@ -694,7 +693,7 @@ grub_xfs_mount (grub_disk_t disk)
72      goto fail;
73  
74    data->diropen.data = data;
75 -  data->diropen.ino = data->sblock.rootino;
76 +  data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino);
77    data->diropen.inode_read = 1;
78    data->bsize = grub_be_to_cpu32 (data->sblock.bsize);
79    data->agsize = grub_be_to_cpu32 (data->sblock.agsize);
80 -- 
81 1.8.1.4
82