diff options
-rw-r--r-- | sbin/newlfs/config.h | 10 | ||||
-rw-r--r-- | sbin/newlfs/extern.h | 8 | ||||
-rw-r--r-- | sbin/newlfs/lfs.c | 40 | ||||
-rw-r--r-- | sbin/newlfs/newfs.c | 8 |
4 files changed, 44 insertions, 22 deletions
diff --git a/sbin/newlfs/config.h b/sbin/newlfs/config.h index dba63649d3c..5f546fdbbc0 100644 --- a/sbin/newlfs/config.h +++ b/sbin/newlfs/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.2 1996/06/23 14:31:51 deraadt Exp $ */ +/* $OpenBSD: config.h,v 1.3 1996/07/01 11:02:53 downsj Exp $ */ /* $NetBSD: config.h,v 1.2 1995/03/18 14:58:47 cgd Exp $ */ /*- @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)config.h 8.2 (Berkeley) 4/22/94 + * @(#)config.h 8.3 (Berkeley) 5/24/95 */ /* @@ -135,3 +135,9 @@ #define DFL_LFSBLOCK 4096 #define DFL_LFSBLOCK_SHIFT 12 #define DFL_LFSBLOCK_MASK 0xFFF + +#define DFL_LFSFRAG 4096 +#define DFL_LFS_FFMASK DFL_LFSBLOCK_MASK +#define DFL_LFS_FFSHIFT DFL_LFSBLOCK_SHIFT +#define DFL_LFS_FBMASK 0 +#define DFL_LFS_FBSHIFT 0 diff --git a/sbin/newlfs/extern.h b/sbin/newlfs/extern.h index c24531fe47f..65ec0cbc77f 100644 --- a/sbin/newlfs/extern.h +++ b/sbin/newlfs/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.2 1996/06/23 14:31:52 deraadt Exp $ */ +/* $OpenBSD: extern.h,v 1.3 1996/07/01 11:02:54 downsj Exp $ */ /* $NetBSD: extern.h,v 1.2 1995/03/18 14:58:48 cgd Exp $ */ /*- @@ -33,15 +33,15 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)extern.h 8.1 (Berkeley) 6/5/93 + * @(#)extern.h 8.2 (Berkeley) 5/24/95 */ u_long cksum __P((void *, size_t)); u_short dkcksum __P((struct disklabel *)); void fatal __P((const char *fmt, ...)); u_int log2 __P((u_int)); -int make_lfs - __P((int, struct disklabel *, struct partition *, int, int, int)); +int make_lfs __P((int, struct disklabel *, struct partition *, int, + int, int, int)); int mkfs __P((struct partition *, char *, int, int)); extern char *progname; diff --git a/sbin/newlfs/lfs.c b/sbin/newlfs/lfs.c index 45dc058b8ba..caf3eedb47e 100644 --- a/sbin/newlfs/lfs.c +++ b/sbin/newlfs/lfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs.c,v 1.2 1996/06/23 14:31:52 deraadt Exp $ */ +/* $OpenBSD: lfs.c,v 1.3 1996/07/01 11:02:54 downsj Exp $ */ /* $NetBSD: lfs.c,v 1.8 1995/06/19 21:30:36 cgd Exp $ */ /*- @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)lfs.c 8.1 (Berkeley) 6/5/93"; +static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95"; #else -static char rcsid[] = "$OpenBSD: lfs.c,v 1.2 1996/06/23 14:31:52 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: lfs.c,v 1.3 1996/07/01 11:02:54 downsj Exp $"; #endif #endif /* not lint */ @@ -98,7 +98,7 @@ static struct lfs lfs_default = { /* lfs_ssize */ DFL_LFSSEG/DFL_LFSBLOCK, /* lfs_dsize */ 0, /* lfs_bsize */ DFL_LFSBLOCK, - /* lfs_fsize */ DFL_LFSBLOCK, + /* lfs_fsize */ DFL_LFSFRAG, /* lfs_frag */ 1, /* lfs_free */ LFS_FIRST_INUM, /* lfs_bfree */ 0, @@ -128,10 +128,10 @@ static struct lfs lfs_default = { /* lfs_segshift */ DFL_LFSSEG_SHIFT, /* lfs_bmask */ DFL_LFSBLOCK_MASK, /* lfs_bshift */ DFL_LFSBLOCK_SHIFT, - /* lfs_ffmask */ 0, - /* lfs_ffshift */ 0, - /* lfs_fbmask */ 0, - /* lfs_fbshift */ 0, + /* lfs_ffmask */ DFL_LFS_FFMASK, + /* lfs_ffshift */ DFL_LFS_FFSHIFT, + /* lfs_fbmask */ DFL_LFS_FBMASK, + /* lfs_fbshift */ DFL_LFS_FBSHIFT, /* lfs_fsbtodb */ 0, /* lfs_sushift */ 0, /* lfs_maxsymlinklen */ MAXSYMLINKLEN, @@ -151,6 +151,7 @@ static struct lfs lfs_default = { /* lfs_ronly */ 0, /* lfs_flags */ 0, /* lfs_fsmnt */ { 0 }, + /* lfs_pad */ { 0 }, }; @@ -172,12 +173,13 @@ static void make_dir __P(( void *, struct direct *, int)); static void put __P((int, off_t, void *, size_t)); int -make_lfs(fd, lp, partp, minfree, block_size, seg_size) +make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size) int fd; struct disklabel *lp; struct partition *partp; int minfree; int block_size; + int frag_size; int seg_size; { struct dinode *dip; /* Pointer to a disk inode */ @@ -203,6 +205,7 @@ make_lfs(fd, lp, partp, minfree, block_size, seg_size) u_long *datasump; /* Used to computed checksum on data */ int block_array_size; /* How many entries in block array */ int bsize; /* Block size */ + int fsize; /* Fragment size */ int db_per_fb; /* Disk blocks per file block */ int i, j; int off; /* Offset at which to write */ @@ -215,18 +218,27 @@ make_lfs(fd, lp, partp, minfree, block_size, seg_size) if (!(bsize = block_size)) bsize = DFL_LFSBLOCK; + if (!(fsize = frag_size)) + fsize = DFL_LFSFRAG; if (!(ssize = seg_size)) ssize = DFL_LFSSEG; /* Modify parts of superblock overridden by command line arguments */ - if (bsize != DFL_LFSBLOCK) { + if (bsize != DFL_LFSBLOCK || fsize != DFL_LFSFRAG) { lfsp->lfs_bshift = log2(bsize); if (1 << lfsp->lfs_bshift != bsize) fatal("%d: block size not a power of 2", bsize); lfsp->lfs_bsize = bsize; - lfsp->lfs_fsize = bsize; + lfsp->lfs_fsize = fsize; lfsp->lfs_bmask = bsize - 1; lfsp->lfs_inopb = bsize / sizeof(struct dinode); + lfsp->lfs_ffmask = fsize - 1; + lfsp->lfs_ffshift = log2(fsize); + if (1 << lfsp->lfs_ffshift != fsize) + fatal("%d: frag size not a power of 2", fsize); + lfsp->lfs_frag = numfrags(lfsp, bsize); + lfsp->lfs_fbmask = lfsp->lfs_frag - 1; + lfsp->lfs_fbshift = log2(lfsp->lfs_frag); /* MIS -- should I round to power of 2 */ lfsp->lfs_ifpb = bsize / sizeof(IFILE); lfsp->lfs_sepb = bsize / sizeof(SEGUSE); @@ -488,6 +500,7 @@ make_lfs(fd, lp, partp, minfree, block_size, seg_size) summary.ss_create = lfsp->lfs_tstamp; summary.ss_nfinfo = 3; summary.ss_ninos = 3; + summary.ss_magic = SS_MAGIC; summary.ss_datasum = cksum(datasump, sizeof(u_long) * blocks_used); /* @@ -524,6 +537,7 @@ make_lfs(fd, lp, partp, minfree, block_size, seg_size) /* Now, add the ifile */ file_info.fi_nblocks = block_array_size; file_info.fi_version = 1; + file_info.fi_lastlength = lfsp->lfs_bsize; file_info.fi_ino = LFS_IFILE_INUM; memcpy(sump, &file_info, sizeof(FINFO) - sizeof(u_long)); @@ -534,6 +548,7 @@ make_lfs(fd, lp, partp, minfree, block_size, seg_size) /* Now, add the root directory */ file_info.fi_nblocks = 1; file_info.fi_version = 1; + file_info.fi_lastlength = lfsp->lfs_bsize; file_info.fi_ino = ROOTINO; file_info.fi_blocks[0] = 0; memcpy(sump, &file_info, sizeof(FINFO)); @@ -554,6 +569,7 @@ make_lfs(fd, lp, partp, minfree, block_size, seg_size) sp->ss_nfinfo = 0; sp->ss_ninos = 0; sp->ss_datasum = 0; + sp->ss_magic = SS_MAGIC; /* Now write the summary block for the next partial so it's invalid */ lfsp->lfs_tstamp = 0; @@ -630,7 +646,7 @@ make_dinode(ino, dip, nblocks, saddr, lfsp) dip->di_blocks = nblocks << lfsp->lfs_fsbtodb; dip->di_size = (nblocks << lfsp->lfs_bshift); - dip->di_atime = dip->di_mtime =dip->di_ctime = lfsp->lfs_tstamp; + dip->di_atime = dip->di_mtime = dip->di_ctime = lfsp->lfs_tstamp; dip->di_atimensec = dip->di_mtimensec = dip->di_ctimensec = 0; dip->di_inumber = ino; diff --git a/sbin/newlfs/newfs.c b/sbin/newlfs/newfs.c index dc6a08814c0..a13694c89a2 100644 --- a/sbin/newlfs/newfs.c +++ b/sbin/newlfs/newfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs.c,v 1.3 1996/06/23 14:31:54 deraadt Exp $ */ +/* $OpenBSD: newfs.c,v 1.4 1996/07/01 11:02:55 downsj Exp $ */ /* $NetBSD: newfs.c,v 1.5 1996/05/16 07:17:50 thorpej Exp $ */ /*- @@ -42,9 +42,9 @@ static char copyright[] = #ifndef lint #if 0 -static char sccsid[] = "@(#)newfs.c 8.3 (Berkeley) 4/22/94"; +static char sccsid[] = "@(#)newfs.c 8.5 (Berkeley) 5/24/95"; #else -static char rcsid[] = "$OpenBSD: newfs.c,v 1.3 1996/06/23 14:31:54 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: newfs.c,v 1.4 1996/07/01 11:02:55 downsj Exp $"; #endif #endif /* not lint */ @@ -328,7 +328,7 @@ main(argc, argv) fatal("%s: `%c' partition is unavailable", argv[0], *cp); /* If we're making a LFS, we break out here */ - exit(make_lfs(fso, lp, pp, minfree, bsize, segsize)); + exit(make_lfs(fso, lp, pp, minfree, bsize, fsize, segsize)); } #ifdef COMPAT |