From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ys2ee-0007o6-W1 for mharc-grub-devel@gnu.org; Tue, 12 May 2015 01:22:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys2ec-0007nJ-50 for grub-devel@gnu.org; Tue, 12 May 2015 01:22:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ys2eY-0000lW-Qj for grub-devel@gnu.org; Tue, 12 May 2015 01:22:54 -0400 Received: from mail-la0-x235.google.com ([2a00:1450:4010:c03::235]:34877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys2eY-0000lS-Ir for grub-devel@gnu.org; Tue, 12 May 2015 01:22:50 -0400 Received: by labbd9 with SMTP id bd9so108682540lab.2 for ; Mon, 11 May 2015 22:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=fcdeGRFsw0JpdYBx7WbA2X9ivJh3rLZNgtGUeSuwDHE=; b=iQjHkcV9neUMyicNgdpq8JXEWUO0AQkoYN6K0URrmnYl7aAMnaROW8Wgs2nJ50DGw3 FeR5tsKSgSch5QABp7OBd6bQBHCQb7KhAO1ycRjhCKVbqt3B4AxXWdYOWw6x6fghEcnf XRxAwlxi9EMgdHZIiSi9b4CcRiFsi3vAazFvcaD1X5+m3YifdFuReM9Lri1/65BWM1ru W2Lgs3d7yZW/0jiUx0/VAH/r6/IUJyzh2cpyohDu1jMUnOmX/AHSrHVxkkdLXblJNqPS QPz+J3gNBJH748OINuDec19pHJ0Lp3wnE0OxiYf6YYoPdbD+tAtTw+GVN7A1AVobSCzm UM3w== X-Received: by 10.152.88.80 with SMTP id be16mr10497227lab.39.1431408169857; Mon, 11 May 2015 22:22:49 -0700 (PDT) Received: from opensuse.site (ppp91-76-14-38.pppoe.mtu-net.ru. [91.76.14.38]) by mx.google.com with ESMTPSA id dc7sm1679927lac.0.2015.05.11.22.22.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2015 22:22:48 -0700 (PDT) Date: Tue, 12 May 2015 08:22:47 +0300 From: Andrei Borzenkov To: Jan Kara Subject: Re: [PATCH 3/4] xfs: Convert inode numbers to cpu endianity immediately after reading Message-ID: <20150512082247.63841ed9@opensuse.site> In-Reply-To: <1405351291-24767-4-git-send-email-jack@suse.cz> References: <1405351291-24767-1-git-send-email-jack@suse.cz> <1405351291-24767-4-git-send-email-jack@suse.cz> X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.27; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::235 Cc: grub-devel@gnu.org 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: Tue, 12 May 2015 05:22:55 -0000 =D0=92 Mon, 14 Jul 2014 17:21:30 +0200 Jan Kara =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > Currently XFS driver converted inode numbers to native endianity only > when using them to compute inode position. Although this works, it is > somewhat confusing. So convert inode numbers when reading them from disk > structures as every other field. >=20 Not sure whether it is better, but committed to avoid risk breaking followup patch. > Signed-off-by: Jan Kara > --- > grub-core/fs/xfs.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) >=20 > diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c > index ef3bc787e968..7e247a32df5c 100644 > --- a/grub-core/fs/xfs.c > +++ b/grub-core/fs/xfs.c > @@ -180,14 +180,14 @@ static inline grub_uint64_t > GRUB_XFS_INO_INOINAG (struct grub_xfs_data *data, > grub_uint64_t ino) > { > - return (grub_be_to_cpu64 (ino) & ((1LL << GRUB_XFS_INO_AGBITS (data)) = - 1)); > + return (ino & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1)); > } > =20 > static inline grub_uint64_t > GRUB_XFS_INO_AG (struct grub_xfs_data *data, > grub_uint64_t ino) > { > - return (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data)); > + return (ino >> GRUB_XFS_INO_AGBITS (data)); > } > =20 > static inline grub_disk_addr_t > @@ -511,13 +511,12 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, > if (smallino) > { > parent =3D grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4= ); > - parent =3D grub_cpu_to_be64 (parent); > /* The header is a bit smaller than usual. */ > de =3D (struct grub_xfs_dir_entry *) ((char *) de - 4); > } > else > { > - parent =3D diro->inode.data.dir.dirhead.parent.i8; > + parent =3D grub_be_to_cpu64(diro->inode.data.dir.dirhead.parent.i8); > } > =20 > /* Synthesize the direntries for `.' and `..'. */ > @@ -550,7 +549,6 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, > | (((grub_uint64_t) inopos[5]) << 16) > | (((grub_uint64_t) inopos[6]) << 8) > | (((grub_uint64_t) inopos[7]) << 0); > - ino =3D grub_cpu_to_be64 (ino); > =20 > c =3D de->name[de->len]; > de->name[de->len] =3D '\0'; > @@ -632,7 +630,8 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, > is not used by GRUB. So it can be overwritten. */ > filename[direntry->len] =3D '\0'; > =20 > - if (iterate_dir_call_hook (direntry->inode, filename, &ctx)) > + if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode),=20 > + filename, &ctx)) > { > grub_free (dirblock); > return 1; > @@ -694,7 +693,7 @@ grub_xfs_mount (grub_disk_t disk) > goto fail; > =20 > data->diropen.data =3D data; > - data->diropen.ino =3D data->sblock.rootino; > + data->diropen.ino =3D grub_be_to_cpu64(data->sblock.rootino); > data->diropen.inode_read =3D 1; > data->bsize =3D grub_be_to_cpu32 (data->sblock.bsize); > data->agsize =3D grub_be_to_cpu32 (data->sblock.agsize);