Subject: Re: UFS and byteswapping.
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: tech-kern
Date: 01/27/2007 23:56:31
In article <20070126153327.GD62666@garage.freebsd.pl>,
Pawel Jakub Dawidek  <pjd@FreeBSD.org> wrote:
>-=-=-=-=-=-
>
>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 != 0.
>	 */
>	if (dp->i_dirhash != NULL)
>		ufsdirhash_remove(dp, (dp->i_count == 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 = 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 = ep->d_ino ? DIRSIZ(FSFMT(dvp), ep, needswap) : 0;
>

I think you are right, but I am not sure. The code is too confusing for
me.

christos