Add smaller versions of fsck_ffs(8) and newfs(8) for install media, where
support for Endian-Independent FFS and Apple UFS is disabled unless FFS_EI=1 and APPLE_UFS=1 are added to CRUNCHENV, respectively. This reduces the size of ramdisk image for atari by over 15KB. Thanks tsutsui and christos for their useful comments.
This commit is contained in:
parent
b4ccad3ff2
commit
ccc9d98e52
28
distrib/utils/x_fsck_ffs/Makefile
Normal file
28
distrib/utils/x_fsck_ffs/Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
# $NetBSD: Makefile,v 1.1 2017/02/08 16:11:39 rin Exp $
|
||||
# Build a smaller fsck_ffs (i.e. for boot media).
|
||||
# Support for Endian-Independent FFS and Apple UFS is dropped unless FFS_EI=1
|
||||
# and APPLE_UFS=1 are added to CRUNCHENV, respectively.
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
SRCDIR= ${.CURDIR}/../../../sbin/fsck_ffs
|
||||
|
||||
.ifdef FFS_EI
|
||||
SRCS+= ffs_bswap.c
|
||||
.else
|
||||
CPPFLAGS+= -DNO_FFS_EI
|
||||
.endif
|
||||
|
||||
.ifdef APPLE_UFS
|
||||
SRCS+= ffs_appleufs.c
|
||||
.else
|
||||
CPPFLAGS+= -DNO_APPLE_UFS
|
||||
.endif
|
||||
|
||||
.PATH: ${SRCDIR}
|
||||
|
||||
.include "${SRCDIR}/Makefile.common"
|
||||
|
||||
.include <bsd.prog.mk>
|
28
distrib/utils/x_newfs/Makefile
Normal file
28
distrib/utils/x_newfs/Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
# $NetBSD: Makefile,v 1.1 2017/02/08 16:11:40 rin Exp $
|
||||
# Build a smaller newfs (i.e. for boot media).
|
||||
# Support for Endian-Independent FFS and Apple UFS is dropped unless FFS_EI=1
|
||||
# and APPLE_UFS=1 are added to CRUNCHENV, respectively.
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
SRCDIR= ${.CURDIR}/../../../sbin/newfs
|
||||
|
||||
.ifdef FFS_EI
|
||||
SRCS+= ffs_bswap.c
|
||||
.else
|
||||
CPPFLAGS+= -DNO_FFS_EI
|
||||
.endif
|
||||
|
||||
.ifdef APPLE_UFS
|
||||
SRCS+= ffs_appleufs.c
|
||||
.else
|
||||
CPPFLAGS+= -DNO_APPLE_UFS
|
||||
.endif
|
||||
|
||||
.PATH: ${SRCDIR}
|
||||
|
||||
.include "${SRCDIR}/Makefile.common"
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,45 +1,17 @@
|
||||
# $NetBSD: Makefile,v 1.47 2017/02/07 16:14:47 rin Exp $
|
||||
# $NetBSD: Makefile,v 1.48 2017/02/08 16:11:40 rin Exp $
|
||||
# @(#)Makefile 8.2 (Berkeley) 4/27/95
|
||||
|
||||
# when making a change to this file, please check if the change is
|
||||
# also needed for src/distrib/utils/x_fsck_ffs.
|
||||
# such stuff should be into Makefile.common.
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
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
|
||||
SRCS= ffs_bswap.c ffs_appleufs.c
|
||||
SUBDIR= SMM.doc
|
||||
|
||||
FSCK= ${NETBSDSRCDIR}/sbin/fsck
|
||||
DUMP= ${NETBSDSRCDIR}/sbin/dump
|
||||
CPPFLAGS+=-I${FSCK} -I${DUMP}
|
||||
.ifndef SMALLPROG
|
||||
CPPFLAGS+=-DPROGRESS
|
||||
SRCS+= progress.c
|
||||
.endif
|
||||
.PATH: ${FSCK}
|
||||
|
||||
.PATH: ${NETBSDSRCDIR}/sys/ufs/ffs ${NETBSDSRCDIR}/sys/ufs/ufs ${FSCK} ${DUMP}
|
||||
|
||||
SRCS+= vfs_wapbl.c wapbl.c
|
||||
.PATH: ${NETBSDSRCDIR}/sys/kern
|
||||
CPPFLAGS+=-DWAPBL_DEBUG_PRINT=0
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
LDADD+=-lprop
|
||||
DPADD+=${LIBPROP}
|
||||
|
||||
COPTS.ffs_appleufs.c+= -Wno-pointer-sign
|
||||
|
||||
.if ${MACHINE_ARCH} == "m68000"
|
||||
COPTS.pass1.c+= -fno-tree-fre -fno-tree-lrs
|
||||
.endif
|
||||
.if ${MACHINE_ARCH} == "vax"
|
||||
COPTS.pass1.c+= -O0
|
||||
.endif
|
||||
|
||||
SUBDIR+=SMM.doc
|
||||
.include "Makefile.common"
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <bsd.subdir.mk>
|
||||
|
41
sbin/fsck_ffs/Makefile.common
Normal file
41
sbin/fsck_ffs/Makefile.common
Normal file
@ -0,0 +1,41 @@
|
||||
# $NetBSD: Makefile.common,v 1.1 2017/02/08 16:11:40 rin Exp $
|
||||
# @(#)Makefile 8.2 (Berkeley) 4/27/95
|
||||
|
||||
# shared stuff with src/distrib/utils/x_newfs for install media.
|
||||
# stuff not required by install media should be into Makefile.
|
||||
|
||||
PROG= fsck_ffs
|
||||
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_subr.c ffs_tables.c \
|
||||
partutil.c snapshot.c quota2.c quota2_subr.c
|
||||
|
||||
FSCK= ${NETBSDSRCDIR}/sbin/fsck
|
||||
DUMP= ${NETBSDSRCDIR}/sbin/dump
|
||||
CPPFLAGS+=-I${FSCK} -I${DUMP}
|
||||
|
||||
.PATH: ${FSCK}
|
||||
.PATH: ${NETBSDSRCDIR}/sys/ufs/ffs ${NETBSDSRCDIR}/sys/ufs/ufs ${FSCK} ${DUMP}
|
||||
|
||||
SRCS+= vfs_wapbl.c wapbl.c
|
||||
.PATH: ${NETBSDSRCDIR}/sys/kern
|
||||
CPPFLAGS+=-DWAPBL_DEBUG_PRINT=0
|
||||
|
||||
.ifndef SMALLPROG
|
||||
CPPFLAGS+=-DPROGRESS
|
||||
SRCS+= progress.c
|
||||
.endif
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
LDADD+=-lprop
|
||||
DPADD+=${LIBPROP}
|
||||
|
||||
COPTS.ffs_appleufs.c+= -Wno-pointer-sign
|
||||
|
||||
.if ${MACHINE_ARCH} == "m68000"
|
||||
COPTS.pass1.c+= -fno-tree-fre -fno-tree-lrs
|
||||
.endif
|
||||
.if ${MACHINE_ARCH} == "vax"
|
||||
COPTS.pass1.c+= -O0
|
||||
.endif
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dir.c,v 1.57 2013/06/23 07:28:36 dholland Exp $ */
|
||||
/* $NetBSD: dir.c,v 1.58 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: dir.c,v 1.57 2013/06/23 07:28:36 dholland Exp $");
|
||||
__RCSID("$NetBSD: dir.c,v 1.58 2017/02/08 16:11:40 rin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -154,10 +154,10 @@ dirscan(struct inodesc *idesc)
|
||||
struct bufarea *bp;
|
||||
int dsize, n;
|
||||
long blksiz;
|
||||
#if UFS_DIRBLKSIZ > APPLEUFS_DIRBLKSIZ
|
||||
char dbuf[UFS_DIRBLKSIZ];
|
||||
#else
|
||||
#if !defined(NO_APPLE_UFS) && UFS_DIRBLKSIZ < APPLEUFS_DIRBLKSIZ
|
||||
char dbuf[APPLEUFS_DIRBLKSIZ];
|
||||
#else
|
||||
char dbuf[UFS_DIRBLKSIZ];
|
||||
#endif
|
||||
|
||||
if (idesc->id_type != DATA)
|
||||
@ -703,10 +703,10 @@ expanddir(union dinode *dp, char *name)
|
||||
daddr_t lastbn, newblk, dirblk;
|
||||
struct bufarea *bp;
|
||||
char *cp;
|
||||
#if DIRBLKSIZ > APPLEUFS_DIRBLKSIZ
|
||||
char firstblk[DIRBLKSIZ];
|
||||
#else
|
||||
#if !defined(NO_APPLE_UFS) && UFS_DIRBLKSIZ < APPLEUFS_DIRBLKSIZ
|
||||
char firstblk[APPLEUFS_DIRBLKSIZ];
|
||||
#else
|
||||
char firstblk[UFS_DIRBLKSIZ];
|
||||
#endif
|
||||
struct ufs1_dinode *dp1 = NULL;
|
||||
struct ufs2_dinode *dp2 = NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fsck.h,v 1.49 2011/03/06 17:08:16 bouyer Exp $ */
|
||||
/* $NetBSD: fsck.h,v 1.50 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -120,7 +120,9 @@ struct bufarea {
|
||||
struct cg *b_cg; /* cylinder group */
|
||||
struct ufs1_dinode *b_dinode1; /* UFS1 inode block */
|
||||
struct ufs2_dinode *b_dinode2; /* UFS2 inode block */
|
||||
#ifndef NO_APPLE_UFS
|
||||
struct appleufslabel *b_appleufs; /* Apple UFS volume label */
|
||||
#endif
|
||||
} b_un;
|
||||
char b_dirty;
|
||||
};
|
||||
@ -142,7 +144,9 @@ struct bufarea bufhead; /* head of list of other blks in filesys */
|
||||
struct bufarea sblk; /* file system superblock */
|
||||
struct bufarea asblk; /* file system superblock */
|
||||
struct bufarea cgblk; /* cylinder group blocks */
|
||||
struct bufarea appleufsblk; /* Apple UFS volume label */
|
||||
#ifndef NO_APPLE_UFS
|
||||
struct bufarea appleufsblk; /* Apple UFS volume label */
|
||||
#endif
|
||||
struct bufarea *pdirbp; /* current directory contents */
|
||||
struct bufarea *pbp; /* current inode block */
|
||||
|
||||
@ -280,12 +284,7 @@ char usedsoftdep; /* just fix soft dependency inconsistencies */
|
||||
int preen; /* just fix normal inconsistencies */
|
||||
int quiet; /* Don't print anything if clean */
|
||||
int forceimage; /* file system is an image file */
|
||||
int doswap; /* convert byte order */
|
||||
int needswap; /* need to convert byte order in memory */
|
||||
int is_ufs2; /* we're dealing with an UFS2 filesystem */
|
||||
int do_blkswap; /* need to do block addr byteswap */
|
||||
int do_dirswap; /* need to do dir entry byteswap */
|
||||
int endian; /* endian coversion */
|
||||
int markclean; /* mark file system clean when done */
|
||||
char havesb; /* superblock has been read */
|
||||
char skipclean; /* skip clean file systems if preening */
|
||||
@ -294,7 +293,33 @@ int fsreadfd; /* file descriptor for reading file system */
|
||||
int fswritefd; /* file descriptor for writing file system */
|
||||
int rerun; /* rerun fsck. Only used in non-preen mode */
|
||||
char resolved; /* cleared if unresolved changes => not clean */
|
||||
|
||||
#ifndef NO_FFS_EI
|
||||
int endian; /* endian coversion */
|
||||
int doswap; /* convert byte order */
|
||||
int needswap; /* need to convert byte order in memory */
|
||||
int do_blkswap; /* need to do block addr byteswap */
|
||||
int do_dirswap; /* need to do dir entry byteswap */
|
||||
#else
|
||||
/* Disable Endian-Independent FFS support for install media */
|
||||
#define endian (0)
|
||||
#define doswap (0)
|
||||
#define needswap (0)
|
||||
#define do_blkswap (0)
|
||||
#define do_dirswap (0)
|
||||
#define ffs_cg_swap(a, b, c) do {} while (/*CONSTCOND*/0)
|
||||
#define ffs_csum_swap(a, b, c) do {} while (/*CONSTCOND*/0)
|
||||
#define ffs_sb_swap(a, b) do {} while (/*CONSTCOND*/0)
|
||||
#define swap_dinode1(a, b) do {} while (/*CONSTCOND*/0)
|
||||
#define swap_dinode2(a, b) do {} while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
#ifndef NO_APPLE_UFS
|
||||
int isappleufs; /* filesystem is Apple UFS */
|
||||
#else
|
||||
/* Disable Apple UFS support for install media */
|
||||
#define isappleufs (0)
|
||||
#endif
|
||||
|
||||
daddr_t maxfsblock; /* number of blocks in the file system */
|
||||
char *blockmap; /* ptr to primary blk allocation map */
|
||||
@ -334,6 +359,7 @@ struct ufs2_dinode ufs2_zino;
|
||||
#define ALTERED 0x08
|
||||
#define FOUND 0x10
|
||||
|
||||
#ifndef NO_FFS_EI
|
||||
/* some inline functs to help the byte-swapping mess */
|
||||
static inline u_int16_t iswap16 (u_int16_t);
|
||||
static inline u_int32_t iswap32 (u_int32_t);
|
||||
@ -362,3 +388,8 @@ iswap64(u_int64_t x)
|
||||
return bswap64(x);
|
||||
else return x;
|
||||
}
|
||||
#else
|
||||
#define iswap16(x) (x)
|
||||
#define iswap32(x) (x)
|
||||
#define iswap64(x) (x)
|
||||
#endif /* NO_FFS_EI */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: inode.c,v 1.71 2014/04/05 12:32:27 justin Exp $ */
|
||||
/* $NetBSD: inode.c,v 1.72 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: inode.c,v 1.71 2014/04/05 12:32:27 justin Exp $");
|
||||
__RCSID("$NetBSD: inode.c,v 1.72 2017/02/08 16:11:40 rin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -64,8 +64,10 @@ __RCSID("$NetBSD: inode.c,v 1.71 2014/04/05 12:32:27 justin Exp $");
|
||||
static ino_t startinum;
|
||||
|
||||
static int iblock(struct inodesc *, long, u_int64_t);
|
||||
#ifndef NO_FFS_EI
|
||||
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 +344,7 @@ ginode(ino_t inumber)
|
||||
return ((union dinode *)((caddr_t)pbp->b_un.b_buf + blkoff));
|
||||
}
|
||||
|
||||
#ifndef NO_FFS_EI
|
||||
static void
|
||||
swap_dinode1(union dinode *dp, int n)
|
||||
{
|
||||
@ -385,6 +388,7 @@ swap_dinode2(union dinode *dp, int n)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* !NO_FFS_EI */
|
||||
|
||||
/*
|
||||
* Special purpose version of ginode used to optimize first pass
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.83 2015/06/16 23:58:30 christos Exp $ */
|
||||
/* $NetBSD: main.c,v 1.84 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.83 2015/06/16 23:58:30 christos Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.84 2017/02/08 16:11:40 rin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -96,21 +96,30 @@ main(int argc, char *argv[])
|
||||
skipclean = 1;
|
||||
markclean = 1;
|
||||
forceimage = 0;
|
||||
#ifndef NO_FFS_EI
|
||||
endian = 0;
|
||||
#endif
|
||||
#ifndef NO_APPLE_UFS
|
||||
isappleufs = 0;
|
||||
#endif
|
||||
while ((ch = getopt(argc, argv, "aB:b:c:dFfm:npPqUyx:X")) != -1) {
|
||||
switch (ch) {
|
||||
#ifndef NO_APPLE_UFS
|
||||
case 'a':
|
||||
isappleufs = 1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifndef NO_FFS_EI
|
||||
case 'B':
|
||||
if (strcmp(optarg, "be") == 0)
|
||||
endian = BIG_ENDIAN;
|
||||
else if (strcmp(optarg, "le") == 0)
|
||||
endian = LITTLE_ENDIAN;
|
||||
else usage();
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'b':
|
||||
skipclean = 0;
|
||||
@ -511,8 +520,15 @@ usage(void)
|
||||
{
|
||||
|
||||
(void) fprintf(stderr,
|
||||
"usage: %s [-adFfPpqUX] [-B byteorder] [-b block] [-c level] "
|
||||
"[-m mode]\n"
|
||||
"usage: %s [-"
|
||||
#ifndef NO_APPLE_UFS
|
||||
"a"
|
||||
#endif
|
||||
"dFfPpqUX] "
|
||||
#ifndef NO_FFS_EI
|
||||
"[-B byteorder] "
|
||||
#endif
|
||||
"[-b block] [-c level] [-m mode]\n"
|
||||
"\t[-x snap-backup] [-y | -n] filesystem ...\n",
|
||||
getprogname());
|
||||
exit(FSCK_EXIT_USAGE);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pass1.c,v 1.56 2013/10/19 01:09:58 christos Exp $ */
|
||||
/* $NetBSD: pass1.c,v 1.57 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pass1.c 8.6 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: pass1.c,v 1.56 2013/10/19 01:09:58 christos Exp $");
|
||||
__RCSID("$NetBSD: pass1.c,v 1.57 2017/02/08 16:11:40 rin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -220,7 +220,9 @@ pass1(void)
|
||||
progress_done();
|
||||
#endif /* PROGRESS */
|
||||
freeinodebuf();
|
||||
#ifndef NO_FFS_EI
|
||||
do_blkswap = 0; /* has been done */
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pass2.c,v 1.50 2013/06/09 17:57:09 dholland Exp $ */
|
||||
/* $NetBSD: pass2.c,v 1.51 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pass2.c 8.9 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: pass2.c,v 1.50 2013/06/09 17:57:09 dholland Exp $");
|
||||
__RCSID("$NetBSD: pass2.c,v 1.51 2017/02/08 16:11:40 rin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -70,7 +70,9 @@ pass2(void)
|
||||
struct inodesc curino;
|
||||
union dinode dino;
|
||||
int i, maxblk;
|
||||
#ifndef NO_FFS_EI
|
||||
unsigned ii;
|
||||
#endif
|
||||
char pathbuf[MAXPATHLEN + 1];
|
||||
|
||||
rinfo = inoinfo(UFS_ROOTINO);
|
||||
@ -223,6 +225,7 @@ pass2(void)
|
||||
(void)ckinode(&dino, &curino);
|
||||
}
|
||||
|
||||
#ifndef NO_FFS_EI
|
||||
/*
|
||||
* Byte swapping in directory entries, if needed, has been done.
|
||||
* Now rescan dirs for pass2check()
|
||||
@ -252,6 +255,7 @@ pass2(void)
|
||||
(void)ckinode(&dino, &curino);
|
||||
}
|
||||
}
|
||||
#endif /* !NO_FFS_EI */
|
||||
|
||||
/*
|
||||
* Now that the parents of all directories have been found,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: setup.c,v 1.100 2013/06/23 07:28:36 dholland Exp $ */
|
||||
/* $NetBSD: setup.c,v 1.101 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: setup.c,v 1.100 2013/06/23 07:28:36 dholland Exp $");
|
||||
__RCSID("$NetBSD: setup.c,v 1.101 2017/02/08 16:11:40 rin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -70,7 +70,9 @@ __RCSID("$NetBSD: setup.c,v 1.100 2013/06/23 07:28:36 dholland Exp $");
|
||||
static void badsb(int, const char *);
|
||||
static int calcsb(const char *, int, struct fs *);
|
||||
static int readsb(int);
|
||||
#ifndef NO_APPLE_UFS
|
||||
static int readappleufs(void);
|
||||
#endif
|
||||
|
||||
int16_t sblkpostbl[256];
|
||||
|
||||
@ -527,19 +529,26 @@ setup(const char *dev, const char *origdev)
|
||||
else
|
||||
usedsoftdep = 0;
|
||||
|
||||
#ifndef NO_APPLE_UFS
|
||||
if (!forceimage && dkw.dkw_parent[0])
|
||||
if (strcmp(dkw.dkw_ptype, DKW_PTYPE_APPLEUFS) == 0)
|
||||
isappleufs = 1;
|
||||
|
||||
if (readappleufs())
|
||||
isappleufs = 1;
|
||||
#endif
|
||||
|
||||
dirblksiz = UFS_DIRBLKSIZ;
|
||||
if (isappleufs)
|
||||
dirblksiz = APPLEUFS_DIRBLKSIZ;
|
||||
else
|
||||
dirblksiz = UFS_DIRBLKSIZ;
|
||||
|
||||
if (debug)
|
||||
#ifndef NO_APPLE_UFS
|
||||
printf("isappleufs = %d, dirblksiz = %d\n", isappleufs, dirblksiz);
|
||||
#else
|
||||
printf("dirblksiz = %d\n", dirblksiz);
|
||||
#endif
|
||||
|
||||
if (sblock->fs_flags & FS_DOQUOTA2) {
|
||||
/* allocate the quota hash table */
|
||||
@ -580,6 +589,7 @@ badsblabel:
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef NO_APPLE_UFS
|
||||
static int
|
||||
readappleufs(void)
|
||||
{
|
||||
@ -684,6 +694,7 @@ readappleufs(void)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif /* !NO_APPLE_UFS */
|
||||
|
||||
/*
|
||||
* Detect byte order. Return 0 if valid magic found, -1 otherwise.
|
||||
@ -696,6 +707,7 @@ detect_byteorder(struct fs *fs, int sblockoff)
|
||||
/* Likely to be the first alternate of a fs with 64k blocks */
|
||||
return -1;
|
||||
if (fs->fs_magic == FS_UFS1_MAGIC || fs->fs_magic == FS_UFS2_MAGIC) {
|
||||
#ifndef NO_FFS_EI
|
||||
if (endian == 0 || BYTE_ORDER == endian) {
|
||||
needswap = 0;
|
||||
doswap = do_blkswap = do_dirswap = 0;
|
||||
@ -703,8 +715,11 @@ detect_byteorder(struct fs *fs, int sblockoff)
|
||||
needswap = 1;
|
||||
doswap = do_blkswap = do_dirswap = 1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
} else if (fs->fs_magic == FS_UFS1_MAGIC_SWAPPED ||
|
||||
}
|
||||
#ifndef NO_FFS_EI
|
||||
else if (fs->fs_magic == FS_UFS1_MAGIC_SWAPPED ||
|
||||
fs->fs_magic == FS_UFS2_MAGIC_SWAPPED) {
|
||||
if (endian == 0 || BYTE_ORDER != endian) {
|
||||
needswap = 1;
|
||||
@ -715,6 +730,7 @@ detect_byteorder(struct fs *fs, int sblockoff)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1027,8 +1043,11 @@ calcsb(const char *dev, int devfd, struct fs *fs)
|
||||
pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev);
|
||||
return (0);
|
||||
}
|
||||
if (strcmp(dkw.dkw_ptype, DKW_PTYPE_FFS) &&
|
||||
strcmp(dkw.dkw_ptype, DKW_PTYPE_APPLEUFS)) {
|
||||
if (strcmp(dkw.dkw_ptype, DKW_PTYPE_FFS)
|
||||
#ifndef NO_APPLE_UFS
|
||||
&& strcmp(dkw.dkw_ptype, DKW_PTYPE_APPLEUFS)
|
||||
#endif
|
||||
) {
|
||||
pfatal("%s: NOT LABELED AS A BSD FILE SYSTEM (%s)\n",
|
||||
dev, dkw.dkw_ptype);
|
||||
return (0);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: utilities.c,v 1.64 2013/10/19 01:09:58 christos Exp $ */
|
||||
/* $NetBSD: utilities.c,v 1.65 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: utilities.c,v 1.64 2013/10/19 01:09:58 christos Exp $");
|
||||
__RCSID("$NetBSD: utilities.c,v 1.65 2017/02/08 16:11:40 rin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -140,11 +140,13 @@ bufinit(void)
|
||||
errexit("cannot allocate buffer pool");
|
||||
cgblk.b_un.b_buf = bufp;
|
||||
initbarea(&cgblk);
|
||||
#ifndef NO_APPLE_UFS
|
||||
bufp = malloc((unsigned int)APPLEUFS_LABEL_SIZE);
|
||||
if (bufp == 0)
|
||||
errexit("cannot allocate buffer pool");
|
||||
appleufsblk.b_un.b_buf = bufp;
|
||||
initbarea(&appleufsblk);
|
||||
#endif
|
||||
bufhead.b_next = bufhead.b_prev = &bufhead;
|
||||
bufcnt = MAXBUFSPACE / sblock->fs_bsize;
|
||||
if (bufcnt < MINBUFS)
|
||||
@ -287,8 +289,10 @@ ckfini(int noint)
|
||||
sbdirty();
|
||||
flush(fswritefd, &sblk);
|
||||
}
|
||||
#ifndef NO_APPLE_UFS
|
||||
flush(fswritefd, &appleufsblk);
|
||||
free(appleufsblk.b_un.b_buf);
|
||||
#endif
|
||||
flush(fswritefd, &cgblk);
|
||||
free(cgblk.b_un.b_buf);
|
||||
for (bp = bufhead.b_prev; bp && bp != &bufhead; bp = nbp) {
|
||||
|
@ -1,31 +1,18 @@
|
||||
# $NetBSD: Makefile,v 1.39 2012/08/10 12:20:11 joerg Exp $
|
||||
# $NetBSD: Makefile,v 1.40 2017/02/08 16:11:40 rin Exp $
|
||||
# @(#)Makefile 8.2 (Berkeley) 3/27/94
|
||||
|
||||
# when making a change to this file, please check if the change is
|
||||
# also needed for src/distrib/utils/x_newfs.
|
||||
# such stuff should be into Makefile.common.
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
PROG= newfs
|
||||
SRCS= dkcksum.c newfs.c mkfs.c ffs_bswap.c ffs_appleufs.c partutil.c
|
||||
SRCS+= pathadj.c quota2_subr.c
|
||||
SRCS= ffs_bswap.c ffs_appleufs.c
|
||||
MAN= newfs.8 mount_mfs.8
|
||||
|
||||
DISKLABEL=${NETBSDSRCDIR}/sbin/disklabel
|
||||
FSCK=${NETBSDSRCDIR}/sbin/fsck
|
||||
MOUNT=${NETBSDSRCDIR}/sbin/mount
|
||||
CPPFLAGS+=-DMFS -I${.CURDIR} -I${DISKLABEL} -I${FSCK} -I${MOUNT}
|
||||
CPPFLAGS+=-DGARBAGE
|
||||
|
||||
DPADD+= ${LIBUTIL}
|
||||
LDADD+= -lutil
|
||||
|
||||
LDADD+=-lprop
|
||||
DPADD+=${LIBPROP}
|
||||
|
||||
.PATH: ${DISKLABEL} ${NETBSDSRCDIR}/sys/ufs/ffs ${NETBSDSRCDIR}/sys/ufs/ufs
|
||||
.PATH: ${FSCK} ${MOUNT}
|
||||
|
||||
LINKS= ${BINDIR}/newfs ${BINDIR}/mount_mfs
|
||||
MLINKS= mount_mfs.8 mfs.8
|
||||
|
||||
COPTS.ffs_appleufs.c+= -Wno-pointer-sign
|
||||
.include "Makefile.common"
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
25
sbin/newfs/Makefile.common
Normal file
25
sbin/newfs/Makefile.common
Normal file
@ -0,0 +1,25 @@
|
||||
# $NetBSD: Makefile.common,v 1.1 2017/02/08 16:11:40 rin Exp $
|
||||
# @(#)Makefile 8.2 (Berkeley) 3/27/94
|
||||
|
||||
# shared stuff with src/distrib/utils/x_newfs for install media.
|
||||
# stuff not required by install media should be into Makefile.
|
||||
|
||||
PROG= newfs
|
||||
SRCS+= dkcksum.c newfs.c mkfs.c partutil.c pathadj.c quota2_subr.c
|
||||
|
||||
DISKLABEL=${NETBSDSRCDIR}/sbin/disklabel
|
||||
FSCK=${NETBSDSRCDIR}/sbin/fsck
|
||||
MOUNT=${NETBSDSRCDIR}/sbin/mount
|
||||
CPPFLAGS+=-DMFS -I${.CURDIR} -I${DISKLABEL} -I${FSCK} -I${MOUNT}
|
||||
CPPFLAGS+=-DGARBAGE
|
||||
|
||||
DPADD+= ${LIBUTIL}
|
||||
LDADD+= -lutil
|
||||
|
||||
LDADD+= -lprop
|
||||
DPADD+= ${LIBPROP}
|
||||
|
||||
.PATH: ${DISKLABEL} ${NETBSDSRCDIR}/sys/ufs/ffs ${NETBSDSRCDIR}/sys/ufs/ufs
|
||||
.PATH: ${FSCK} ${MOUNT}
|
||||
|
||||
COPTS.ffs_appleufs.c+= -Wno-pointer-sign
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.15 2011/03/06 17:08:16 bouyer Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.16 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
|
||||
@ -52,7 +52,23 @@ extern int avgfilesize; /* expected average file size */
|
||||
extern int avgfpdir; /* expected number of files per directory */
|
||||
extern u_long memleft; /* virtual memory available */
|
||||
extern caddr_t membase; /* start address of memory based filesystem */
|
||||
extern int quotas; /* filesystem quota to enable */
|
||||
|
||||
#ifndef NO_FFS_EI
|
||||
extern int needswap; /* Filesystem not in native byte order */
|
||||
#else
|
||||
/* Disable Endian-Independent FFS support for install media */
|
||||
#define needswap (0)
|
||||
#define ffs_cg_swap(a, b, c) do {} while (/*CONSTCOND*/0)
|
||||
#define ffs_csum_swap(a, b, c) do {} while (/*CONSTCOND*/0)
|
||||
#define ffs_dinode1_swap(a, b) do {} while (/*CONSTCOND*/0)
|
||||
#define ffs_sb_swap(a, b) do {} while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
#ifndef NO_APPLE_UFS
|
||||
extern int isappleufs; /* Filesystem is Apple UFS */
|
||||
extern char *appleufs_volname; /* Apple UFS volume name */
|
||||
extern int quotas; /* filesystem quota to enable */
|
||||
#else
|
||||
/* Disable Apple UFS support for install media */
|
||||
#define isappleufs (0)
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mkfs.c,v 1.127 2016/03/07 15:55:06 christos Exp $ */
|
||||
/* $NetBSD: mkfs.c,v 1.128 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1989, 1993
|
||||
@ -73,7 +73,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: mkfs.c,v 1.127 2016/03/07 15:55:06 christos Exp $");
|
||||
__RCSID("$NetBSD: mkfs.c,v 1.128 2017/02/08 16:11:40 rin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -631,6 +631,7 @@ mkfs(const char *fsys, int fi, int fo,
|
||||
*/
|
||||
zap_old_sblock(EXT2FS_SBOFF);
|
||||
|
||||
#ifndef NO_APPLE_UFS
|
||||
if (isappleufs) {
|
||||
struct appleufslabel appleufs;
|
||||
ffs_appleufs_set(&appleufs, appleufs_volname,
|
||||
@ -648,6 +649,7 @@ mkfs(const char *fsys, int fi, int fo,
|
||||
APPLEUFS_LABEL_SIZE, &appleufs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: newfs.c,v 1.114 2016/04/01 05:23:56 ryo Exp $ */
|
||||
/* $NetBSD: newfs.c,v 1.115 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1989, 1993, 1994
|
||||
@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1993, 1994\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)newfs.c 8.13 (Berkeley) 5/1/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: newfs.c,v 1.114 2016/04/01 05:23:56 ryo Exp $");
|
||||
__RCSID("$NetBSD: newfs.c,v 1.115 2017/02/08 16:11:40 rin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -225,11 +225,15 @@ int avgfpdir = AFPDIR; /* expected number of files per directory */
|
||||
int mntflags = 0; /* flags to be passed to mount */
|
||||
u_long memleft; /* virtual memory available */
|
||||
caddr_t membase; /* start address of memory based filesystem */
|
||||
#ifndef NO_FFS_EI
|
||||
int needswap; /* Filesystem not in native byte order */
|
||||
#endif
|
||||
char *disktype = NULL;
|
||||
int unlabeled;
|
||||
#ifndef NO_APPLE_UFS
|
||||
char *appleufs_volname = 0; /* Apple UFS volume name */
|
||||
int isappleufs = 0;
|
||||
#endif
|
||||
int quotas = 0;
|
||||
|
||||
char device[MAXPATHLEN];
|
||||
@ -280,18 +284,20 @@ main(int argc, char *argv[])
|
||||
"B:FGINO:S:T:V:Za:b:d:e:f:g:h:i:l:m:n:o:q:r:s:v:";
|
||||
while ((ch = getopt(argc, argv, opstring)) != -1)
|
||||
switch (ch) {
|
||||
#ifndef NO_FFS_EI
|
||||
case 'B':
|
||||
if (strcmp(optarg, "be") == 0) {
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
# if BYTE_ORDER == LITTLE_ENDIAN
|
||||
needswap = 1;
|
||||
#endif
|
||||
# endif
|
||||
} else if (strcmp(optarg, "le") == 0) {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
# if BYTE_ORDER == BIG_ENDIAN
|
||||
needswap = 1;
|
||||
#endif
|
||||
# endif
|
||||
} else
|
||||
usage();
|
||||
break;
|
||||
#endif
|
||||
case 'F':
|
||||
Fflag = 1;
|
||||
break;
|
||||
@ -413,6 +419,7 @@ main(int argc, char *argv[])
|
||||
/* mfs only */
|
||||
mfsuid = mfs_user(optarg);
|
||||
break;
|
||||
#ifndef NO_APPLE_UFS
|
||||
case 'v':
|
||||
appleufs_volname = optarg;
|
||||
if (strchr(appleufs_volname, ':') || strchr(appleufs_volname, '/'))
|
||||
@ -421,6 +428,7 @@ main(int argc, char *argv[])
|
||||
errx(1,"Apple UFS volume name cannot be zero length");
|
||||
isappleufs = 1;
|
||||
break;
|
||||
#endif
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
@ -556,8 +564,10 @@ main(int argc, char *argv[])
|
||||
if (dkw.dkw_size == 0)
|
||||
errx(1, "%s partition is unavailable", special);
|
||||
|
||||
#ifndef NO_APPLE_UFS
|
||||
if (strcmp(dkw.dkw_ptype, DKW_PTYPE_APPLEUFS) == 0)
|
||||
isappleufs = 1;
|
||||
#endif
|
||||
|
||||
if (!Iflag) {
|
||||
static const char m[] =
|
||||
@ -843,7 +853,9 @@ struct help_strings {
|
||||
int flags;
|
||||
const char *str;
|
||||
} const help_strings[] = {
|
||||
#ifndef NO_FFS_EI
|
||||
{ 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 +886,9 @@ struct help_strings {
|
||||
{ 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 NO_APPLE_UFS
|
||||
{ NEWFS, "-v volname\tApple UFS volume name" },
|
||||
#endif
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ufs_bswap.h,v 1.21 2016/04/29 03:05:04 christos Exp $ */
|
||||
/* $NetBSD: ufs_bswap.h,v 1.22 2017/02/08 16:11:40 rin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Manuel Bouyer.
|
||||
@ -45,7 +45,7 @@
|
||||
#define UFS_IPNEEDSWAP(ip) ((void)(ip), 0)
|
||||
#endif
|
||||
|
||||
#if !defined(_KERNEL) || defined(FFS_EI)
|
||||
#if (!defined(_KERNEL) && !defined(NO_FFS_EI)) || defined(FFS_EI)
|
||||
/* inlines for access to swapped data */
|
||||
static inline u_int16_t
|
||||
ufs_rw16(uint16_t a, int ns)
|
||||
|
Loading…
Reference in New Issue
Block a user