diff options
-rw-r--r-- | bin/df/ffs_df.c | 14 | ||||
-rw-r--r-- | sbin/badsect/badsect.c | 6 | ||||
-rw-r--r-- | sbin/dump/traverse.c | 6 | ||||
-rw-r--r-- | sbin/dumpfs/dumpfs.c | 28 | ||||
-rw-r--r-- | sbin/fsck_ffs/main.c | 16 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass1.c | 6 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass5.c | 16 | ||||
-rw-r--r-- | sbin/fsck_ffs/setup.c | 16 | ||||
-rw-r--r-- | sbin/fsck_ffs/utilities.c | 9 | ||||
-rw-r--r-- | sbin/growfs/debug.c | 16 | ||||
-rw-r--r-- | sbin/growfs/growfs.c | 188 | ||||
-rw-r--r-- | sbin/ncheck_ffs/ncheck_ffs.c | 6 | ||||
-rw-r--r-- | sbin/newfs/mkfs.c | 58 | ||||
-rw-r--r-- | sbin/scan_ffs/scan_ffs.c | 12 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 53 | ||||
-rw-r--r-- | sys/ufs/ffs/fs.h | 71 |
16 files changed, 306 insertions, 215 deletions
diff --git a/bin/df/ffs_df.c b/bin/df/ffs_df.c index f510a4c5287..7157e85ad53 100644 --- a/bin/df/ffs_df.c +++ b/bin/df/ffs_df.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_df.c,v 1.10 2004/09/14 22:46:04 deraadt Exp $ */ +/* $OpenBSD: ffs_df.c,v 1.11 2007/03/19 13:27:47 pedro Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -75,13 +75,13 @@ ffs_df(int rfd, char *file, struct statfs *sfsp) sfsp->f_flags = 0; sfsp->f_bsize = sblock.fs_fsize; sfsp->f_iosize = sblock.fs_bsize; - sfsp->f_blocks = sblock.fs_dsize; - sfsp->f_bfree = sblock.fs_cstotal.cs_nbfree * sblock.fs_frag + - sblock.fs_cstotal.cs_nffree; - sfsp->f_bavail = ((int64_t)sblock.fs_dsize * (100 - - sblock.fs_minfree) / 100) - (sblock.fs_dsize - sfsp->f_bfree); + sfsp->f_blocks = sblock.fs_ffs1_dsize; + sfsp->f_bfree = sblock.fs_ffs1_cstotal.cs_nbfree * sblock.fs_frag + + sblock.fs_ffs1_cstotal.cs_nffree; + sfsp->f_bavail = ((int64_t)sblock.fs_ffs1_dsize * (100 - + sblock.fs_minfree) / 100) - (sblock.fs_ffs1_dsize - sfsp->f_bfree); sfsp->f_files = sblock.fs_ncg * sblock.fs_ipg - ROOTINO; - sfsp->f_ffree = sblock.fs_cstotal.cs_nifree; + sfsp->f_ffree = sblock.fs_ffs1_cstotal.cs_nifree; sfsp->f_fsid.val[0] = 0; sfsp->f_fsid.val[1] = 0; if ((mntpt = getmntpt(file)) == 0) diff --git a/sbin/badsect/badsect.c b/sbin/badsect/badsect.c index 258b2fe2d6c..13902b91fde 100644 --- a/sbin/badsect/badsect.c +++ b/sbin/badsect/badsect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: badsect.c,v 1.15 2005/07/21 16:38:54 fgsch Exp $ */ +/* $OpenBSD: badsect.c,v 1.16 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: badsect.c,v 1.10 1995/03/18 14:54:28 cgd Exp $ */ /* @@ -40,7 +40,7 @@ static const char copyright[] = #if 0 static char sccsid[] = "@(#)badsect.c 8.1 (Berkeley) 6/5/93"; #else -static const char rcsid[] = "$OpenBSD: badsect.c,v 1.15 2005/07/21 16:38:54 fgsch Exp $"; +static const char rcsid[] = "$OpenBSD: badsect.c,v 1.16 2007/03/19 13:27:47 pedro Exp $"; #endif #endif /* not lint */ @@ -160,7 +160,7 @@ chkuse(daddr_t blkno, int cnt) daddr_t fsbn, bn; fsbn = dbtofsb(fs, blkno); - if ((unsigned)(fsbn+cnt) > fs->fs_size) { + if ((unsigned)(fsbn+cnt) > fs->fs_ffs1_size) { fprintf(stderr, "block %d out of range of file system\n", blkno); return (1); } diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c index 4f816e38d66..f37bdfa6089 100644 --- a/sbin/dump/traverse.c +++ b/sbin/dump/traverse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traverse.c,v 1.19 2007/03/06 03:27:14 ray Exp $ */ +/* $OpenBSD: traverse.c,v 1.20 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: traverse.c,v 1.17 1997/06/05 11:13:27 lukem Exp $ */ /*- @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)traverse.c 8.2 (Berkeley) 9/23/93"; #else -static const char rcsid[] = "$OpenBSD: traverse.c,v 1.19 2007/03/06 03:27:14 ray Exp $"; +static const char rcsid[] = "$OpenBSD: traverse.c,v 1.20 2007/03/19 13:27:47 pedro Exp $"; #endif #endif /* not lint */ @@ -607,7 +607,7 @@ loop: msg("bread: lseek fails\n"); if ((cnt = read(diskfd, buf, size)) == size) return; - if (blkno + (size / dev_bsize) > fsbtodb(sblock, sblock->fs_size)) { + if (blkno + (size / dev_bsize) > fsbtodb(sblock, sblock->fs_ffs1_size)) { /* * Trying to read the final fragment. * diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c index b18005a4e3e..0a6738613a0 100644 --- a/sbin/dumpfs/dumpfs.c +++ b/sbin/dumpfs/dumpfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dumpfs.c,v 1.19 2006/03/09 13:35:02 pedro Exp $ */ +/* $OpenBSD: dumpfs.c,v 1.20 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: dumpfs.c,v 1.12 1997/04/26 05:41:33 lukem Exp $ */ /* @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)dumpfs.c 8.2 (Berkeley) 2/2/94"; #else -static char rcsid[] = "$OpenBSD: dumpfs.c,v 1.19 2006/03/09 13:35:02 pedro Exp $"; +static char rcsid[] = "$OpenBSD: dumpfs.c,v 1.20 2007/03/19 13:27:47 pedro Exp $"; #endif #endif /* not lint */ @@ -133,7 +133,7 @@ dumpfs(char *name) afs.fs_nrpos = 8; dev_bsize = afs.fs_fsize / fsbtodb(&afs, 1); printf("magic\t%x\ttime\t%s", afs.fs_magic, - ctime(&afs.fs_time)); + ctime(&afs.fs_ffs1_time)); i = 0; if (afs.fs_postblformat != FS_42POSTBLFMT) { i++; @@ -150,12 +150,12 @@ dumpfs(char *name) } printf("cylgrp\t%s\tinodes\t%s\tfslevel %d%s\n", i < 1 ? "static" : "dynamic", i < 2 ? "4.2/4.3BSD" : "4.4BSD", i, - (afs.fs_flags & FS_DOSOFTDEP) ? "\tsoft updates" : ""); + (afs.fs_ffs1_flags & FS_DOSOFTDEP) ? "\tsoft updates" : ""); printf("nbfree\t%d\tndir\t%d\tnifree\t%d\tnffree\t%d\n", - afs.fs_cstotal.cs_nbfree, afs.fs_cstotal.cs_ndir, - afs.fs_cstotal.cs_nifree, afs.fs_cstotal.cs_nffree); + afs.fs_ffs1_cstotal.cs_nbfree, afs.fs_ffs1_cstotal.cs_ndir, + afs.fs_ffs1_cstotal.cs_nifree, afs.fs_ffs1_cstotal.cs_nffree); printf("ncg\t%d\tncyl\t%d\tsize\t%d\tblocks\t%d\n", - afs.fs_ncg, afs.fs_ncyl, afs.fs_size, afs.fs_dsize); + afs.fs_ncg, afs.fs_ncyl, afs.fs_ffs1_size, afs.fs_ffs1_dsize); printf("bsize\t%d\tshift\t%d\tmask\t0x%08x\n", afs.fs_bsize, afs.fs_bshift, afs.fs_bmask); printf("fsize\t%d\tshift\t%d\tmask\t0x%08x\n", @@ -180,19 +180,19 @@ dumpfs(char *name) printf("sbsize\t%d\tcgsize\t%d\tcgoffset %d\tcgmask\t0x%08x\n", afs.fs_sbsize, afs.fs_cgsize, afs.fs_cgoffset, afs.fs_cgmask); printf("csaddr\t%d\tcssize\t%d\tshift\t%d\tmask\t0x%08x\n", - afs.fs_csaddr, afs.fs_cssize, afs.fs_csshift, afs.fs_csmask); + afs.fs_ffs1_csaddr, afs.fs_cssize, afs.fs_csshift, afs.fs_csmask); printf("cgrotor\t%d\tfmod\t%d\tronly\t%d\tclean\t0x%02x\n", afs.fs_cgrotor, afs.fs_fmod, afs.fs_ronly, afs.fs_clean); printf("flags\t"); - if (afs.fs_flags == 0) + if (afs.fs_ffs1_flags == 0) printf("none"); - if (afs.fs_flags & FS_UNCLEAN) + if (afs.fs_ffs1_flags & FS_UNCLEAN) printf("unclean "); - if (afs.fs_flags & FS_DOSOFTDEP) + if (afs.fs_ffs1_flags & FS_DOSOFTDEP) printf("soft-updates "); - if ((afs.fs_flags & ~(FS_UNCLEAN | FS_DOSOFTDEP)) != 0) + if ((afs.fs_ffs1_flags & ~(FS_UNCLEAN | FS_DOSOFTDEP)) != 0) printf("unknown flags (%#x)", - afs.fs_flags & ~(FS_UNCLEAN | FS_DOSOFTDEP)); + afs.fs_ffs1_flags & ~(FS_UNCLEAN | FS_DOSOFTDEP)); printf("\n"); if (afs.fs_cpc != 0) printf("blocks available in each of %d rotational positions", @@ -205,7 +205,7 @@ dumpfs(char *name) size = afs.fs_cssize - i < afs.fs_bsize ? afs.fs_cssize - i : afs.fs_bsize; if (lseek(fd, - (off_t)(fsbtodb(&afs, (afs.fs_csaddr + j * afs.fs_frag))) * + (off_t)(fsbtodb(&afs, (afs.fs_ffs1_csaddr + j * afs.fs_frag))) * dev_bsize, SEEK_SET) == (off_t)-1) goto err; if (read(fd, (char *)afs.fs_csp + i, size) != size) diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index bd79485a2ef..e6e1ae8a2af 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.29 2007/02/09 19:52:32 otto Exp $ */ +/* $OpenBSD: main.c,v 1.30 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: main.c,v 1.22 1996/10/11 20:15:48 thorpej Exp $ */ /* @@ -40,7 +40,7 @@ static const char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94"; #else -static const char rcsid[] = "$OpenBSD: main.c,v 1.29 2007/02/09 19:52:32 otto Exp $"; +static const char rcsid[] = "$OpenBSD: main.c,v 1.30 2007/03/19 13:27:47 pedro Exp $"; #endif #endif /* not lint */ @@ -265,15 +265,15 @@ checkfilesys(char *filesys, char *mntpt, long auxdata, int child) /* * print out summary statistics */ - n_ffree = sblock.fs_cstotal.cs_nffree; - n_bfree = sblock.fs_cstotal.cs_nbfree; + n_ffree = sblock.fs_ffs1_cstotal.cs_nffree; + n_bfree = sblock.fs_ffs1_cstotal.cs_nbfree; pwarn("%d files, %d used, %d free ", n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree); printf("(%d frags, %d blocks, %d.%d%% fragmentation)\n", - n_ffree, n_bfree, (n_ffree * 100) / sblock.fs_dsize, - ((n_ffree * 1000 + sblock.fs_dsize / 2) / sblock.fs_dsize) % 10); + n_ffree, n_bfree, (n_ffree * 100) / sblock.fs_ffs1_dsize, + ((n_ffree * 1000 + sblock.fs_ffs1_dsize / 2) / sblock.fs_ffs1_dsize) % 10); if (debug && - (n_files -= maxino - ROOTINO - sblock.fs_cstotal.cs_nifree)) + (n_files -= maxino - ROOTINO - sblock.fs_ffs1_cstotal.cs_nifree)) printf("%d files missing\n", n_files); if (debug) { n_blks += sblock.fs_ncg * @@ -300,7 +300,7 @@ checkfilesys(char *filesys, char *mntpt, long auxdata, int child) muldup = NULL; inocleanup(); if (fsmodified) { - (void)time(&sblock.fs_time); + (void)time(&sblock.fs_ffs1_time); sbdirty(); } if (cvtlevel && sblk.b_dirty) { diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index 639bf409f26..ef4ad926cf5 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.21 2007/02/12 16:35:55 otto Exp $ */ +/* $OpenBSD: pass1.c,v 1.22 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: pass1.c,v 1.16 1996/09/27 22:45:15 christos Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93"; #else -static const char rcsid[] = "$OpenBSD: pass1.c,v 1.21 2007/02/12 16:35:55 otto Exp $"; +static const char rcsid[] = "$OpenBSD: pass1.c,v 1.22 2007/03/19 13:27:47 pedro Exp $"; #endif #endif /* not lint */ @@ -84,7 +84,7 @@ pass1(void) for (; i < cgd; i++) setbmap(i); } - i = sblock.fs_csaddr; + i = sblock.fs_ffs1_csaddr; cgd = i + howmany(sblock.fs_cssize, sblock.fs_fsize); for (; i < cgd; i++) setbmap(i); diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c index 632763ea009..21a0c3f90e5 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass5.c,v 1.25 2007/03/15 10:27:00 pedro Exp $ */ +/* $OpenBSD: pass5.c,v 1.26 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: pass5.c,v 1.16 1996/09/27 22:45:18 christos Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)pass5.c 8.6 (Berkeley) 11/30/94"; #else -static const char rcsid[] = "$OpenBSD: pass5.c,v 1.25 2007/03/15 10:27:00 pedro Exp $"; +static const char rcsid[] = "$OpenBSD: pass5.c,v 1.26 2007/03/19 13:27:47 pedro Exp $"; #endif #endif /* not lint */ @@ -179,8 +179,8 @@ pass5(void) idesc[i].id_fix = FIX; } memset(&cstotal, 0, sizeof(struct csum)); - j = blknum(fs, fs->fs_size + fs->fs_frag - 1); - for (i = fs->fs_size; i < j; i++) + j = blknum(fs, fs->fs_ffs1_size + fs->fs_frag - 1); + for (i = fs->fs_ffs1_size; i < j; i++) setbmap(i); info_cg = 0; info_maxcg = fs->fs_ncg; @@ -192,8 +192,8 @@ pass5(void) pfatal("CG %d: BAD MAGIC NUMBER\n", c); dbase = cgbase(fs, c); dmax = dbase + fs->fs_fpg; - if (dmax > fs->fs_size) - dmax = fs->fs_size; + if (dmax > fs->fs_ffs1_size) + dmax = fs->fs_ffs1_size; newcg->cg_time = cg->cg_time; newcg->cg_ffs2_time = cg->cg_ffs2_time; newcg->cg_cgx = c; @@ -372,9 +372,9 @@ pass5(void) info_fn = NULL; if (fs->fs_postblformat == FS_42POSTBLFMT) fs->fs_nrpos = savednrpos; - if (memcmp(&cstotal, &fs->fs_cstotal, sizeof *cs) != 0 + if (memcmp(&cstotal, &fs->fs_ffs1_cstotal, sizeof *cs) != 0 && dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) { - memcpy(&fs->fs_cstotal, &cstotal, sizeof *cs); + memcpy(&fs->fs_ffs1_cstotal, &cstotal, sizeof *cs); fs->fs_ronly = 0; fs->fs_fmod = 0; sbdirty(); diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 0c4151d72f8..2bb74be8a8a 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.30 2007/03/18 21:44:01 otto Exp $ */ +/* $OpenBSD: setup.c,v 1.31 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)setup.c 8.5 (Berkeley) 11/23/94"; #else -static const char rcsid[] = "$OpenBSD: setup.c,v 1.30 2007/03/18 21:44:01 otto Exp $"; +static const char rcsid[] = "$OpenBSD: setup.c,v 1.31 2007/03/19 13:27:47 pedro Exp $"; #endif #endif /* not lint */ @@ -155,7 +155,7 @@ setup(char *dev) if (!preen) pwarn("** File system is already clean\n"); } - maxfsblock = sblock.fs_size; + maxfsblock = sblock.fs_ffs1_size; maxino = sblock.fs_ncg * sblock.fs_ipg; sizepb = sblock.fs_bsize; maxfilesize = sblock.fs_bsize * NDADDR - 1; @@ -327,7 +327,7 @@ setup(char *dev) sblock.fs_postblformat = FS_DYNAMICPOSTBLFMT; sblock.fs_nrpos = 8; sblock.fs_postbloff = - (char *)(&sblock.fs_opostbl_start) - + (char *)(&sblock.fs_maxbsize) - (char *)(&sblock.fs_firstfield); sblock.fs_rotbloff = &sblock.fs_space[0] - (u_char *)(&sblock.fs_firstfield); @@ -384,7 +384,7 @@ setup(char *dev) size = sblock.fs_cssize - i < sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize; if (bread(fsreadfd, (char *)sblock.fs_csp + i, - fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag), + fsbtodb(&sblock, sblock.fs_ffs1_csaddr + j * sblock.fs_frag), size) != 0 && !asked) { pfatal("BAD SUMMARY INFORMATION"); if (reply("CONTINUE") == 0) { @@ -422,7 +422,7 @@ setup(char *dev) (unsigned long)(maxino + 1) * sizeof(int16_t)); goto badsblabel; } - numdirs = sblock.fs_cstotal.cs_ndir; + numdirs = sblock.fs_ffs1_cstotal.cs_ndir; inplast = 0; listmax = numdirs + 10; inpsort = calloc((unsigned)listmax, sizeof(struct inoinfo *)); @@ -433,7 +433,7 @@ setup(char *dev) goto badsblabel; } bufinit(); - if (sblock.fs_flags & FS_DOSOFTDEP) + if (sblock.fs_ffs1_flags & FS_DOSOFTDEP) usedsoftdep = 1; else usedsoftdep = 0; @@ -581,7 +581,7 @@ calcsb(char *dev, int devfd, struct fs *fs) fs->fs_cpg = pp->p_cpg; fs->fs_nspf = fs->fs_fsize / lp->d_secsize; /* unit for fs->fs_size is fragments, for pp->p_size it is sectors */ - fs->fs_size = pp->p_size / fs->fs_nspf; + fs->fs_ffs1_size = pp->p_size / fs->fs_nspf; fs->fs_ntrak = lp->d_ntracks; fs->fs_nsect = lp->d_nsectors; fs->fs_spc = lp->d_secpercyl; diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c index 96fa0637a81..8841eac111a 100644 --- a/sbin/fsck_ffs/utilities.c +++ b/sbin/fsck_ffs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.31 2007/02/13 20:37:07 otto Exp $ */ +/* $OpenBSD: utilities.c,v 1.32 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: utilities.c,v 1.18 1996/09/27 22:45:20 christos Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93"; #else -static const char rcsid[] = "$OpenBSD: utilities.c,v 1.31 2007/02/13 20:37:07 otto Exp $"; +static const char rcsid[] = "$OpenBSD: utilities.c,v 1.32 2007/03/19 13:27:47 pedro Exp $"; #endif #endif /* not lint */ @@ -227,7 +227,7 @@ flush(int fd, struct bufarea *bp) return; for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) { bwrite(fswritefd, (char *)sblock.fs_csp + i, - fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag), + fsbtodb(&sblock, sblock.fs_ffs1_csaddr + j * sblock.fs_frag), sblock.fs_cssize - i < sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize); } @@ -261,7 +261,8 @@ ckfini(int markclean) sigprocmask(SIG_SETMASK, &oset, NULL); return; } - sblock.fs_flags &= ~FS_FLAGS_UPDATED; /* Force update on next mount */ + /* Force update on next mount */ + sblock.fs_ffs1_flags &= ~FS_FLAGS_UPDATED; flush(fswritefd, &sblk); if (havesb && sblk.b_bno != SBOFF / dev_bsize && !preen && reply("UPDATE STANDARD SUPERBLOCK")) { diff --git a/sbin/growfs/debug.c b/sbin/growfs/debug.c index 94495d49c48..db46e7a08b5 100644 --- a/sbin/growfs/debug.c +++ b/sbin/growfs/debug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: debug.c,v 1.4 2003/08/25 23:28:15 tedu Exp $ */ +/* $OpenBSD: debug.c,v 1.5 2007/03/19 13:27:47 pedro Exp $ */ /* * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. @@ -43,7 +43,7 @@ #ifndef lint static const char rcsid[] = - "$OpenBSD: debug.c,v 1.4 2003/08/25 23:28:15 tedu Exp $"; + "$OpenBSD: debug.c,v 1.5 2007/03/19 13:27:47 pedro Exp $"; #endif /* not lint */ /* ********************************************************** INCLUDES ***** */ @@ -161,11 +161,11 @@ dbg_dump_fs(struct fs *sb, const char *comment) fprintf(dbg_log, "cgmask int32_t 0x%08x\n", sb->fs_cgmask); fprintf(dbg_log, "time time_t %10u\n", - (unsigned int)sb->fs_time); + (unsigned int)sb->fs_ffs1_time); fprintf(dbg_log, "size int32_t 0x%08x\n", - sb->fs_size); + sb->fs_ffs1_size); fprintf(dbg_log, "dsize int32_t 0x%08x\n", - sb->fs_dsize); + sb->fs_ffs1_dsize); fprintf(dbg_log, "ncg int32_t 0x%08x\n", sb->fs_ncg); fprintf(dbg_log, "bsize int32_t 0x%08x\n", @@ -227,7 +227,7 @@ dbg_dump_fs(struct fs *sb, const char *comment) sb->fs_id[0], sb->fs_id[1]); fprintf(dbg_log, "csaddr ufs_daddr_t 0x%08x\n", - sb->fs_csaddr); + sb->fs_ffs1_csaddr); fprintf(dbg_log, "cssize int32_t 0x%08x\n", sb->fs_cssize); fprintf(dbg_log, "cgsize int32_t 0x%08x\n", @@ -250,7 +250,7 @@ dbg_dump_fs(struct fs *sb, const char *comment) fprintf(dbg_log, "fpg int32_t 0x%08x\n", sb->fs_fpg); - dbg_dump_csum("internal cstotal", &sb->fs_cstotal); + dbg_dump_csum("internal cstotal", &sb->fs_ffs1_cstotal); fprintf(dbg_log, "fmod int8_t 0x%02x\n", sb->fs_fmod); @@ -259,7 +259,7 @@ dbg_dump_fs(struct fs *sb, const char *comment) fprintf(dbg_log, "ronly int8_t 0x%02x\n", sb->fs_ronly); fprintf(dbg_log, "flags int8_t 0x%02x\n", - sb->fs_flags); + sb->fs_ffs1_flags); fprintf(dbg_log, "fsmnt u_char[MAXMNTLEN] \"%s\"\n", sb->fs_fsmnt); diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c index 3a73344d91f..c82ffb1e70a 100644 --- a/sbin/growfs/growfs.c +++ b/sbin/growfs/growfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: growfs.c,v 1.16 2006/04/02 00:48:35 deraadt Exp $ */ +/* $OpenBSD: growfs.c,v 1.17 2007/03/19 13:27:47 pedro Exp $ */ /* * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. @@ -46,7 +46,7 @@ static const char copyright[] = Copyright (c) 1980, 1989, 1993 The Regents of the University of California.\n\ All rights reserved.\n"; -static const char rcsid[] = "$OpenBSD: growfs.c,v 1.16 2006/04/02 00:48:35 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: growfs.c,v 1.17 2007/03/19 13:27:47 pedro Exp $"; #endif /* not lint */ /* ********************************************************** INCLUDES ***** */ @@ -180,7 +180,7 @@ growfs(char *fsys, int fsi, int fso, unsigned int Nflag) if (fscs == NULL) errx(1, "calloc failed"); for (i = 0; i < osblock.fs_cssize; i += osblock.fs_bsize) { - rdfs(fsbtodb(&osblock, osblock.fs_csaddr + + rdfs(fsbtodb(&osblock, osblock.fs_ffs1_csaddr + numfrags(&osblock, i)), (size_t)MIN(osblock.fs_cssize - i, osblock.fs_bsize), (((char *)fscs) + i), fsi); } @@ -212,11 +212,11 @@ growfs(char *fsys, int fsi, int fso, unsigned int Nflag) * Dump out summary information about filesystem. */ printf("%s:\t%d sectors in %d %s of %d tracks, %d sectors\n", - fsys, sblock.fs_size * NSPF(&sblock), sblock.fs_ncyl, + fsys, sblock.fs_ffs1_size * NSPF(&sblock), sblock.fs_ncyl, "cylinders", sblock.fs_ntrak, sblock.fs_nsect); #define B2MBFACTOR (1 / (1024.0 * 1024.0)) printf("\t%.1fMB in %d cyl groups (%d c/g, %.2fMB/g, %d i/g)\n", - (float)sblock.fs_size * sblock.fs_fsize * B2MBFACTOR, + (float)sblock.fs_ffs1_size * sblock.fs_fsize * B2MBFACTOR, sblock.fs_ncg, sblock.fs_cpg, (float)sblock.fs_fpg * sblock.fs_fsize * B2MBFACTOR, sblock.fs_ipg); @@ -264,7 +264,7 @@ growfs(char *fsys, int fsi, int fso, unsigned int Nflag) * Now write the cylinder summary back to disk. */ for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize) { - wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)), + wtfs(fsbtodb(&sblock, sblock.fs_ffs1_csaddr + numfrags(&sblock, i)), (size_t)MIN(sblock.fs_cssize - i, sblock.fs_bsize), (((char *)fscs) + i), fso, Nflag); } @@ -285,12 +285,13 @@ growfs(char *fsys, int fsi, int fso, unsigned int Nflag) } #endif /* FS_DEBUG */ - sblock.fs_flags &= ~FS_FLAGS_UPDATED; /* Force update on next mount */ + /* Force update on next mount */ + sblock.fs_ffs1_flags &= ~FS_FLAGS_UPDATED; /* * Now write the new superblock back to disk. */ - sblock.fs_time = utime; + sblock.fs_ffs1_time = utime; wtfs((daddr_t)(SBOFF / DEV_BSIZE), (size_t)SBSIZE, &sblock, fso, Nflag); DBG_PRINT0("sblock written\n"); @@ -305,7 +306,7 @@ growfs(char *fsys, int fsi, int fso, unsigned int Nflag) sblock.fs_cgrotor = 0; sblock.fs_state = 0; memset(&sblock.fs_fsmnt, 0, sizeof(sblock.fs_fsmnt)); - sblock.fs_flags &= FS_DOSOFTDEP; + sblock.fs_ffs1_flags &= FS_DOSOFTDEP; /* * XXX @@ -317,7 +318,7 @@ growfs(char *fsys, int fsi, int fso, unsigned int Nflag) * fs_maxbpg * fs_minfree, * fs_optim - * fs_flags regarding SOFTUPDATES + * fs_ffs1_flags regarding SOFTUPDATES * * We probably should rather change the summary for the cylinder group * statistics here to the value of what would be in there, if the file @@ -364,8 +365,8 @@ initcg(int cylno, time_t utime, int fso, unsigned int Nflag) */ cbase = cgbase(&sblock, cylno); dmax = cbase + sblock.fs_fpg; - if (dmax > sblock.fs_size) - dmax = sblock.fs_size; + if (dmax > sblock.fs_ffs1_size) + dmax = sblock.fs_ffs1_size; dlower = cgsblock(&sblock, cylno) - cbase; dupper = cgdmin(&sblock, cylno) - cbase; if (cylno == 0) /* XXX fscs may be relocated */ @@ -432,8 +433,8 @@ initcg(int cylno, time_t utime, int fso, unsigned int Nflag) cg_blks(&sblock, &acg, cbtocylno(&sblock, d)) [cbtorpos(&sblock, d)]++; } - sblock.fs_dsize += dlower; - sblock.fs_dsize += acg.cg_ndblk - dupper; + sblock.fs_ffs1_dsize += dlower; + sblock.fs_ffs1_dsize += acg.cg_ndblk - dupper; if ((i = dupper % sblock.fs_frag)) { acg.cg_frsum[sblock.fs_frag - i]++; for (d = dupper + sblock.fs_frag - i; dupper < d; dupper++) { @@ -490,10 +491,10 @@ initcg(int cylno, time_t utime, int fso, unsigned int Nflag) sump[run]++; } } - sblock.fs_cstotal.cs_ndir += acg.cg_cs.cs_ndir; - sblock.fs_cstotal.cs_nffree += acg.cg_cs.cs_nffree; - sblock.fs_cstotal.cs_nbfree += acg.cg_cs.cs_nbfree; - sblock.fs_cstotal.cs_nifree += acg.cg_cs.cs_nifree; + sblock.fs_ffs1_cstotal.cs_ndir += acg.cg_cs.cs_ndir; + sblock.fs_ffs1_cstotal.cs_nffree += acg.cg_cs.cs_nffree; + sblock.fs_ffs1_cstotal.cs_nbfree += acg.cg_cs.cs_nbfree; + sblock.fs_ffs1_cstotal.cs_nifree += acg.cg_cs.cs_nifree; *cs = acg.cg_cs; wtfs(fsbtodb(&sblock, cgtod(&sblock, cylno)), (size_t)sblock.fs_bsize, &acg, fso, Nflag); @@ -670,7 +671,7 @@ updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag) * cylinder group we have to change that value now to fs_cpg. */ - if (cgbase(&osblock, cylno + 1) == osblock.fs_size) { + if (cgbase(&osblock, cylno + 1) == osblock.fs_ffs1_size) { acg.cg_ncyl = sblock.fs_cpg; wtfs(fsbtodb(&sblock, cgtod(&sblock, cylno)), @@ -686,8 +687,8 @@ updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag) */ cbase = cgbase(&sblock, cylno); dmax = cbase + sblock.fs_fpg; - if (dmax > sblock.fs_size) - dmax = sblock.fs_size; + if (dmax > sblock.fs_ffs1_size) + dmax = sblock.fs_ffs1_size; dupper = cgdmin(&sblock, cylno) - cbase; if (cylno == 0) /* XXX fscs may be relocated */ dupper += howmany(sblock.fs_cssize, sblock.fs_fsize); @@ -713,7 +714,7 @@ updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag) DBG_PRINT4("jcg dbg: %d %u %d %u\n", cylno, sblock.fs_ncg, acg.cg_ncyl, sblock.fs_cpg); acg.cg_ndblk = dmax - cbase; - sblock.fs_dsize += acg.cg_ndblk - aocg.cg_ndblk; + sblock.fs_ffs1_dsize += acg.cg_ndblk - aocg.cg_ndblk; if (sblock.fs_contigsumsize > 0) acg.cg_nclusterblks = acg.cg_ndblk / sblock.fs_frag; @@ -729,15 +730,15 @@ updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag) * Handle the first new block here if it was partially available * before. */ - if (osblock.fs_size % sblock.fs_frag) { - if (roundup(osblock.fs_size, sblock.fs_frag)<=sblock.fs_size) { + if (osblock.fs_ffs1_size % sblock.fs_frag) { + if (roundup(osblock.fs_ffs1_size, sblock.fs_frag)<=sblock.fs_ffs1_size) { /* * The new space is enough to fill at least this * block */ j = 0; - for (i = roundup(osblock.fs_size - cbase, sblock.fs_frag)-1; - i >= osblock.fs_size - cbase; i--) { + for (i = roundup(osblock.fs_ffs1_size - cbase, sblock.fs_frag)-1; + i >= osblock.fs_ffs1_size - cbase; i--) { setbit(cg_blksfree(&acg), i); acg.cg_cs.cs_nffree++; j++; @@ -749,21 +750,21 @@ updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag) * filesystem. */ if (isblock(&sblock, cg_blksfree(&acg), - ((osblock.fs_size - cgbase(&sblock, cylno))/ + ((osblock.fs_ffs1_size - cgbase(&sblock, cylno))/ sblock.fs_frag))) { /* * The block is now completely available */ DBG_PRINT0("block was\n"); - acg.cg_frsum[osblock.fs_size % sblock.fs_frag]--; + acg.cg_frsum[osblock.fs_ffs1_size % sblock.fs_frag]--; acg.cg_cs.cs_nbfree++; acg.cg_cs.cs_nffree-=sblock.fs_frag; - k = rounddown(osblock.fs_size - cbase, + k = rounddown(osblock.fs_ffs1_size - cbase, sblock.fs_frag); cg_blktot(&acg)[cbtocylno(&sblock, k)]++; cg_blks(&sblock, &acg, cbtocylno(&sblock, k)) [cbtorpos(&sblock, k)]++; - updclst((osblock.fs_size - cbase)/sblock.fs_frag); + updclst((osblock.fs_ffs1_size - cbase)/sblock.fs_frag); } else { /* * Lets rejoin a possible partially growed @@ -771,7 +772,7 @@ updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag) */ k = 0; while (isset(cg_blksfree(&acg), i) && - (i >= rounddown(osblock.fs_size - cbase, + (i >= rounddown(osblock.fs_ffs1_size - cbase, sblock.fs_frag))) { i--; k++; @@ -785,8 +786,8 @@ updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag) * We only grow by some fragments within this last * block. */ - for (i = sblock.fs_size - cbase - 1; - i >= osblock.fs_size - cbase; i--) { + for (i = sblock.fs_ffs1_size - cbase - 1; + i >= osblock.fs_ffs1_size - cbase; i--) { setbit(cg_blksfree(&acg), i); acg.cg_cs.cs_nffree++; j++; @@ -796,7 +797,7 @@ updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag) */ k = 0; while (isset(cg_blksfree(&acg), i) && - (i >= rounddown(osblock.fs_size - cbase, + (i >= rounddown(osblock.fs_ffs1_size - cbase, sblock.fs_frag))) { i--; k++; @@ -810,7 +811,7 @@ updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag) /* * Handle all new complete blocks here. */ - for (i = roundup(osblock.fs_size - cbase, sblock.fs_frag); + for (i = roundup(osblock.fs_ffs1_size - cbase, sblock.fs_frag); i + sblock.fs_frag<=dmax-cbase; /* XXX <= or only < ? */ i += sblock.fs_frag) { j = i / sblock.fs_frag; @@ -835,14 +836,14 @@ updjcg(int cylno, time_t utime, int fsi, int fso, unsigned int Nflag) } } - sblock.fs_cstotal.cs_nffree += + sblock.fs_ffs1_cstotal.cs_nffree += (acg.cg_cs.cs_nffree - aocg.cg_cs.cs_nffree); - sblock.fs_cstotal.cs_nbfree += + sblock.fs_ffs1_cstotal.cs_nbfree += (acg.cg_cs.cs_nbfree - aocg.cg_cs.cs_nbfree); /* * The following statistics are not changed here: - * sblock.fs_cstotal.cs_ndir - * sblock.fs_cstotal.cs_nifree + * sblock.fs_ffs1_cstotal.cs_ndir + * sblock.fs_ffs1_cstotal.cs_nifree * As the statistics for this cylinder group are ready, copy it to * the summary information array. */ @@ -903,7 +904,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) DBG_LEAVE; return; } - ocscg = dtog(&osblock, osblock.fs_csaddr); + ocscg = dtog(&osblock, osblock.fs_ffs1_csaddr); cs = fscs + ocscg; blocks = 1+howmany(sblock.fs_cssize, sblock.fs_bsize)- howmany(osblock.fs_cssize, osblock.fs_bsize); @@ -935,7 +936,8 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) * also up to 8*3 blocks for indirect blocks for all possible * references. */ - if (/* ((int)sblock.fs_time & 0x3) > 0 || */ cs->cs_nbfree < blocks) { + if (/* ((int)sblock.fs_ffs1_time & 0x3) > 0 || */ + cs->cs_nbfree < blocks) { /* * There is not enough space in the old cylinder group to * relocate all blocks as needed, so we relocate the whole @@ -963,7 +965,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) * Point "d" to the first fragment not used by the cylinder * summary. */ - d = osblock.fs_csaddr+(osblock.fs_cssize/osblock.fs_fsize); + d = osblock.fs_ffs1_csaddr+(osblock.fs_cssize/osblock.fs_fsize); /* * Set up last cluster size ("lcs") already here. Calculate @@ -997,7 +999,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) d); setbit(cg_blksfree(&acg), d % sblock.fs_fpg); acg.cg_cs.cs_nffree++; - sblock.fs_cstotal.cs_nffree++; + sblock.fs_ffs1_cstotal.cs_nffree++; } /* * Point "d" to the last fragment of the last @@ -1012,8 +1014,8 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) d); acg.cg_cs.cs_nffree-=sblock.fs_frag; acg.cg_cs.cs_nbfree++; - sblock.fs_cstotal.cs_nffree-=sblock.fs_frag; - sblock.fs_cstotal.cs_nbfree++; + sblock.fs_ffs1_cstotal.cs_nffree-=sblock.fs_frag; + sblock.fs_ffs1_cstotal.cs_nbfree++; cg_blktot(&acg)[cbtocylno(&sblock, d % sblock.fs_fpg)]++; cg_blks(&sblock, &acg, cbtocylno(&sblock, @@ -1039,7 +1041,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) DBG_PRINT1("d=%d\n", d); - for (d = rounddown(d, sblock.fs_frag); d >= osblock.fs_csaddr; + for (d = rounddown(d, sblock.fs_frag); d >= osblock.fs_ffs1_csaddr; d -= sblock.fs_frag) { DBG_TRC; DBG_PRINT1("d=%d\n", @@ -1047,7 +1049,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) setblock(&sblock, cg_blksfree(&acg), (d % sblock.fs_fpg)/sblock.fs_frag); acg.cg_cs.cs_nbfree++; - sblock.fs_cstotal.cs_nbfree++; + sblock.fs_ffs1_cstotal.cs_nbfree++; cg_blktot(&acg)[cbtocylno(&sblock, d % sblock.fs_fpg)]++; cg_blks(&sblock, &acg, cbtocylno(&sblock, d % sblock.fs_fpg))[cbtorpos(&sblock, @@ -1081,8 +1083,8 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) * Find the beginning of the new cylinder group containing the * cylinder summary. */ - sblock.fs_csaddr = cgdmin(&sblock, osblock.fs_ncg); - ncscg = dtog(&sblock, sblock.fs_csaddr); + sblock.fs_ffs1_csaddr = cgdmin(&sblock, osblock.fs_ncg); + ncscg = dtog(&sblock, sblock.fs_ffs1_csaddr); cs = fscs + ncscg; @@ -1114,13 +1116,13 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) * Allocate all complete blocks used by the new cylinder * summary. */ - for (d = sblock.fs_csaddr; d + sblock.fs_frag <= - sblock.fs_csaddr+(sblock.fs_cssize/sblock.fs_fsize); + for (d = sblock.fs_ffs1_csaddr; d + sblock.fs_frag <= + sblock.fs_ffs1_csaddr+(sblock.fs_cssize/sblock.fs_fsize); d+=sblock.fs_frag) { clrblock(&sblock, cg_blksfree(&acg), (d%sblock.fs_fpg)/sblock.fs_frag); acg.cg_cs.cs_nbfree--; - sblock.fs_cstotal.cs_nbfree--; + sblock.fs_ffs1_cstotal.cs_nbfree--; cg_blktot(&acg)[cbtocylno(&sblock, d%sblock.fs_fpg)]--; cg_blks(&sblock, &acg, cbtocylno(&sblock, d%sblock.fs_fpg))[cbtorpos(&sblock, @@ -1135,18 +1137,18 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) * Allocate all fragments used by the cylinder summary in the * last block. */ - if (d < sblock.fs_csaddr+(sblock.fs_cssize/sblock.fs_fsize)) { - for (; d - sblock.fs_csaddr< + if (d < sblock.fs_ffs1_csaddr+(sblock.fs_cssize/sblock.fs_fsize)) { + for (; d - sblock.fs_ffs1_csaddr< sblock.fs_cssize/sblock.fs_fsize; d++) { clrbit(cg_blksfree(&acg), d%sblock.fs_fpg); acg.cg_cs.cs_nffree--; - sblock.fs_cstotal.cs_nffree--; + sblock.fs_ffs1_cstotal.cs_nffree--; } acg.cg_cs.cs_nbfree--; acg.cg_cs.cs_nffree+=sblock.fs_frag; - sblock.fs_cstotal.cs_nbfree--; - sblock.fs_cstotal.cs_nffree+=sblock.fs_frag; + sblock.fs_ffs1_cstotal.cs_nbfree--; + sblock.fs_ffs1_cstotal.cs_nffree+=sblock.fs_frag; cg_blktot(&acg)[cbtocylno(&sblock, d%sblock.fs_fpg)]--; cg_blks(&sblock, &acg, cbtocylno(&sblock, d%sblock.fs_fpg))[cbtorpos(&sblock, @@ -1195,12 +1197,12 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) DBG_TRC; cbase = cgbase(&osblock, ocscg); /* old and new are equal */ - dupper = sblock.fs_csaddr - cbase + + dupper = sblock.fs_ffs1_csaddr - cbase + howmany(sblock.fs_cssize, sblock.fs_fsize); - odupper = osblock.fs_csaddr - cbase + + odupper = osblock.fs_ffs1_csaddr - cbase + howmany(osblock.fs_cssize, osblock.fs_fsize); - sblock.fs_dsize -= dupper - odupper; + sblock.fs_ffs1_dsize -= dupper - odupper; /* * Allocate the space for the array of blocks to be relocated. @@ -1235,7 +1237,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) } else { clrbit(cg_blksfree(&acg), d); acg.cg_cs.cs_nffree--; - sblock.fs_cstotal.cs_nffree--; + sblock.fs_ffs1_cstotal.cs_nffree--; } /* * No cluster handling is needed here, as there was at least @@ -1257,7 +1259,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) for (f = d; f < d + sblock.fs_frag; f++) { if (isset(cg_blksfree(&aocg), f)) { acg.cg_cs.cs_nffree--; - sblock.fs_cstotal.cs_nffree--; + sblock.fs_ffs1_cstotal.cs_nffree--; } } clrblock(&sblock, cg_blksfree(&acg), d/sblock.fs_frag); @@ -1266,7 +1268,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) } else { clrblock(&sblock, cg_blksfree(&acg), d/sblock.fs_frag); acg.cg_cs.cs_nbfree--; - sblock.fs_cstotal.cs_nbfree--; + sblock.fs_ffs1_cstotal.cs_nbfree--; cg_blktot(&acg)[cbtocylno(&sblock, d)]--; cg_blks(&sblock, &acg, cbtocylno(&sblock, d)) [cbtorpos(&sblock, d)]--; @@ -1299,9 +1301,9 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) if (isblock(&sblock, cg_blksfree(&acg), d/sblock.fs_frag)) { acg.cg_cs.cs_nbfree--; - sblock.fs_cstotal.cs_nbfree--; + sblock.fs_ffs1_cstotal.cs_nbfree--; acg.cg_cs.cs_nffree+=sblock.fs_frag; - sblock.fs_cstotal.cs_nffree+=sblock.fs_frag; + sblock.fs_ffs1_cstotal.cs_nffree+=sblock.fs_frag; cg_blktot(&acg)[cbtocylno(&sblock, d)]--; cg_blks(&sblock, &acg, cbtocylno(&sblock, d)) [cbtorpos(&sblock, d)]--; @@ -1329,7 +1331,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) } else { clrbit(cg_blksfree(&acg), d); acg.cg_cs.cs_nffree--; - sblock.fs_cstotal.cs_nffree--; + sblock.fs_ffs1_cstotal.cs_nffree--; } } if (bp[ind].flags & GFS_FL_LAST) /* we have to advance here */ @@ -1367,7 +1369,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) if (isset(cg_blksfree(&aocg), f)) { setbit(cg_blksfree(&acg), g); acg.cg_cs.cs_nffree++; - sblock.fs_cstotal.cs_nffree++; + sblock.fs_ffs1_cstotal.cs_nffree++; } } @@ -1385,7 +1387,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) f < odupper; f++, g++) { setbit(cg_blksfree(&acg), g); acg.cg_cs.cs_nffree++; - sblock.fs_cstotal.cs_nffree++; + sblock.fs_ffs1_cstotal.cs_nffree++; } if (!(bp[i].flags & GFS_FL_LAST)) frag_adjust(bp[i].new * sblock.fs_frag,1); @@ -1404,7 +1406,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) if (isclr(cg_blksfree(&acg), f)) { setbit(cg_blksfree(&acg), f); acg.cg_cs.cs_nffree++; - sblock.fs_cstotal.cs_nffree++; + sblock.fs_ffs1_cstotal.cs_nffree++; } } frag_adjust(bp[i].old * sblock.fs_frag, 1); @@ -1461,11 +1463,11 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) } /* * The following statistics are not changed here: - * sblock.fs_cstotal.cs_ndir - * sblock.fs_cstotal.cs_nifree + * sblock.fs_ffs1_cstotal.cs_ndir + * sblock.fs_ffs1_cstotal.cs_nifree * The following statistics were already updated on the fly: - * sblock.fs_cstotal.cs_nffree - * sblock.fs_cstotal.cs_nbfree + * sblock.fs_ffs1_cstotal.cs_nffree + * sblock.fs_ffs1_cstotal.cs_nbfree * As the statistics for this cylinder group are ready, copy it to * the summary information array. */ @@ -1571,11 +1573,11 @@ alloc(void) dlower = cgsblock(&sblock, acg.cg_cgx) - cgbase(&sblock, acg.cg_cgx); dupper = cgdmin(&sblock, acg.cg_cgx) - cgbase(&sblock, acg.cg_cgx); dmax = cgbase(&sblock, acg.cg_cgx) + sblock.fs_fpg; - if (dmax > sblock.fs_size) { - dmax = sblock.fs_size; + if (dmax > sblock.fs_ffs1_size) { + dmax = sblock.fs_ffs1_size; } dmax -= cgbase(&sblock, acg.cg_cgx); /* retransform into cg */ - csmin = sblock.fs_csaddr - cgbase(&sblock, acg.cg_cgx); + csmin = sblock.fs_ffs1_csaddr - cgbase(&sblock, acg.cg_cgx); csmax = csmin + howmany(sblock.fs_cssize, sblock.fs_fsize); DBG_PRINT3("seek range: dl=%d, du=%d, dm=%d\n", dlower, dupper, dmax); @@ -1653,7 +1655,7 @@ alloc(void) * Update all statistics based on blocks. */ acg.cg_cs.cs_nbfree--; - sblock.fs_cstotal.cs_nbfree--; + sblock.fs_ffs1_cstotal.cs_nbfree--; cg_blktot(&acg)[cbtocylno(&sblock, d)]--; cg_blks(&sblock, &acg, cbtocylno(&sblock, d))[cbtorpos(&sblock, d)]--; @@ -1967,21 +1969,21 @@ main(int argc, char **argv) * Determine size to grow to. Default to the full size specified in * the disk label. */ - sblock.fs_size = dbtofsb(&osblock, pp->p_size); + sblock.fs_ffs1_size = dbtofsb(&osblock, pp->p_size); if (size != 0) { if (size > pp->p_size) { errx(1, "There is not enough space (%d < %d)", pp->p_size, size); } - sblock.fs_size = dbtofsb(&osblock, size); + sblock.fs_ffs1_size = dbtofsb(&osblock, size); } /* * Are we really growing ? */ - if (osblock.fs_size >= sblock.fs_size) { - errx(1, "we are not growing (%d->%d)", osblock.fs_size, - sblock.fs_size); + if (osblock.fs_ffs1_size >= sblock.fs_ffs1_size) { + errx(1, "we are not growing (%d->%d)", osblock.fs_ffs1_size, + sblock.fs_ffs1_size); } @@ -2014,7 +2016,7 @@ main(int argc, char **argv) } if (!quiet) - printf("new file system size is: %d frags\n", sblock.fs_size); + printf("new file system size is: %d frags\n", sblock.fs_ffs1_size); /* * Try to access our new last block in the filesystem. Even if we @@ -2027,18 +2029,18 @@ main(int argc, char **argv) /* * Now calculate new superblock values and check for reasonable * bound for new filesystem size: - * fs_size: is derived from label or user input - * fs_dsize: should get updated in the routines creating or + * fs_ffs1_size: is derived from label or user input + * fs_ffs1_dsize: should get updated in the routines creating or * updating the cylinder groups on the fly - * fs_cstotal: should get updated in the routines creating or + * fs_ffs1_cstotal: should get updated in the routines creating or * updating the cylinder groups */ /* * Update the number of cylinders in the filesystem. */ - sblock.fs_ncyl = sblock.fs_size * NSPF(&sblock) / sblock.fs_spc; - if (sblock.fs_size * NSPF(&sblock) > sblock.fs_ncyl * sblock.fs_spc) + sblock.fs_ncyl = sblock.fs_ffs1_size * NSPF(&sblock) / sblock.fs_spc; + if (sblock.fs_ffs1_size * NSPF(&sblock) > sblock.fs_ncyl * sblock.fs_spc) sblock.fs_ncyl++; /* @@ -2048,9 +2050,9 @@ main(int argc, char **argv) if (sblock.fs_ncyl % sblock.fs_cpg) sblock.fs_ncg++; - if ((sblock.fs_size - (sblock.fs_ncg - 1) * sblock.fs_fpg) < + if ((sblock.fs_ffs1_size - (sblock.fs_ncg - 1) * sblock.fs_fpg) < sblock.fs_fpg && cgdmin(&sblock, (sblock.fs_ncg - 1))- - cgbase(&sblock, (sblock.fs_ncg - 1)) > (sblock.fs_size - + cgbase(&sblock, (sblock.fs_ncg - 1)) > (sblock.fs_ffs1_size - (sblock.fs_ncg - 1) * sblock.fs_fpg)) { /* * The space in the new last cylinder group is too small, @@ -2065,9 +2067,9 @@ main(int argc, char **argv) sblock.fs_ncyl -= sblock.fs_ncyl % sblock.fs_cpg; if (!quiet) printf("Warning: %d sector(s) cannot be allocated.\n", - (sblock.fs_size-(sblock.fs_ncg)*sblock.fs_fpg) * + (sblock.fs_ffs1_size-(sblock.fs_ncg)*sblock.fs_fpg) * NSPF(&sblock)); - sblock.fs_size = sblock.fs_ncyl * sblock.fs_spc / NSPF(&sblock); + sblock.fs_ffs1_size = sblock.fs_ncyl * sblock.fs_spc / NSPF(&sblock); } /* @@ -2077,7 +2079,7 @@ main(int argc, char **argv) sblock.fs_cssize = fragroundup(&sblock, sblock.fs_ncg * sizeof(struct csum)); - if (osblock.fs_size >= sblock.fs_size) { + if (osblock.fs_ffs1_size >= sblock.fs_ffs1_size) { errx(1, "not enough new space"); } diff --git a/sbin/ncheck_ffs/ncheck_ffs.c b/sbin/ncheck_ffs/ncheck_ffs.c index 88cc670ef07..6182561ec4f 100644 --- a/sbin/ncheck_ffs/ncheck_ffs.c +++ b/sbin/ncheck_ffs/ncheck_ffs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncheck_ffs.c,v 1.26 2006/04/02 00:48:35 deraadt Exp $ */ +/* $OpenBSD: ncheck_ffs.c,v 1.27 2007/03/19 13:27:47 pedro Exp $ */ /*- * Copyright (c) 1995, 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com> @@ -26,7 +26,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: ncheck_ffs.c,v 1.26 2006/04/02 00:48:35 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: ncheck_ffs.c,v 1.27 2007/03/19 13:27:47 pedro Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -221,7 +221,7 @@ loop: warnx("bread: lseek fails"); if ((cnt = read(diskfd, buf, size)) == size) return; - if (blkno + (size / dev_bsize) > fsbtodb(sblock, sblock->fs_size)) { + if (blkno + (size / dev_bsize) > fsbtodb(sblock, sblock->fs_ffs1_size)) { /* * Trying to read the final fragment. * diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 27656019802..045e00ae28a 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.50 2006/03/09 13:35:02 pedro Exp $ */ +/* $OpenBSD: mkfs.c,v 1.51 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)mkfs.c 8.3 (Berkeley) 2/3/94"; #else -static char rcsid[] = "$OpenBSD: mkfs.c,v 1.50 2006/03/09 13:35:02 pedro Exp $"; +static char rcsid[] = "$OpenBSD: mkfs.c,v 1.51 2007/03/19 13:27:47 pedro Exp $"; #endif #endif /* not lint */ @@ -483,9 +483,9 @@ recalc: * Now have size for file system and nsect and ntrak. * Determine number of cylinders and blocks in the file system. */ - sblock.fs_size = dbtofsb(&sblock, fssize); - sblock.fs_ncyl = sblock.fs_size * NSPF(&sblock) / sblock.fs_spc; - if (sblock.fs_size * NSPF(&sblock) > sblock.fs_ncyl * sblock.fs_spc) { + sblock.fs_ffs1_size = dbtofsb(&sblock, fssize); + sblock.fs_ncyl = sblock.fs_ffs1_size * NSPF(&sblock) / sblock.fs_spc; + if (sblock.fs_ffs1_size * NSPF(&sblock) > sblock.fs_ncyl * sblock.fs_spc) { sblock.fs_ncyl++; warn = 1; } @@ -553,7 +553,7 @@ next: exit(29); } j = sblock.fs_ncg - 1; - if ((i = sblock.fs_size - j * sblock.fs_fpg) < sblock.fs_fpg && + if ((i = sblock.fs_ffs1_size - j * sblock.fs_fpg) < sblock.fs_fpg && cgdmin(&sblock, j) - cgbase(&sblock, j) > i) { if (j == 0) { errx(30, "filesystem must have at least %d sectors", @@ -567,8 +567,8 @@ next: i * NSPF(&sblock)); sblock.fs_ncg--; sblock.fs_ncyl -= sblock.fs_ncyl % sblock.fs_cpg; - sblock.fs_size = sblock.fs_ncyl * sblock.fs_spc / NSPF(&sblock); - fssize = fsbtodb(&sblock, sblock.fs_size); + sblock.fs_ffs1_size = sblock.fs_ncyl * sblock.fs_spc / NSPF(&sblock); + fssize = fsbtodb(&sblock, sblock.fs_ffs1_size); warn = 0; } if (!quiet && warn && !mfs) { @@ -580,7 +580,7 @@ next: /* * fill in remaining fields of the super block */ - sblock.fs_csaddr = cgdmin(&sblock, 0); + sblock.fs_ffs1_csaddr = cgdmin(&sblock, 0); sblock.fs_cssize = fragroundup(&sblock, sblock.fs_ncg * sizeof(struct csum)); @@ -603,10 +603,10 @@ next: sblock.fs_rps = rpm / 60; sblock.fs_optim = opt; sblock.fs_cgrotor = 0; - sblock.fs_cstotal.cs_ndir = 0; - sblock.fs_cstotal.cs_nbfree = 0; - sblock.fs_cstotal.cs_nifree = 0; - sblock.fs_cstotal.cs_nffree = 0; + sblock.fs_ffs1_cstotal.cs_ndir = 0; + sblock.fs_ffs1_cstotal.cs_nbfree = 0; + sblock.fs_ffs1_cstotal.cs_nifree = 0; + sblock.fs_ffs1_cstotal.cs_nffree = 0; sblock.fs_fmod = 0; sblock.fs_ronly = 0; sblock.fs_clean = FS_ISCLEAN; @@ -618,11 +618,11 @@ next: */ if (!mfs) { printf("%s:\t%d sectors in %d %s of %d tracks, %d sectors\n", - fsys, sblock.fs_size * NSPF(&sblock), sblock.fs_ncyl, + fsys, sblock.fs_ffs1_size * NSPF(&sblock), sblock.fs_ncyl, "cylinders", sblock.fs_ntrak, sblock.fs_nsect); #define B2MBFACTOR (1 / (1024.0 * 1024.0)) printf("\t%.1fMB in %d cyl groups (%d c/g, %.2fMB/g, %d i/g)\n", - (float)sblock.fs_size * sblock.fs_fsize * B2MBFACTOR, + (float)sblock.fs_ffs1_size * sblock.fs_fsize * B2MBFACTOR, sblock.fs_ncg, sblock.fs_cpg, (float)sblock.fs_fpg * sblock.fs_fsize * B2MBFACTOR, sblock.fs_ipg); @@ -669,13 +669,13 @@ next: */ if (fsinit(utime, mfsmode, mfsuid, mfsgid) != 0) errx(32, "fsinit failed"); - sblock.fs_time = utime; + sblock.fs_ffs1_time = utime; /* don't write magic until we are done */ sblock.fs_magic = 0; wtfs((int)SBOFF / sectorsize, sbsize, (char *)&sblock); sblock.fs_magic = FS_MAGIC; for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize) - wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)), + wtfs(fsbtodb(&sblock, sblock.fs_ffs1_csaddr + numfrags(&sblock, i)), sblock.fs_cssize - i < sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize, ((char *)fscs) + i); @@ -714,8 +714,8 @@ initcg(int cylno, time_t utime) */ cbase = cgbase(&sblock, cylno); dmax = cbase + sblock.fs_fpg; - if (dmax > sblock.fs_size) - dmax = sblock.fs_size; + if (dmax > sblock.fs_ffs1_size) + dmax = sblock.fs_ffs1_size; dlower = cgsblock(&sblock, cylno) - cbase; dupper = cgdmin(&sblock, cylno) - cbase; if (cylno == 0) @@ -781,9 +781,9 @@ initcg(int cylno, time_t utime) cg_blks(&sblock, &acg, cbtocylno(&sblock, d)) [cbtorpos(&sblock, d)]++; } - sblock.fs_dsize += dlower; + sblock.fs_ffs1_dsize += dlower; } - sblock.fs_dsize += acg.cg_ndblk - dupper; + sblock.fs_ffs1_dsize += acg.cg_ndblk - dupper; if ((i = dupper % sblock.fs_frag)) { acg.cg_frsum[sblock.fs_frag - i]++; for (d = dupper + sblock.fs_frag - i; dupper < d; dupper++) { @@ -838,10 +838,10 @@ initcg(int cylno, time_t utime) sump[run]++; } } - sblock.fs_cstotal.cs_ndir += acg.cg_cs.cs_ndir; - sblock.fs_cstotal.cs_nffree += acg.cg_cs.cs_nffree; - sblock.fs_cstotal.cs_nbfree += acg.cg_cs.cs_nbfree; - sblock.fs_cstotal.cs_nifree += acg.cg_cs.cs_nifree; + sblock.fs_ffs1_cstotal.cs_ndir += acg.cg_cs.cs_ndir; + sblock.fs_ffs1_cstotal.cs_nffree += acg.cg_cs.cs_nffree; + sblock.fs_ffs1_cstotal.cs_nbfree += acg.cg_cs.cs_nbfree; + sblock.fs_ffs1_cstotal.cs_nifree += acg.cg_cs.cs_nifree; *cs = acg.cg_cs; wtfs(fsbtodb(&sblock, cgtod(&sblock, cylno)), sblock.fs_bsize, (char *)&acg); @@ -1004,11 +1004,11 @@ goth: if (sblock.fs_contigsumsize > 0) clrbit(cg_clustersfree(&acg), blkno); acg.cg_cs.cs_nbfree--; - sblock.fs_cstotal.cs_nbfree--; + sblock.fs_ffs1_cstotal.cs_nbfree--; fscs[0].cs_nbfree--; if (mode & IFDIR) { acg.cg_cs.cs_ndir++; - sblock.fs_cstotal.cs_ndir++; + sblock.fs_ffs1_cstotal.cs_ndir++; fscs[0].cs_ndir++; } cg_blktot(&acg)[cbtocylno(&sblock, d)]--; @@ -1016,7 +1016,7 @@ goth: if (size != sblock.fs_bsize) { frag = howmany(size, sblock.fs_fsize); fscs[0].cs_nffree += sblock.fs_frag - frag; - sblock.fs_cstotal.cs_nffree += sblock.fs_frag - frag; + sblock.fs_ffs1_cstotal.cs_nffree += sblock.fs_frag - frag; acg.cg_cs.cs_nffree += sblock.fs_frag - frag; acg.cg_frsum[sblock.fs_frag - frag]++; for (i = frag; i < sblock.fs_frag; i++) @@ -1047,7 +1047,7 @@ iput(struct ufs1_dinode *ip, ino_t ino) setbit(cg_inosused(&acg), ino); wtfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, (char *)&acg); - sblock.fs_cstotal.cs_nifree--; + sblock.fs_ffs1_cstotal.cs_nifree--; fscs[0].cs_nifree--; if (ino >= sblock.fs_ipg * sblock.fs_ncg) { errx(32, "fsinit: inode value %d out of range", ino); diff --git a/sbin/scan_ffs/scan_ffs.c b/sbin/scan_ffs/scan_ffs.c index e1ba6ff0420..c6645d6867d 100644 --- a/sbin/scan_ffs/scan_ffs.c +++ b/sbin/scan_ffs/scan_ffs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scan_ffs.c,v 1.12 2006/06/28 19:17:56 pedro Exp $ */ +/* $OpenBSD: scan_ffs.c,v 1.13 2007/03/19 13:27:47 pedro Exp $ */ /* * Copyright (c) 1998 Niklas Hallqvist, Tobias Weingartner @@ -71,12 +71,12 @@ ufsscan(int fd, daddr_t beg, daddr_t end, int flags) if (flags & FLAG_VERBOSE) printf("block %d id %x,%x size %d\n", blk + (n/512), sb->fs_id[0], - sb->fs_id[1], sb->fs_size); + sb->fs_id[1], sb->fs_ffs1_size); if (((blk+(n/512)) - lastblk) == (SBSIZE/512)) { if (flags & FLAG_LABELS ) { printf("X: %d %d 4.2BSD %d %d %d # %s\n", - (daddr_t)((off_t)sb->fs_size * + (daddr_t)((off_t)sb->fs_ffs1_size * sb->fs_fsize / 512), blk+(n/512)-(2*SBSIZE/512), sb->fs_fsize, sb->fs_bsize, @@ -85,13 +85,13 @@ ufsscan(int fd, daddr_t beg, daddr_t end, int flags) printf("ffs at %d size %lld " "mount %s time %s", blk+(n/512)-(2*SBSIZE/512), - (long long)(off_t)sb->fs_size * + (long long)(off_t)sb->fs_ffs1_size * sb->fs_fsize, - lastmount, ctime(&sb->fs_time)); + lastmount, ctime(&sb->fs_ffs1_time)); } if (flags & FLAG_SMART) { - off_t size = (off_t)sb->fs_size * + off_t size = (off_t)sb->fs_ffs1_size * sb->fs_fsize; if ((n + size) < (SBSIZE * SBCOUNT)) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 3e881ee9453..9582206d94a 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.98 2006/12/28 20:33:24 thib Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.99 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -69,6 +69,9 @@ int ffs_reload_vnode(struct vnode *, void *); int ffs_sync_vnode(struct vnode *, void *); int ffs_validate(struct fs *); +void ffs1_compat_read(struct fs *, struct ufsmount *, ufs2_daddr_t); +void ffs1_compat_write(struct fs *, struct ufsmount *); + const struct vfsops ffs_vfsops = { ffs_mount, ufs_start, @@ -719,11 +722,13 @@ ffs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p) fs = (struct fs *) bp->b_data; sbloc = sbtry[i]; +#if 0 if (fs->fs_magic == FS_UFS2_MAGIC) { printf("ffs_mountfs(): Sorry, no UFS2 support (yet)\n"); error = EFTYPE; goto out; } +#endif /* * Do not look for an FFS1 file system at SBLOCK_UFS2. Doing so @@ -800,6 +805,8 @@ ffs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p) bp = NULL; fs = ump->um_fs; + ffs1_compat_read(fs, ump, sbloc); + fs->fs_ronly = ronly; size = fs->fs_cssize; blks = howmany(size, fs->fs_fsize); @@ -947,6 +954,48 @@ ffs_oldfscompat(struct fs *fs) } /* + * Auxiliary function for reading FFS1 super blocks. + */ +void +ffs1_compat_read(struct fs *fs, struct ufsmount *ump, ufs2_daddr_t sbloc) +{ + if (fs->fs_magic == FS_UFS2_MAGIC) + return; /* UFS2 */ +#if 0 + if (fs->fs_ffs1_flags & FS_FLAGS_UPDATED) + return; /* Already updated */ +#endif + fs->fs_flags = fs->fs_ffs1_flags; + fs->fs_sblockloc = sbloc; + fs->fs_maxbsize = fs->fs_bsize; + fs->fs_time = fs->fs_ffs1_time; + fs->fs_size = fs->fs_ffs1_size; + fs->fs_dsize = fs->fs_ffs1_dsize; + fs->fs_csaddr = fs->fs_ffs1_csaddr; + fs->fs_cstotal.cs_ndir = fs->fs_ffs1_cstotal.cs_ndir; + fs->fs_cstotal.cs_nbfree = fs->fs_ffs1_cstotal.cs_nbfree; + fs->fs_cstotal.cs_nifree = fs->fs_ffs1_cstotal.cs_nifree; + fs->fs_cstotal.cs_nffree = fs->fs_ffs1_cstotal.cs_nffree; + fs->fs_ffs1_flags |= FS_FLAGS_UPDATED; +} + +/* + * Auxiliary function for writing FFS1 super blocks. + */ +void +ffs1_compat_write(struct fs *fs, struct ufsmount *ump) +{ + if (fs->fs_magic != FS_UFS1_MAGIC) + return; /* UFS2 */ + + fs->fs_ffs1_time = fs->fs_time; + fs->fs_ffs1_cstotal.cs_ndir = fs->fs_cstotal.cs_ndir; + fs->fs_ffs1_cstotal.cs_nbfree = fs->fs_cstotal.cs_nbfree; + fs->fs_ffs1_cstotal.cs_nifree = fs->fs_cstotal.cs_nifree; + fs->fs_ffs1_cstotal.cs_nffree = fs->fs_cstotal.cs_nffree; +} + +/* * unmount system call */ int @@ -1423,6 +1472,8 @@ ffs_sbupdate(struct ufsmount *mp, int waitfor) } /* XXX */ dfs->fs_maxfilesize = mp->um_savedmaxfilesize; /* XXX */ + ffs1_compat_write(dfs, mp); + if (waitfor != MNT_WAIT) bawrite(bp); else if ((error = bwrite(bp))) diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h index 32a87a9c876..fdb2f45329d 100644 --- a/sys/ufs/ffs/fs.h +++ b/sys/ufs/ffs/fs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fs.h,v 1.26 2007/02/17 14:32:38 mickey Exp $ */ +/* $OpenBSD: fs.h,v 1.27 2007/03/19 13:27:47 pedro Exp $ */ /* $NetBSD: fs.h,v 1.6 1995/04/12 21:21:02 mycroft Exp $ */ /* @@ -104,7 +104,13 @@ * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in * the super block for this name. */ -#define MAXMNTLEN 512 +#define MAXMNTLEN 468 + +/* + * The volume name for this file system is kept in fs_volname. + * MAXVOLLEN defines the length of the buffer allocated. + */ +#define MAXVOLLEN 32 /* * There is a 128-byte region in the superblock reserved for in-core @@ -119,7 +125,7 @@ * and the third points to an array that tracks the creation of new * directories. */ -#define NOCSPTRS ((128 / sizeof(void *)) - 3) +#define NOCSPTRS ((128 / sizeof(void *)) - 4) /* * A summary of contiguous blocks of various sizes is maintained @@ -154,6 +160,11 @@ #define AFPDIR 64 /* expected number of files per directory */ /* + * Size of superblock space reserved for snapshots. + */ +#define FSMAXSNAP 20 + +/* * Per cylinder group information; summarized in blocks allocated * from first cylinder group data blocks. These blocks have to be * read in from fs_csaddr (size fs_cssize) in addition to the @@ -166,6 +177,14 @@ struct csum { int32_t cs_nffree; /* number of free frags */ }; +struct csum_total { + int64_t cs_ndir; /* number of directories */ + int64_t cs_nbfree; /* number of free blocks */ + int64_t cs_nifree; /* number of free inodes */ + int64_t cs_nffree; /* number of free frags */ + int64_t cs_spare[4]; /* future expansion */ +}; + /* * Super block for an FFS file system. */ @@ -178,9 +197,9 @@ struct fs { int32_t fs_dblkno; /* offset of first data / frags */ int32_t fs_cgoffset; /* cylinder group offset in cylinder */ int32_t fs_cgmask; /* used to calc mod fs_ntrak */ - time_t fs_time; /* last time written */ - int32_t fs_size; /* # of blocks in fs / frags */ - int32_t fs_dsize; /* # of data blocks in fs */ + time_t fs_ffs1_time; /* last time written */ + int32_t fs_ffs1_size; /* # of blocks in fs / frags */ + int32_t fs_ffs1_dsize; /* # of data blocks in fs */ int32_t fs_ncg; /* # of cylinder groups */ int32_t fs_bsize; /* size of basic blocks / bytes */ int32_t fs_fsize; /* size of frag blocks / bytes */ @@ -215,7 +234,7 @@ struct fs { /* fs_id takes the space of the unused fs_headswitch and fs_trkseek fields */ int32_t fs_id[2]; /* unique filesystem id */ /* sizes determined by number of cylinder groups and their sizes */ - int32_t fs_csaddr; /* blk addr of cyl grp summary area */ + int32_t fs_ffs1_csaddr; /* blk addr of cyl grp summary area */ int32_t fs_cssize; /* cyl grp summary area size / bytes */ int32_t fs_cgsize; /* cyl grp block size / bytes */ /* these fields are derived from the hardware */ @@ -229,25 +248,41 @@ struct fs { int32_t fs_ipg; /* inodes per group */ int32_t fs_fpg; /* blocks per group * fs_frag */ /* this data must be re-computed after crashes */ - struct csum fs_cstotal; /* cylinder summary information */ + struct csum fs_ffs1_cstotal; /* cylinder summary information */ /* these fields are cleared at mount time */ int8_t fs_fmod; /* super block modified flag */ int8_t fs_clean; /* file system is clean flag */ int8_t fs_ronly; /* mounted read-only flag */ - int8_t fs_flags; /* see FS_ below */ + int8_t fs_ffs1_flags; /* see FS_ below */ u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */ + u_char fs_volname[MAXVOLLEN]; /* volume name */ + u_int64_t fs_swuid; /* system-wide uid */ + int32_t fs_pad; /* due to alignment of fs_swuid */ /* these fields retain the current block allocation info */ int32_t fs_cgrotor; /* last cg searched */ void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */ u_int8_t *fs_contigdirs; /* # of contiguously allocated dirs */ struct csum *fs_csp; /* cg summary info buffer for fs_cs */ int32_t *fs_maxcluster; /* max cluster in each cyl group */ + u_char *fs_active; /* reserved for snapshots */ int32_t fs_cpc; /* cyl per cycle in postbl */ - int16_t fs_opostbl[16][8]; /* old rotation block list head */ - int32_t fs_snapinum[20]; /* reserved for snapshot inode nums */ +/* this area is only allocated if fs_ffs1_flags & FS_FLAGS_UPDATED */ + int32_t fs_maxbsize; /* maximum blocking factor permitted */ + int64_t fs_spareconf64[17]; /* old rotation block list head */ + int64_t fs_sblockloc; /* offset of standard super block */ + struct csum_total fs_cstotal; /* cylinder summary information */ + int64_t fs_time; /* time last written */ + int64_t fs_size; /* number of blocks in fs */ + int64_t fs_dsize; /* number of data blocks in fs */ + int64_t fs_csaddr; /* blk addr of cyl grp summary area */ + int64_t fs_pendingblocks; /* blocks in process of being freed */ + int32_t fs_pendinginodes; /* inodes in process of being freed */ + int32_t fs_snapinum[FSMAXSNAP];/* space reserved for snapshots */ +/* back to stuff that has been around a while */ int32_t fs_avgfilesize; /* expected average file size */ int32_t fs_avgfpdir; /* expected # of files per directory */ - int32_t fs_sparecon[27]; /* reserved for future constants */ + int32_t fs_sparecon[26]; /* reserved for future constants */ + u_int32_t fs_flags; /* see FS_ flags below */ time_t fs_fscktime; /* last time fsck(8)ed */ int32_t fs_contigsumsize; /* size of cluster summary array */ int32_t fs_maxsymlinklen; /* max length of an internal symlink */ @@ -265,8 +300,6 @@ struct fs { /* actually longer */ }; -#define fs_opostbl_start fs_opostbl[0][0] - /* * Filesystem identification */ @@ -292,9 +325,13 @@ struct fs { /* * Filesystem flags. */ -#define FS_UNCLEAN 0x01 /* filesystem not clean at mount */ -#define FS_DOSOFTDEP 0x02 /* filesystem using soft dependencies */ -#define FS_FLAGS_UPDATED 0x80 /* XXX using ffs2 style superblock */ +#define FS_UNCLEAN 0x01 /* filesystem not clean at mount */ +#define FS_DOSOFTDEP 0x02 /* filesystem using soft dependencies */ +/* + * The following flag is used to detect a FFS1 file system that had its flags + * moved to the new (FFS2) location for compatibility. + */ +#define FS_FLAGS_UPDATED 0x80 /* file system has FFS2-like flags */ /* * Rotational layout table format types |