Port-atari archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Floppy image overflow



On 12 Jan 2017 14:32:59 +0100, Martin Husemann wrote:
Hey folks,

in -current the atari build fails due to the 1.4MB floppy image
overflowing.

See: http://releng.netbsd.org/cgi-bin/builds.cgi

Any ideas what to strip out?

How about dropping Apple and byte-swapped UFS support from fsck_ffs and
newfs? Both seem to be useless for atari (is it right?). This reduces
about 10KB from instbin, and the resulting filesystem successfully fits
within 1.4MB.

Thanks,
Rin

--- src/distrib/atari/floppies/common/Makefile.images.orig	2017-02-07 07:14:09.304814268 +0900
+++ src/distrib/atari/floppies/common/Makefile.images	2017-02-07 14:11:13.928606822 +0900
@@ -8,6 +8,8 @@
 WARNS=		1
 DBG=		-Os -m68020-60	# -m68020-60 seems to generate smaller binaries
 DBG+=		-DNDEBUG	# to remove assert(3) macro
+CRUNCHENV+=	NOAPPLEUFS=1	# disable Apple UFS support
+CRUNCHENV+=	NOUFSBSWAP=1	# disable byte-swapped UFS support
CRUNCHBIN= instbin
 LISTS=		${.CURDIR}/list ${.CURDIR}/../common/list.images
--- src/sbin/fsck_ffs/Makefile.orig	2017-02-07 14:09:42.700416503 +0900
+++ src/sbin/fsck_ffs/Makefile	2017-02-07 11:29:54.319623708 +0900
@@ -6,8 +6,20 @@
 PROG=	fsck_ffs
 MAN=	fsck_ffs.8
 SRCS=	dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
-	pass5.c pass6.c fsutil.c setup.c utilities.c ffs_bswap.c ffs_subr.c \
-	ffs_tables.c ffs_appleufs.c partutil.c snapshot.c quota2.c quota2_subr.c
+	pass5.c pass6.c fsutil.c setup.c utilities.c ffs_subr.c \
+	ffs_tables.c partutil.c snapshot.c quota2.c quota2_subr.c
+
+.if defined(NOAPPLEUFS)
+CPPFLAGS+=-DNOAPPLEUFS
+.else
+SRCS+=	ffs_appleufs.c
+.endif
+
+.if defined(NOUFSBSWAP)
+CPPFLAGS+=-DNOUFSBSWAP
+.else
+SRCS+=	ffs_bswap.c
+.endif
FSCK= ${NETBSDSRCDIR}/sbin/fsck
 DUMP=	${NETBSDSRCDIR}/sbin/dump
--- src/sbin/fsck_ffs/fsck.h.orig	2017-02-07 14:09:42.702586585 +0900
+++ src/sbin/fsck_ffs/fsck.h	2017-02-07 13:51:55.865661950 +0900
@@ -156,6 +156,7 @@
 struct fs *altsblock;
 struct cg *cgrp;
 struct fs *sblocksave;
+#ifndef NOUFSBSWAP
 #define	sbdirty() \
 	do { \
 		memmove(sblk.b_un.b_fs, sblock, SBLOCKSIZE); \
@@ -164,6 +165,14 @@
 			ffs_sb_swap(sblk.b_un.b_fs, sblk.b_un.b_fs); \
 		sblk.b_dirty = 1; \
 	} while (0)
+#else
+#define	sbdirty() \
+	do { \
+		memmove(sblk.b_un.b_fs, sblock, SBLOCKSIZE); \
+		sb_oldfscompat_write(sblk.b_un.b_fs, sblocksave); \
+		sblk.b_dirty = 1; \
+	} while (0)
+#endif
 #define	cgdirty()	do {copyback_cg(&cgblk); cgblk.b_dirty = 1;} while (0)
#define appleufsdirty() \
@@ -362,3 +371,8 @@
 		return bswap64(x);
 	else return x;
 }
+
+/* XXX */
+#ifdef NOUFSBSWAP
+#define	ufs_rw32(x, ns)	(x)
+#endif
--- src/sbin/fsck_ffs/inode.c.orig	2017-02-07 14:09:42.704024121 +0900
+++ src/sbin/fsck_ffs/inode.c	2017-02-07 11:33:09.813269777 +0900
@@ -46,7 +46,9 @@
 #include <ufs/ufs/dir.h>
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
+#ifndef NOUFSBSWAP
 #include <ufs/ufs/ufs_bswap.h>
+#endif
#ifndef SMALL
 #include <err.h>
@@ -64,8 +66,10 @@
 static ino_t startinum;
static int iblock(struct inodesc *, long, u_int64_t);
+#ifndef NOUFSBSWAP
 static void swap_dinode1(union dinode *, int);
 static void swap_dinode2(union dinode *, int);
+#endif
int
 ckinode(union dinode *dp, struct inodesc *idesc)
@@ -342,6 +346,7 @@
 	return ((union dinode *)((caddr_t)pbp->b_un.b_buf + blkoff));
 }
+#ifndef NOUFSBSWAP
 static void
 swap_dinode1(union dinode *dp, int n)
 {
@@ -385,6 +390,7 @@
 		}
 	}
 }
+#endif
/*
  * Special purpose version of ginode used to optimize first pass
@@ -417,6 +423,7 @@
 			lastinum += fullcnt;
 		}
 		(void)bread(fsreadfd, (caddr_t)inodebuf, dblk, size);
+#ifndef NOUFSBSWAP
 		if (doswap) {
 			if (is_ufs2)
 				swap_dinode2(inodebuf, lastinum - inumber);
@@ -424,6 +431,7 @@
 				swap_dinode1(inodebuf, lastinum - inumber);
 			bwrite(fswritefd, (char *)inodebuf, dblk, size);
 		}
+#endif
 		dp = (union dinode *)inodebuf;
 	}
 	ret = dp;
@@ -750,12 +758,16 @@
 	}
 	getblk(&cgblk, cgtod(sblock, cg), sblock->fs_cgsize);
 	memcpy(cgp, cgblk.b_un.b_cg, sblock->fs_cgsize);
+#ifndef NOUFSBSWAP
 	if ((doswap && !needswap) || (!doswap && needswap))
 		ffs_cg_swap(cgblk.b_un.b_cg, cgp, sblock);
+#endif
 	if (!cg_chkmagic(cgp, 0))
 		pfatal("CG %d: ALLOCINO: BAD MAGIC NUMBER\n", cg);
+#ifndef NOUFSBSWAP
 	if (doswap)
 		cgdirty();
+#endif
 	setbit(cg_inosused(cgp, 0), ino % sblock->fs_ipg);
 	cgp->cg_cs.cs_nifree--;
 	sblock->fs_cstotal.cs_nifree--;
@@ -830,8 +842,10 @@
 	cg = ino_to_cg(sblock, ino);
 	getblk(&cgblk, cgtod(sblock, cg), sblock->fs_cgsize);
 	memcpy(cgp, cgblk.b_un.b_cg, sblock->fs_cgsize);
+#ifndef NOUFSBSWAP
 	if ((doswap && !needswap) || (!doswap && needswap))
 		ffs_cg_swap(cgblk.b_un.b_cg, cgp, sblock);
+#endif
 	if (!cg_chkmagic(cgp, 0)) {
 		pwarn("CG %d: FREEINO: BAD MAGIC NUMBER\n", cg);
 		cgp = NULL;
--- src/sbin/fsck_ffs/main.c.orig	2017-02-07 14:09:42.704735053 +0900
+++ src/sbin/fsck_ffs/main.c	2017-02-07 14:08:07.492049315 +0900
@@ -98,18 +98,27 @@
 	forceimage = 0;
 	endian = 0;
 	isappleufs = 0;
+#ifndef NOAPPLEUFS
 	while ((ch = getopt(argc, argv, "aB:b:c:dFfm:npPqUyx:X")) != -1) {
+#else
+	while ((ch = getopt(argc, argv, "B:b:c:dFfm:npPqUyx:X")) != -1) {
+#endif
 		switch (ch) {
+#ifndef NOAPPLEUFS
 		case 'a':
 			isappleufs = 1;
 			break;
+#endif
case 'B':
+#ifndef NOUFSBSWAP
 			if (strcmp(optarg, "be") == 0)
 				endian = BIG_ENDIAN;
 			else if (strcmp(optarg, "le") == 0)
 				endian = LITTLE_ENDIAN;
-			else usage();
+			else
+#endif
+				usage();
 			break;
case 'b':
@@ -511,8 +520,15 @@
 {
(void) fprintf(stderr,
-	    "usage: %s [-adFfPpqUX] [-B byteorder] [-b block] [-c level] "
-	    "[-m mode]\n"
+	    "usage: %s [-"
+#ifndef NOAPPLEUFS
+	    "a"
+#endif
+	    "dFfPpqUX] "
+#ifndef NOUFSBSWAP
+	    "[-B byteorder] "
+#endif
+	    "[-b block] [-c level] [-m mode]\n"
 	    "\t[-x snap-backup] [-y | -n] filesystem ...\n",
 	    getprogname());
 	exit(FSCK_EXIT_USAGE);
--- src/sbin/fsck_ffs/pass1.c.orig	2017-02-07 14:09:42.705440103 +0900
+++ src/sbin/fsck_ffs/pass1.c	2017-02-07 11:29:54.326516818 +0900
@@ -45,7 +45,9 @@
 #include <ufs/ufs/dinode.h>
 #include <ufs/ufs/dir.h>
 #include <ufs/ffs/fs.h>
+#ifndef NOUFSBSWAP
 #include <ufs/ufs/ufs_bswap.h>
+#endif
 #include <ufs/ffs/ffs_extern.h>
#include <err.h>
@@ -102,8 +104,10 @@
 		setinodebuf(inumber);
 		getblk(&cgblk, cgtod(sblock, c), sblock->fs_cgsize);
 		memcpy(cgp, cgblk.b_un.b_cg, sblock->fs_cgsize);
+#ifndef NOUFSBSWAP
 		if((doswap && !needswap) || (!doswap && needswap))
 			ffs_cg_swap(cgblk.b_un.b_cg, cgp, sblock);
+#endif
 		if (is_ufs2)
 			inosused = cgp->cg_initediblk;
 		else
--- src/sbin/fsck_ffs/pass4.c.orig	2017-02-07 14:09:42.708308211 +0900
+++ src/sbin/fsck_ffs/pass4.c	2017-02-07 11:29:54.329532165 +0900
@@ -42,7 +42,9 @@
 #include <sys/time.h>
 #include <sys/stat.h>
+#ifndef NOUFSBSWAP
 #include <ufs/ufs/ufs_bswap.h>
+#endif
 #include <ufs/ufs/dinode.h>
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
@@ -165,8 +167,10 @@
 	cg = dtog(sblock, blkno);
 	getblk(&cgblk, cgtod(sblock, cg), sblock->fs_cgsize);
 	memcpy(cgp, cgblk.b_un.b_cg, sblock->fs_cgsize);
+#ifndef NOUFSBSWAP
 	if ((doswap && !needswap) || (!doswap && needswap))
 		ffs_cg_swap(cgblk.b_un.b_cg, cgp, sblock);
+#endif
 	if (!cg_chkmagic(cgp, 0)) {
 		pwarn("CG %d: ALLOCBLK: BAD MAGIC NUMBER\n", cg);
 		cgp = NULL;
--- src/sbin/fsck_ffs/pass5.c.orig	2017-02-07 14:09:42.709010933 +0900
+++ src/sbin/fsck_ffs/pass5.c	2017-02-07 11:48:43.594684664 +0900
@@ -44,7 +44,9 @@
 #include <ufs/ufs/dinode.h>
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
+#ifndef NOUFSBSWAP
 #include <ufs/ufs/ufs_bswap.h>
+#endif
#include <err.h>
 #include <string.h>
@@ -212,12 +214,16 @@
 #endif /* PROGRESS */
 		getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
 		memcpy(cg, cgblk.b_un.b_cg, fs->fs_cgsize);
+#ifndef NOUFSBSWAP
 		if((doswap && !needswap) || (!doswap && needswap))
 			ffs_cg_swap(cgblk.b_un.b_cg, cg, sblock);
+#endif
 		if (!doinglevel1 && !cg_chkmagic(cg, 0))
 			pfatal("CG %d: PASS5: BAD MAGIC NUMBER\n", c);
+#ifndef NOUFSBSWAP
 		if(doswap)
 			cgdirty();
+#endif
 		/*
 		 * While we have the disk head where we want it,
 		 * write back the superblock to the spare at this
@@ -240,8 +246,10 @@
 			else {
 				memmove(altsblock, asblk.b_un.b_fs,
 				    sblock->fs_sbsize);
+#ifndef NOUFSBSWAP
 				if (needswap)
 					ffs_sb_swap(asblk.b_un.b_fs, altsblock);
+#endif
 			}
 			sb_oldfscompat_write(sblock, sblocksave);
 			if ((asblk.b_errs || cmpsblks(sblock, altsblock)) &&
--- src/sbin/fsck_ffs/pass6.c.orig	2017-02-07 14:09:42.709691390 +0900
+++ src/sbin/fsck_ffs/pass6.c	2017-02-07 11:48:59.997557571 +0900
@@ -31,7 +31,9 @@
 #include <ufs/ufs/dinode.h>
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
+#ifndef NOUFSBSWAP
 #include <ufs/ufs/ufs_bswap.h>
+#endif
#include <err.h>
 #include <string.h>
--- src/sbin/fsck_ffs/quota2.c.orig	2017-02-07 14:09:42.710392968 +0900
+++ src/sbin/fsck_ffs/quota2.c	2017-02-07 11:29:54.331805934 +0900
@@ -31,7 +31,9 @@
 #include <ufs/ufs/dinode.h>
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
+#ifndef NOUFSBSWAP
 #include <ufs/ufs/ufs_bswap.h>
+#endif
#include <err.h>
 #include <string.h>
--- src/sbin/fsck_ffs/setup.c.orig	2017-02-07 14:09:42.711129160 +0900
+++ src/sbin/fsck_ffs/setup.c	2017-02-07 13:53:03.153413675 +0900
@@ -47,7 +47,9 @@
#include <ufs/ufs/dinode.h>
 #include <ufs/ufs/dir.h>
+#ifndef NOUFSBSWAP
 #include <ufs/ufs/ufs_bswap.h>
+#endif
 #include <ufs/ufs/quota2.h>
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
@@ -70,7 +72,9 @@
 static void badsb(int, const char *);
 static int calcsb(const char *, int, struct fs *);
 static int readsb(int);
+#ifndef NOAPPLEUFS
 static int readappleufs(void);
+#endif
int16_t sblkpostbl[256]; @@ -438,8 +442,10 @@
 	if (asblk.b_dirty && !bflag) {
 		memmove(sblk.b_un.b_fs, sblock, SBLOCKSIZE);
 		sb_oldfscompat_write(sblk.b_un.b_fs, sblocksave);
+#ifndef NOUFSBSWAP
 		if (needswap)
 			ffs_sb_swap(sblk.b_un.b_fs, sblk.b_un.b_fs);
+#endif
 		memmove(asblk.b_un.b_fs, sblk.b_un.b_fs, (size_t)sblock->fs_sbsize);
 		flush(fswritefd, &asblk);
 	}
@@ -467,6 +473,7 @@
 			}
 			asked++;
 		}
+#ifndef NOUFSBSWAP
 		if (doswap) {
 			ffs_csum_swap(ccsp, ccsp, size);
 			bwrite(fswritefd, (char *)ccsp,
@@ -476,6 +483,7 @@
 		}
 		if (needswap)
 			ffs_csum_swap(ccsp, ccsp, size);
+#endif
 	}
 	/*
 	 * allocate and initialize the necessary maps
@@ -529,10 +537,16 @@
if (!forceimage && dkw.dkw_parent[0])
 		if (strcmp(dkw.dkw_ptype, DKW_PTYPE_APPLEUFS) == 0)
+#ifndef NOAPPLEUFS
 			isappleufs = 1;
+#else
+			errexit("Apple UFS support is not compiled in");
+#endif
+#ifndef NOAPPLEUFS
 	if (readappleufs())
 		isappleufs = 1;
+#endif
dirblksiz = UFS_DIRBLKSIZ;
 	if (isappleufs)
@@ -580,6 +594,7 @@
 	return (0);
 }
+#ifndef NOAPPLEUFS
 static int
 readappleufs(void)
 {
@@ -684,6 +699,7 @@
 	}
 	return 1;
 }
+#endif
/*
  * Detect byte order. Return 0 if valid magic found, -1 otherwise.
@@ -700,12 +716,17 @@
 			needswap = 0;
 			doswap = do_blkswap = do_dirswap = 0;
 		} else {
+#ifndef NOUFSBSWAP
 			needswap = 1;
 			doswap = do_blkswap = do_dirswap = 1;
+#else
+			errexit("Byte-swapped UFS support is not compiled in");
+#endif
 		}
 		return 0;
 	} else if (fs->fs_magic == FS_UFS1_MAGIC_SWAPPED ||
 		   fs->fs_magic == FS_UFS2_MAGIC_SWAPPED) {
+#ifndef NOUFSBSWAP
 		if (endian == 0 || BYTE_ORDER != endian) {
 			needswap = 1;
 			doswap = do_blkswap = do_dirswap = 0;
@@ -714,6 +735,9 @@
 			doswap = do_blkswap = do_dirswap = 1;
 		}
 		return 0;
+#else
+		errexit("Byte-swapped UFS support is not compiled in");
+#endif
 	}
 	return -1;
 }
@@ -758,6 +782,7 @@
 			return (0);
 		}
 	}
+#ifndef NOUFSBSWAP
 	if (doswap) {
 		if (preen)
 			errx(FSCK_EXIT_USAGE,
@@ -779,10 +804,13 @@
 	/* swap SB byte order if asked */
 	if (doswap)
 		ffs_sb_swap(sblk.b_un.b_fs, sblk.b_un.b_fs);
+#endif
memmove(sblock, sblk.b_un.b_fs, SBLOCKSIZE);
+#ifndef NOUFSBSWAP
 	if (needswap)
 		ffs_sb_swap(sblk.b_un.b_fs, sblock);
+#endif
is_ufs2 = sblock->fs_magic == FS_UFS2_MAGIC; @@ -810,13 +838,17 @@
 	getblk(&asblk, cgsblock(sblock, sblock->fs_ncg - 1), sblock->fs_sbsize);
 	if (asblk.b_errs)
 		return (0);
+#ifndef NOUFSBSWAP
 	/* swap SB byte order if asked */
 	if (doswap)
 		ffs_sb_swap(asblk.b_un.b_fs, asblk.b_un.b_fs);
+#endif
memmove(altsblock, asblk.b_un.b_fs, sblock->fs_sbsize);
+#ifndef NOUFSBSWAP
 	if (needswap)
 		ffs_sb_swap(asblk.b_un.b_fs, altsblock);
+#endif
 	if (cmpsblks(sblock, altsblock)) {
 		if (debug) {
 			uint32_t *nlp, *olp, *endlp;
@@ -844,11 +876,13 @@
sb_oldfscompat_read(sblock, &sblocksave); +#ifndef NOUFSBSWAP
 	/* Now we know the SB is valid, we can write it back if needed */
 	if (doswap) {
 		sbdirty();
 		dirty(&asblk);
 	}
+#endif
 	havesb = 1;
 	return (1);
 }
--- src/sbin/fsck_ffs/utilities.c.orig	2017-02-07 14:09:42.711847753 +0900
+++ src/sbin/fsck_ffs/utilities.c	2017-02-07 11:29:54.333521181 +0900
@@ -45,7 +45,9 @@
 #include <ufs/ufs/dir.h>
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
+#ifndef NOUFSBSWAP
 #include <ufs/ufs/ufs_bswap.h>
+#endif
 #include <ufs/ufs/quota2.h>
#include <ctype.h>
@@ -238,13 +240,17 @@
 		int size = sblock->fs_cssize - i < sblock->fs_bsize ?
 			sblock->fs_cssize - i : sblock->fs_bsize;
 		ccsp = (struct csum *)((char *)sblock->fs_csp + i);
+#ifndef NOUFSBSWAP
 		if (needswap)
 			ffs_csum_swap(ccsp, ccsp, size);
+#endif
 		bwrite(fswritefd, (char *)ccsp,
 		    FFS_FSBTODB(sblock, sblock->fs_csaddr + j * sblock->fs_frag),
 		    size);
+#ifndef NOUFSBSWAP
 		if (needswap)
 			ffs_csum_swap(ccsp, ccsp, size);
+#endif
 	}
 }
@@ -409,8 +415,10 @@
 			cg = dtog(sblock, i + j);
 			getblk(&cgblk, cgtod(sblock, cg), sblock->fs_cgsize);
 			memcpy(cgp, cgblk.b_un.b_cg, sblock->fs_cgsize);
+#ifndef NOUFSBSWAP
 			if ((doswap && !needswap) || (!doswap && needswap))
 				ffs_cg_swap(cgblk.b_un.b_cg, cgp, sblock);
+#endif
 			if (!cg_chkmagic(cgp, 0))
 				pfatal("CG %d: ALLOCBLK: BAD MAGIC NUMBER\n",
 				    cg);
@@ -556,8 +564,10 @@
 {
memcpy(blk->b_un.b_cg, cgrp, sblock->fs_cgsize);
+#ifndef NOUFSBSWAP
 	if (needswap)
 		ffs_cg_swap(cgrp, blk->b_un.b_cg, sblock);
+#endif
 }
void
@@ -604,6 +614,7 @@
 		if (debug)
 			printf("detected ufs1 superblock not yet updated for ufs2 kernels\n");
+#ifndef NOUFSBSWAP
 		if (doswap) {
 			uint16_t postbl[256];
 			int i, n;
@@ -635,6 +646,7 @@
 			if (needswap)
 				ffs_sb_swap(*fssave, *fssave);
 		}
+#endif
} --- src/sbin/fsck_ffs/wapbl.c.orig 2017-02-07 14:09:42.712539626 +0900
+++ src/sbin/fsck_ffs/wapbl.c	2017-02-07 11:29:54.334285153 +0900
@@ -51,7 +51,9 @@
#include <ufs/ufs/dinode.h>
 #include <ufs/ufs/dir.h>
+#ifndef NOUFSBSWAP
 #include <ufs/ufs/ufs_bswap.h>
+#endif
 #include <ufs/ufs/ufs_wapbl.h>
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
--- src/sbin/newfs/Makefile.orig	2017-02-07 14:10:29.805101042 +0900
+++ src/sbin/newfs/Makefile	2017-02-07 11:53:31.316219505 +0900
@@ -4,10 +4,22 @@
 .include <bsd.own.mk>
PROG= newfs
-SRCS=	dkcksum.c newfs.c mkfs.c ffs_bswap.c ffs_appleufs.c partutil.c
+SRCS=	dkcksum.c newfs.c mkfs.c partutil.c
 SRCS+=	pathadj.c quota2_subr.c
 MAN=	newfs.8 mount_mfs.8
+.if defined(NOAPPLEUFS)
+CPPFLAGS+=-DNOAPPLEUFS
+.else
+SRCS+=  ffs_appleufs.c
+.endif
+
+.if defined(NOUFSBSWAP)
+CPPFLAGS+=-DNOUFSBSWAP
+.else
+SRCS+=  ffs_bswap.c
+.endif
+
 DISKLABEL=${NETBSDSRCDIR}/sbin/disklabel
 FSCK=${NETBSDSRCDIR}/sbin/fsck
 MOUNT=${NETBSDSRCDIR}/sbin/mount
--- src/sbin/newfs/mkfs.c.orig	2017-02-07 14:10:29.806633589 +0900
+++ src/sbin/newfs/mkfs.c	2017-02-07 14:19:16.827654581 +0900
@@ -83,7 +83,9 @@
 #include <sys/resource.h>
 #include <ufs/ufs/dinode.h>
 #include <ufs/ufs/dir.h>
+#ifndef NOUFSBSWAP
 #include <ufs/ufs/ufs_bswap.h>
+#endif
 #include <ufs/ufs/quota2.h>
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
@@ -101,6 +103,12 @@
 #include <stdio.h>
 #endif
+/* XXX */
+#ifdef NOUFSBSWAP
+#define	ufs_rw32(x, ns)	(x)
+#define	ufs_rw64(x, ns)	(x)
+#endif
+
 #include "extern.h"
union dinode {
@@ -631,6 +639,7 @@
 		 */
 		zap_old_sblock(EXT2FS_SBOFF);
+#ifndef NOAPPLEUFS
 		if (isappleufs) {
 			struct appleufslabel appleufs;
 			ffs_appleufs_set(&appleufs, appleufs_volname,
@@ -648,6 +657,7 @@
 				    APPLEUFS_LABEL_SIZE, &appleufs);
 			}
 		}
+#endif
 	}
/*
@@ -655,8 +665,10 @@
 	 * writing out in each cylinder group.
 	 */
 	memcpy(iobuf, &sblock, sizeof sblock);
+#ifndef NOUFSBSWAP
 	if (needswap)
 		ffs_sb_swap(&sblock, (struct fs *)iobuf);
+#endif
 	if ((sblock.fs_old_flags & FS_FLAGS_UPDATED) == 0)
 		memset(iobuf + offsetof(struct fs, fs_old_postbl_start),
 		    0xff, 256);
@@ -739,21 +751,27 @@
 		errx(1, "No space for superblock");
 	memcpy(iobuf, &sblock, sizeof(sblock));
 	memset(iobuf + sizeof(sblock), 0, i - sizeof(sblock));
+#ifndef NOUFSBSWAP
 	if (needswap)
 		ffs_sb_swap(&sblock, (struct fs *)iobuf);
+#endif
 	if ((sblock.fs_old_flags & FS_FLAGS_UPDATED) == 0)
 		memset(iobuf + offsetof(struct fs, fs_old_postbl_start),
 		    0xff, 256);
 	wtfs(sblock.fs_sblockloc / sectorsize, i, iobuf);
/* Write out first and last cylinder summary sectors */
+#ifndef NOUFSBSWAP
 	if (needswap)
 		ffs_csum_swap(fscs_0, fscs_0, sblock.fs_fsize);
+#endif
 	wtfs(FFS_FSBTODB(&sblock, sblock.fs_csaddr), sblock.fs_fsize, fscs_0);
if (fscs_next > fscs_reset) {
+#ifndef NOUFSBSWAP
 		if (needswap)
 			ffs_csum_swap(fscs_reset, fscs_reset, sblock.fs_fsize);
+#endif
 		fs_csaddr++;
 		wtfs(FFS_FSBTODB(&sblock, fs_csaddr), sblock.fs_fsize, fscs_reset);
 	}
@@ -934,8 +952,10 @@
 	*fscs_next++ = acg.cg_cs;
 	if (fscs_next == fscs_end) {
 		/* write block of cylinder group summary info into cyl 0 */
+#ifndef NOUFSBSWAP
 		if (needswap)
 			ffs_csum_swap(fscs_reset, fscs_reset, sblock.fs_fsize);
+#endif
 		fs_csaddr++;
 		wtfs(FFS_FSBTODB(&sblock, fs_csaddr), sblock.fs_fsize, fscs_reset);
 		fscs_next = fscs_reset;
@@ -947,8 +967,10 @@
 	 */
 	start = sblock.fs_bsize > SBLOCKSIZE ? sblock.fs_bsize : SBLOCKSIZE;
 	memcpy(&iobuf[start], &acg, sblock.fs_cgsize);
+#ifndef NOUFSBSWAP
 	if (needswap)
 		ffs_cg_swap(&acg, (struct cg*)&iobuf[start], &sblock);
+#endif
 	start += sblock.fs_bsize;
 	dp1 = (struct ufs1_dinode *)(&iobuf[start]);
 	dp2 = (struct ufs2_dinode *)(&iobuf[start]);
@@ -1294,9 +1316,11 @@
 	daddr_t d, blkno;
rdfs(FFS_FSBTODB(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, &acg);
+#ifndef NOUFSBSWAP
 	/* fs -> host byte order */
 	if (needswap)
 		ffs_cg_swap(&acg, &acg, &sblock);
+#endif
 	if (acg.cg_magic != CG_MAGIC) {
 		printf("cg 0: bad magic number\n");
 		return (0);
@@ -1339,9 +1363,11 @@
 		for (i = frag; i < sblock.fs_frag; i++)
 			setbit(cg_blksfree(&acg, 0), d + i);
 	}
+#ifndef NOUFSBSWAP
 	/* host -> fs byte order */
 	if (needswap)
 		ffs_cg_swap(&acg, &acg, &sblock);
+#endif
 	wtfs(FFS_FSBTODB(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, &acg);
 	return (d);
 }
@@ -1353,14 +1379,18 @@
 iput(union dinode *ip, ino_t ino)
 {
 	daddr_t d;
+#ifndef NOUFSBSWAP
 	int i;
+#endif
 	struct ufs1_dinode *dp1;
 	struct ufs2_dinode *dp2;
rdfs(FFS_FSBTODB(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, &acg);
 	/* fs -> host byte order */
+#ifndef NOUFSBSWAP
 	if (needswap)
 		ffs_cg_swap(&acg, &acg, &sblock);
+#endif
 	if (acg.cg_magic != CG_MAGIC) {
 		printf("cg 0: bad magic number\n");
 		fserr(31);
@@ -1368,8 +1398,10 @@
 	acg.cg_cs.cs_nifree--;
 	setbit(cg_inosused(&acg, 0), ino);
 	/* host -> fs byte order */
+#ifndef NOUFSBSWAP
 	if (needswap)
 		ffs_cg_swap(&acg, &acg, &sblock);
+#endif
 	wtfs(FFS_FSBTODB(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, &acg);
 	sblock.fs_cstotal.cs_nifree--;
 	fscs_0->cs_nifree--;
@@ -1383,6 +1415,7 @@
 	if (sblock.fs_magic == FS_UFS1_MAGIC) {
 		dp1 = (struct ufs1_dinode *)iobuf;
 		dp1 += ino_to_fsbo(&sblock, ino);
+#ifndef NOUFSBSWAP
 		if (needswap) {
 			ffs_dinode1_swap(&ip->dp1, dp1);
 			/* ffs_dinode1_swap() doesn't swap blocks addrs */
@@ -1391,11 +1424,13 @@
 			for (i=0; i<UFS_NIADDR; i++)
 			    dp1->di_ib[i] = bswap32(ip->dp1.di_ib[i]);
 		} else
+#endif
 			*dp1 = ip->dp1;
 		dp1->di_gen = arc4random() & INT32_MAX;
 	} else {
 		dp2 = (struct ufs2_dinode *)iobuf;
 		dp2 += ino_to_fsbo(&sblock, ino);
+#ifndef NOUFSBSWAP
 		if (needswap) {
 			ffs_dinode2_swap(&ip->dp2, dp2);
 			for (i=0; i<UFS_NDADDR; i++)
@@ -1403,6 +1438,7 @@
 			for (i=0; i<UFS_NIADDR; i++)
 			    dp2->di_ib[i] = bswap64(ip->dp2.di_ib[i]);
 		} else
+#endif
 			*dp2 = ip->dp2;
 		dp2->di_gen = arc4random() & INT32_MAX;
 	}
@@ -1558,6 +1594,7 @@
 copy_dir(struct direct *dir, struct direct *dbuf)
 {
 	memcpy(dbuf, dir, UFS_DIRSIZ(Oflag == 0, dir, 0));
+#ifndef NOUFSBSWAP
 	if (needswap) {
 		dbuf->d_ino = bswap32(dir->d_ino);
 		dbuf->d_reclen = bswap16(dir->d_reclen);
@@ -1565,6 +1602,7 @@
 			((struct odirect*)dbuf)->d_namlen =
 				bswap16(((struct odirect*)dir)->d_namlen);
 	}
+#endif
 }
static int
--- src/sbin/newfs/newfs.c.orig	2017-02-07 14:10:29.808749889 +0900
+++ src/sbin/newfs/newfs.c	2017-02-07 13:49:49.426535941 +0900
@@ -277,10 +277,15 @@
opstring = mfs ?
 	    "NT:V:a:b:d:e:f:g:h:i:m:n:o:p:q:s:u:" :
+#ifndef NOAPPLEUFS
 	    "B:FGINO:S:T:V:Za:b:d:e:f:g:h:i:l:m:n:o:q:r:s:v:";
+#else
+	    "B:FGINO:S:T:V:Za:b:d:e:f:g:h:i:l:m:n:o:q:r:s:";
+#endif
 	while ((ch = getopt(argc, argv, opstring)) != -1)
 		switch (ch) {
 		case 'B':
+#ifndef NOUFSBSWAP
 			if (strcmp(optarg, "be") == 0) {
 #if BYTE_ORDER == LITTLE_ENDIAN
 				needswap = 1;
@@ -290,6 +295,7 @@
 				needswap = 1;
 #endif
 			} else
+#endif
 				usage();
 			break;
 		case 'F':
@@ -413,6 +419,7 @@
 			/* mfs only */
 			mfsuid = mfs_user(optarg);
 			break;
+#ifndef NOAPPLEUFS
 		case 'v':
 			appleufs_volname = optarg;
 			if (strchr(appleufs_volname, ':') || strchr(appleufs_volname, '/'))
@@ -421,6 +428,7 @@
 				errx(1,"Apple UFS volume name cannot be zero length");
 			isappleufs = 1;
 			break;
+#endif
 		case '?':
 		default:
 			usage();
@@ -557,7 +565,11 @@
 				errx(1, "%s partition is unavailable", special);
if (strcmp(dkw.dkw_ptype, DKW_PTYPE_APPLEUFS) == 0)
+#ifndef NOAPPLEUFS
 				isappleufs = 1;
+#else
+				errx(1, "Apple UFS support is not compiled in");
+#endif
 				
 			if (!Iflag) {
 				static const char m[] =
@@ -843,7 +855,9 @@
 	int flags;
 	const char *str;
 } const help_strings[] = {
+#ifndef NOUFSBSWAP
 	{ NEWFS,	"-B byteorder\tbyte order (`be' or `le')" },
+#endif
 	{ NEWFS,	"-F \t\tcreate file system image in regular file" },
 	{ NEWFS,	"-G \t\tmake sanity calculations non-fatal (testing only!)" },
 	{ NEWFS,	"-I \t\tdo not check that the file system type is '4.2BSD'" },
@@ -874,7 +888,9 @@
 	{ MFS_MOUNT,	"-p perm\t\tpermissions (in octal)" },
 	{ BOTH,		"-s fssize\tfile system size (sectors)" },
 	{ MFS_MOUNT,	"-u username\tuser name of mount point" },
+#ifndef NOAPPLEUFS
 	{ NEWFS,	"-v volname\tApple UFS volume name" },
+#endif
 	{ 0, NULL }
 };


Home | Main Index | Thread Index | Old Index