[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Big endian fixes for btrfs
From: |
Anton Blanchard |
Subject: |
Re: [PATCH] Big endian fixes for btrfs |
Date: |
Mon, 26 Mar 2012 08:10:08 +1100 |
Hi Vladimir,
> object_id is left unconverted on purpose and is converted only on
> comparisons.
Could you be a bit more specific about which byteswapping of object_id
is bad?
Since we always byteswap when doing a comparison, object_ids need to be
created in little endian format:
- key->object_id = GRUB_BTRFS_OBJECT_ID_CHUNK;
+ key->object_id = grub_cpu_to_le64 (GRUB_BTRFS_OBJECT_ID_CHUNK);
Whenever we use the contents of an object, eg as an address for reading
we need to byteswap it to native endian:
- err = grub_btrfs_read_inode (data, &inode, cdirel->key.object_id,
+ err = grub_btrfs_read_inode (data, &inode,
+ grub_le_to_cpu64 (cdirel->key.object_id),
tree);
and
- data->inode = key_in.object_id;
+ data->inode = grub_le_to_cpu64 (key_in.object_id);
Comparisons need to be in native endian:
- if (key_out.object_id != ino
+ if (grub_le_to_cpu64 (key_out.object_id) != ino
Finally we want to print the object_id in native endian or else they
will make no sense:
grub_dprintf ("btrfs",
"leaf (depth %d) %" PRIxGRUB_UINT64_T
" %x %" PRIxGRUB_UINT64_T "\n", depth,
- leaf.key.object_id,leaf.key.type,leaf.key.offset);
+ grub_le_to_cpu64(leaf.key.object_id),leaf.key.type,
+ grub_le_to_cpu64 (leaf.key.offset));
I did test these with your fstest.sh script. Before the changes nothing
passed, after the changes everything passes.
Anton