Source-Changes-HG archive

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

[src/trunk]: src Add smaller versions of fsck_ffs(8) and newfs(8) for install...



details:   https://anonhg.NetBSD.org/src/rev/0d1e6ae48a64
branches:  trunk
changeset: 821507:0d1e6ae48a64
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Feb 08 16:11:39 2017 +0000

description:
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.

diffstat:

 distrib/utils/x_fsck_ffs/Makefile |  28 ++++++++++++++++++++++++
 distrib/utils/x_newfs/Makefile    |  28 ++++++++++++++++++++++++
 sbin/fsck_ffs/Makefile            |  44 ++++++-------------------------------
 sbin/fsck_ffs/Makefile.common     |  41 +++++++++++++++++++++++++++++++++++
 sbin/fsck_ffs/dir.c               |  16 ++++++------
 sbin/fsck_ffs/fsck.h              |  45 ++++++++++++++++++++++++++++++++------
 sbin/fsck_ffs/inode.c             |   8 +++++-
 sbin/fsck_ffs/main.c              |  26 ++++++++++++++++++----
 sbin/fsck_ffs/pass1.c             |   6 +++-
 sbin/fsck_ffs/pass2.c             |   8 +++++-
 sbin/fsck_ffs/setup.c             |  31 +++++++++++++++++++++-----
 sbin/fsck_ffs/utilities.c         |   8 +++++-
 sbin/newfs/Makefile               |  27 ++++++-----------------
 sbin/newfs/Makefile.common        |  25 +++++++++++++++++++++
 sbin/newfs/extern.h               |  20 +++++++++++++++-
 sbin/newfs/mkfs.c                 |   6 +++-
 sbin/newfs/newfs.c                |  26 +++++++++++++++++-----
 sys/ufs/ufs/ufs_bswap.h           |   4 +-
 18 files changed, 295 insertions(+), 102 deletions(-)

diffs (truncated from 912 to 300 lines):

diff -r a18f97d71a30 -r 0d1e6ae48a64 distrib/utils/x_fsck_ffs/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/utils/x_fsck_ffs/Makefile Wed Feb 08 16:11:39 2017 +0000
@@ -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>
diff -r a18f97d71a30 -r 0d1e6ae48a64 distrib/utils/x_newfs/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/utils/x_newfs/Makefile    Wed Feb 08 16:11:39 2017 +0000
@@ -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>
diff -r a18f97d71a30 -r 0d1e6ae48a64 sbin/fsck_ffs/Makefile
--- a/sbin/fsck_ffs/Makefile    Wed Feb 08 16:00:30 2017 +0000
+++ b/sbin/fsck_ffs/Makefile    Wed Feb 08 16:11:39 2017 +0000
@@ -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
-
-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=  ffs_bswap.c ffs_appleufs.c
+SUBDIR=        SMM.doc
 
-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>
diff -r a18f97d71a30 -r 0d1e6ae48a64 sbin/fsck_ffs/Makefile.common
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/fsck_ffs/Makefile.common     Wed Feb 08 16:11:39 2017 +0000
@@ -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
diff -r a18f97d71a30 -r 0d1e6ae48a64 sbin/fsck_ffs/dir.c
--- a/sbin/fsck_ffs/dir.c       Wed Feb 08 16:00:30 2017 +0000
+++ b/sbin/fsck_ffs/dir.c       Wed Feb 08 16:11:39 2017 +0000
@@ -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 @@
        struct bufarea *bp;
        int dsize, n;
        long blksiz;
-#if UFS_DIRBLKSIZ > APPLEUFS_DIRBLKSIZ
+#if !defined(NO_APPLE_UFS) && UFS_DIRBLKSIZ < APPLEUFS_DIRBLKSIZ
+       char dbuf[APPLEUFS_DIRBLKSIZ];
+#else
        char dbuf[UFS_DIRBLKSIZ];
-#else
-       char dbuf[APPLEUFS_DIRBLKSIZ];
 #endif
 
        if (idesc->id_type != DATA)
@@ -703,10 +703,10 @@
        daddr_t lastbn, newblk, dirblk;
        struct bufarea *bp;
        char *cp;
-#if DIRBLKSIZ > APPLEUFS_DIRBLKSIZ
-       char firstblk[DIRBLKSIZ];
+#if !defined(NO_APPLE_UFS) && UFS_DIRBLKSIZ < APPLEUFS_DIRBLKSIZ
+       char firstblk[APPLEUFS_DIRBLKSIZ];
 #else
-       char firstblk[APPLEUFS_DIRBLKSIZ];
+       char firstblk[UFS_DIRBLKSIZ];
 #endif
        struct ufs1_dinode *dp1 = NULL;
        struct ufs2_dinode *dp2 = NULL;
diff -r a18f97d71a30 -r 0d1e6ae48a64 sbin/fsck_ffs/fsck.h
--- a/sbin/fsck_ffs/fsck.h      Wed Feb 08 16:00:30 2017 +0000
+++ b/sbin/fsck_ffs/fsck.h      Wed Feb 08 16:11:39 2017 +0000
@@ -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 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 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 @@
 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    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 @@
 #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 @@
                return bswap64(x);
        else return x;



Home | Main Index | Thread Index | Old Index