From 5d439a2c2615b70e5e9f7d6a50975c6cef656c14 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 19 Mar 2002 20:01:38 +0000 Subject: Further cleanups. --- sbin/newfs/mkfs.c | 73 ++++++++++++++++-------------------------------------- sbin/newfs/newfs.c | 13 +++++----- sbin/newfs/newfs.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 58 deletions(-) create mode 100644 sbin/newfs/newfs.h (limited to 'sbin') diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index f8e0026..d7fea21 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -58,6 +58,7 @@ static const char rcsid[] = #include #include #include +#include "newfs.h" /* * make file system for cylinder-group style file systems @@ -76,69 +77,37 @@ static const char rcsid[] = #define MAXINOPB (MAXBSIZE / sizeof(struct dinode)) #define POWEROF2(num) (((num) & ((num) - 1)) == 0) -/* - * variables set up by front end. - */ -extern int Nflag; /* run mkfs without writing file system */ -extern int Oflag; /* format as an 4.3BSD file system */ -extern int Uflag; /* enable soft updates for file system */ -extern int fssize; /* file system size */ -extern int ntracks; /* # tracks/cylinder */ -extern int nsectors; /* # sectors/track */ -extern int nphyssectors; /* # sectors/track including spares */ -extern int secpercyl; /* sectors per cylinder */ -extern int sectorsize; /* bytes/sector */ -extern int realsectorsize; /* bytes/sector in hardware*/ -extern int rpm; /* revolutions/minute of drive */ -extern int interleave; /* hardware sector interleave */ -extern int trackskew; /* sector 0 skew, per track */ -extern int fsize; /* fragment size */ -extern int bsize; /* block size */ -extern int cpg; /* cylinders/cylinder group */ -extern int cpgflg; /* cylinders/cylinder group flag was given */ -extern int minfree; /* free space threshold */ -extern int opt; /* optimization preference (space or time) */ -extern int density; /* number of bytes per inode */ -extern int maxcontig; /* max contiguous blocks to allocate */ -extern int rotdelay; /* rotational delay between blocks */ -extern int maxbpg; /* maximum blocks per file in a cyl group */ -extern int nrpos; /* # of distinguished rotational positions */ -extern int bbsize; /* boot block size */ -extern int sbsize; /* superblock size */ -extern int avgfilesize; /* expected average file size */ -extern int avgfilesperdir; /* expected number of files per directory */ - -union { +static union { struct fs fs; char pad[SBSIZE]; } fsun; #define sblock fsun.fs -struct csum *fscs; +static struct csum *fscs; -union { +static union { struct cg cg; char pad[MAXBSIZE]; } cgun; #define acg cgun.cg -struct dinode zino[MAXBSIZE / sizeof(struct dinode)]; +static struct dinode zino[MAXBSIZE / sizeof(struct dinode)]; -int fsi, fso; -int randinit; -daddr_t alloc(); -long calcipg(); -static int charsperline(); -void clrblock (struct fs *, unsigned char *, int); -void fsinit (time_t); +static int fsi, fso; +static int randinit; +static daddr_t alloc(int size, int mode); +static long calcipg(long cpg, long bpcg, off_t *usedbp); +static int charsperline(void); +static void clrblock (struct fs *, unsigned char *, int); +static void fsinit (time_t); static int ilog2(int); -void initcg (int, time_t); -int isblock (struct fs *, unsigned char *, int); -void iput (struct dinode *, ino_t); -int makedir (struct direct *, int); -void rdfs (daddr_t, int, char *); -void setblock (struct fs *, unsigned char *, int); -void wtfs (daddr_t, int, char *); -void wtfsflush (void); +static void initcg (int, time_t); +static int isblock (struct fs *, unsigned char *, int); +static void iput (struct dinode *, ino_t); +static int makedir (struct direct *, int); +static void rdfs (daddr_t, int, char *); +static void setblock (struct fs *, unsigned char *, int); +static void wtfs (daddr_t, int, char *); +static void wtfsflush (void); void mkfs(struct partition *pp, char *fsys, int fi, int fo) @@ -1216,7 +1185,7 @@ setblock(struct fs *fs, unsigned char *cp, int h) */ static int -charsperline() +charsperline(void) { int columns; char *cp; diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 7aee58d..ba0c31a 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -70,8 +70,10 @@ static const char rcsid[] = #include #include +#include "newfs.h" -void fatal(const char *fmt, ...) __printflike(1, 2); +static void fatal(const char *fmt, ...) __printflike(1, 2); +static struct disklabel *getdisklabel(char *s, int fd); #define COMPAT /* allow non-labeled disks */ @@ -194,11 +196,10 @@ main(int argc, char *argv[]) { struct partition *pp; struct disklabel *lp; - struct disklabel *getdisklabel(); struct partition oldpartition; struct stat st; struct statfs *mp; - char *cp, *s1, *s2, *special, *opstring; + char *cp, *s1, *s2, *special; int ch, fsi, fso, len, n, vflag; vflag = 0; @@ -207,8 +208,8 @@ main(int argc, char *argv[]) else progname = *argv; - opstring = "NOS:T:Ua:b:c:d:e:f:g:h:i:k:l:m:n:o:p:r:s:t:u:vx:"; - while ((ch = getopt(argc, argv, opstring)) != -1) + while ((ch = getopt(argc, argv, + "NOS:T:Ua:b:c:d:e:f:g:h:i:k:l:m:n:o:p:r:s:t:u:vx:")) != -1) switch (ch) { case 'N': Nflag = 1; @@ -532,7 +533,7 @@ getdisklabel(char *s, int fd) if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { #ifdef COMPAT if (disktype) { - struct disklabel *lp, *getdiskbyname(); + struct disklabel *lp; unlabeled++; lp = getdiskbyname(disktype); diff --git a/sbin/newfs/newfs.h b/sbin/newfs/newfs.h new file mode 100644 index 0000000..0386c5f --- /dev/null +++ b/sbin/newfs/newfs.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1980, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY 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$ + */ + + +/* + * variables set up by front end. + */ +extern int Nflag; /* run mkfs without writing file system */ +extern int Oflag; /* format as an 4.3BSD file system */ +extern int Uflag; /* enable soft updates for file system */ +extern int fssize; /* file system size */ +extern int ntracks; /* # tracks/cylinder */ +extern int nsectors; /* # sectors/track */ +extern int nphyssectors; /* # sectors/track including spares */ +extern int secpercyl; /* sectors per cylinder */ +extern int sectorsize; /* bytes/sector */ +extern int realsectorsize; /* bytes/sector in hardware*/ +extern int rpm; /* revolutions/minute of drive */ +extern int interleave; /* hardware sector interleave */ +extern int trackskew; /* sector 0 skew, per track */ +extern int fsize; /* fragment size */ +extern int bsize; /* block size */ +extern int cpg; /* cylinders/cylinder group */ +extern int cpgflg; /* cylinders/cylinder group flag was given */ +extern int minfree; /* free space threshold */ +extern int opt; /* optimization preference (space or time) */ +extern int density; /* number of bytes per inode */ +extern int maxcontig; /* max contiguous blocks to allocate */ +extern int rotdelay; /* rotational delay between blocks */ +extern int maxbpg; /* maximum blocks per file in a cyl group */ +extern int nrpos; /* # of distinguished rotational positions */ +extern int bbsize; /* boot block size */ +extern int sbsize; /* superblock size */ +extern int avgfilesize; /* expected average file size */ +extern int avgfilesperdir; /* expected number of files per directory */ + -- cgit v1.1