Subject: UFS and byteswapping.
To: None <tech-kern@netbsd.org>
From: Pawel Jakub Dawidek <pjd@FreeBSD.org>
List: tech-kern
Date: 01/26/2007 16:33:27
--9UV9rz0O2dU/yYYn
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hi.
I'm looking at NetBSD changes to make UFS usable on architectures with
different endianess than the one on which file system was created.
I found one bug I think and I'm looking for confirmation.
In ufs_dirremove() function one may find:
#ifdef UFS_DIRHASH
/*
* Remove the dirhash entry. This is complicated by the fact
* that `ep' is the previous entry when dp->i_count !=3D 0.
*/
if (dp->i_dirhash !=3D NULL)
ufsdirhash_remove(dp, (dp->i_count =3D=3D 0) ? ep :
(struct direct *)((char *)ep + ep->d_reclen), dp->i_offset);
#endif
If my understanding is correct, ep->d_reclen should be replaced with
ufs_rw16(ep->d_reclen).
The one below is not really an issue, but... Code from ufs_direnter():
dsize =3D ufs_rw32(ep->d_ino, needswap) ?
DIRSIZ(FSFMT(dvp), ep, needswap) : 0;
I've seen many places where you assume that bswap(0) is 0, so I think
ufs_rw32() can be eliminated:
dsize =3D ep->d_ino ? DIRSIZ(FSFMT(dvp), ep, needswap) : 0;
--=20
Pawel Jakub Dawidek http://www.wheel.pl
pjd@FreeBSD.org http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!
--9UV9rz0O2dU/yYYn
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (FreeBSD)
iD8DBQFFuh9HForvXbEpPzQRAtrMAJ4n3mZUPvFwaY5Xz9ig4FQafNDuRACfUeZJ
F/d9XJR9VRL2K37yH7Jg18k=
=vceY
-----END PGP SIGNATURE-----
--9UV9rz0O2dU/yYYn--