From ebdb43a2f8b1002462d9e7ca14f3615efdb8b06e Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sun, 7 Apr 2002 14:57:57 +0000 Subject: [PATCH] bbsize and sbsize cannot ever be trusted from the disklabel, in particular as there may not be one. Remove #if 0'ed code which might mislead people to think otherwise. unifdef -ULOSTDIR, fsck can make lost+found on the fly. Sponsored by: DARPA & NAI Labs --- sbin/newfs/mkfs.c | 49 ++++------------------------------------------ sbin/newfs/newfs.c | 6 ------ sbin/newfs/newfs.h | 2 -- 3 files changed, 4 insertions(+), 53 deletions(-) diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index c6c64e649732..68870696cbab 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -217,9 +217,9 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo) sblock.fs_nspf = sblock.fs_fsize / sectorsize; sblock.fs_fsbtodb = ilog2(NSPF(&sblock)); sblock.fs_sblkno = - roundup(howmany(bbsize + sbsize, sblock.fs_fsize), sblock.fs_frag); + roundup(howmany(BBSIZE + SBSIZE, sblock.fs_fsize), sblock.fs_frag); sblock.fs_cblkno = (daddr_t)(sblock.fs_sblkno + - roundup(howmany(sbsize, sblock.fs_fsize), sblock.fs_frag)); + roundup(howmany(SBSIZE, sblock.fs_fsize), sblock.fs_frag)); sblock.fs_iblkno = sblock.fs_cblkno + sblock.fs_frag; sblock.fs_cgoffset = roundup(howmany(sblock.fs_nsect, NSPF(&sblock)), sblock.fs_frag); @@ -545,7 +545,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo) */ fsinit(utime); sblock.fs_time = utime; - wtfs((int)SBOFF / sectorsize, sbsize, (char *)&sblock); + wtfs((int)SBOFF / sectorsize, SBSIZE, (char *)&sblock); for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize) wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)), sblock.fs_cssize - i < sblock.fs_bsize ? @@ -556,7 +556,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo) */ for (cylno = 0; cylno < sblock.fs_ncg; cylno++) wtfs(fsbtodb(&sblock, cgsblock(&sblock, cylno)), - sbsize, (char *)&sblock); + SBSIZE, (char *)&sblock); wtfsflush(); /* * Update information about this partion in pack @@ -727,18 +727,11 @@ initcg(int cylno, time_t utime) */ struct dinode node; -#ifdef LOSTDIR -#define PREDEFDIR 3 -#else #define PREDEFDIR 2 -#endif struct direct root_dir[] = { { ROOTINO, sizeof(struct direct), DT_DIR, 1, "." }, { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, -#ifdef LOSTDIR - { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 10, "lost+found" }, -#endif }; struct odirect { u_long d_ino; @@ -748,30 +741,12 @@ struct odirect { } oroot_dir[] = { { ROOTINO, sizeof(struct direct), 1, "." }, { ROOTINO, sizeof(struct direct), 2, ".." }, -#ifdef LOSTDIR - { LOSTFOUNDINO, sizeof(struct direct), 10, "lost+found" }, -#endif }; -#ifdef LOSTDIR -struct direct lost_found_dir[] = { - { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 1, "." }, - { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, - { 0, DIRBLKSIZ, 0, 0, 0 }, -}; -struct odirect olost_found_dir[] = { - { LOSTFOUNDINO, sizeof(struct direct), 1, "." }, - { ROOTINO, sizeof(struct direct), 2, ".." }, - { 0, DIRBLKSIZ, 0, 0 }, -}; -#endif char buf[MAXBSIZE]; void fsinit(time_t utime) { -#ifdef LOSTDIR - int i; -#endif /* * initialize the node @@ -779,22 +754,6 @@ fsinit(time_t utime) node.di_atime = utime; node.di_mtime = utime; node.di_ctime = utime; -#ifdef LOSTDIR - /* - * create the lost+found directory - */ - (void)makedir(lost_found_dir, 2); - for (i = DIRBLKSIZ; i < sblock.fs_bsize; i += DIRBLKSIZ) - memmove(&buf[i], &lost_found_dir[2], - DIRSIZ(0, &lost_found_dir[2])); - node.di_mode = IFDIR | UMASK; - node.di_nlink = 2; - node.di_size = sblock.fs_bsize; - node.di_db[0] = alloc(node.di_size, node.di_mode); - node.di_blocks = btodb(fragroundup(&sblock, node.di_size)); - wtfs(fsbtodb(&sblock, node.di_db[0]), node.di_size, buf); - iput(&node, LOSTFOUNDINO); -#endif /* * create the root directory */ diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 1c3f2239a6d3..e70c7c375bf6 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -134,8 +134,6 @@ int maxcontig = 0; /* max contiguous blocks to allocate */ int maxbpg; /* maximum blocks per file in a cyl group */ int avgfilesize = AVFILESIZ;/* expected average file size */ int avgfilesperdir = AFPDIR;/* expected number of files per directory */ -int bbsize = BBSIZE; /* boot block size */ -int sbsize = SBSIZE; /* superblock size */ static char device[MAXPATHLEN]; static char *disktype; @@ -372,10 +370,6 @@ main(int argc, char *argv[]) "disagrees with disk label", (u_long)lp->d_secpercyl); if (maxbpg == 0) maxbpg = MAXBLKPG(bsize); -#ifdef notdef /* label may be 0 if faked up by kernel */ - bbsize = lp->d_bbsize; - sbsize = lp->d_sbsize; -#endif oldpartition = *pp; realsectorsize = sectorsize; if (sectorsize != DEV_BSIZE) { /* XXX */ diff --git a/sbin/newfs/newfs.h b/sbin/newfs/newfs.h index 9bfe66fd71ee..ae92c0d47eb9 100644 --- a/sbin/newfs/newfs.h +++ b/sbin/newfs/newfs.h @@ -53,8 +53,6 @@ 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 maxbpg; /* maximum blocks per file in a cyl group */ -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 */ void mkfs (struct partition *, char *, int, int);