Subject: hacking dumpfs to show fs level (to solve [bin/1353])
To: None <tech-userlevel@NetBSD.ORG>
From: Luke Mewburn <lukem@connect.com.au>
List: tech-userlevel
Date: 04/18/1997 16:22:42
PR bin/1353 mentions that it's difficult to determine the filesystem
level from dumpfs. This is the level that fsck upgrades a filesystem
to with the "-c" flag.

Here's a patch do to what I think is the correct thing. However, I
don't have anything < level 3 to test it on.

Does anyone out there have an old sunos or ultrix partition that's
probably level 0 or level 1 to test this on?

Just run "dumpfs <rawpartition> | head -20" and have a look.

Things to determine if it's doing the correct thing:

level		message
-----		-------
0		cylgrp static   inodes 4.2/4.3BSD  level 0
1		cylgrp dynamic  inodes 4.2/4.3BSD  level 1
2		cylgrp dynamic  inodes 4.4BSD      level 2
3		cylgrp dynamic  inodes 4.4BSD      level 3

(From reading the source to fsck_ffs(1) I think the difference
 between level 2 & level 3 has to do with the settings of
 maxcontig and contigsize)

I'd like to commit this if this does the right thing, so if you have
some old filesystems, or have access to them via COMPAT_xxx mode,
could you run this patch and see how it goes? Thanks.



Index: dumpfs.c
===================================================================
RCS file: /cvsroot/src/sbin/dumpfs/dumpfs.c,v
retrieving revision 1.11
diff -c -r1.11 dumpfs.c
*** dumpfs.c	1996/01/09 21:23:36	1.11
--- dumpfs.c	1997/04/18 03:45:06
***************
*** 134,142 ****
  	dev_bsize = afs.fs_fsize / fsbtodb(&afs, 1);
  	printf("magic\t%x\ttime\t%s", afs.fs_magic,
  	    ctime(&afs.fs_time));
! 	printf("cylgrp\t%s\tinodes\t%s\n",
! 	    afs.fs_postblformat == FS_42POSTBLFMT ? "static" : "dynamic",
! 	    afs.fs_inodefmt < FS_44INODEFMT ? "4.2/4.3BSD" : "4.4BSD");
  	printf("nbfree\t%d\tndir\t%d\tnifree\t%d\tnffree\t%d\n",
  	    afs.fs_cstotal.cs_nbfree, afs.fs_cstotal.cs_ndir,
  	    afs.fs_cstotal.cs_nifree, afs.fs_cstotal.cs_nffree);
--- 134,155 ----
  	dev_bsize = afs.fs_fsize / fsbtodb(&afs, 1);
  	printf("magic\t%x\ttime\t%s", afs.fs_magic,
  	    ctime(&afs.fs_time));
! 	i = 0;
! 	if (afs.fs_postblformat != FS_42POSTBLFMT) {
! 		i++;
! 		if (afs.fs_inodefmt >= FS_44INODEFMT) {
! 			int max, siz;
! 
! 			i++;
! 			max = afs.fs_maxcontig;
! 			size = afs.fs_contigsumsize;
! 			if ((max < 2 && size == 0)
! 			    || (max > 1 && size >= MIN(max, FS_MAXCONTIG)))
! 				i++;
! 		}
! 	}
! 	printf("cylgrp\t%s\tinodes\t%s\tfslevel %d\n",
! 	    i < 1 ? "static" : "dynamic", i < 2 ? "4.2/4.3BSD" : "4.4BSD", i);
  	printf("nbfree\t%d\tndir\t%d\tnifree\t%d\tnffree\t%d\n",
  	    afs.fs_cstotal.cs_nbfree, afs.fs_cstotal.cs_ndir,
  	    afs.fs_cstotal.cs_nifree, afs.fs_cstotal.cs_nffree);