Received: from list by lists.gnu.org with archive (Exim 4.71) id 1SBuhe-00086l-9F for mharc-grub-devel@gnu.org; Sun, 25 Mar 2012 17:10:18 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBuhb-00086K-1n for grub-devel@gnu.org; Sun, 25 Mar 2012 17:10:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SBuhZ-00025v-8C for grub-devel@gnu.org; Sun, 25 Mar 2012 17:10:14 -0400 Received: from ozlabs.org ([203.10.76.45]:54386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBuhY-00025f-T0 for grub-devel@gnu.org; Sun, 25 Mar 2012 17:10:13 -0400 Received: from kryten (ppp121-44-32-91.lns20.syd6.internode.on.net [121.44.32.91]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id 61700B6EEC for ; Mon, 26 Mar 2012 08:10:09 +1100 (EST) Date: Mon, 26 Mar 2012 08:10:08 +1100 From: Anton Blanchard To: grub-devel@gnu.org Subject: Re: [PATCH] Big endian fixes for btrfs Message-ID: <20120326081008.37315b3c@kryten> In-Reply-To: <4F6F21F7.90409@gmail.com> References: <20120326003636.38c4fdd5@kryten> <4F6F21F7.90409@gmail.com> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.24.4; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 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: Sun, 25 Mar 2012 21:10:16 -0000 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