Subject: NetBSD/pmax fsck gets symlinks wrong on Ultrix ffs partitions +GROSS FIX
To: None <>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: port-pmax
Date: 08/22/1994 21:21:21
I followed a suggestion from Chris Demetriou, changing off_t in a
private copy of netbsd's sys/types.h from quad_t to unsigned long, and
compiling an fsck under Ultrix.  I used something like

	bmake -k CC="gcc -nostdinc -I- -I. -I/src/NetBSD/src/include
	-I/src/NetBSD/src/sys -I/src/NetBSD/binaries/pmax
	-I/src/NetBSD/src/sbin/fsck -I/src/NetBSD/src/sys/sys"

where I have my netBSD tree in /src/NetBSD; and I'd made symlinks from
/src/NetBSD/src/sys/arch/pmax/include to
/src/NetBSD/src/sbin/fsck/machine; *and* also made a copy of the
Ultrix stdio in the fsck directory, with the include of sys/types
taken out.

I find that almost works. Thanks for the tip, Crhis!

But the resulting fsck just doesn't work on symlinks. It says it
expects a bunch of inodes - the first two of which appear
to be symlinks -- are size 2 blocks and should be zero,
and tries to correct them. This is clearly wrong: on 4.2 filesystems,
the destination of a soft link is put into direct blocks.
I believe that they're really two blocks --it's an 8k/1k filesystem,
with DEV_BSIZE at 512 bytes. This has the really nasty effect
that if one follow's Adam's suggestion on booting, the
symlink  in /sbin from /init to /bin/init gets trashed..

Some debugging shows that sblock.fs_maxsymlinklen was being set to -1,
presumably from the superblock.  I tried the following (gross) patch,
and it works for me.  Now I can safely, happily mount local
filesystems read-write. Hooray!

(PS: if someone'd remind me what I'm meant to do to remount
  the root partition read-write, I'd be grateful...)

*** src/sbin/fsck/setup.c.DIST	Thu Jun 30 03:31:27 1994
--- src/sbin/fsck/setup.c	Mon Aug 22 21:09:11 1994
*** 181,186 ****
--- 181,194 ----
  		newinofmt = 0;
+ 	 * XXX Apparenlty necessary for Ultrix filesystems with symlinks
+ 	 */
+ 	if (sblock.fs_postblformat == FS_42POSTBLFMT && sblock.fs_maxsymlinklen == -1) {
+ 		pwarn("IMPOSSIBLE IN-INODE SYMINK MAXLEN= %d, set to zero\n",
+ 			sblock.fs_maxsymlinklen);
+ 		sblock.fs_maxsymlinklen = 0;
+ 	}
+ 	/*
  	 * Convert to new inode format.
  	if (cvtlevel >= 2 && sblock.fs_inodefmt < FS_44INODEFMT) {