From b523d3b06f454471cbd1a8c5607d2a6f6375f7a1 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Sun, 27 Jan 2019 22:51:50 +0100
Subject: [PATCH 2/3] makefs(8): DragonFly porting.

---
 sbin/newfs/newfs.8                         |   3 +-
 usr.sbin/Makefile                          |   1 +
 usr.sbin/makefs/Makefile                   |  29 +--
 usr.sbin/makefs/cd9660.c                   |   6 +-
 usr.sbin/makefs/cd9660/Makefile.inc        |   4 +-
 usr.sbin/makefs/cd9660/cd9660_archimedes.c |   5 +-
 usr.sbin/makefs/cd9660/cd9660_conversion.c |   5 +-
 usr.sbin/makefs/cd9660/cd9660_debug.c      |   4 +-
 usr.sbin/makefs/cd9660/cd9660_eltorito.c   |  10 +-
 usr.sbin/makefs/cd9660/cd9660_strings.c    |   4 +-
 usr.sbin/makefs/cd9660/cd9660_write.c      |   5 +-
 usr.sbin/makefs/cd9660/iso9660_rrip.c      |   5 +-
 usr.sbin/makefs/ffs.c                      | 145 ++---------
 usr.sbin/makefs/ffs.h                      |  19 +-
 usr.sbin/makefs/ffs/Makefile.inc           |   2 +-
 usr.sbin/makefs/ffs/buf.c                  |   9 +-
 usr.sbin/makefs/ffs/buf.h                  |   8 +-
 usr.sbin/makefs/ffs/ffs_alloc.c            | 101 +++-----
 usr.sbin/makefs/ffs/ffs_balloc.c           | 265 +--------------------
 usr.sbin/makefs/ffs/ffs_bswap.c            |  84 ++-----
 usr.sbin/makefs/ffs/ffs_extern.h           |  12 +-
 usr.sbin/makefs/ffs/ffs_subr.c             |   4 +-
 usr.sbin/makefs/ffs/mkfs.c                 | 234 +++++++-----------
 usr.sbin/makefs/ffs/newfs_extern.h         |   4 +-
 usr.sbin/makefs/ffs/ufs_bmap.c             |   8 +-
 usr.sbin/makefs/ffs/ufs_inode.h            |  26 +-
 usr.sbin/makefs/makefs.8                   |   7 +-
 usr.sbin/makefs/makefs.c                   |   9 +-
 usr.sbin/makefs/makefs.h                   |   5 +-
 usr.sbin/makefs/mtree.c                    |   5 +-
 usr.sbin/makefs/walk.c                     |  15 +-
 31 files changed, 248 insertions(+), 795 deletions(-)

diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8
index 5000ad42a4..fd82da46ec 100644
--- a/sbin/newfs/newfs.8
+++ b/sbin/newfs/newfs.8
@@ -28,7 +28,7 @@
 .\"     @(#)newfs.8	8.6 (Berkeley) 5/3/95
 .\" $FreeBSD: src/sbin/newfs/newfs.8,v 1.26.2.15 2003/05/13 12:16:08 joerg Exp $
 .\"
-.Dd September 29, 2016
+.Dd January 27, 2019
 .Dt NEWFS 8
 .Os
 .Sh NAME
@@ -406,6 +406,7 @@ and
 .Xr disklabel 8 ,
 .Xr dumpfs 8 ,
 .Xr fsck 8 ,
+.Xr makefs 8 ,
 .Xr mount 8 ,
 .Xr tunefs 8 ,
 .Xr vinum 8
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index d3fbd8efe2..06a80c3b45 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -55,6 +55,7 @@ SUBDIR= 802_11 \
 	keyserv \
 	lastlogin \
 	mailwrapper \
+	makefs \
 	makewhatis \
 	manctl \
 	memcontrol \
diff --git a/usr.sbin/makefs/Makefile b/usr.sbin/makefs/Makefile
index 7987440cc3..bfcb873d4d 100644
--- a/usr.sbin/makefs/Makefile
+++ b/usr.sbin/makefs/Makefile
@@ -1,12 +1,8 @@
 #	$FreeBSD: head/usr.sbin/makefs/Makefile 332844 2018-04-20 22:23:38Z emaste $
 
-SRCDIR:=${.PARSEDIR:tA}
-
-.include <src.opts.mk>
-
 PROG=	makefs
 
-CFLAGS+=-I${SRCDIR}
+CFLAGS+=-I${.CURDIR}
 
 SRCS=	cd9660.c ffs.c \
 	makefs.c \
@@ -16,23 +12,20 @@ MAN=	makefs.8
 
 WARNS?=	2
 
-.include "${SRCDIR}/cd9660/Makefile.inc"
-.include "${SRCDIR}/ffs/Makefile.inc"
+.include "${.CURDIR}/cd9660/Makefile.inc"
+.include "${.CURDIR}/ffs/Makefile.inc"
 
 CFLAGS+=-DHAVE_STRUCT_STAT_ST_FLAGS=1
 
-.PATH: ${SRCTOP}/contrib/mtree
-CFLAGS+=-I${SRCTOP}/contrib/mtree
-SRCS+=	getid.c misc.c spec.c
-
-.PATH: ${SRCTOP}/contrib/mknod
-CFLAGS+=-I${SRCTOP}/contrib/mknod
-SRCS+=	pack_dev.c
+.PATH: ${.CURDIR}/../mtree
+CFLAGS+=-I${.CURDIR}/../mtree
+SRCS+=	getid.c misc.c pack_dev.c spec.c stat_flags.c
 
-CFLAGS+=	-I${SRCTOP}/lib/libnetbsd
-LIBADD=		netbsd util sbuf
+DPADD=	${LIBUTIL} ${LIBSBUF}
+LDADD=	-lutil -lsbuf
 
-HAS_TESTS=
-SUBDIR.${MK_TESTS}+= tests
+#.if ${MK_TESTS} != "no"
+#SUBDIR+=	tests
+#.endif
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index 67c0f5b45f..e48f2d076d 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -95,10 +95,8 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
-  */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/cd9660.c 331843 2018-03-31 15:04:41Z benno $");
+ * $FreeBSD: head/usr.sbin/makefs/cd9660.c 331843 2018-03-31 15:04:41Z benno $
+ */
 
 #include <sys/param.h>
 #include <sys/queue.h>
diff --git a/usr.sbin/makefs/cd9660/Makefile.inc b/usr.sbin/makefs/cd9660/Makefile.inc
index 2d3e934fa1..adf0e42e8e 100644
--- a/usr.sbin/makefs/cd9660/Makefile.inc
+++ b/usr.sbin/makefs/cd9660/Makefile.inc
@@ -1,9 +1,9 @@
 #	$FreeBSD: head/usr.sbin/makefs/cd9660/Makefile.inc 332844 2018-04-20 22:23:38Z emaste $
 #
 
-.PATH:	${SRCDIR}/cd9660
+.PATH:	${.CURDIR}/cd9660
 
-CFLAGS+=-I${SRCTOP}/sys/fs/cd9660/
+CFLAGS+=-I${.CURDIR}/../../sys/vfs/isofs/cd9660/
 
 SRCS+=	cd9660_strings.c cd9660_debug.c cd9660_eltorito.c \
 	cd9660_write.c cd9660_conversion.c iso9660_rrip.c cd9660_archimedes.c
diff --git a/usr.sbin/makefs/cd9660/cd9660_archimedes.c b/usr.sbin/makefs/cd9660/cd9660_archimedes.c
index a6e2d86f11..d3eda19f47 100644
--- a/usr.sbin/makefs/cd9660/cd9660_archimedes.c
+++ b/usr.sbin/makefs/cd9660/cd9660_archimedes.c
@@ -27,6 +27,8 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_archimedes.c 326276 2017-11-27 15:37:16Z pfg $
  */
 /*
  * cd9660_archimedes.c - support for RISC OS "ARCHIMEDES" extension
@@ -39,9 +41,6 @@
  * RISC OS filenames do).
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_archimedes.c 326276 2017-11-27 15:37:16Z pfg $");
-
 #include <assert.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/usr.sbin/makefs/cd9660/cd9660_conversion.c b/usr.sbin/makefs/cd9660/cd9660_conversion.c
index 59e3545637..e589841efd 100644
--- a/usr.sbin/makefs/cd9660/cd9660_conversion.c
+++ b/usr.sbin/makefs/cd9660/cd9660_conversion.c
@@ -32,12 +32,11 @@
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  * OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_conversion.c 326276 2017-11-27 15:37:16Z pfg $
  */
 #include "cd9660.h"
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_conversion.c 326276 2017-11-27 15:37:16Z pfg $");
-
 static char cd9660_compute_gm_offset(time_t);
 
 #if 0
diff --git a/usr.sbin/makefs/cd9660/cd9660_debug.c b/usr.sbin/makefs/cd9660/cd9660_debug.c
index ee7c07a10f..5fc6eb34c5 100644
--- a/usr.sbin/makefs/cd9660/cd9660_debug.c
+++ b/usr.sbin/makefs/cd9660/cd9660_debug.c
@@ -32,10 +32,10 @@
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  * OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_debug.c 333664 2018-05-16 02:58:05Z emaste $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_debug.c 333664 2018-05-16 02:58:05Z emaste $");
 #include <sys/param.h>
 
 #include <sys/mount.h>
diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
index 3d81265fc8..6b3d9a0079 100644
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
@@ -32,15 +32,14 @@
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  * OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_eltorito.c 331843 2018-03-31 15:04:41Z benno $
  */
 
 #include "cd9660.h"
 #include "cd9660_eltorito.h"
 #include <util.h>
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_eltorito.c 331843 2018-03-31 15:04:41Z benno $");
-
 #ifdef DEBUG
 #define	ELTORITO_DPRINTF(__x)	printf __x
 #else
@@ -50,7 +49,6 @@ __FBSDID("$FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_eltorito.c 331843 2018-03
 #include <util.h>
 
 static struct boot_catalog_entry *cd9660_init_boot_catalog_entry(void);
-static struct boot_catalog_entry *cd9660_boot_setup_validation_entry(char);
 static struct boot_catalog_entry *cd9660_boot_setup_default_entry(
     struct cd9660_boot_image *);
 static struct boot_catalog_entry *cd9660_boot_setup_section_head(char);
@@ -636,7 +634,7 @@ cd9660_write_boot(iso9660_disk *diskStructure, FILE *fd)
 		    diskStructure->boot_catalog_sector);
 	}
 	LIST_FOREACH(e, &diskStructure->boot_entries, ll_struct) {
-		if (diskStructure->verbose_level > 0) {
+	if (diskStructure->verbose_level > 0) {
 			printf("Writing catalog entry of type %d\n",
 			    e->entry_type);
 		}
@@ -732,7 +730,7 @@ cd9660_write_boot(iso9660_disk *diskStructure, FILE *fd)
 		}
 
 		/* Write ISO9660 descriptor, enclosing the whole disk */
-		cd9660_write_apm_partition_entry(fd, 2 + apm_partitions,
+                cd9660_write_apm_partition_entry(fd, 2 + apm_partitions,
 		    total_parts, 0, diskStructure->totalSectors *
 		    (diskStructure->sectorSize / 512), 512, "ISO9660",
 		    "CD_ROM_Mode_1");
diff --git a/usr.sbin/makefs/cd9660/cd9660_strings.c b/usr.sbin/makefs/cd9660/cd9660_strings.c
index 9e7741dee9..0f43ada3f3 100644
--- a/usr.sbin/makefs/cd9660/cd9660_strings.c
+++ b/usr.sbin/makefs/cd9660/cd9660_strings.c
@@ -32,12 +32,12 @@
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  * OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_strings.c 326276 2017-11-27 15:37:16Z pfg $
  */
 
 #include <sys/mount.h>
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_strings.c 326276 2017-11-27 15:37:16Z pfg $");
 #include <sys/param.h>
 #include <ctype.h>
 
diff --git a/usr.sbin/makefs/cd9660/cd9660_write.c b/usr.sbin/makefs/cd9660/cd9660_write.c
index 23a2174cc8..e20e50819b 100644
--- a/usr.sbin/makefs/cd9660/cd9660_write.c
+++ b/usr.sbin/makefs/cd9660/cd9660_write.c
@@ -32,14 +32,13 @@
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  * OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_write.c 326276 2017-11-27 15:37:16Z pfg $
  */
 
 #include "cd9660.h"
 #include "iso9660_rrip.h"
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/cd9660/cd9660_write.c 326276 2017-11-27 15:37:16Z pfg $");
-
 #include <util.h>
 
 static int cd9660_write_volume_descriptors(iso9660_disk *, FILE *);
diff --git a/usr.sbin/makefs/cd9660/iso9660_rrip.c b/usr.sbin/makefs/cd9660/iso9660_rrip.c
index 672d799c2e..cf75377740 100644
--- a/usr.sbin/makefs/cd9660/iso9660_rrip.c
+++ b/usr.sbin/makefs/cd9660/iso9660_rrip.c
@@ -32,14 +32,13 @@
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  * OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/cd9660/iso9660_rrip.c 326276 2017-11-27 15:37:16Z pfg $
  */
 /* This will hold all the function definitions
  * defined in iso9660_rrip.h
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/cd9660/iso9660_rrip.c 326276 2017-11-27 15:37:16Z pfg $");
-
 #include <sys/queue.h>
 #include <sys/types.h>
 #include <stdio.h>
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
index ff51619157..bc2e2aba67 100644
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -65,11 +65,9 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_alloc.c	8.19 (Berkeley) 7/13/95
+ * $FreeBSD: head/usr.sbin/makefs/ffs.c 336736 2018-07-26 13:33:10Z emaste $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs.c 336736 2018-07-26 13:33:10Z emaste $");
-
 #if HAVE_NBTOOL_CONFIG_H
 #include "nbtool_config.h"
 #endif
@@ -108,15 +106,18 @@ __FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs.c 336736 2018-07-26 13:33:10Z emast
 #include "ffs/ffs_extern.h"
 
 #undef DIP
-#define DIP(dp, field) \
-	((ffs_opts->version == 1) ? \
-	(dp)->ffs1_din.di_##field : (dp)->ffs2_din.di_##field)
+#define DIP(dp, field) (dp)->ffs1_din.di_##field
 
 /*
  * Various file system defaults (cribbed from newfs(8)).
  */
+#ifdef __DragonFly__
+#define	DFL_FRAGSIZE		2048		/* fragment size */
+#define	DFL_BLKSIZE		16384		/* block size */
+#else
 #define	DFL_FRAGSIZE		4096		/* fragment size */
 #define	DFL_BLKSIZE		32768		/* block size */
+#endif
 #define	DFL_SECSIZE		512		/* sector size */
 #define	DFL_CYLSPERGROUP	65536		/* cylinders per group */
 #define	DFL_FRAGSPERINODE	4		/* fragments per inode */
@@ -145,8 +146,6 @@ static	void	ffs_write_file(union dinode *, uint32_t, void *, fsinfo_t *);
 static	void	ffs_write_inode(union dinode *, uint32_t, const fsinfo_t *);
 static  void	*ffs_build_dinode1(struct ufs1_dinode *, dirbuf_t *, fsnode *,
 				 fsnode *, fsinfo_t *);
-static  void	*ffs_build_dinode2(struct ufs2_dinode *, dirbuf_t *, fsnode *,
-				 fsnode *, fsinfo_t *);
 
 
 	/* publicly visible functions */
@@ -171,8 +170,6 @@ ffs_prep_opts(fsinfo_t *fsopts)
 	      1, INT_MAX, "expected average file size" },
 	    { 'n', "avgfpdir", &ffs_opts->avgfpdir, OPT_INT32,
 	      1, INT_MAX, "expected # of files per directory" },
-	    { 'x', "extent", &ffs_opts->maxbsize, OPT_INT32,
-	      1, INT_MAX, "maximum # extent size" },
 	    { 'g', "maxbpcg", &ffs_opts->maxblkspercg, OPT_INT32,
 	      1, INT_MAX, "max # of blocks per group" },
 	    { 'v', "version", &ffs_opts->version, OPT_INT32,
@@ -299,10 +296,6 @@ ffs_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
 		/* update various superblock parameters */
 	superblock = fsopts->superblock;
 	superblock->fs_fmod = 0;
-	superblock->fs_old_cstotal.cs_ndir   = superblock->fs_cstotal.cs_ndir;
-	superblock->fs_old_cstotal.cs_nbfree = superblock->fs_cstotal.cs_nbfree;
-	superblock->fs_old_cstotal.cs_nifree = superblock->fs_cstotal.cs_nifree;
-	superblock->fs_old_cstotal.cs_nffree = superblock->fs_cstotal.cs_nffree;
 
 		/* write out superblock; image is now complete */
 	ffs_write_superblock(fsopts->superblock, fsopts);
@@ -395,16 +388,10 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts)
 	 * typically used for small filesystems where space matters.
 	 * XXX make this an option.
 	 */
-	fsopts->size += (SBLOCK_UFS1 + SBLOCKSIZE) * ncg;
+	fsopts->size += (8192 + SBSIZE) * ncg;
 		/* add space needed to store inodes, x3 for blockmaps, etc */
-	if (ffs_opts->version == 1)
-		fsopts->size += ncg * DINODE1_SIZE *
-		    roundup(fsopts->inodes / ncg, 
-			ffs_opts->bsize / DINODE1_SIZE);
-	else
-		fsopts->size += ncg * DINODE2_SIZE *
-		    roundup(fsopts->inodes / ncg, 
-			ffs_opts->bsize / DINODE2_SIZE);
+	fsopts->size += ncg * DINODE1_SIZE *
+	    roundup(fsopts->inodes / ncg, ffs_opts->bsize / DINODE1_SIZE);
 
 		/* add minfree */
 	if (ffs_opts->minfree > 0)
@@ -642,9 +629,7 @@ ffs_size_dir(fsnode *root, fsinfo_t *fsopts)
 				size_t slen;
 
 				slen = strlen(node->symlink) + 1;
-				if (slen >= (ffs_opts->version == 1 ?
-						UFS1_MAXSYMLINKLEN :
-						UFS2_MAXSYMLINKLEN))
+				if (slen >= UFS1_MAXSYMLINKLEN)
 					ADDSIZE(slen);
 			}
 		}
@@ -706,58 +691,6 @@ ffs_build_dinode1(struct ufs1_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
 	return membuf;
 }
 
-static void *
-ffs_build_dinode2(struct ufs2_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
-		 fsnode *root, fsinfo_t *fsopts)
-{
-	size_t slen;
-	void *membuf;
-	struct stat *st = stampst.st_ino != 0 ? &stampst : &cur->inode->st;
-
-	memset(dinp, 0, sizeof(*dinp));
-	dinp->di_mode = cur->inode->st.st_mode;
-	dinp->di_nlink = cur->inode->nlink;
-	dinp->di_size = cur->inode->st.st_size;
-#if HAVE_STRUCT_STAT_ST_FLAGS
-	dinp->di_flags = cur->inode->st.st_flags;
-#endif
-	dinp->di_gen = random();
-	dinp->di_uid = cur->inode->st.st_uid;
-	dinp->di_gid = cur->inode->st.st_gid;
-
-	dinp->di_atime = st->st_atime;
-	dinp->di_mtime = st->st_mtime;
-	dinp->di_ctime = st->st_ctime;
-#if HAVE_STRUCT_STAT_ST_MTIMENSEC
-	dinp->di_atimensec = st->st_atimensec;
-	dinp->di_mtimensec = st->st_mtimensec;
-	dinp->di_ctimensec = st->st_ctimensec;
-#endif
-#if HAVE_STRUCT_STAT_BIRTHTIME
-	dinp->di_birthtime = st->st_birthtime;
-	dinp->di_birthnsec = st->st_birthtimensec;
-#endif
-		/* not set: di_db, di_ib, di_blocks, di_spare */
-
-	membuf = NULL;
-	if (cur == root) {			/* "."; write dirbuf */
-		membuf = dbufp->buf;
-		dinp->di_size = dbufp->size;
-	} else if (S_ISBLK(cur->type) || S_ISCHR(cur->type)) {
-		dinp->di_size = 0;	/* a device */
-		dinp->di_rdev =
-		    ufs_rw64(cur->inode->st.st_rdev, fsopts->needswap);
-	} else if (S_ISLNK(cur->type)) {	/* symlink */
-		slen = strlen(cur->symlink);
-		if (slen < UFS2_MAXSYMLINKLEN) {	/* short link */
-			memcpy(dinp->di_db, cur->symlink, slen);
-		} else
-			membuf = cur->symlink;
-		dinp->di_size = slen;
-	}
-	return membuf;
-}
-
 static int
 ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
 {
@@ -830,12 +763,8 @@ ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
 			continue;		/* child creates own inode */
 
 				/* build on-disk inode */
-		if (ffs_opts->version == 1)
-			membuf = ffs_build_dinode1(&din.ffs1_din, &dirbuf, cur,
-			    root, fsopts);
-		else
-			membuf = ffs_build_dinode2(&din.ffs2_din, &dirbuf, cur,
-			    root, fsopts);
+		membuf = ffs_build_dinode1(&din.ffs1_din, &dirbuf, cur,
+		    root, fsopts);
 
 		if (debug & DEBUG_FS_POPULATE_NODE) {
 			printf("ffs_populate_dir: writing ino %d, %s",
@@ -919,12 +848,7 @@ ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
 
 	in.i_number = ino;
 	in.i_size = DIP(din, size);
-	if (ffs_opts->version == 1)
-		memcpy(&in.i_din.ffs1_din, &din->ffs1_din,
-		    sizeof(in.i_din.ffs1_din));
-	else
-		memcpy(&in.i_din.ffs2_din, &din->ffs2_din,
-		    sizeof(in.i_din.ffs2_din));
+	memcpy(&in.i_din.ffs1_din, &din->ffs1_din, sizeof(in.i_din.ffs1_din));
 
 	if (DIP(din, size) == 0)
 		goto write_inode_and_leave;		/* mmm, cheating */
@@ -1079,14 +1003,11 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
 {
 	char 		*buf;
 	struct ufs1_dinode *dp1;
-	struct ufs2_dinode *dp2, *dip;
 	struct cg	*cgp;
 	struct fs	*fs;
 	int		cg, cgino;
-	uint32_t	i;
-	daddr_t		d;
+	makefs_daddr_t		d;
 	char		sbbuf[FFS_MAXBSIZE];
-	uint32_t	initediblk;
 	ffs_opt_t	*ffs_opts = fsopts->fs_specific;
 
 	assert (dp != NULL);
@@ -1111,7 +1032,6 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
 
 	buf = emalloc(fs->fs_bsize);
 	dp1 = (struct ufs1_dinode *)buf;
-	dp2 = (struct ufs2_dinode *)buf;
 
 	if (fs->fs_cstotal.cs_nifree == 0)
 		errx(1, "ffs_write_inode: fs out of inodes for ino %u",
@@ -1130,24 +1050,6 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
 		fs->fs_cs(fs, cg).cs_ndir++; 
 	}
 
-	/*
-	 * Initialize inode blocks on the fly for UFS2.
-	 */
-	initediblk = ufs_rw32(cgp->cg_initediblk, fsopts->needswap);
-	while (ffs_opts->version == 2 && cgino + INOPB(fs) > initediblk &&
-	    initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) {
-		memset(buf, 0, fs->fs_bsize);
-		dip = (struct ufs2_dinode *)buf;
-		for (i = 0; i < INOPB(fs); i++) {
-			dip->di_gen = random();
-			dip++;
-		}
-		ffs_wtfs(fsbtodb(fs, ino_to_fsba(fs,
-				  cg * fs->fs_ipg + initediblk)),
-		    fs->fs_bsize, buf, fsopts);
-		initediblk += INOPB(fs);
-		cgp->cg_initediblk = ufs_rw32(initediblk, fsopts->needswap);
-	}
 
 
 	ffs_wtfs(fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, &sbbuf,
@@ -1156,19 +1058,10 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
 					/* now write inode */
 	d = fsbtodb(fs, ino_to_fsba(fs, ino));
 	ffs_rdfs(d, fs->fs_bsize, buf, fsopts);
-	if (fsopts->needswap) {
-		if (ffs_opts->version == 1)
-			ffs_dinode1_swap(&dp->ffs1_din,
-			    &dp1[ino_to_fsbo(fs, ino)]);
-		else
-			ffs_dinode2_swap(&dp->ffs2_din,
-			    &dp2[ino_to_fsbo(fs, ino)]);
-	} else {
-		if (ffs_opts->version == 1)
-			dp1[ino_to_fsbo(fs, ino)] = dp->ffs1_din;
-		else
-			dp2[ino_to_fsbo(fs, ino)] = dp->ffs2_din;
-	}
+	if (fsopts->needswap)
+		ffs_dinode1_swap(&dp->ffs1_din, &dp1[ino_to_fsbo(fs, ino)]);
+	else
+		dp1[ino_to_fsbo(fs, ino)] = dp->ffs1_din;
 	ffs_wtfs(d, fs->fs_bsize, buf, fsopts);
 	free(buf);
 }
diff --git a/usr.sbin/makefs/ffs.h b/usr.sbin/makefs/ffs.h
index 49edc3d2bf..77552065e1 100644
--- a/usr.sbin/makefs/ffs.h
+++ b/usr.sbin/makefs/ffs.h
@@ -64,10 +64,27 @@ typedef struct {
 	int	avgfilesize;	/* expected average file size */
 	int	avgfpdir;	/* expected # of files per directory */
 	int	version;	/* filesystem version (1 = FFS, 2 = UFS2) */
-	int	maxbsize;	/* maximum extent size */
 	int	maxblkspercg;	/* max # of blocks per cylinder group */
 	int	softupdates;	/* soft updates */
 		/* XXX: support `old' file systems ? */
 } ffs_opt_t;
 
+#if 1
+/*
+ * The size of a cylinder group is calculated by CGSIZE. The maximum size
+ * is limited by the fact that cylinder groups are at most one block.
+ * Its size is derived from the size of the maps maintained in the
+ * cylinder group and the (struct cg) size.
+ */
+#define	FBSD_CGSIZE(fs) \
+    /* base cg */	(sizeof(struct cg) + sizeof(int32_t) + \
+    /* old btotoff */	(fs)->fs_cpg * sizeof(int32_t) + \
+    /* old boff */	(fs)->fs_cpg * sizeof(u_int16_t) + \
+    /* inode map */	howmany((fs)->fs_ipg, NBBY) + \
+    /* block map */	howmany((fs)->fs_fpg, NBBY) +\
+    /* if present */	((fs)->fs_contigsumsize <= 0 ? 0 : \
+    /* cluster sum */	(fs)->fs_contigsumsize * sizeof(int32_t) + \
+    /* cluster map */	howmany(fragstoblks(fs, (fs)->fs_fpg), NBBY)))
+#endif
+
 #endif /* _FFS_H */
diff --git a/usr.sbin/makefs/ffs/Makefile.inc b/usr.sbin/makefs/ffs/Makefile.inc
index 6a9792a92e..d17fed6fe2 100644
--- a/usr.sbin/makefs/ffs/Makefile.inc
+++ b/usr.sbin/makefs/ffs/Makefile.inc
@@ -1,7 +1,7 @@
 #	$FreeBSD: head/usr.sbin/makefs/ffs/Makefile.inc 332844 2018-04-20 22:23:38Z emaste $
 #
 
-.PATH:	${SRCDIR}/ffs ${SRCTOP}/sys/ufs/ffs
+.PATH:	${.CURDIR}/ffs ${.CURDIR}/../../sys/vfs/ufs
 SRCS+=	ffs_alloc.c ffs_balloc.c ffs_bswap.c ffs_subr.c ufs_bmap.c
 SRCS+=	buf.c mkfs.c
 
diff --git a/usr.sbin/makefs/ffs/buf.c b/usr.sbin/makefs/ffs/buf.c
index 16329f70b5..32911c3de6 100644
--- a/usr.sbin/makefs/ffs/buf.c
+++ b/usr.sbin/makefs/ffs/buf.c
@@ -35,11 +35,10 @@
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/ffs/buf.c 336736 2018-07-26 13:33:10Z emaste $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/buf.c 336736 2018-07-26 13:33:10Z emaste $");
-
 #include <sys/param.h>
 #include <sys/time.h>
 
@@ -57,7 +56,7 @@ __FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/buf.c 336736 2018-07-26 13:33:10Z e
 static TAILQ_HEAD(buftailhead,buf) buftail;
 
 int
-bread(struct vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused,
+bread(struct vnode *vp, makefs_daddr_t blkno, int size, struct ucred *u1 __unused,
     struct buf **bpp)
 {
 	off_t	offset;
@@ -173,7 +172,7 @@ bcleanup(void)
 }
 
 struct buf *
-getblk(struct vnode *vp, daddr_t blkno, int size, int u1 __unused,
+getblk(struct vnode *vp, makefs_daddr_t blkno, int size, int u1 __unused,
     int u2 __unused, int u3 __unused)
 {
 	static int buftailinitted;
diff --git a/usr.sbin/makefs/ffs/buf.h b/usr.sbin/makefs/ffs/buf.h
index 8df6be5b61..b0f5cd4397 100644
--- a/usr.sbin/makefs/ffs/buf.h
+++ b/usr.sbin/makefs/ffs/buf.h
@@ -57,19 +57,19 @@ struct buf {
 	void *		b_data;
 	long		b_bufsize;
 	long		b_bcount;
-	daddr_t		b_blkno;
-	daddr_t		b_lblkno;
+	__int64_t		b_blkno;
+	__int64_t		b_lblkno;
 	struct makefs_fsinfo *b_fs;
 
 	TAILQ_ENTRY(buf)	b_tailq;
 };
 
 void		bcleanup(void);
-int		bread(struct vnode *, daddr_t, int, struct ucred *,
+int		bread(struct vnode *, __int64_t, int, struct ucred *,
     struct buf **);
 void		brelse(struct buf *);
 int		bwrite(struct buf *);
-struct buf *	getblk(struct vnode *, daddr_t, int, int, int, int);
+struct buf *	getblk(struct vnode *, __int64_t, int, int, int, int);
 
 #define	bdwrite(bp)	bwrite(bp)
 #define	clrbuf(bp)	memset((bp)->b_data, 0, (u_int)(bp)->b_bcount)
diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c
index ee114d1075..97a12cf996 100644
--- a/usr.sbin/makefs/ffs/ffs_alloc.c
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c
@@ -41,11 +41,9 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_alloc.c	8.19 (Berkeley) 7/13/95
+ * $FreeBSD: head/usr.sbin/makefs/ffs/ffs_alloc.c 336736 2018-07-26 13:33:10Z emaste $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/ffs_alloc.c 336736 2018-07-26 13:33:10Z emaste $");
-
 #include <sys/param.h>
 #include <sys/time.h>
 
@@ -64,11 +62,11 @@ __FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/ffs_alloc.c 336736 2018-07-26 13:33
 
 static int scanc(u_int, const u_char *, const u_char *, int);
 
-static daddr_t ffs_alloccg(struct inode *, int, daddr_t, int);
-static daddr_t ffs_alloccgblk(struct inode *, struct buf *, daddr_t);
-static daddr_t ffs_hashalloc(struct inode *, u_int, daddr_t, int,
-		     daddr_t (*)(struct inode *, int, daddr_t, int));
-static int32_t ffs_mapsearch(struct fs *, struct cg *, daddr_t, int);
+static makefs_daddr_t ffs_alloccg(struct inode *, int, makefs_daddr_t, int);
+static makefs_daddr_t ffs_alloccgblk(struct inode *, struct buf *, makefs_daddr_t);
+static makefs_daddr_t ffs_hashalloc(struct inode *, u_int, makefs_daddr_t, int,
+		     makefs_daddr_t (*)(struct inode *, int, makefs_daddr_t, int));
+static int32_t ffs_mapsearch(struct fs *, struct cg *, makefs_daddr_t, int);
 
 /*
  * Allocate a block in the file system.
@@ -90,11 +88,11 @@ static int32_t ffs_mapsearch(struct fs *, struct cg *, daddr_t, int);
  *      available block is located.
  */
 int
-ffs_alloc(struct inode *ip, daddr_t lbn __unused, daddr_t bpref, int size,
-    daddr_t *bnp)
+ffs_alloc(struct inode *ip, makefs_daddr_t lbn __unused, makefs_daddr_t bpref, int size,
+    makefs_daddr_t *bnp)
 {
 	struct fs *fs = ip->i_fs;
-	daddr_t bno;
+	makefs_daddr_t bno;
 	int cg;
 	
 	*bnp = 0;
@@ -112,10 +110,7 @@ ffs_alloc(struct inode *ip, daddr_t lbn __unused, daddr_t bpref, int size,
 		cg = dtog(fs, bpref);
 	bno = ffs_hashalloc(ip, cg, bpref, size, ffs_alloccg);
 	if (bno > 0) {
-		if (ip->i_fs->fs_magic == FS_UFS1_MAGIC)
-			ip->i_ffs1_blocks += size / DEV_BSIZE;
-		else
-			ip->i_ffs2_blocks += size / DEV_BSIZE;
+		ip->i_ffs1_blocks += size / DEV_BSIZE;
 		*bnp = bno;
 		return (0);
 	}
@@ -150,8 +145,8 @@ ffs_alloc(struct inode *ip, daddr_t lbn __unused, daddr_t bpref, int size,
  * schedule another I/O transfer.
  */
 /* XXX ondisk32 */
-daddr_t
-ffs_blkpref_ufs1(struct inode *ip, daddr_t lbn, int indx, int32_t *bap)
+makefs_daddr_t
+ffs_blkpref_ufs1(struct inode *ip, makefs_daddr_t lbn, int indx, int32_t *bap)
 {
 	struct fs *fs;
 	u_int cg, startcg;
@@ -189,47 +184,6 @@ ffs_blkpref_ufs1(struct inode *ip, daddr_t lbn, int indx, int32_t *bap)
 	return ufs_rw32(bap[indx - 1], UFS_FSNEEDSWAP(fs)) + fs->fs_frag;
 }
 
-daddr_t
-ffs_blkpref_ufs2(struct inode *ip, daddr_t lbn, int indx, int64_t *bap)
-{
-	struct fs *fs;
-	u_int cg, startcg;
-	int avgbfree;
-
-	fs = ip->i_fs;
-	if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) {
-		if (lbn < UFS_NDADDR + NINDIR(fs)) {
-			cg = ino_to_cg(fs, ip->i_number);
-			return (fs->fs_fpg * cg + fs->fs_frag);
-		}
-		/*
-		 * Find a cylinder with greater than average number of
-		 * unused data blocks.
-		 */
-		if (indx == 0 || bap[indx - 1] == 0)
-			startcg =
-			    ino_to_cg(fs, ip->i_number) + lbn / fs->fs_maxbpg;
-		else
-			startcg = dtog(fs,
-				ufs_rw64(bap[indx - 1], UFS_FSNEEDSWAP(fs)) + 1);
-		startcg %= fs->fs_ncg;
-		avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg;
-		for (cg = startcg; cg < fs->fs_ncg; cg++)
-			if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) {
-				return (fs->fs_fpg * cg + fs->fs_frag);
-			}
-		for (cg = 0; cg < startcg; cg++)
-			if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) {
-				return (fs->fs_fpg * cg + fs->fs_frag);
-			}
-		return (0);
-	}
-	/*
-	 * We just always try to lay things out contiguously.
-	 */
-	return ufs_rw64(bap[indx - 1], UFS_FSNEEDSWAP(fs)) + fs->fs_frag;
-}
-
 /*
  * Implement the cylinder overflow algorithm.
  *
@@ -241,12 +195,12 @@ ffs_blkpref_ufs2(struct inode *ip, daddr_t lbn, int indx, int64_t *bap)
  * `size':	size for data blocks, mode for inodes
  */
 /*VARARGS5*/
-static daddr_t
-ffs_hashalloc(struct inode *ip, u_int cg, daddr_t pref, int size,
-    daddr_t (*allocator)(struct inode *, int, daddr_t, int))
+static makefs_daddr_t
+ffs_hashalloc(struct inode *ip, u_int cg, makefs_daddr_t pref, int size,
+    makefs_daddr_t (*allocator)(struct inode *, int, makefs_daddr_t, int))
 {
 	struct fs *fs;
-	daddr_t result;
+	makefs_daddr_t result;
 	u_int i, icg = cg;
 
 	fs = ip->i_fs;
@@ -290,12 +244,12 @@ ffs_hashalloc(struct inode *ip, u_int cg, daddr_t pref, int size,
  * Check to see if a block of the appropriate size is available,
  * and if it is, allocate it.
  */
-static daddr_t
-ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
+static makefs_daddr_t
+ffs_alloccg(struct inode *ip, int cg, makefs_daddr_t bpref, int size)
 {
 	struct cg *cgp;
 	struct buf *bp;
-	daddr_t bno, blkno;
+	makefs_daddr_t bno, blkno;
 	int error, frags, allocsiz, i;
 	struct fs *fs = ip->i_fs;
 	const int needswap = UFS_FSNEEDSWAP(fs);
@@ -376,11 +330,11 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
  * Note that this routine only allocates fs_bsize blocks; these
  * blocks may be fragmented by the routine that allocates them.
  */
-static daddr_t
-ffs_alloccgblk(struct inode *ip, struct buf *bp, daddr_t bpref)
+static makefs_daddr_t
+ffs_alloccgblk(struct inode *ip, struct buf *bp, makefs_daddr_t bpref)
 {
 	struct cg *cgp;
-	daddr_t blkno;
+	makefs_daddr_t blkno;
 	int32_t bno;
 	struct fs *fs = ip->i_fs;
 	const int needswap = UFS_FSNEEDSWAP(fs);
@@ -413,6 +367,8 @@ ffs_alloccgblk(struct inode *ip, struct buf *bp, daddr_t bpref)
 	ufs_add32(cgp->cg_cs.cs_nbfree, -1, needswap);
 	fs->fs_cstotal.cs_nbfree--;
 	fs->fs_cs(fs, ufs_rw32(cgp->cg_cgx, needswap)).cs_nbfree--;
+	cg_blks(fs, cgp, cbtocylno(fs, bno))[cbtorpos(fs, bno)]--;
+	cg_blktot(cgp)[cbtocylno(fs, bno)]--;
 	fs->fs_fmod = 1;
 	blkno = ufs_rw32(cgp->cg_cgx, needswap) * fs->fs_fpg + bno;
 	return (blkno);
@@ -426,7 +382,7 @@ ffs_alloccgblk(struct inode *ip, struct buf *bp, daddr_t bpref)
  * block reassembly is checked.
  */
 void
-ffs_blkfree(struct inode *ip, daddr_t bno, long size)
+ffs_blkfree(struct inode *ip, makefs_daddr_t bno, long size)
 {
 	struct cg *cgp;
 	struct buf *bp;
@@ -469,6 +425,8 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size)
 		ufs_add32(cgp->cg_cs.cs_nbfree, 1, needswap);
 		fs->fs_cstotal.cs_nbfree++;
 		fs->fs_cs(fs, cg).cs_nbfree++;
+		cg_blks(fs, cgp, cbtocylno(fs, bno))[cbtorpos(fs, bno)]++;
+		cg_blktot(cgp)[cbtocylno(fs, bno)]++;
 	} else {
 		bbase = cgbno - fragnum(fs, cgbno);
 		/*
@@ -507,6 +465,9 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size)
 			ufs_add32(cgp->cg_cs.cs_nbfree, 1, needswap);
 			fs->fs_cstotal.cs_nbfree++;
 			fs->fs_cs(fs, cg).cs_nbfree++;
+			cg_blks(fs, cgp,
+			    cbtocylno(fs, bbase))[cbtorpos(fs, bbase)]++;
+			cg_blktot(cgp)[cbtocylno(fs, bbase)]++;
 		}
 	}
 	fs->fs_fmod = 1;
@@ -531,7 +492,7 @@ scanc(u_int size, const u_char *cp, const u_char table[], int mask)
  * available.
  */
 static int32_t
-ffs_mapsearch(struct fs *fs, struct cg *cgp, daddr_t bpref, int allocsiz)
+ffs_mapsearch(struct fs *fs, struct cg *cgp, makefs_daddr_t bpref, int allocsiz)
 {
 	int32_t bno;
 	int start, len, loc, i;
diff --git a/usr.sbin/makefs/ffs/ffs_balloc.c b/usr.sbin/makefs/ffs/ffs_balloc.c
index c390de9efd..c0da5c7af7 100644
--- a/usr.sbin/makefs/ffs/ffs_balloc.c
+++ b/usr.sbin/makefs/ffs/ffs_balloc.c
@@ -32,11 +32,9 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_balloc.c	8.8 (Berkeley) 6/16/95
+ * $FreeBSD: head/usr.sbin/makefs/ffs/ffs_balloc.c 336736 2018-07-26 13:33:10Z emaste $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/ffs_balloc.c 336736 2018-07-26 13:33:10Z emaste $");
-
 #include <sys/param.h>
 #include <sys/time.h>
 
@@ -57,7 +55,6 @@ __FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/ffs_balloc.c 336736 2018-07-26 13:3
 #include "ffs/ffs_extern.h"
 
 static int ffs_balloc_ufs1(struct inode *, off_t, int, struct buf **);
-static int ffs_balloc_ufs2(struct inode *, off_t, int, struct buf **);
 
 /*
  * Balloc defines the structure of file system storage
@@ -70,22 +67,19 @@ static int ffs_balloc_ufs2(struct inode *, off_t, int, struct buf **);
 int
 ffs_balloc(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
 {
-	if (ip->i_fs->fs_magic == FS_UFS2_MAGIC)
-		return ffs_balloc_ufs2(ip, offset, bufsize, bpp);
-	else
-		return ffs_balloc_ufs1(ip, offset, bufsize, bpp);
+	return ffs_balloc_ufs1(ip, offset, bufsize, bpp);
 }
 
 static int
 ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
 {
-	daddr_t lbn, lastlbn;
+	makefs_daddr_t lbn, lastlbn;
 	int size;
 	int32_t nb;
 	struct buf *bp, *nbp;
 	struct fs *fs = ip->i_fs;
 	struct indir indirs[UFS_NIADDR + 2];
-	daddr_t newb, pref;
+	makefs_daddr_t newb, pref;
 	int32_t *bap;
 	int osize, nsize, num, i, error;
 	int32_t *allocblk, allociblk[UFS_NIADDR + 1];
@@ -327,254 +321,3 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
 	}
 	return (0);
 }
-
-static int
-ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
-{
-	daddr_t lbn, lastlbn;
-	int size;
-	struct buf *bp, *nbp;
-	struct fs *fs = ip->i_fs;
-	struct indir indirs[UFS_NIADDR + 2];
-	daddr_t newb, pref, nb;
-	int64_t *bap;
-	int osize, nsize, num, i, error;
-	int64_t *allocblk, allociblk[UFS_NIADDR + 1];
-	int64_t *allocib;
-	const int needswap = UFS_FSNEEDSWAP(fs);
-
-	lbn = lblkno(fs, offset);
-	size = blkoff(fs, offset) + bufsize;
-	if (bpp != NULL) {
-		*bpp = NULL;
-	}
-
-	assert(size <= fs->fs_bsize);
-	if (lbn < 0)
-		return (EFBIG);
-
-	/*
-	 * If the next write will extend the file into a new block,
-	 * and the file is currently composed of a fragment
-	 * this fragment has to be extended to be a full block.
-	 */
-
-	lastlbn = lblkno(fs, ip->i_ffs2_size);
-	if (lastlbn < UFS_NDADDR && lastlbn < lbn) {
-		nb = lastlbn;
-		osize = blksize(fs, ip, nb);
-		if (osize < fs->fs_bsize && osize > 0) {
-			warnx("need to ffs_realloccg; not supported!");
-			abort();
-		}
-	}
-
-	/*
-	 * The first UFS_NDADDR blocks are direct blocks
-	 */
-
-	if (lbn < UFS_NDADDR) {
-		nb = ufs_rw64(ip->i_ffs2_db[lbn], needswap);
-		if (nb != 0 && ip->i_ffs2_size >=
-		    (uint64_t)lblktosize(fs, lbn + 1)) {
-
-			/*
-			 * The block is an already-allocated direct block
-			 * and the file already extends past this block,
-			 * thus this must be a whole block.
-			 * Just read the block (if requested).
-			 */
-
-			if (bpp != NULL) {
-				error = bread(ip->i_devvp, lbn, fs->fs_bsize,
-				    NULL, bpp);
-				if (error) {
-					brelse(*bpp);
-					return (error);
-				}
-			}
-			return (0);
-		}
-		if (nb != 0) {
-
-			/*
-			 * Consider need to reallocate a fragment.
-			 */
-
-			osize = fragroundup(fs, blkoff(fs, ip->i_ffs2_size));
-			nsize = fragroundup(fs, size);
-			if (nsize <= osize) {
-
-				/*
-				 * The existing block is already
-				 * at least as big as we want.
-				 * Just read the block (if requested).
-				 */
-
-				if (bpp != NULL) {
-					error = bread(ip->i_devvp, lbn, osize,
-					    NULL, bpp);
-					if (error) {
-						brelse(*bpp);
-						return (error);
-					}
-				}
-				return 0;
-			} else {
-				warnx("need to ffs_realloccg; not supported!");
-				abort();
-			}
-		} else {
-
-			/*
-			 * the block was not previously allocated,
-			 * allocate a new block or fragment.
-			 */
-
-			if (ip->i_ffs2_size < (uint64_t)lblktosize(fs, lbn + 1))
-				nsize = fragroundup(fs, size);
-			else
-				nsize = fs->fs_bsize;
-			error = ffs_alloc(ip, lbn,
-			    ffs_blkpref_ufs2(ip, lbn, (int)lbn,
-				&ip->i_ffs2_db[0]),
-				nsize, &newb);
-			if (error)
-				return (error);
-			if (bpp != NULL) {
-				bp = getblk(ip->i_devvp, lbn, nsize, 0, 0, 0);
-				bp->b_blkno = fsbtodb(fs, newb);
-				clrbuf(bp);
-				*bpp = bp;
-			}
-		}
-		ip->i_ffs2_db[lbn] = ufs_rw64(newb, needswap);
-		return (0);
-	}
-
-	/*
-	 * Determine the number of levels of indirection.
-	 */
-
-	pref = 0;
-	if ((error = ufs_getlbns(ip, lbn, indirs, &num)) != 0)
-		return (error);
-
-	if (num < 1) {
-		warnx("ffs_balloc: ufs_getlbns returned indirect block");
-		abort();
-	}
-
-	/*
-	 * Fetch the first indirect block allocating if necessary.
-	 */
-
-	--num;
-	nb = ufs_rw64(ip->i_ffs2_ib[indirs[0].in_off], needswap);
-	allocib = NULL;
-	allocblk = allociblk;
-	if (nb == 0) {
-		pref = ffs_blkpref_ufs2(ip, lbn, 0, (int64_t *)0);
-		error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
-		if (error)
-			return error;
-		nb = newb;
-		*allocblk++ = nb;
-		bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0);
-		bp->b_blkno = fsbtodb(fs, nb);
-		clrbuf(bp);
-		/*
-		 * Write synchronously so that indirect blocks
-		 * never point at garbage.
-		 */
-		if ((error = bwrite(bp)) != 0)
-			return error;
-		allocib = &ip->i_ffs2_ib[indirs[0].in_off];
-		*allocib = ufs_rw64(nb, needswap);
-	}
-
-	/*
-	 * Fetch through the indirect blocks, allocating as necessary.
-	 */
-
-	for (i = 1;;) {
-		error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize,
-		    NULL, &bp);
-		if (error) {
-			brelse(bp);
-			return error;
-		}
-		bap = (int64_t *)bp->b_data;
-		nb = ufs_rw64(bap[indirs[i].in_off], needswap);
-		if (i == num)
-			break;
-		i++;
-		if (nb != 0) {
-			brelse(bp);
-			continue;
-		}
-		if (pref == 0)
-			pref = ffs_blkpref_ufs2(ip, lbn, 0, (int64_t *)0);
-		error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
-		if (error) {
-			brelse(bp);
-			return error;
-		}
-		nb = newb;
-		*allocblk++ = nb;
-		nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0);
-		nbp->b_blkno = fsbtodb(fs, nb);
-		clrbuf(nbp);
-		/*
-		 * Write synchronously so that indirect blocks
-		 * never point at garbage.
-		 */
-
-		if ((error = bwrite(nbp)) != 0) {
-			brelse(bp);
-			return error;
-		}
-		bap[indirs[i - 1].in_off] = ufs_rw64(nb, needswap);
-
-		bwrite(bp);
-	}
-
-	/*
-	 * Get the data block, allocating if necessary.
-	 */
-
-	if (nb == 0) {
-		pref = ffs_blkpref_ufs2(ip, lbn, indirs[num].in_off, &bap[0]);
-		error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
-		if (error) {
-			brelse(bp);
-			return error;
-		}
-		nb = newb;
-		*allocblk++ = nb;
-		if (bpp != NULL) {
-			nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0, 0);
-			nbp->b_blkno = fsbtodb(fs, nb);
-			clrbuf(nbp);
-			*bpp = nbp;
-		}
-		bap[indirs[num].in_off] = ufs_rw64(nb, needswap);
-
-		/*
-		 * If required, write synchronously, otherwise use
-		 * delayed write.
-		 */
-		bwrite(bp);
-		return (0);
-	}
-	brelse(bp);
-	if (bpp != NULL) {
-		error = bread(ip->i_devvp, lbn, (int)fs->fs_bsize, NULL, &nbp);
-		if (error) {
-			brelse(nbp);
-			return error;
-		}
-		*bpp = nbp;
-	}
-	return (0);
-}
diff --git a/usr.sbin/makefs/ffs/ffs_bswap.c b/usr.sbin/makefs/ffs/ffs_bswap.c
index 6bc4f797b0..3ce6710f90 100644
--- a/usr.sbin/makefs/ffs/ffs_bswap.c
+++ b/usr.sbin/makefs/ffs/ffs_bswap.c
@@ -25,11 +25,9 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
+ * $FreeBSD: head/usr.sbin/makefs/ffs/ffs_bswap.c 326276 2017-11-27 15:37:16Z pfg $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/ffs_bswap.c 326276 2017-11-27 15:37:16Z pfg $");
-
 #include <sys/param.h>
 #if defined(_KERNEL)
 #include <sys/systm.h>
@@ -48,19 +46,10 @@ __FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/ffs_bswap.c 326276 2017-11-27 15:37
 #include <ufs/ffs/fs.h>
 #include "ffs/ffs_extern.h"
 
-#define	fs_old_postbloff	fs_spare5[0]
-#define	fs_old_rotbloff		fs_spare5[1]
-#define	fs_old_postbl_start	fs_maxbsize
-#define	fs_old_headswitch	fs_id[0]
-#define	fs_old_trkseek	fs_id[1]
-#define	fs_old_csmask	fs_spare1[0]
-#define	fs_old_csshift	fs_spare1[1]
-
 #define	FS_42POSTBLFMT		-1	/* 4.2BSD rotational table format */
 #define	FS_DYNAMICPOSTBLFMT	1	/* dynamic rotational table format */
 
-void ffs_csum_swap(struct csum *o, struct csum *n, int size);
-void ffs_csumtotal_swap(struct csum_total *o, struct csum_total *n);
+void ffs_csumtotal_swap(struct csum *o, struct csum *n);
 
 void
 ffs_sb_swap(struct fs *o, struct fs *n)
@@ -80,14 +69,12 @@ ffs_sb_swap(struct fs *o, struct fs *n)
 
 	n->fs_swuid = bswap64(o->fs_swuid);
 	n->fs_cgrotor = bswap32(o->fs_cgrotor); /* Unused */
-	n->fs_old_cpc = bswap32(o->fs_old_cpc);
+	n->fs_cpc = bswap32(o->fs_cpc);
 
 	/* These fields overlap with a possible location for the
 	 * historic FS_DYNAMICPOSTBLFMT postbl table, and with the
 	 * first half of the historic FS_42POSTBLFMT postbl table.
 	 */
-	n->fs_maxbsize = bswap32(o->fs_maxbsize);
-	n->fs_sblockloc = bswap64(o->fs_sblockloc);
 	ffs_csumtotal_swap(&o->fs_cstotal, &n->fs_cstotal);
 	n->fs_time = bswap64(o->fs_time);
 	n->fs_size = bswap64(o->fs_size);
@@ -107,15 +94,15 @@ ffs_sb_swap(struct fs *o, struct fs *n)
 	n->fs_flags = bswap32(o->fs_flags);
 	n->fs_contigsumsize = bswap32(o->fs_contigsumsize);
 	n->fs_maxsymlinklen = bswap32(o->fs_maxsymlinklen);
-	n->fs_old_inodefmt = bswap32(o->fs_old_inodefmt);
+	n->fs_inodefmt = bswap32(o->fs_inodefmt);
 	n->fs_maxfilesize = bswap64(o->fs_maxfilesize);
 	n->fs_qbmask = bswap64(o->fs_qbmask);
 	n->fs_qfmask = bswap64(o->fs_qfmask);
 	n->fs_state = bswap32(o->fs_state);
-	n->fs_old_postblformat = bswap32(o->fs_old_postblformat);
-	n->fs_old_nrpos = bswap32(o->fs_old_nrpos);
-	n->fs_old_postbloff = bswap32(o->fs_old_postbloff);
-	n->fs_old_rotbloff = bswap32(o->fs_old_rotbloff);
+	n->fs_postblformat = bswap32(o->fs_postblformat);
+	n->fs_nrpos = bswap32(o->fs_nrpos);
+	n->fs_postbloff = bswap32(o->fs_postbloff);
+	n->fs_rotbloff = bswap32(o->fs_rotbloff);
 
 	n->fs_magic = bswap32(o->fs_magic);
 }
@@ -142,33 +129,6 @@ ffs_dinode1_swap(struct ufs1_dinode *o, struct ufs1_dinode *n)
 	n->di_gid = bswap32(o->di_gid);
 }
 
-void
-ffs_dinode2_swap(struct ufs2_dinode *o, struct ufs2_dinode *n)
-{
-	n->di_mode = bswap16(o->di_mode);
-	n->di_nlink = bswap16(o->di_nlink);
-	n->di_uid = bswap32(o->di_uid);
-	n->di_gid = bswap32(o->di_gid);
-	n->di_blksize = bswap32(o->di_blksize);
-	n->di_size = bswap64(o->di_size);
-	n->di_blocks = bswap64(o->di_blocks);
-	n->di_atime = bswap64(o->di_atime);
-	n->di_atimensec = bswap32(o->di_atimensec);
-	n->di_mtime = bswap64(o->di_mtime);
-	n->di_mtimensec = bswap32(o->di_mtimensec);
-	n->di_ctime = bswap64(o->di_ctime);
-	n->di_ctimensec = bswap32(o->di_ctimensec);
-	n->di_birthtime = bswap64(o->di_ctime);
-	n->di_birthnsec = bswap32(o->di_ctimensec);
-	n->di_gen = bswap32(o->di_gen);
-	n->di_kernflags = bswap32(o->di_kernflags);
-	n->di_flags = bswap32(o->di_flags);
-	n->di_extsize = bswap32(o->di_extsize);
-	memcpy(n->di_extb, o->di_extb, sizeof(n->di_extb));
-	memcpy(n->di_db, o->di_db, sizeof(n->di_db));
-	memcpy(n->di_ib, o->di_ib, sizeof(n->di_ib));
-}
-
 void
 ffs_csum_swap(struct csum *o, struct csum *n, int size)
 {
@@ -183,7 +143,7 @@ ffs_csum_swap(struct csum *o, struct csum *n, int size)
 }
 
 void
-ffs_csumtotal_swap(struct csum_total *o, struct csum_total *n)
+ffs_csumtotal_swap(struct csum *o, struct csum *n)
 {
 	n->cs_ndir = bswap64(o->cs_ndir);
 	n->cs_nbfree = bswap64(o->cs_nbfree);
@@ -204,10 +164,9 @@ ffs_cg_swap(struct cg *o, struct cg *n, struct fs *fs)
 
 	n->cg_firstfield = bswap32(o->cg_firstfield);
 	n->cg_magic = bswap32(o->cg_magic);
-	n->cg_old_time = bswap32(o->cg_old_time);
 	n->cg_cgx = bswap32(o->cg_cgx);
-	n->cg_old_ncyl = bswap16(o->cg_old_ncyl);
-	n->cg_old_niblk = bswap16(o->cg_old_niblk);
+	n->cg_ncyl = bswap16(o->cg_ncyl);
+	n->cg_niblk = bswap16(o->cg_niblk);
 	n->cg_ndblk = bswap32(o->cg_ndblk);
 	n->cg_cs.cs_ndir = bswap32(o->cg_cs.cs_ndir);
 	n->cg_cs.cs_nbfree = bswap32(o->cg_cs.cs_nbfree);
@@ -219,28 +178,23 @@ ffs_cg_swap(struct cg *o, struct cg *n, struct fs *fs)
 	for (i = 0; i < MAXFRAG; i++)
 		n->cg_frsum[i] = bswap32(o->cg_frsum[i]);
 	
-	n->cg_old_btotoff = bswap32(o->cg_old_btotoff);
-	n->cg_old_boff = bswap32(o->cg_old_boff);
+	n->cg_btotoff = bswap32(o->cg_btotoff);
+	n->cg_boff = bswap32(o->cg_boff);
 	n->cg_iusedoff = bswap32(o->cg_iusedoff);
 	n->cg_freeoff = bswap32(o->cg_freeoff);
 	n->cg_nextfreeoff = bswap32(o->cg_nextfreeoff);
 	n->cg_clustersumoff = bswap32(o->cg_clustersumoff);
 	n->cg_clusteroff = bswap32(o->cg_clusteroff);
 	n->cg_nclusterblks = bswap32(o->cg_nclusterblks);
-	n->cg_niblk = bswap32(o->cg_niblk);
-	n->cg_initediblk = bswap32(o->cg_initediblk);
 	n->cg_time = bswap64(o->cg_time);
 
-	if (fs->fs_magic == FS_UFS2_MAGIC)
-		return;
-
 	if (n->cg_magic == CG_MAGIC) {
-		btotoff = n->cg_old_btotoff;
-		boff = n->cg_old_boff;
+		btotoff = n->cg_btotoff;
+		boff = n->cg_boff;
 		clustersumoff = n->cg_clustersumoff;
 	} else {
-		btotoff = bswap32(n->cg_old_btotoff);
-		boff = bswap32(n->cg_old_boff);
+		btotoff = bswap32(n->cg_btotoff);
+		boff = bswap32(n->cg_boff);
 		clustersumoff = bswap32(n->cg_clustersumoff);
 	}
 	n32 = (u_int32_t *)((u_int8_t *)n + btotoff);
@@ -248,10 +202,10 @@ ffs_cg_swap(struct cg *o, struct cg *n, struct fs *fs)
 	n16 = (u_int16_t *)((u_int8_t *)n + boff);
 	o16 = (u_int16_t *)((u_int8_t *)o + boff);
 
-	for (i = 0; i < fs->fs_old_cpg; i++)
+	for (i = 0; i < fs->fs_cpg; i++)
 		n32[i] = bswap32(o32[i]);
 	
-	for (i = 0; i < fs->fs_old_cpg * fs->fs_old_nrpos; i++)
+	for (i = 0; i < fs->fs_cpg * fs->fs_nrpos; i++)
 		n16[i] = bswap16(o16[i]);
 
 	n32 = (u_int32_t *)((u_int8_t *)n + clustersumoff);
diff --git a/usr.sbin/makefs/ffs/ffs_extern.h b/usr.sbin/makefs/ffs/ffs_extern.h
index 99a2371806..8abf64e6ea 100644
--- a/usr.sbin/makefs/ffs/ffs_extern.h
+++ b/usr.sbin/makefs/ffs/ffs_extern.h
@@ -44,7 +44,7 @@ struct inode;
  * ufs_getlbns and used by truncate and bmap code.
  */
 struct indir {
-	daddr_t in_lbn;		/* Logical block number. */
+	__int64_t in_lbn;		/* Logical block number. */
 	int	in_off;			/* Offset in buffer. */
 };
 
@@ -52,10 +52,9 @@ struct indir {
 _Noreturn void panic(const char *, ...) __printflike(1, 2);
 
 	/* ffs_alloc.c */
-int ffs_alloc(struct inode *, daddr_t, daddr_t, int, daddr_t *);
-daddr_t ffs_blkpref_ufs1(struct inode *, daddr_t, int, int32_t *);
-daddr_t ffs_blkpref_ufs2(struct inode *, daddr_t, int, int64_t *);
-void ffs_blkfree(struct inode *, daddr_t, long);
+int ffs_alloc(struct inode *, __int64_t, __int64_t, int, __int64_t *);
+__int64_t ffs_blkpref_ufs1(struct inode *, __int64_t, int, int32_t *);
+void ffs_blkfree(struct inode *, __int64_t, long);
 void ffs_clusteracct(struct fs *, struct cg *, int32_t, int);
 
 	/* ffs_balloc.c */
@@ -64,7 +63,6 @@ int ffs_balloc(struct inode *, off_t, int, struct buf **);
 	/* ffs_bswap.c */
 void ffs_sb_swap(struct fs*, struct fs *);
 void ffs_dinode1_swap(struct ufs1_dinode *, struct ufs1_dinode *);
-void ffs_dinode2_swap(struct ufs2_dinode *, struct ufs2_dinode *);
 void ffs_csum_swap(struct csum *, struct csum *, int);
 void ffs_cg_swap(struct cg *, struct cg *, struct fs *);
 
@@ -76,4 +74,4 @@ void ffs_clrblock(struct fs *, u_char *, int32_t);
 void ffs_setblock(struct fs *, u_char *, int32_t);
 
 	/* ufs_bmap.c */
-int ufs_getlbns(struct inode *, daddr_t, struct indir *, int *);
+int ufs_getlbns(struct inode *, __int64_t, struct indir *, int *);
diff --git a/usr.sbin/makefs/ffs/ffs_subr.c b/usr.sbin/makefs/ffs/ffs_subr.c
index 4f8aeffd74..45dda21917 100644
--- a/usr.sbin/makefs/ffs/ffs_subr.c
+++ b/usr.sbin/makefs/ffs/ffs_subr.c
@@ -31,11 +31,9 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_subr.c	8.5 (Berkeley) 3/21/95
+ * $FreeBSD: head/usr.sbin/makefs/ffs/ffs_subr.c 333664 2018-05-16 02:58:05Z emaste $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/ffs_subr.c 333664 2018-05-16 02:58:05Z emaste $");
-
 #include <sys/param.h>
 #include <sys/types.h>
 
diff --git a/usr.sbin/makefs/ffs/mkfs.c b/usr.sbin/makefs/ffs/mkfs.c
index 55121b30c2..ba95f7833b 100644
--- a/usr.sbin/makefs/ffs/mkfs.c
+++ b/usr.sbin/makefs/ffs/mkfs.c
@@ -38,11 +38,10 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/ffs/mkfs.c 326025 2017-11-20 19:49:47Z pfg $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/mkfs.c 326025 2017-11-20 19:49:47Z pfg $");
-
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/resource.h>
@@ -82,7 +81,7 @@ static int count_digits(int);
 
 static union {
 	struct fs fs;
-	char pad[SBLOCKSIZE];
+	char pad[SBSIZE];
 } fsun;
 #define	sblock	fsun.fs
 
@@ -97,12 +96,10 @@ static int iobufsize;
 
 static char writebuf[FFS_MAXBSIZE];
 
-static int     Oflag;	   /* format as an 4.3BSD file system */
 static int64_t fssize;	   /* file system size */
 static int     sectorsize;	   /* bytes/sector */
 static int     fsize;	   /* fragment size */
 static int     bsize;	   /* block size */
-static int     maxbsize;   /* maximum clustering */
 static int     maxblkspercg;
 static int     minfree;	   /* free space threshold */
 static int     opt;		   /* optimization preference (space or time) */
@@ -126,12 +123,10 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 	int nprintcols, printcolwidth;
 	ffs_opt_t	*ffs_opts = fsopts->fs_specific;
 
-	Oflag =		ffs_opts->version;
 	fssize =        fsopts->size / fsopts->sectorsize;
 	sectorsize =    fsopts->sectorsize;
 	fsize =         ffs_opts->fsize;
 	bsize =         ffs_opts->bsize;
-	maxbsize =      ffs_opts->maxbsize;
 	maxblkspercg =  ffs_opts->maxblkspercg;
 	minfree =       ffs_opts->minfree;
 	opt =           ffs_opts->optimization;
@@ -141,21 +136,13 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 	avgfilesize =   ffs_opts->avgfilesize;
 	avgfpdir =      ffs_opts->avgfpdir;
 	bbsize =        BBSIZE;
-	sbsize =        SBLOCKSIZE;
+	sbsize =        SBSIZE;
 
 	strlcpy(sblock.fs_volname, ffs_opts->label, sizeof(sblock.fs_volname));
 
-	if (Oflag == 0) {
-		sblock.fs_old_inodefmt = FS_42INODEFMT;
-		sblock.fs_maxsymlinklen = 0;
-		sblock.fs_old_flags = 0;
-	} else {
-		sblock.fs_old_inodefmt = FS_44INODEFMT;
-		sblock.fs_maxsymlinklen = (Oflag == 1 ? UFS1_MAXSYMLINKLEN :
-		    UFS2_MAXSYMLINKLEN);
-		sblock.fs_old_flags = FS_FLAGS_UPDATED;
-		sblock.fs_flags = 0;
-	}
+	sblock.fs_inodefmt = FS_44INODEFMT;
+	sblock.fs_maxsymlinklen = UFS1_MAXSYMLINKLEN;
+	sblock.fs_flags = 0;
 	/*
 	 * Validate the given file system size.
 	 * Verify that its last block can actually be accessed.
@@ -214,20 +201,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 		exit(20);
 	}
 
-	if (maxbsize < bsize || !POWEROF2(maxbsize)) {
-		sblock.fs_maxbsize = sblock.fs_bsize;
-		printf("Extent size set to %d\n", sblock.fs_maxbsize);
-	} else if (sblock.fs_maxbsize > FS_MAXCONTIG * sblock.fs_bsize) {
-		sblock.fs_maxbsize = FS_MAXCONTIG * sblock.fs_bsize;
-		printf("Extent size reduced to %d\n", sblock.fs_maxbsize);
-	} else {
-		sblock.fs_maxbsize = maxbsize;
-	}
 	sblock.fs_maxcontig = maxcontig;
-	if (sblock.fs_maxcontig < sblock.fs_maxbsize / sblock.fs_bsize) {
-		sblock.fs_maxcontig = sblock.fs_maxbsize / sblock.fs_bsize;
-		printf("Maxcontig raised to %d\n", sblock.fs_maxbsize);
-	}
 
 	if (sblock.fs_maxcontig > 1)
 		sblock.fs_contigsumsize = MIN(sblock.fs_maxcontig,FS_MAXCONTIG);
@@ -251,45 +225,34 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 		exit(21);
 	}
 	sblock.fs_fsbtodb = ilog2(sblock.fs_fsize / sectorsize);
-	sblock.fs_size = sblock.fs_providersize = fssize =
-	    dbtofsb(&sblock, fssize);
-
-	if (Oflag <= 1) {
-		sblock.fs_magic = FS_UFS1_MAGIC;
-		sblock.fs_sblockloc = SBLOCK_UFS1;
-		sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs1_daddr_t);
-		sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs1_dinode);
-		sblock.fs_maxsymlinklen = ((UFS_NDADDR + UFS_NIADDR) *
-		    sizeof (ufs1_daddr_t));
-		sblock.fs_old_inodefmt = FS_44INODEFMT;
-		sblock.fs_old_cgoffset = 0;
-		sblock.fs_old_cgmask = 0xffffffff;
-		sblock.fs_old_size = sblock.fs_size;
-		sblock.fs_old_rotdelay = 0;
-		sblock.fs_old_rps = 60;
-		sblock.fs_old_nspf = sblock.fs_fsize / sectorsize;
-		sblock.fs_old_cpg = 1;
-		sblock.fs_old_interleave = 1;
-		sblock.fs_old_trackskew = 0;
-		sblock.fs_old_cpc = 0;
-		sblock.fs_old_postblformat = 1;
-		sblock.fs_old_nrpos = 1;
-	} else {
-		sblock.fs_magic = FS_UFS2_MAGIC;
-		sblock.fs_sblockloc = SBLOCK_UFS2;
-		sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs2_daddr_t);
-		sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs2_dinode);
-		sblock.fs_maxsymlinklen = ((UFS_NDADDR + UFS_NIADDR) *
-		    sizeof (ufs2_daddr_t));
-		if (ffs_opts->softupdates == 1)
-			sblock.fs_flags |= FS_DOSOFTDEP;
-	}
+	sblock.fs_size = fssize = dbtofsb(&sblock, fssize);
+
+	sblock.fs_magic = FS_MAGIC;
+	sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs_daddr_t);
+	sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs1_dinode);
+	sblock.fs_maxsymlinklen = ((UFS_NDADDR + UFS_NIADDR) *
+	    sizeof (ufs_daddr_t));
+	sblock.fs_inodefmt = FS_44INODEFMT;
+	sblock.fs_cgoffset = 0;
+	sblock.fs_cgmask = 0xffffffff;
+	sblock.fs_size = sblock.fs_size;
+	sblock.fs_rotdelay = 0;
+	sblock.fs_rps = 60;
+	sblock.fs_nspf = sblock.fs_fsize / sectorsize;
+	sblock.fs_cpg = 1;
+	sblock.fs_interleave = 1;
+	sblock.fs_trackskew = 0;
+	sblock.fs_cpc = 0;
+	sblock.fs_postblformat = 1;
+	sblock.fs_nrpos = 1;
+	if (ffs_opts->softupdates == 1)
+		sblock.fs_flags |= FS_DOSOFTDEP;
 
 	sblock.fs_sblkno =
-	    roundup(howmany(sblock.fs_sblockloc + SBLOCKSIZE, sblock.fs_fsize),
+	    roundup(howmany(8192 + SBSIZE, sblock.fs_fsize),
 		sblock.fs_frag);
-	sblock.fs_cblkno = (daddr_t)(sblock.fs_sblkno +
-	    roundup(howmany(SBLOCKSIZE, sblock.fs_fsize), sblock.fs_frag));
+	sblock.fs_cblkno = (makefs_daddr_t)(sblock.fs_sblkno +
+	    roundup(howmany(SBSIZE, sblock.fs_fsize), sblock.fs_frag));
 	sblock.fs_iblkno = sblock.fs_cblkno + sblock.fs_frag;
 	sblock.fs_maxfilesize = sblock.fs_bsize * UFS_NDADDR - 1;
 	for (sizepb = sblock.fs_bsize, i = 0; i < UFS_NIADDR; i++) {
@@ -330,8 +293,14 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 			sblock.fs_fpg = minfpg;
 		sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
 		    INOPB(&sblock));
+#if 0
+		sblock.fs_spc = sblock.fs_fpg * sblock.fs_nspf;
 		if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize)
 			break;
+#else
+		if (FBSD_CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize)
+			break;
+#endif
 		density -= sblock.fs_fsize;
 	}
 	if (density != origdensity)
@@ -349,10 +318,18 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 		    INOPB(&sblock));
 		if (sblock.fs_size / sblock.fs_fpg < 1)
 			break;
+#if 0
+		sblock.fs_spc = sblock.fs_fpg * sblock.fs_nspf;
 		if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize)
 			continue;
 		if (CGSIZE(&sblock) == (unsigned long)sblock.fs_bsize)
 			break;
+#else
+		if (FBSD_CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize)
+			continue;
+		if (FBSD_CGSIZE(&sblock) == (unsigned long)sblock.fs_bsize)
+			break;
+#endif
 		sblock.fs_fpg -= sblock.fs_frag;
 		sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
 		    INOPB(&sblock));
@@ -384,14 +361,17 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 	if (optimalfpg != sblock.fs_fpg)
 		printf("Reduced frags per cylinder group from %d to %d %s\n",
 		   optimalfpg, sblock.fs_fpg, "to enlarge last cyl group");
+#if 0
+	sblock.fs_spc = sblock.fs_fpg * sblock.fs_nspf;
 	sblock.fs_cgsize = fragroundup(&sblock, CGSIZE(&sblock));
+#else
+	sblock.fs_cgsize = fragroundup(&sblock, FBSD_CGSIZE(&sblock));
+#endif
 	sblock.fs_dblkno = sblock.fs_iblkno + sblock.fs_ipg / INOPF(&sblock);
-	if (Oflag <= 1) {
-		sblock.fs_old_spc = sblock.fs_fpg * sblock.fs_old_nspf;
-		sblock.fs_old_nsect = sblock.fs_old_spc;
-		sblock.fs_old_npsect = sblock.fs_old_spc;
-		sblock.fs_old_ncyl = sblock.fs_ncg;
-	}
+	sblock.fs_spc = sblock.fs_fpg * sblock.fs_nspf;
+	sblock.fs_nsect = sblock.fs_spc;
+	sblock.fs_npsect = sblock.fs_spc;
+	sblock.fs_ncyl = sblock.fs_ncg;
 
 	/*
 	 * fill in remaining fields of the super block
@@ -419,8 +399,8 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 	}
 
 	sblock.fs_sbsize = fragroundup(&sblock, sizeof(struct fs));
-	if (sblock.fs_sbsize > SBLOCKSIZE)
-		sblock.fs_sbsize = SBLOCKSIZE;
+	if (sblock.fs_sbsize > SBSIZE)
+		sblock.fs_sbsize = SBSIZE;
 	sblock.fs_minfree = minfree;
 	sblock.fs_maxcontig = maxcontig;
 	sblock.fs_maxbpg = maxbpg;
@@ -455,15 +435,6 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 	sblock.fs_cstotal.cs_ndir = 0;
 	sblock.fs_dsize -= csfrags;
 	sblock.fs_time = tstamp;
-	if (Oflag <= 1) {
-		sblock.fs_old_time = tstamp;
-		sblock.fs_old_dsize = sblock.fs_dsize;
-		sblock.fs_old_csaddr = sblock.fs_csaddr;
-		sblock.fs_old_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
-		sblock.fs_old_cstotal.cs_nbfree = sblock.fs_cstotal.cs_nbfree;
-		sblock.fs_old_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree;
-		sblock.fs_old_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree;
-	}
 	/*
 	 * Dump out summary information about file system.
 	 */
@@ -492,8 +463,8 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 	 * allocate space for superblock, cylinder group map, and
 	 * two sets of inode blocks.
 	 */
-	if (sblock.fs_bsize < SBLOCKSIZE)
-		iobufsize = SBLOCKSIZE + 3 * sblock.fs_bsize;
+	if (sblock.fs_bsize < SBSIZE)
+		iobufsize = SBSIZE + 3 * sblock.fs_bsize;
 	else
 		iobufsize = 4 * sblock.fs_bsize;
 	iobuf = ecalloc(1, iobufsize);
@@ -504,7 +475,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 	memcpy(writebuf, &sblock, sbsize);
 	if (fsopts->needswap)
 		ffs_sb_swap(&sblock, (struct fs*)writebuf);
-	memcpy(iobuf, writebuf, SBLOCKSIZE);
+	memcpy(iobuf, writebuf, SBSIZE);
 
 	printf("super-block backups (for fsck -b #) at:");
 	for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
@@ -522,12 +493,6 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 	 * then write out the super-block.
 	 */
 	sblock.fs_time = tstamp;
-	if (Oflag <= 1) {
-		sblock.fs_old_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
-		sblock.fs_old_cstotal.cs_nbfree = sblock.fs_cstotal.cs_nbfree;
-		sblock.fs_old_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree;
-		sblock.fs_old_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree;
-	}
 	if (fsopts->needswap)
 		sblock.fs_flags |= FS_SWAPPED;
 	ffs_write_superblock(&sblock, fsopts);
@@ -552,7 +517,7 @@ ffs_write_superblock(struct fs *fs, const fsinfo_t *fsopts)
         memcpy(writebuf, &sblock, sbsize);
 	if (fsopts->needswap)
 		ffs_sb_swap(fs, (struct fs*)writebuf);
-	ffs_wtfs(fs->fs_sblockloc / sectorsize, sbsize, writebuf, fsopts);
+	ffs_wtfs(8192 / sectorsize, sbsize, writebuf, fsopts);
 
 	/* Write out the duplicate super blocks */
 	for (cylno = 0; cylno < fs->fs_ncg; cylno++)
@@ -586,11 +551,10 @@ ffs_write_superblock(struct fs *fs, const fsinfo_t *fsopts)
 static void
 initcg(uint32_t cylno, time_t utime, const fsinfo_t *fsopts)
 {
-	daddr_t cbase, dmax;
+	makefs_daddr_t cbase, dmax;
 	int32_t blkno;
 	uint32_t i, j, d, dlower, dupper;
 	struct ufs1_dinode *dp1;
-	struct ufs2_dinode *dp2;
 	int start;
 
 	/*
@@ -611,30 +575,19 @@ initcg(uint32_t cylno, time_t utime, const fsinfo_t *fsopts)
 	acg.cg_magic = CG_MAGIC;
 	acg.cg_cgx = cylno;
 	acg.cg_niblk = sblock.fs_ipg;
-	acg.cg_initediblk = MIN(sblock.fs_ipg, 2 * INOPB(&sblock));
 	acg.cg_ndblk = dmax - cbase;
 	if (sblock.fs_contigsumsize > 0)
 		acg.cg_nclusterblks = acg.cg_ndblk >> sblock.fs_fragshift;
 	start = &acg.cg_space[0] - (u_char *)(&acg.cg_firstfield);
-	if (Oflag == 2) {
-		acg.cg_iusedoff = start;
-	} else {
-		if (cylno == sblock.fs_ncg - 1)
-			acg.cg_old_ncyl = howmany(acg.cg_ndblk,
-			    sblock.fs_fpg / sblock.fs_old_cpg);
-		else
-			acg.cg_old_ncyl = sblock.fs_old_cpg;
-		acg.cg_old_time = acg.cg_time;
-		acg.cg_time = 0;
-		acg.cg_old_niblk = acg.cg_niblk;
-		acg.cg_niblk = 0;
-		acg.cg_initediblk = 0;
-		acg.cg_old_btotoff = start;
-		acg.cg_old_boff = acg.cg_old_btotoff +
-		    sblock.fs_old_cpg * sizeof(int32_t);
-		acg.cg_iusedoff = acg.cg_old_boff +
-		    sblock.fs_old_cpg * sizeof(u_int16_t);
-	}
+	if (cylno == sblock.fs_ncg - 1)
+		acg.cg_ncyl = sblock.fs_ncyl % sblock.fs_cpg;
+	else
+		acg.cg_ncyl = sblock.fs_cpg;
+	acg.cg_btotoff = start;
+	acg.cg_boff = acg.cg_btotoff +
+	    sblock.fs_cpg * sizeof(int32_t);
+	acg.cg_iusedoff = acg.cg_boff +
+	    sblock.fs_cpg * sizeof(u_int16_t);
 	acg.cg_freeoff = acg.cg_iusedoff + howmany(sblock.fs_ipg, CHAR_BIT);
 	if (sblock.fs_contigsumsize <= 0) {
 		acg.cg_nextfreeoff = acg.cg_freeoff +
@@ -669,6 +622,9 @@ initcg(uint32_t cylno, time_t utime, const fsinfo_t *fsopts)
 			if (sblock.fs_contigsumsize > 0)
 				setbit(cg_clustersfree_swap(&acg, 0), blkno);
 			acg.cg_cs.cs_nbfree++;
+			cg_blktot(&acg)[cbtocylno(&sblock, d)]++;
+			cg_blks(&sblock, &acg, cbtocylno(&sblock, d))
+			    [cbtorpos(&sblock, d)]++;
 			d += sblock.fs_frag;
 			blkno++;
 		}
@@ -686,6 +642,9 @@ initcg(uint32_t cylno, time_t utime, const fsinfo_t *fsopts)
 		if (sblock.fs_contigsumsize > 0)
 			setbit(cg_clustersfree_swap(&acg, 0), blkno);
 		acg.cg_cs.cs_nbfree++;
+		cg_blktot(&acg)[cbtocylno(&sblock, d)]++;
+		cg_blks(&sblock, &acg, cbtocylno(&sblock, d))
+		    [cbtorpos(&sblock, d)]++;
 		d += sblock.fs_frag;
 		blkno++;
 	}
@@ -730,40 +689,27 @@ initcg(uint32_t cylno, time_t utime, const fsinfo_t *fsopts)
 	 * Write out the duplicate super block, the cylinder group map
 	 * and two blocks worth of inodes in a single write.
 	 */
-	start = MAX(sblock.fs_bsize, SBLOCKSIZE);
+	start = MAX(sblock.fs_bsize, SBSIZE);
 	memcpy(&iobuf[start], &acg, sblock.fs_cgsize);
 	if (fsopts->needswap)
 		ffs_cg_swap(&acg, (struct cg*)&iobuf[start], &sblock);
 	start += sblock.fs_bsize;
 	dp1 = (struct ufs1_dinode *)(&iobuf[start]);
-	dp2 = (struct ufs2_dinode *)(&iobuf[start]);
-	for (i = 0; i < acg.cg_initediblk; i++) {
-		if (sblock.fs_magic == FS_UFS1_MAGIC) {
-			/* No need to swap, it'll stay random */
-			dp1->di_gen = random();
-			dp1++;
-		} else {
-			dp2->di_gen = random();
-			dp2++;
-		}
-	}
 	ffs_wtfs(fsbtodb(&sblock, cgsblock(&sblock, cylno)), iobufsize, iobuf,
 	    fsopts);
 	/*
-	 * For the old file system, we have to initialize all the inodes.
+	 * Initialize all the inodes.
 	 */
-	if (Oflag <= 1) {
-		for (i = 2 * sblock.fs_frag;
-		     i < sblock.fs_ipg / INOPF(&sblock);
-		     i += sblock.fs_frag) {
-			dp1 = (struct ufs1_dinode *)(&iobuf[start]);
-			for (j = 0; j < INOPB(&sblock); j++) {
-				dp1->di_gen = random();
-				dp1++;
-			}
-			ffs_wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
-			    sblock.fs_bsize, &iobuf[start], fsopts);
+	for (i = 2 * sblock.fs_frag;
+	     i < sblock.fs_ipg / INOPF(&sblock);
+	     i += sblock.fs_frag) {
+		dp1 = (struct ufs1_dinode *)(&iobuf[start]);
+		for (j = 0; j < INOPB(&sblock); j++) {
+			dp1->di_gen = random();
+			dp1++;
 		}
+		ffs_wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
+		    sblock.fs_bsize, &iobuf[start], fsopts);
 	}
 }
 
@@ -771,7 +717,7 @@ initcg(uint32_t cylno, time_t utime, const fsinfo_t *fsopts)
  * read a block from the file system
  */
 void
-ffs_rdfs(daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
+ffs_rdfs(makefs_daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
 {
 	int n;
 	off_t offset;
@@ -795,7 +741,7 @@ ffs_rdfs(daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
  * write a block to the file system
  */
 void
-ffs_wtfs(daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
+ffs_wtfs(makefs_daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
 {
 	int n;
 	off_t offset;
diff --git a/usr.sbin/makefs/ffs/newfs_extern.h b/usr.sbin/makefs/ffs/newfs_extern.h
index 4cadf8514f..0d2136627b 100644
--- a/usr.sbin/makefs/ffs/newfs_extern.h
+++ b/usr.sbin/makefs/ffs/newfs_extern.h
@@ -32,7 +32,7 @@
 /* prototypes */
 struct fs	*ffs_mkfs(const char *, const fsinfo_t *, time_t);
 void		ffs_write_superblock(struct fs *, const fsinfo_t *);
-void		ffs_rdfs(daddr_t, int, void *, const fsinfo_t *);
-void		ffs_wtfs(daddr_t, int, void *, const fsinfo_t *);
+void		ffs_rdfs(makefs_daddr_t, int, void *, const fsinfo_t *);
+void		ffs_wtfs(makefs_daddr_t, int, void *, const fsinfo_t *);
 
 #define	FFS_MAXBSIZE	65536
diff --git a/usr.sbin/makefs/ffs/ufs_bmap.c b/usr.sbin/makefs/ffs/ufs_bmap.c
index e6576c6936..adf9199a1c 100644
--- a/usr.sbin/makefs/ffs/ufs_bmap.c
+++ b/usr.sbin/makefs/ffs/ufs_bmap.c
@@ -37,11 +37,9 @@
  * SUCH DAMAGE.
  *
  *	@(#)ufs_bmap.c	8.8 (Berkeley) 8/11/95
+ * $FreeBSD: head/usr.sbin/makefs/ffs/ufs_bmap.c 326025 2017-11-20 19:49:47Z pfg $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/ufs_bmap.c 326025 2017-11-20 19:49:47Z pfg $");
-
 #include <sys/param.h>
 #include <sys/time.h>
 
@@ -68,9 +66,9 @@ __FBSDID("$FreeBSD: head/usr.sbin/makefs/ffs/ufs_bmap.c 326025 2017-11-20 19:49:
  * once with the offset into the page itself.
  */
 int
-ufs_getlbns(struct inode *ip, daddr_t bn, struct indir *ap, int *nump)
+ufs_getlbns(struct inode *ip, makefs_daddr_t bn, struct indir *ap, int *nump)
 {
-	daddr_t metalbn, realbn;
+	makefs_daddr_t metalbn, realbn;
 	int64_t blockcnt;
 	int lbc;
 	int i, numlevels, off;
diff --git a/usr.sbin/makefs/ffs/ufs_inode.h b/usr.sbin/makefs/ffs/ufs_inode.h
index 8f561a7c7f..58185484f4 100644
--- a/usr.sbin/makefs/ffs/ufs_inode.h
+++ b/usr.sbin/makefs/ffs/ufs_inode.h
@@ -42,7 +42,6 @@
 
 union dinode {
 	struct ufs1_dinode ffs1_din;
-	struct ufs2_dinode ffs2_din;
 };
 
 struct inode {
@@ -72,28 +71,5 @@ struct inode {
 #define	i_ffs1_size		i_din.ffs1_din.di_size
 #define	i_ffs1_uid		i_din.ffs1_din.di_uid
 
-#define	i_ffs2_atime		i_din.ffs2_din.di_atime
-#define	i_ffs2_atimensec	i_din.ffs2_din.di_atimensec
-#define	i_ffs2_blocks		i_din.ffs2_din.di_blocks
-#define	i_ffs2_ctime		i_din.ffs2_din.di_ctime
-#define	i_ffs2_ctimensec	i_din.ffs2_din.di_ctimensec
-#define	i_ffs2_birthtime	i_din.ffs2_din.di_birthtime
-#define	i_ffs2_birthnsec	i_din.ffs2_din.di_birthnsec
-#define	i_ffs2_db		i_din.ffs2_din.di_db
-#define	i_ffs2_flags		i_din.ffs2_din.di_flags
-#define	i_ffs2_gen		i_din.ffs2_din.di_gen
-#define	i_ffs21_gid		i_din.ffs2_din.di_gid
-#define	i_ffs2_ib		i_din.ffs2_din.di_ib
-#define	i_ffs2_mode		i_din.ffs2_din.di_mode
-#define	i_ffs2_mtime		i_din.ffs2_din.di_mtime
-#define	i_ffs2_mtimensec	i_din.ffs2_din.di_mtimensec
-#define	i_ffs2_nlink		i_din.ffs2_din.di_nlink
-#define	i_ffs2_rdev		i_din.ffs2_din.di_rdev
-#define	i_ffs2_shortlink	i_din.ffs2_din.db
-#define	i_ffs2_size		i_din.ffs2_din.di_size
-#define	i_ffs2_uid		i_din.ffs2_din.di_uid
-
 #undef DIP
-#define DIP(ip, field) \
-        (((ip)->i_fs->fs_magic == FS_UFS1_MAGIC) ? \
-        (ip)->i_ffs1_##field : (ip)->i_ffs2_##field)
+#define DIP(ip, field) (ip)->i_ffs1_##field
diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8
index e08327ac14..326be916d5 100644
--- a/usr.sbin/makefs/makefs.8
+++ b/usr.sbin/makefs/makefs.8
@@ -35,7 +35,7 @@
 .\"
 .\" $FreeBSD: head/usr.sbin/makefs/makefs.8 331843 2018-03-31 15:04:41Z benno $
 .\"
-.Dd March 30, 2018
+.Dd January 3, 2019
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -307,13 +307,12 @@ Optimization preference; one of
 .Ql space
 or
 .Ql time .
-.It Sy extent
-Maximum extent size.
 .It Sy maxbpcg
 Maximum total number of blocks in a cylinder group.
 .It Sy version
 UFS version.
-1 for FFS (default), 2 for UFS2.
+1 for FFS (default)
+.\", 2 for UFS2.
 .It Sy softupdates
 0 for disable (default), 1 for enable
 .El
diff --git a/usr.sbin/makefs/makefs.c b/usr.sbin/makefs/makefs.c
index c0ca920b38..e19f229270 100644
--- a/usr.sbin/makefs/makefs.c
+++ b/usr.sbin/makefs/makefs.c
@@ -35,11 +35,10 @@
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/makefs.c 326276 2017-11-27 15:37:16Z pfg $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/makefs.c 326276 2017-11-27 15:37:16Z pfg $");
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <assert.h>
@@ -82,10 +81,10 @@ static fstype_t fstypes[] = {
 u_int		debug;
 int		dupsok;
 struct timespec	start_time;
-struct stat stampst;
+struct stat	stampst;
 
 static	fstype_t *get_fstype(const char *);
-static int get_tstamp(const char *, struct stat *);
+static	int	get_tstamp(const char *, struct stat *);
 static	void	usage(fstype_t *, fsinfo_t *);
 
 int
diff --git a/usr.sbin/makefs/makefs.h b/usr.sbin/makefs/makefs.h
index 420a0629b4..c7d3887224 100644
--- a/usr.sbin/makefs/makefs.h
+++ b/usr.sbin/makefs/makefs.h
@@ -165,6 +165,7 @@ typedef struct makefs_fsinfo {
 	option_t *fs_options;	/* File system specific options */
 } fsinfo_t;
 
+typedef	__int64_t	makefs_daddr_t;
 
 void		apply_specfile(const char *, const char *, fsnode *, int);
 void		dump_fsnodes(fsnode *);
@@ -270,10 +271,6 @@ extern	struct stat stampst;
 #define        FS_ISCLEAN      1
 
 #define        DINODE1_SIZE    (sizeof(struct ufs1_dinode))
-#define        DINODE2_SIZE    (sizeof(struct ufs2_dinode))
-
-#define UFS1_MAXSYMLINKLEN   ((UFS_NDADDR + UFS_NIADDR) * sizeof(ufs1_daddr_t))
-#define UFS2_MAXSYMLINKLEN   ((UFS_NDADDR + UFS_NIADDR) * sizeof(ufs2_daddr_t))
 
 #if (BYTE_ORDER == LITTLE_ENDIAN)
 #define DIRSIZ_SWAP(oldfmt, dp, needswap)      \
diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c
index 42ea2cabbf..9f5ecc2a54 100644
--- a/usr.sbin/makefs/mtree.c
+++ b/usr.sbin/makefs/mtree.c
@@ -23,15 +23,14 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/mtree.c 332986 2018-04-25 02:43:53Z pfg $
  */
 
 #if HAVE_NBTOOL_CONFIG_H
 #include "nbtool_config.h"
 #endif
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/mtree.c 332986 2018-04-25 02:43:53Z pfg $");
-
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/sbuf.h>
diff --git a/usr.sbin/makefs/walk.c b/usr.sbin/makefs/walk.c
index 6b39fca815..562404559e 100644
--- a/usr.sbin/makefs/walk.c
+++ b/usr.sbin/makefs/walk.c
@@ -35,12 +35,11 @@
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/usr.sbin/makefs/walk.c 326276 2017-11-27 15:37:16Z pfg $
  */
 
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/makefs/walk.c 326276 2017-11-27 15:37:16Z pfg $");
-
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -404,15 +403,6 @@ apply_specdir(const char *dir, NODE *specnode, fsnode *dirnode, int speconly)
 			errx(1, "Pathname too long.");
 		if (curfsnode == NULL) {	/* need new entry */
 			struct stat	stbuf;
-
-					    /*
-					     * don't add optional spec entries
-					     * that lack an existing fs entry
-					     */
-			if ((curnode->flags & F_OPT) &&
-			    lstat(path, &stbuf) == -1)
-					continue;
-
 					/* check that enough info is provided */
 #define NODETEST(t, m)							\
 			if (!(t))					\
@@ -553,7 +543,6 @@ apply_specentry(const char *dir, NODE *specnode, fsnode *dirnode)
 	dirnode->flags |= FSNODE_F_HASSPEC;
 }
 
-
 /*
  * dump_fsnodes --
  *	dump the fsnodes from `cur'
-- 
2.19.2

