dumpfs: don't pick alternate superblock

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

dumpfs: don't pick alternate superblock

Otto Moerbeek
Hi,

If the block size is 64k, the first alternate ffs1 superblock ends up
in a location first looked at by dumpfs.

fsck_ffs(8) (see setup.c) and ffs_mountfs() in
sys/ufs/ffs/ffs_vfsops.c have protection against that case, since we
really want the primary superblock, that's the one that is actually
updated when a fs is used.

So also do that in dumpfs(8).

OK?

        -Otto

Index: dumpfs.c
===================================================================
RCS file: /cvs/src/sbin/dumpfs/dumpfs.c,v
retrieving revision 1.34
diff -u -p -r1.34 dumpfs.c
--- dumpfs.c 28 Jun 2019 13:32:43 -0000 1.34
+++ dumpfs.c 16 Feb 2020 12:24:31 -0000
@@ -139,6 +139,8 @@ open_disk(const char *name)
  if (n == SBLOCKSIZE && (afs.fs_magic == FS_UFS1_MAGIC ||
     (afs.fs_magic == FS_UFS2_MAGIC &&
     afs.fs_sblockloc == sbtry[i])) &&
+    !(afs.fs_magic == FS_UFS1_MAGIC &&
+    sbtry[i] == SBLOCK_UFS2) &&
     afs.fs_bsize <= MAXBSIZE &&
     afs.fs_bsize >= sizeof(struct fs))
  break;