type size paranoia, and allow one to mount an mfs on the device 'swap',

so that diskless machines can use MFS /tmp directories.
This commit is contained in:
cgd 1994-12-18 05:09:39 +00:00
parent 02ae34d854
commit 4c998ed311
2 changed files with 41 additions and 10 deletions

View File

@ -33,10 +33,9 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/
static char *rcsid = "$Id: mkfs.c,v 1.13 1994/10/31 04:22:12 cgd Exp $";
static char *rcsid = "$Id: mkfs.c,v 1.14 1994/12/18 05:09:39 cgd Exp $";
#endif /* not lint */
#include <unistd.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/wait.h>
@ -46,6 +45,9 @@ static char *rcsid = "$Id: mkfs.c,v 1.13 1994/10/31 04:22:12 cgd Exp $";
#include <ufs/ffs/fs.h>
#include <sys/disklabel.h>
#include <string.h>
#include <unistd.h>
#ifndef STANDALONE
#include <a.out.h>
#include <stdio.h>
@ -674,7 +676,7 @@ initcg(cylno, utime)
if (sblock.fs_contigsumsize > 0)
acg.cg_nclusterblks = acg.cg_ndblk / sblock.fs_frag;
acg.cg_btotoff = &acg.cg_space[0] - (u_char *)(&acg.cg_unused_1);
acg.cg_boff = acg.cg_btotoff + sblock.fs_cpg * sizeof(long);
acg.cg_boff = acg.cg_btotoff + sblock.fs_cpg * sizeof(int32_t);
acg.cg_iusedoff = acg.cg_boff +
sblock.fs_cpg * sblock.fs_nrpos * sizeof(short);
acg.cg_freeoff = acg.cg_iusedoff + howmany(sblock.fs_ipg, NBBY);
@ -684,11 +686,11 @@ initcg(cylno, utime)
} else {
acg.cg_clustersumoff = acg.cg_freeoff + howmany
(sblock.fs_cpg * sblock.fs_spc / NSPF(&sblock), NBBY) -
sizeof(long);
sizeof(int32_t);
acg.cg_clustersumoff =
roundup(acg.cg_clustersumoff, sizeof(long));
roundup(acg.cg_clustersumoff, sizeof(int32_t));
acg.cg_clusteroff = acg.cg_clustersumoff +
(sblock.fs_contigsumsize + 1) * sizeof(long);
(sblock.fs_contigsumsize + 1) * sizeof(int32_t);
acg.cg_nextfreeoff = acg.cg_clusteroff + howmany
(sblock.fs_cpg * sblock.fs_spc / NSPB(&sblock), NBBY);
}
@ -805,9 +807,9 @@ struct direct root_dir[] = {
#endif
};
struct odirect {
u_long d_ino;
u_short d_reclen;
u_short d_namlen;
u_int32_t d_ino;
u_int16_t d_reclen;
u_int16_t d_namlen;
u_char d_name[MAXNAMLEN + 1];
} oroot_dir[] = {
{ ROOTINO, sizeof(struct direct), 1, "." },

View File

@ -39,7 +39,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)newfs.c 8.8 (Berkeley) 4/18/94";*/
static char *rcsid = "$Id: newfs.c,v 1.13 1994/12/01 18:46:38 mycroft Exp $";
static char *rcsid = "$Id: newfs.c,v 1.14 1994/12/18 05:09:44 cgd Exp $";
#endif /* not lint */
/*
@ -191,6 +191,7 @@ main(argc, argv)
register int ch;
register struct partition *pp;
register struct disklabel *lp;
struct disklabel mfsfakelabel;
struct disklabel *getdisklabel();
struct partition oldpartition;
struct stat st;
@ -325,6 +326,33 @@ main(argc, argv)
usage();
special = argv[0];
if (mfs && !strcmp(special, "swap")) {
/*
* it's an MFS, mounted on "swap." fake up a label.
* XXX XXX XXX
*/
fso = -1; /* XXX; normally done below. */
memset(&mfsfakelabel, 0, sizeof(mfsfakelabel));
mfsfakelabel.d_secsize = 512;
mfsfakelabel.d_nsectors = 64;
mfsfakelabel.d_ntracks = 16;
mfsfakelabel.d_ncylinders = 16;
mfsfakelabel.d_secpercyl = 1024;
mfsfakelabel.d_secperunit = 16384;
mfsfakelabel.d_rpm = 3600;
mfsfakelabel.d_interleave = 1;
mfsfakelabel.d_npartitions = 1;
mfsfakelabel.d_partitions[0].p_size = 16384;
mfsfakelabel.d_partitions[0].p_fsize = 1024;
mfsfakelabel.d_partitions[0].p_frag = 8;
mfsfakelabel.d_partitions[0].p_cpg = 16;
lp = &mfsfakelabel;
pp = &mfsfakelabel.d_partitions[0];
goto havelabel;
}
cp = strrchr(special, '/');
if (cp == 0) {
/*
@ -398,6 +426,7 @@ main(argc, argv)
fatal("%s: `%c' partition overlaps boot program",
argv[0], *cp);
}
havelabel:
if (fssize == 0)
fssize = pp->p_size;
if (fssize > pp->p_size && !mfs)