Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Make the "-O" (start filesystem offset) flag to newfs_lfs wo...
details: https://anonhg.NetBSD.org/src/rev/6c4724afea52
branches: trunk
changeset: 543325:6c4724afea52
user: perseant <perseant%NetBSD.org@localhost>
date: Sun Feb 23 04:32:05 2003 +0000
description:
Make the "-O" (start filesystem offset) flag to newfs_lfs work correctly,
and update fsck_lfs and dumplfs to deal with it. Note that while the argument
to -O is given in disk sectors, it must be a multiple of the fragment size,
and although it can be lower than the label or superblock, it can't intersect
either.
diffstat:
sbin/fsck_lfs/pass5.c | 8 +++++---
sbin/newfs_lfs/lfs.c | 34 ++++++++++++++++++++++++++++------
usr.sbin/dumplfs/dumplfs.c | 16 ++++++++++------
3 files changed, 43 insertions(+), 15 deletions(-)
diffs (135 lines):
diff -r 238273f558ca -r 6c4724afea52 sbin/fsck_lfs/pass5.c
--- a/sbin/fsck_lfs/pass5.c Sun Feb 23 04:20:06 2003 +0000
+++ b/sbin/fsck_lfs/pass5.c Sun Feb 23 04:32:05 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass5.c,v 1.10 2002/05/23 04:05:11 perseant Exp $ */
+/* $NetBSD: pass5.c,v 1.11 2003/02/23 04:32:05 perseant Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -151,8 +151,10 @@
sbdirty();
}
}
- labelskew = (sblock.lfs_version == 1 ? 0 :
- btofsb(&sblock, LFS_LABELPAD));
+ labelskew = 0;
+ if (sblock.lfs_version > 1 &&
+ sblock.lfs_start < btofsb(&sblock, LFS_LABELPAD))
+ labelskew = btofsb(&sblock, LFS_LABELPAD);
if (sblock.lfs_bfree > sblock.lfs_dsize - bb - labelskew ||
sblock.lfs_bfree < sblock.lfs_dsize - ubb - labelskew) {
pwarn("bfree given as %d, should be between %ld and %ld\n",
diff -r 238273f558ca -r 6c4724afea52 sbin/newfs_lfs/lfs.c
--- a/sbin/newfs_lfs/lfs.c Sun Feb 23 04:20:06 2003 +0000
+++ b/sbin/newfs_lfs/lfs.c Sun Feb 23 04:32:05 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.24 2003/01/24 21:55:12 fvdl Exp $ */
+/* $NetBSD: lfs.c,v 1.25 2003/02/23 04:32:06 perseant Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95";
#else
-__RCSID("$NetBSD: lfs.c,v 1.24 2003/01/24 21:55:12 fvdl Exp $");
+__RCSID("$NetBSD: lfs.c,v 1.25 2003/02/23 04:32:06 perseant Exp $");
#endif
#endif /* not lint */
@@ -447,7 +447,23 @@
* structures into a free list.
*/
- /* Figure out where the superblocks are going to live */
+ /*
+ * Figure out where the superblocks are going to live.
+ *
+ * Make segment 0 start at either zero, or LFS_LABELPAD, or
+ * >= LFS_SBPAD+LFS_LABELPAD, in order to prevent segment 0
+ * from having half a superblock in it.
+ */
+ if (fsbtodb(lfsp, dbtofsb(lfsp, start)) != start)
+ fatal("Segment 0 offset is not multiple of frag size\n");
+ if (start != 0 && dbtob(start) != LFS_LABELPAD &&
+ dbtob(start) < LFS_SBPAD + LFS_LABELPAD) {
+ fatal("Using flags \"-O %d\" would result in the first "
+ "segment containing only\npart of a superblock. "
+ "Please choose an offset of 0, %d, or %d or more,\n",
+ start, btodb(LFS_LABELPAD),
+ btodb(LFS_LABELPAD + LFS_SBPAD));
+ }
lfsp->lfs_sboffs[0] = label_fsb;
if (version == 1)
lfsp->lfs_start = lfsp->lfs_sboffs[0];
@@ -508,7 +524,9 @@
segp->su_lastmod = lfsp->lfs_tstamp;
segp->su_nsums = 1; /* 1 summary blocks */
segp->su_ninos = 1; /* 1 inode block */
- segp->su_flags = SEGUSE_SUPERBLOCK | SEGUSE_DIRTY;
+ segp->su_flags = SEGUSE_DIRTY;
+ if (lfsp->lfs_start < btofsb(lfsp, LFS_LABELPAD + LFS_SBPAD))
+ segp->su_flags |= SEGUSE_SUPERBLOCK;
lfsp->lfs_bfree -= btofsb(lfsp, lfsp->lfs_sumsize);
lfsp->lfs_bfree -= fragstofsb(lfsp, blkstofrags(lfsp,
@@ -518,8 +536,10 @@
* Now figure out the address of the ifile inode. The inode block
* appears immediately after the segment summary.
*/
- lfsp->lfs_idaddr = label_fsb + sb_fsb +
- btofsb(lfsp, lfsp->lfs_sumsize);
+ lfsp->lfs_idaddr = label_fsb + sb_fsb;
+ if (lfsp->lfs_idaddr < lfsp->lfs_start)
+ lfsp->lfs_idaddr = lfsp->lfs_start;
+ lfsp->lfs_idaddr += btofsb(lfsp, lfsp->lfs_sumsize);
for (i = 1, j = 1; i < lfsp->lfs_nseg; i++) {
segp = (SEGUSE *)(((char *)segtable) +
@@ -750,6 +770,8 @@
if (lfsp->lfs_start < label_fsb)
lfsp->lfs_avail -= label_fsb - lfsp->lfs_start;
lfsp->lfs_bfree = lfsp->lfs_avail; /* XXX */
+ if (lfsp->lfs_start >= label_fsb + sb_fsb) /* XXX */
+ lfsp->lfs_avail += sb_fsb;
/* Slop for an imperfect cleaner */
lfsp->lfs_avail += segtod(lfsp, lfsp->lfs_minfreeseg / 2);
lfsp->lfs_cksum = lfs_sb_cksum(&(lfsp->lfs_dlfs));
diff -r 238273f558ca -r 6c4724afea52 usr.sbin/dumplfs/dumplfs.c
--- a/usr.sbin/dumplfs/dumplfs.c Sun Feb 23 04:20:06 2003 +0000
+++ b/usr.sbin/dumplfs/dumplfs.c Sun Feb 23 04:32:05 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dumplfs.c,v 1.23 2003/02/21 04:01:07 simonb Exp $ */
+/* $NetBSD: dumplfs.c,v 1.24 2003/02/23 04:32:07 perseant Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -45,7 +45,7 @@
#if 0
static char sccsid[] = "@(#)dumplfs.c 8.5 (Berkeley) 5/24/95";
#else
-__RCSID("$NetBSD: dumplfs.c,v 1.23 2003/02/21 04:01:07 simonb Exp $");
+__RCSID("$NetBSD: dumplfs.c,v 1.24 2003/02/23 04:32:07 perseant Exp $");
#endif
#endif /* not lint */
@@ -560,10 +560,14 @@
sumblock = malloc(lfsp->lfs_sumsize);
if (lfsp->lfs_version > 1 && segnum == 0) {
- /* First segment eats the label as well as the superblock */
- sum_offset += fragroundup(lfsp, LFS_LABELPAD);
- addr += btofsb(lfsp, fragroundup(lfsp, LFS_LABELPAD));
- printf("Disklabel at 0x0\n");
+ if (fsbtob(lfsp, lfsp->lfs_start) < LFS_LABELPAD) {
+ /* First segment eats the disklabel */
+ sum_offset += fragroundup(lfsp, LFS_LABELPAD) -
+ fsbtob(lfsp, lfsp->lfs_start);
+ addr += btofsb(lfsp, fragroundup(lfsp, LFS_LABELPAD)) -
+ lfsp->lfs_start;
+ printf("Disklabel at 0x0\n");
+ }
}
sb = 0;
Home |
Main Index |
Thread Index |
Old Index