Subject: Re: kern/26823: FFS_EI problems
To: None <>
From: Michael L. Hitch <>
List: netbsd-bugs
Date: 10/29/2004 19:34:16
I had just experienced this same problem when trying to get NetBSD
partitions on an amiga disk to mount on a Decstation.  I started sticking
in some debug printfs here and there and found out what was happening.
The filesystem gets mounted fine, with all the superblock stuff swapped,
but no disk inodes were getting swapped.

Further investigation shows that the FS_SWAPPED bit in fs_flags was not
getting set (well, actually it was getting set, but then getting cleared).
The problem is that FS_SWAPPED is set after the superblock values are
swapped, but then ffs_oldfscompat_read() copies fs_old_flags over fs_flags
and the FS_SWAPPED bit is lost.

I tested a couple of different ways to fix this.  One was to set the
FS_SWAPPED bit later in the code where UFS_NEEDSWAP gets set in
ump->um_flags (inside an existing #ifdef FFS_EI).  A second was was to
keep the bits in fs_flags masked by FS_INTENAL merged with the
fs_old_flags in ffs_oldfscompat_read().

The patch for the first method was:

--- sys/ufs/ffs/ffs_vfsops.c    29 May 2004 09:03:56 -0000
+++ sys/ufs/ffs/ffs_vfsops.c    29 Oct 2004 19:24:37 -0000
@@ -925,8 +925,10 @@
        mp->mnt_dev_bshift = DEV_BSHIFT;        /* XXX */
        mp->mnt_flag |= MNT_LOCAL;
 #ifdef FFS_EI
-       if (needswap)
+       if (needswap) {
                ump->um_flags |= UFS_NEEDSWAP;
+               fs->fs_flags |= FS_SWAPPED;
+       }
        ump->um_mountp = mp;
        ump->um_dev = dev;

And the patch for the second was:

--- /c/NetBSD-current/src/sys/ufs/ffs/ffs_vfsops.c      2004-07-06 21:54:15.000000000 -0600
+++ sys/ufs/ffs/ffs_vfsops.c    2004-10-28 10:28:42.000000000 -0600
@@ -1024,7 +1024,7 @@
        fs->fs_csaddr = fs->fs_old_csaddr;
        fs->fs_sblockloc = sblockloc;

-       fs->fs_flags = fs->fs_old_flags;
+       fs->fs_flags = fs->fs_old_flags | (fs->fs_flags & FS_INTERNAL);

        if (fs->fs_old_postblformat == FS_42POSTBLFMT) {
                fs->fs_old_nrpos = 8;

Michael L. Hitch
Computer Consultant
Information Technology Center
Montana State University	Bozeman, MT	USA