From: Anton Blanchard <anton@samba.org>
To: grub-devel@gnu.org
Subject: Re: [PATCH] Big endian fixes for btrfs
Date: Mon, 26 Mar 2012 08:10:08 +1100 [thread overview]
Message-ID: <20120326081008.37315b3c@kryten> (raw)
In-Reply-To: <4F6F21F7.90409@gmail.com>
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
next prev parent reply other threads:[~2012-03-25 21:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-25 13:36 [PATCH] Big endian fixes for btrfs Anton Blanchard
2012-03-25 13:47 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-25 21:10 ` Anton Blanchard [this message]
2012-03-25 21:29 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-25 22:20 ` [PATCH v2] " Anton Blanchard
2012-03-31 20:14 ` [PATCH] " Vladimir 'φ-coder/phcoder' Serbinenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120326081008.37315b3c@kryten \
--to=anton@samba.org \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.