Date: Thu, 18 Dec 2008 00:54:15 +0000 (UTC) From: Sam Leffler <sam@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r186261 - in projects/makefs: . compat compat/machine ffs sys Message-ID: <200812180054.mBI0sFZM019899@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sam Date: Thu Dec 18 00:54:15 2008 New Revision: 186261 URL: http://svn.freebsd.org/changeset/base/186261 Log: Apply the big hammer: o remove all of compat except for pwcache and strstuftoll; these might end up in libutil or similar so keep them in the subdir o mv getid.c up to the top level; this looks like something that'll be makefs-specific o eliminate private versions of .h files in sys; use system files instead o eliminate private ffs_tables.c; use the system version directly (might want to adopt const'ification at some point but that's the only diff I can see) o mv remaining code from sys to ffs and strip out unused bits; this now becomes part of makefs o add compat defs and shims to makefs.h o strip all vestiges of nbtool_config.h, compat_defs.h, etc. o fixup includes after file shuffling o rename system #defines that do implicit byte swapping to have an _swap suffix; e.g. DIRSIZ -> DIRSIZ_SWAP, cg_inosused -> cg_inosused_swap; if we ever add endian-agnostic support to the kernel these can go back to their original names o strip some netbsd'isms that aren't worth shim'ing (e.g. _DIAGASSERT) Code compiles w/o complaints but is untested. Added: projects/makefs/ffs/ffs_bswap.c (contents, props changed) - copied, changed from r186109, projects/makefs/sys/ufs/ffs/ffs_bswap.c projects/makefs/ffs/ffs_subr.c (contents, props changed) - copied, changed from r186109, projects/makefs/sys/ufs/ffs/ffs_subr.c projects/makefs/ffs/ufs_bswap.h (contents, props changed) - copied, changed from r186109, projects/makefs/sys/ufs/ufs/ufs_bswap.h projects/makefs/getid.c - copied, changed from r186256, projects/makefs/compat/getid.c Deleted: projects/makefs/compat/compat_defs.h projects/makefs/compat/getid.c projects/makefs/compat/machine/ projects/makefs/compat/namespace.h projects/makefs/compat/nbtool_config.h projects/makefs/compat/util.h projects/makefs/sys/ Modified: projects/makefs/Makefile projects/makefs/compat/pwcache.c projects/makefs/compat/strsuftoll.c projects/makefs/ffs.c projects/makefs/ffs/buf.c projects/makefs/ffs/ffs_alloc.c projects/makefs/ffs/ffs_balloc.c projects/makefs/ffs/mkfs.c projects/makefs/ffs/ufs_bmap.c projects/makefs/makefs.c projects/makefs/makefs.h projects/makefs/walk.c Modified: projects/makefs/Makefile ============================================================================== --- projects/makefs/Makefile Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/Makefile Thu Dec 18 00:54:15 2008 (r186261) @@ -5,25 +5,22 @@ MAN= makefs.8 WARNS?= 2 -CFLAGS+=-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 - CFLAGS+=-I. -SRCS= ffs.c makefs.c walk.c +SRCS= ffs.c getid.c makefs.c walk.c .PATH: ${.CURDIR}/ffs CFLAGS+=-Iffs -SRCS+= buf.c ffs_alloc.c ffs_balloc.c mkfs.c ufs_bmap.c +SRCS+= buf.c ffs_alloc.c ffs_balloc.c ffs_bswap.c ffs_subr.c mkfs.c ufs_bmap.c -.PATH: ${.CURDIR}/sys/ufs/ffs -CFLAGS+=-Isys -Isys/ufs -SRCS+= ffs_bswap.c ffs_subr.c ffs_tables.c +.PATH: ${.CURDIR}/compat +CFLAGS+=-Icompat +SRCS+= pwcache.c strsuftoll.c .PATH: ${.CURDIR}/../mtree CFLAGS+=-I../mtree SRCS+= misc.c spec.c -.PATH: ${.CURDIR}/compat -CFLAGS+=-Icompat -SRCS+= fparseln.c getid.c getmode.c pwcache.c strsuftoll.c +.PATH: ${.CURDIR}/../../sys/ufs/ffs +SRCS+= ffs_tables.c .include <bsd.prog.mk> Modified: projects/makefs/compat/pwcache.c ============================================================================== --- projects/makefs/compat/pwcache.c Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/compat/pwcache.c Thu Dec 18 00:54:15 2008 (r186261) @@ -66,16 +66,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -/* - * XXX Undefine the renames of these functions so that we don't - * XXX rename the versions found in the host's <pwd.h> by mistake! - */ -#undef group_from_gid -#undef user_from_uid -#endif - #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) #if 0 @@ -85,8 +75,6 @@ __RCSID("$NetBSD: pwcache.c,v 1.29 2004/ #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" - #include <sys/types.h> #include <sys/param.h> @@ -98,12 +86,6 @@ __RCSID("$NetBSD: pwcache.c,v 1.29 2004/ #include <string.h> #include <unistd.h> -#if HAVE_NBTOOL_CONFIG_H -/* XXX Now, re-apply the renaming that we undid above. */ -#define group_from_gid __nbcompat_group_from_gid -#define user_from_uid __nbcompat_user_from_uid -#endif - #ifdef __weak_alias __weak_alias(user_from_uid,_user_from_uid) __weak_alias(group_from_gid,_group_from_gid) @@ -111,7 +93,6 @@ __weak_alias(pwcache_userdb,_pwcache_use __weak_alias(pwcache_groupdb,_pwcache_groupdb) #endif -#if !HAVE_PWCACHE_USERDB || HAVE_NBTOOL_CONFIG_H #include "pwcache.h" /* @@ -162,8 +143,6 @@ st_hash(const char *name, size_t len, in { u_int key = 0; - _DIAGASSERT(name != NULL); - while (len--) { key += *name++; key = (key << 8) | (key >> 24); @@ -648,4 +627,3 @@ main(int argc, char *argv[]) return (0); } #endif /* TEST_PWCACHE */ -#endif /* !HAVE_PWCACHE_USERDB */ Modified: projects/makefs/compat/strsuftoll.c ============================================================================== --- projects/makefs/compat/strsuftoll.c Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/compat/strsuftoll.c Thu Dec 18 00:54:15 2008 (r186261) @@ -67,22 +67,12 @@ * SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) __RCSID("$NetBSD: strsuftoll.c,v 1.6 2004/03/05 05:58:29 lukem Exp $"); #endif /* LIBC_SCCS and not lint */ -#ifdef _LIBC -#include "namespace.h" -#endif - -#if !HAVE_STRSUFTOLL - #include <sys/types.h> #include <sys/time.h> @@ -118,19 +108,6 @@ __weak_alias(strsuftollx, _strsuftollx) * appropriate error. * */ -/* LONGLONG */ -long long -strsuftoll(const char *desc, const char *val, - long long min, long long max) -{ - long long result; - char errbuf[100]; - - result = strsuftollx(desc, val, min, max, errbuf, sizeof(errbuf)); - if (*errbuf != '\0') - errx(1, "%s", errbuf); - return (result); -} /* * As strsuftoll(), but returns the error message into the provided buffer @@ -144,10 +121,6 @@ strsuftollx(const char *desc, const char long long num, t; char *expr; - _DIAGASSERT(desc != NULL); - _DIAGASSERT(val != NULL); - _DIAGASSERT(ebuf != NULL); - errno = 0; ebuf[0] = '\0'; @@ -244,4 +217,16 @@ strsuftollx(const char *desc, const char return (num); } -#endif /* !HAVE_STRSUFTOLL */ +/* LONGLONG */ +long long +strsuftoll(const char *desc, const char *val, + long long min, long long max) +{ + long long result; + char errbuf[100]; + + result = strsuftollx(desc, val, min, max, errbuf, sizeof(errbuf)); + if (*errbuf != '\0') + errx(1, "%s", errbuf); + return (result); +} Modified: projects/makefs/ffs.c ============================================================================== --- projects/makefs/ffs.c Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/ffs.c Thu Dec 18 00:54:15 2008 (r186261) @@ -65,10 +65,6 @@ * @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95 */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: ffs.c,v 1.30 2004/06/24 22:30:13 lukem Exp $"); @@ -94,8 +90,8 @@ __RCSID("$NetBSD: ffs.c,v 1.30 2004/06/2 #include <ufs/ufs/dinode.h> #include <ufs/ufs/dir.h> #include <ufs/ffs/fs.h> -#include <ufs/ufs/ufs_bswap.h> +#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/newfs_extern.h" #include "ffs/ffs_extern.h" @@ -516,7 +512,7 @@ ffs_size_dir(fsnode *root, fsinfo_t *fso #define ADDDIRENT(e) do { \ tmpdir.d_namlen = strlen((e)); \ - this = DIRSIZ(0, &tmpdir, 0); \ + this = DIRSIZ_SWAP(0, &tmpdir, 0); \ if (debug & DEBUG_FS_SIZE_DIR_ADD_DIRENT) \ printf("ADDDIRENT: was: %s (%d) this %d cur %d\n", \ e, tmpdir.d_namlen, this, curdirsize); \ @@ -943,13 +939,13 @@ ffs_make_dirbuf(dirbuf_t *dbuf, const ch de.d_type = IFTODT(node->type); de.d_namlen = (uint8_t)strlen(name); strcpy(de.d_name, name); - reclen = DIRSIZ(0, &de, needswap); + reclen = DIRSIZ_SWAP(0, &de, needswap); de.d_reclen = ufs_rw16(reclen, needswap); dp = (struct direct *)(dbuf->buf + dbuf->cur); llen = 0; if (dp != NULL) - llen = DIRSIZ(0, dp, needswap); + llen = DIRSIZ_SWAP(0, dp, needswap); if (debug & DEBUG_FS_MAKE_DIRBUF) printf( @@ -1008,10 +1004,10 @@ ffs_write_inode(union dinode *dp, uint32 ffs_rdfs(fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, &sbbuf, fsopts); cgp = (struct cg *)sbbuf; - if (!cg_chkmagic(cgp, fsopts->needswap)) + if (!cg_chkmagic_swap(cgp, fsopts->needswap)) errx(1, "ffs_write_inode: cg %d: bad magic number", cg); - assert (isclr(cg_inosused(cgp, fsopts->needswap), cgino)); + assert (isclr(cg_inosused_swap(cgp, fsopts->needswap), cgino)); buf = malloc(fs->fs_bsize); if (buf == NULL) @@ -1027,7 +1023,7 @@ ffs_write_inode(union dinode *dp, uint32 errx(1, "ffs_write_inode: cg %d out of inodes for ino %u", cg, ino); - setbit(cg_inosused(cgp, fsopts->needswap), cgino); + setbit(cg_inosused_swap(cgp, fsopts->needswap), cgino); ufs_add32(cgp->cg_cs.cs_nifree, -1, fsopts->needswap); fs->fs_cstotal.cs_nifree--; fs->fs_cs(fs, cg).cs_nifree--; Modified: projects/makefs/ffs/buf.c ============================================================================== --- projects/makefs/ffs/buf.c Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/ffs/buf.c Thu Dec 18 00:54:15 2008 (r186261) @@ -35,10 +35,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: buf.c,v 1.12 2004/06/20 22:20:18 jmc Exp $"); Modified: projects/makefs/ffs/ffs_alloc.c ============================================================================== --- projects/makefs/ffs/ffs_alloc.c Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/ffs/ffs_alloc.c Thu Dec 18 00:54:15 2008 (r186261) @@ -41,10 +41,6 @@ * @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95 */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: ffs_alloc.c,v 1.14 2004/06/20 22:20:18 jmc Exp $"); @@ -58,14 +54,13 @@ __RCSID("$NetBSD: ffs_alloc.c,v 1.14 200 #include "makefs.h" #include <ufs/ufs/dinode.h> -#include <ufs/ufs/ufs_bswap.h> #include <ufs/ffs/fs.h> +#include "ffs/ufs_bswap.h" #include "ffs/buf.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" - static int scanc(u_int, const u_char *, const u_char *, int); static daddr_t ffs_alloccg(struct inode *, int, daddr_t, int); @@ -74,10 +69,6 @@ static daddr_t ffs_hashalloc(struct inod daddr_t (*)(struct inode *, int, daddr_t, int)); static int32_t ffs_mapsearch(struct fs *, struct cg *, daddr_t, int); -/* in ffs_tables.c */ -extern const int inside[], around[]; -extern const u_char * const fragtbl[]; - /* * Allocate a block in the file system. * @@ -321,7 +312,7 @@ ffs_alloccg(struct inode *ip, int cg, da return (0); } cgp = (struct cg *)bp->b_data; - if (!cg_chkmagic(cgp, needswap) || + if (!cg_chkmagic_swap(cgp, needswap) || (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) { brelse(bp); return (0); @@ -352,7 +343,7 @@ ffs_alloccg(struct inode *ip, int cg, da bno = ffs_alloccgblk(ip, bp, bpref); bpref = dtogd(fs, bno); for (i = frags; i < fs->fs_frag; i++) - setbit(cg_blksfree(cgp, needswap), bpref + i); + setbit(cg_blksfree_swap(cgp, needswap), bpref + i); i = fs->fs_frag - frags; ufs_add32(cgp->cg_cs.cs_nffree, i, needswap); fs->fs_cstotal.cs_nffree += i; @@ -364,7 +355,7 @@ ffs_alloccg(struct inode *ip, int cg, da } bno = ffs_mapsearch(fs, cgp, bpref, allocsiz); for (i = 0; i < frags; i++) - clrbit(cg_blksfree(cgp, needswap), bno + i); + clrbit(cg_blksfree_swap(cgp, needswap), bno + i); ufs_add32(cgp->cg_cs.cs_nffree, -frags, needswap); fs->fs_cstotal.cs_nffree -= frags; fs->fs_cs(fs, cg).cs_nffree -= frags; @@ -399,7 +390,7 @@ ffs_alloccgblk(struct inode *ip, struct u_int8_t *blksfree; cgp = (struct cg *)bp->b_data; - blksfree = cg_blksfree(cgp, needswap); + blksfree = cg_blksfree_swap(cgp, needswap); if (bpref == 0 || dtog(fs, bpref) != ufs_rw32(cgp->cg_cgx, needswap)) { bpref = ufs_rw32(cgp->cg_rotor, needswap); } else { @@ -464,18 +455,18 @@ ffs_blkfree(struct inode *ip, daddr_t bn return; } cgp = (struct cg *)bp->b_data; - if (!cg_chkmagic(cgp, needswap)) { + if (!cg_chkmagic_swap(cgp, needswap)) { brelse(bp); return; } cgbno = dtogd(fs, bno); if (size == fs->fs_bsize) { fragno = fragstoblks(fs, cgbno); - if (!ffs_isfreeblock(fs, cg_blksfree(cgp, needswap), fragno)) { + if (!ffs_isfreeblock(fs, cg_blksfree_swap(cgp, needswap), fragno)) { errx(1, "blkfree: freeing free block %lld", (long long)bno); } - ffs_setblock(fs, cg_blksfree(cgp, needswap), fragno); + ffs_setblock(fs, cg_blksfree_swap(cgp, needswap), fragno); ffs_clusteracct(fs, cgp, fragno, 1); ufs_add32(cgp->cg_cs.cs_nbfree, 1, needswap); fs->fs_cstotal.cs_nbfree++; @@ -485,18 +476,18 @@ ffs_blkfree(struct inode *ip, daddr_t bn /* * decrement the counts associated with the old frags */ - blk = blkmap(fs, cg_blksfree(cgp, needswap), bbase); - ffs_fragacct(fs, blk, cgp->cg_frsum, -1, needswap); + blk = blkmap(fs, cg_blksfree_swap(cgp, needswap), bbase); + ffs_fragacct_swap(fs, blk, cgp->cg_frsum, -1, needswap); /* * deallocate the fragment */ frags = numfrags(fs, size); for (i = 0; i < frags; i++) { - if (isset(cg_blksfree(cgp, needswap), cgbno + i)) { + if (isset(cg_blksfree_swap(cgp, needswap), cgbno + i)) { errx(1, "blkfree: freeing free frag: block %lld", (long long)(cgbno + i)); } - setbit(cg_blksfree(cgp, needswap), cgbno + i); + setbit(cg_blksfree_swap(cgp, needswap), cgbno + i); } ufs_add32(cgp->cg_cs.cs_nffree, i, needswap); fs->fs_cstotal.cs_nffree += i; @@ -504,13 +495,13 @@ ffs_blkfree(struct inode *ip, daddr_t bn /* * add back in counts associated with the new frags */ - blk = blkmap(fs, cg_blksfree(cgp, needswap), bbase); - ffs_fragacct(fs, blk, cgp->cg_frsum, 1, needswap); + blk = blkmap(fs, cg_blksfree_swap(cgp, needswap), bbase); + ffs_fragacct_swap(fs, blk, cgp->cg_frsum, 1, needswap); /* * if a complete block has been reassembled, account for it */ fragno = fragstoblks(fs, bbase); - if (ffs_isblock(fs, cg_blksfree(cgp, needswap), fragno)) { + if (ffs_isblock(fs, cg_blksfree_swap(cgp, needswap), fragno)) { ufs_add32(cgp->cg_cs.cs_nffree, -fs->fs_frag, needswap); fs->fs_cstotal.cs_nffree -= fs->fs_frag; fs->fs_cs(fs, cg).cs_nffree -= fs->fs_frag; @@ -562,14 +553,14 @@ ffs_mapsearch(struct fs *fs, struct cg * ostart = start; olen = len; loc = scanc((u_int)len, - (const u_char *)&cg_blksfree(cgp, needswap)[start], + (const u_char *)&cg_blksfree_swap(cgp, needswap)[start], (const u_char *)fragtbl[fs->fs_frag], (1 << (allocsiz - 1 + (fs->fs_frag % NBBY)))); if (loc == 0) { len = start + 1; start = 0; loc = scanc((u_int)len, - (const u_char *)&cg_blksfree(cgp, needswap)[0], + (const u_char *)&cg_blksfree_swap(cgp, needswap)[0], (const u_char *)fragtbl[fs->fs_frag], (1 << (allocsiz - 1 + (fs->fs_frag % NBBY)))); if (loc == 0) { @@ -577,7 +568,7 @@ ffs_mapsearch(struct fs *fs, struct cg * "ffs_alloccg: map corrupted: start %d len %d offset %d %ld", ostart, olen, ufs_rw32(cgp->cg_freeoff, needswap), - (long)cg_blksfree(cgp, needswap) - (long)cgp); + (long)cg_blksfree_swap(cgp, needswap) - (long)cgp); /* NOTREACHED */ } } @@ -588,7 +579,7 @@ ffs_mapsearch(struct fs *fs, struct cg * * sift through the bits to find the selected frag */ for (i = bno + NBBY; bno < i; bno += fs->fs_frag) { - blk = blkmap(fs, cg_blksfree(cgp, needswap), bno); + blk = blkmap(fs, cg_blksfree_swap(cgp, needswap), bno); blk <<= 1; field = around[allocsiz]; subfield = inside[allocsiz]; @@ -619,8 +610,8 @@ ffs_clusteracct(struct fs *fs, struct cg if (fs->fs_contigsumsize <= 0) return; - freemapp = cg_clustersfree(cgp, needswap); - sump = cg_clustersum(cgp, needswap); + freemapp = cg_clustersfree_swap(cgp, needswap); + sump = cg_clustersum_swap(cgp, needswap); /* * Allocate or clear the actual block. */ Modified: projects/makefs/ffs/ffs_balloc.c ============================================================================== --- projects/makefs/ffs/ffs_balloc.c Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/ffs/ffs_balloc.c Thu Dec 18 00:54:15 2008 (r186261) @@ -32,10 +32,6 @@ * @(#)ffs_balloc.c 8.8 (Berkeley) 6/16/95 */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: ffs_balloc.c,v 1.13 2004/06/20 22:20:18 jmc Exp $"); @@ -53,9 +49,9 @@ __RCSID("$NetBSD: ffs_balloc.c,v 1.13 20 #include "makefs.h" #include <ufs/ufs/dinode.h> -#include <ufs/ufs/ufs_bswap.h> #include <ufs/ffs/fs.h> +#include "ffs/ufs_bswap.h" #include "ffs/buf.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" Copied and modified: projects/makefs/ffs/ffs_bswap.c (from r186109, projects/makefs/sys/ufs/ffs/ffs_bswap.c) ============================================================================== --- projects/makefs/sys/ufs/ffs/ffs_bswap.c Mon Dec 15 02:06:02 2008 (r186109, copy source) +++ projects/makefs/ffs/ffs_bswap.c Thu Dec 18 00:54:15 2008 (r186261) @@ -30,12 +30,11 @@ * */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> +#if 0 __KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,v 1.28 2004/05/25 14:54:59 hannken Exp $"); +#endif +__FBSDID("$FreeBSD$"); #include <sys/param.h> #if defined(_KERNEL) @@ -43,8 +42,15 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c, #endif #include <ufs/ufs/dinode.h> -#include <ufs/ufs/ufs_bswap.h> +#include "ffs/ufs_bswap.h" #include <ufs/ffs/fs.h> +/* XXX temporary */ +struct ufsmount; +struct bufobj; +struct mount; +struct vnode; +typedef int vfs_vget_t(struct mount *mp, ino_t ino, int flags, + struct vnode **vpp); #include <ufs/ffs/ffs_extern.h> #if !defined(_KERNEL) @@ -55,6 +61,20 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c, #define panic(x) printf("%s\n", (x)), abort() #endif +#define fs_old_postbloff fs_spare5[0] +#define fs_old_rotbloff fs_spare5[1] +#define fs_old_postbl_start fs_maxbsize +#define fs_old_headswitch fs_id[0] +#define fs_old_trkseek fs_id[1] +#define fs_old_csmask fs_spare1[0] +#define fs_old_csshift fs_spare1[1] + +#define FS_42POSTBLFMT -1 /* 4.2BSD rotational table format */ +#define FS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */ + +void ffs_csum_swap(struct csum *o, struct csum *n, int size); +void ffs_csumtotal_swap(struct csum_total *o, struct csum_total *n); + void ffs_sb_swap(struct fs *o, struct fs *n) { @@ -211,60 +231,43 @@ ffs_cg_swap(struct cg *o, struct cg *n, for (i = 0; i < MAXFRAG; i++) n->cg_frsum[i] = bswap32(o->cg_frsum[i]); - if ((fs->fs_magic != FS_UFS2_MAGIC) && - (fs->fs_old_postblformat == FS_42POSTBLFMT)) { /* old format */ - struct ocg *on, *oo; - int j; - on = (struct ocg *)n; - oo = (struct ocg *)o; - - for (i = 0; i < 32; i++) { - on->cg_btot[i] = bswap32(oo->cg_btot[i]); - for (j = 0; j < 8; j++) - on->cg_b[i][j] = bswap16(oo->cg_b[i][j]); - } - memmove(on->cg_iused, oo->cg_iused, 256); - on->cg_magic = bswap32(oo->cg_magic); - } else { /* new format */ - - n->cg_old_btotoff = bswap32(o->cg_old_btotoff); - n->cg_old_boff = bswap32(o->cg_old_boff); - n->cg_iusedoff = bswap32(o->cg_iusedoff); - n->cg_freeoff = bswap32(o->cg_freeoff); - n->cg_nextfreeoff = bswap32(o->cg_nextfreeoff); - n->cg_clustersumoff = bswap32(o->cg_clustersumoff); - n->cg_clusteroff = bswap32(o->cg_clusteroff); - n->cg_nclusterblks = bswap32(o->cg_nclusterblks); - n->cg_niblk = bswap32(o->cg_niblk); - n->cg_initediblk = bswap32(o->cg_initediblk); - n->cg_time = bswap64(o->cg_time); - - if (fs->fs_magic == FS_UFS2_MAGIC) - return; - - if (n->cg_magic == CG_MAGIC) { - btotoff = n->cg_old_btotoff; - boff = n->cg_old_boff; - clustersumoff = n->cg_clustersumoff; - } else { - btotoff = bswap32(n->cg_old_btotoff); - boff = bswap32(n->cg_old_boff); - clustersumoff = bswap32(n->cg_clustersumoff); - } - n32 = (u_int32_t *)((u_int8_t *)n + btotoff); - o32 = (u_int32_t *)((u_int8_t *)o + btotoff); - n16 = (u_int16_t *)((u_int8_t *)n + boff); - o16 = (u_int16_t *)((u_int8_t *)o + boff); - - for (i = 0; i < fs->fs_old_cpg; i++) - n32[i] = bswap32(o32[i]); - - for (i = 0; i < fs->fs_old_cpg * fs->fs_old_nrpos; i++) - n16[i] = bswap16(o16[i]); - - n32 = (u_int32_t *)((u_int8_t *)n + clustersumoff); - o32 = (u_int32_t *)((u_int8_t *)o + clustersumoff); - for (i = 1; i < fs->fs_contigsumsize + 1; i++) - n32[i] = bswap32(o32[i]); + n->cg_old_btotoff = bswap32(o->cg_old_btotoff); + n->cg_old_boff = bswap32(o->cg_old_boff); + n->cg_iusedoff = bswap32(o->cg_iusedoff); + n->cg_freeoff = bswap32(o->cg_freeoff); + n->cg_nextfreeoff = bswap32(o->cg_nextfreeoff); + n->cg_clustersumoff = bswap32(o->cg_clustersumoff); + n->cg_clusteroff = bswap32(o->cg_clusteroff); + n->cg_nclusterblks = bswap32(o->cg_nclusterblks); + n->cg_niblk = bswap32(o->cg_niblk); + n->cg_initediblk = bswap32(o->cg_initediblk); + n->cg_time = bswap64(o->cg_time); + + if (fs->fs_magic == FS_UFS2_MAGIC) + return; + + if (n->cg_magic == CG_MAGIC) { + btotoff = n->cg_old_btotoff; + boff = n->cg_old_boff; + clustersumoff = n->cg_clustersumoff; + } else { + btotoff = bswap32(n->cg_old_btotoff); + boff = bswap32(n->cg_old_boff); + clustersumoff = bswap32(n->cg_clustersumoff); } + n32 = (u_int32_t *)((u_int8_t *)n + btotoff); + o32 = (u_int32_t *)((u_int8_t *)o + btotoff); + n16 = (u_int16_t *)((u_int8_t *)n + boff); + o16 = (u_int16_t *)((u_int8_t *)o + boff); + + for (i = 0; i < fs->fs_old_cpg; i++) + n32[i] = bswap32(o32[i]); + + for (i = 0; i < fs->fs_old_cpg * fs->fs_old_nrpos; i++) + n16[i] = bswap16(o16[i]); + + n32 = (u_int32_t *)((u_int8_t *)n + clustersumoff); + o32 = (u_int32_t *)((u_int8_t *)o + clustersumoff); + for (i = 1; i < fs->fs_contigsumsize + 1; i++) + n32[i] = bswap32(o32[i]); } Copied and modified: projects/makefs/ffs/ffs_subr.c (from r186109, projects/makefs/sys/ufs/ffs/ffs_subr.c) ============================================================================== --- projects/makefs/sys/ufs/ffs/ffs_subr.c Mon Dec 15 02:06:02 2008 (r186109, copy source) +++ projects/makefs/ffs/ffs_subr.c Thu Dec 18 00:54:15 2008 (r186261) @@ -31,141 +31,34 @@ * @(#)ffs_subr.c 8.5 (Berkeley) 3/21/95 */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> +#if 0 __KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.32 2003/12/30 12:33:24 pk Exp $"); +#endif +__FBSDID("$FreeBSD$"); #include <sys/param.h> -/* in ffs_tables.c */ -extern const int inside[], around[]; -extern const u_char * const fragtbl[]; - -#ifndef _KERNEL #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> +/* XXX temporary */ +struct ufsmount; +struct bufobj; +struct mount; +struct vnode; +typedef int vfs_vget_t(struct mount *mp, ino_t ino, int flags, + struct vnode **vpp); #include <ufs/ffs/ffs_extern.h> -#include <ufs/ufs/ufs_bswap.h> +#include "ffs/ufs_bswap.h" void panic __P((const char *, ...)) __attribute__((__noreturn__,__format__(__printf__,1,2))); -#else /* _KERNEL */ -#include <sys/systm.h> -#include <sys/vnode.h> -#include <sys/mount.h> -#include <sys/buf.h> -#include <sys/inttypes.h> -#include <sys/pool.h> -#include <ufs/ufs/inode.h> -#include <ufs/ufs/ufsmount.h> -#include <ufs/ufs/ufs_extern.h> -#include <ufs/ffs/fs.h> -#include <ufs/ffs/ffs_extern.h> -#include <ufs/ufs/ufs_bswap.h> - -/* - * Return buffer with the contents of block "offset" from the beginning of - * directory "ip". If "res" is non-zero, fill it in with a pointer to the - * remaining space in the directory. - */ -int -ffs_blkatoff(v) - void *v; -{ - struct vop_blkatoff_args /* { - struct vnode *a_vp; - off_t a_offset; - char **a_res; - struct buf **a_bpp; - } */ *ap = v; - struct inode *ip; - struct fs *fs; - struct buf *bp; - daddr_t lbn; - int bsize, error; - - ip = VTOI(ap->a_vp); - fs = ip->i_fs; - lbn = lblkno(fs, ap->a_offset); - bsize = blksize(fs, ip, lbn); - - *ap->a_bpp = NULL; - if ((error = bread(ap->a_vp, lbn, bsize, NOCRED, &bp)) != 0) { - brelse(bp); - return (error); - } - if (ap->a_res) - *ap->a_res = (char *)bp->b_data + blkoff(fs, ap->a_offset); - *ap->a_bpp = bp; - return (0); -} - - -/* - * Load up the contents of an inode and copy the appropriate pieces - * to the incore copy. - */ -void -ffs_load_inode(bp, ip, fs, ino) - struct buf *bp; - struct inode *ip; - struct fs *fs; - ino_t ino; -{ - struct ufs1_dinode *dp1; - struct ufs2_dinode *dp2; - - if (ip->i_ump->um_fstype == UFS1) { - dp1 = (struct ufs1_dinode *)bp->b_data + ino_to_fsbo(fs, ino); -#ifdef FFS_EI - if (UFS_FSNEEDSWAP(fs)) - ffs_dinode1_swap(dp1, ip->i_din.ffs1_din); - else -#endif - *ip->i_din.ffs1_din = *dp1; - - ip->i_mode = ip->i_ffs1_mode; - ip->i_nlink = ip->i_ffs1_nlink; - ip->i_size = ip->i_ffs1_size; - ip->i_flags = ip->i_ffs1_flags; - ip->i_gen = ip->i_ffs1_gen; - ip->i_uid = ip->i_ffs1_uid; - ip->i_gid = ip->i_ffs1_gid; - } else { - dp2 = (struct ufs2_dinode *)bp->b_data + ino_to_fsbo(fs, ino); -#ifdef FFS_EI - if (UFS_FSNEEDSWAP(fs)) - ffs_dinode2_swap(dp2, ip->i_din.ffs2_din); - else -#endif - *ip->i_din.ffs2_din = *dp2; - - ip->i_mode = ip->i_ffs2_mode; - ip->i_nlink = ip->i_ffs2_nlink; - ip->i_size = ip->i_ffs2_size; - ip->i_flags = ip->i_ffs2_flags; - ip->i_gen = ip->i_ffs2_gen; - ip->i_uid = ip->i_ffs2_uid; - ip->i_gid = ip->i_ffs2_gid; - } -} - -#endif /* _KERNEL */ - /* * Update the frsum fields to reflect addition or deletion * of some frags. */ void -ffs_fragacct(fs, fragmap, fraglist, cnt, needswap) - struct fs *fs; - int fragmap; - int32_t fraglist[]; - int cnt; - int needswap; +ffs_fragacct_swap(struct fs *fs, int fragmap, int32_t fraglist[], int cnt, int needswap) { int inblk; int field, subfield; @@ -193,45 +86,6 @@ ffs_fragacct(fs, fragmap, fraglist, cnt, } } -#if defined(_KERNEL) && defined(DIAGNOSTIC) -void -ffs_checkoverlap(bp, ip) - struct buf *bp; - struct inode *ip; -{ -#if 0 - struct buf *ebp, *ep; - daddr_t start, last; - struct vnode *vp; - - ebp = &buf[nbuf]; - start = bp->b_blkno; - last = start + btodb(bp->b_bcount) - 1; - for (ep = buf; ep < ebp; ep++) { - if (ep == bp || (ep->b_flags & B_INVAL) || - ep->b_vp == NULLVP) - continue; - if (VOP_BMAP(ep->b_vp, (daddr_t)0, &vp, (daddr_t)0, NULL)) - continue; - if (vp != ip->i_devvp) - continue; - /* look for overlap */ - if (ep->b_bcount == 0 || ep->b_blkno > last || - ep->b_blkno + btodb(ep->b_bcount) <= start) - continue; - vprint("Disk overlap", vp); - printf("\tstart %" PRId64 ", end %" PRId64 " overlap start " - "%" PRId64 ", end %" PRId64 "\n", - start, last, ep->b_blkno, - ep->b_blkno + btodb(ep->b_bcount) - 1); - panic("Disk buffer overlap"); - } -#else - printf("ffs_checkoverlap disabled due to buffer cache implementation changes\n"); -#endif -} -#endif /* _KERNEL && DIAGNOSTIC */ - /* * block operations * Modified: projects/makefs/ffs/mkfs.c ============================================================================== --- projects/makefs/ffs/mkfs.c Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/ffs/mkfs.c Thu Dec 18 00:54:15 2008 (r186261) @@ -38,10 +38,6 @@ * SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> #ifndef lint #if 0 @@ -66,9 +62,9 @@ __RCSID("$NetBSD: mkfs.c,v 1.20 2004/06/ #include "makefs.h" #include <ufs/ufs/dinode.h> -#include <ufs/ufs/ufs_bswap.h> #include <ufs/ffs/fs.h> +#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" #include "ffs/newfs_extern.h" @@ -114,7 +110,6 @@ static int opt; /* optimization static int density; /* number of bytes per inode */ static int maxcontig; /* max contiguous blocks to allocate */ static int maxbpg; /* maximum blocks per file in a cyl group */ -static int bbsize; /* boot block size */ static int sbsize; /* superblock size */ static int avgfilesize; /* expected average file size */ static int avgfpdir; /* expected number of files per directory */ @@ -143,7 +138,6 @@ ffs_mkfs(const char *fsys, const fsinfo_ maxbpg = fsopts->maxbpg; avgfilesize = fsopts->avgfilesize; avgfpdir = fsopts->avgfpdir; - bbsize = BBSIZE; sbsize = SBLOCKSIZE; if (Oflag == 0) { @@ -663,7 +657,7 @@ initcg(int cylno, time_t utime, const fs acg.cg_cs.cs_nifree += sblock.fs_ipg; if (cylno == 0) for (i = 0; i < ROOTINO; i++) { - setbit(cg_inosused(&acg, 0), i); + setbit(cg_inosused_swap(&acg, 0), i); acg.cg_cs.cs_nifree--; } if (cylno > 0) { @@ -672,9 +666,9 @@ initcg(int cylno, time_t utime, const fs * for boot and super blocks. */ for (d = 0, blkno = 0; d < dlower;) { - ffs_setblock(&sblock, cg_blksfree(&acg, 0), blkno); + ffs_setblock(&sblock, cg_blksfree_swap(&acg, 0), blkno); if (sblock.fs_contigsumsize > 0) - setbit(cg_clustersfree(&acg, 0), blkno); + setbit(cg_clustersfree_swap(&acg, 0), blkno); acg.cg_cs.cs_nbfree++; d += sblock.fs_frag; blkno++; @@ -683,15 +677,15 @@ initcg(int cylno, time_t utime, const fs if ((i = (dupper & (sblock.fs_frag - 1))) != 0) { acg.cg_frsum[sblock.fs_frag - i]++; for (d = dupper + sblock.fs_frag - i; dupper < d; dupper++) { - setbit(cg_blksfree(&acg, 0), dupper); + setbit(cg_blksfree_swap(&acg, 0), dupper); acg.cg_cs.cs_nffree++; } } for (d = dupper, blkno = dupper >> sblock.fs_fragshift; d + sblock.fs_frag <= acg.cg_ndblk; ) { - ffs_setblock(&sblock, cg_blksfree(&acg, 0), blkno); + ffs_setblock(&sblock, cg_blksfree_swap(&acg, 0), blkno); if (sblock.fs_contigsumsize > 0) - setbit(cg_clustersfree(&acg, 0), blkno); + setbit(cg_clustersfree_swap(&acg, 0), blkno); acg.cg_cs.cs_nbfree++; d += sblock.fs_frag; blkno++; @@ -699,13 +693,13 @@ initcg(int cylno, time_t utime, const fs if (d < acg.cg_ndblk) { acg.cg_frsum[acg.cg_ndblk - d]++; for (; d < acg.cg_ndblk; d++) { - setbit(cg_blksfree(&acg, 0), d); + setbit(cg_blksfree_swap(&acg, 0), d); acg.cg_cs.cs_nffree++; } } if (sblock.fs_contigsumsize > 0) { - int32_t *sump = cg_clustersum(&acg, 0); - u_char *mapp = cg_clustersfree(&acg, 0); + int32_t *sump = cg_clustersum_swap(&acg, 0); + u_char *mapp = cg_clustersfree_swap(&acg, 0); int map = *mapp++; int bit = 1; int run = 0; Modified: projects/makefs/ffs/ufs_bmap.c ============================================================================== --- projects/makefs/ffs/ufs_bmap.c Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/ffs/ufs_bmap.c Thu Dec 18 00:54:15 2008 (r186261) @@ -37,10 +37,6 @@ * @(#)ufs_bmap.c 8.8 (Berkeley) 8/11/95 */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: ufs_bmap.c,v 1.14 2004/06/20 22:20:18 jmc Exp $"); @@ -56,9 +52,9 @@ __RCSID("$NetBSD: ufs_bmap.c,v 1.14 2004 #include "makefs.h" #include <ufs/ufs/dinode.h> -#include <ufs/ufs/ufs_bswap.h> #include <ufs/ffs/fs.h> +#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" Copied and modified: projects/makefs/ffs/ufs_bswap.h (from r186109, projects/makefs/sys/ufs/ufs/ufs_bswap.h) ============================================================================== --- projects/makefs/sys/ufs/ufs/ufs_bswap.h Mon Dec 15 02:06:02 2008 (r186109, copy source) +++ projects/makefs/ffs/ufs_bswap.h Thu Dec 18 00:54:15 2008 (r186261) @@ -37,7 +37,7 @@ #include "opt_ffs.h" #endif -#include <machine/bswap.h> +#include <sys/endian.h> /* Macros to access UFS flags */ #ifdef FFS_EI Copied and modified: projects/makefs/getid.c (from r186256, projects/makefs/compat/getid.c) ============================================================================== --- projects/makefs/compat/getid.c Wed Dec 17 21:54:08 2008 (r186256, copy source) +++ projects/makefs/getid.c Thu Dec 18 00:54:15 2008 (r186261) @@ -67,10 +67,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/param.h> #include <grp.h> @@ -82,6 +78,8 @@ #include <time.h> #include <unistd.h> +#include "makefs.h" + #include "mtree.h" #include "extern.h" @@ -433,4 +431,3 @@ pwmatchline(int search, uid_t uid, const return 1; } - Modified: projects/makefs/makefs.c ============================================================================== --- projects/makefs/makefs.c Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/makefs.c Thu Dec 18 00:54:15 2008 (r186261) @@ -35,10 +35,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: makefs.c,v 1.20 2004/06/20 22:20:18 jmc Exp $"); Modified: projects/makefs/makefs.h ============================================================================== --- projects/makefs/makefs.h Wed Dec 17 22:59:29 2008 (r186260) +++ projects/makefs/makefs.h Thu Dec 18 00:54:15 2008 (r186261) @@ -38,16 +38,6 @@ #ifndef _MAKEFS_H #define _MAKEFS_H -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812180054.mBI0sFZM019899>