diff options
| author | Olivier Houchard <cognet@FreeBSD.org> | 2010-11-07 16:05:04 +0000 |
|---|---|---|
| committer | Olivier Houchard <cognet@FreeBSD.org> | 2010-11-07 16:05:04 +0000 |
| commit | 01a0f8531a382e7efc0dbc815e837bed0419011a (patch) | |
| tree | 60af890ef59672ab4e08377f2819cf9ec9d4e9e3 /usr.sbin/makefs/ffs | |
| parent | 96a6480a53c0e69c918eb194cdd4f7a1d74222c7 (diff) | |
Notes
Diffstat (limited to 'usr.sbin/makefs/ffs')
| -rw-r--r-- | usr.sbin/makefs/ffs/Makefile.inc | 9 | ||||
| -rw-r--r-- | usr.sbin/makefs/ffs/buf.c | 6 | ||||
| -rw-r--r-- | usr.sbin/makefs/ffs/ffs_alloc.c | 27 | ||||
| -rw-r--r-- | usr.sbin/makefs/ffs/mkfs.c | 32 |
4 files changed, 44 insertions, 30 deletions
diff --git a/usr.sbin/makefs/ffs/Makefile.inc b/usr.sbin/makefs/ffs/Makefile.inc new file mode 100644 index 000000000000..d681c4eff773 --- /dev/null +++ b/usr.sbin/makefs/ffs/Makefile.inc @@ -0,0 +1,9 @@ +# $FreeBSD$ +# + +.PATH: ${.CURDIR}/ffs ${.CURDIR}/../../sys/ufs/ffs + +CFLAGS+= -I${.CURDIR}/../../sys/ufs/ffs + +SRCS+= ffs_alloc.c ffs_balloc.c ffs_bswap.c ffs_subr.c ufs_bmap.c +SRCS+= buf.c mkfs.c diff --git a/usr.sbin/makefs/ffs/buf.c b/usr.sbin/makefs/ffs/buf.c index 08fb6277656f..06538f509363 100644 --- a/usr.sbin/makefs/ffs/buf.c +++ b/usr.sbin/makefs/ffs/buf.c @@ -118,7 +118,7 @@ brelse(struct buf *bp) bp->b_bcount = 0; return; } - + TAILQ_REMOVE(&buftail, bp, b_tailq); free(bp->b_data); free(bp); @@ -160,7 +160,7 @@ bcleanup(void) * know why there's still some buffers lying around that * aren't brelse()d */ - + if (TAILQ_EMPTY(&buftail)) return; @@ -201,7 +201,7 @@ getblk(int fd, struct fs *fs, daddr_t blkno, int size) if (bp == NULL) { if ((bp = calloc(1, sizeof(struct buf))) == NULL) err(1, "getblk: calloc"); - + bp->b_bufsize = 0; bp->b_blkno = bp->b_lblkno = blkno; bp->b_fd = fd; diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c index 0fe65e6b82e0..f676a39af3c7 100644 --- a/usr.sbin/makefs/ffs/ffs_alloc.c +++ b/usr.sbin/makefs/ffs/ffs_alloc.c @@ -87,7 +87,7 @@ static int32_t ffs_mapsearch(struct fs *, struct cg *, daddr_t, int); * available block is located. */ int -ffs_alloc(struct inode *ip, daddr_t lbn, daddr_t bpref, int size, +ffs_alloc(struct inode *ip, daddr_t lbn __unused, daddr_t bpref, int size, daddr_t *bnp) { struct fs *fs = ip->i_fs; @@ -95,7 +95,7 @@ ffs_alloc(struct inode *ip, daddr_t lbn, daddr_t bpref, int size, int cg; *bnp = 0; - if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { + if (size > fs->fs_bsize || fragoff(fs, size) != 0) { errx(1, "ffs_alloc: bad size: bsize %d size %d", fs->fs_bsize, size); } @@ -187,11 +187,7 @@ ffs_blkpref_ufs1(struct inode *ip, daddr_t lbn, int indx, int32_t *bap) } daddr_t -ffs_blkpref_ufs2(ip, lbn, indx, bap) - struct inode *ip; - daddr_t lbn; - int indx; - int64_t *bap; +ffs_blkpref_ufs2(struct inode *ip, daddr_t lbn, int indx, int64_t *bap) { struct fs *fs; int cg; @@ -385,11 +381,11 @@ ffs_alloccgblk(struct inode *ip, struct buf *bp, daddr_t bpref) int32_t bno; struct fs *fs = ip->i_fs; const int needswap = UFS_FSNEEDSWAP(fs); - u_int8_t *blksfree; + u_int8_t *blksfree_swap; cgp = (struct cg *)bp->b_data; - blksfree = cg_blksfree_swap(cgp, needswap); - if (bpref == 0 || dtog(fs, bpref) != ufs_rw32(cgp->cg_cgx, needswap)) { + blksfree_swap = cg_blksfree_swap(cgp, needswap); + if (bpref == 0 || (uint32_t)dtog(fs, bpref) != ufs_rw32(cgp->cg_cgx, needswap)) { bpref = ufs_rw32(cgp->cg_rotor, needswap); } else { bpref = blknum(fs, bpref); @@ -397,7 +393,7 @@ ffs_alloccgblk(struct inode *ip, struct buf *bp, daddr_t bpref) /* * if the requested block is available, use it */ - if (ffs_isblock(fs, blksfree, fragstoblks(fs, bno))) + if (ffs_isblock(fs, blksfree_swap, fragstoblks(fs, bno))) goto gotit; } /* @@ -409,7 +405,7 @@ ffs_alloccgblk(struct inode *ip, struct buf *bp, daddr_t bpref) cgp->cg_rotor = ufs_rw32(bno, needswap); gotit: blkno = fragstoblks(fs, bno); - ffs_clrblock(fs, blksfree, (long)blkno); + ffs_clrblock(fs, blksfree_swap, (long)blkno); ffs_clusteracct(fs, cgp, blkno, -1); ufs_add32(cgp->cg_cs.cs_nbfree, -1, needswap); fs->fs_cstotal.cs_nbfree--; @@ -436,14 +432,15 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size) struct fs *fs = ip->i_fs; const int needswap = UFS_FSNEEDSWAP(fs); - if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0 || + if (size > fs->fs_bsize || fragoff(fs, size) != 0 || fragnum(fs, bno) + numfrags(fs, size) > fs->fs_frag) { errx(1, "blkfree: bad size: bno %lld bsize %d size %ld", (long long)bno, fs->fs_bsize, size); } cg = dtog(fs, bno); if (bno >= fs->fs_size) { - warnx("bad block %lld, ino %d", (long long)bno, ip->i_number); + warnx("bad block %lld, ino %llu", (long long)bno, + (unsigned long long)ip->i_number); return; } error = bread(ip->i_fd, ip->i_fs, fsbtodb(fs, cgtod(fs, cg)), @@ -622,7 +619,7 @@ ffs_clusteracct(struct fs *fs, struct cg *cgp, int32_t blkno, int cnt) */ start = blkno + 1; end = start + fs->fs_contigsumsize; - if (end >= ufs_rw32(cgp->cg_nclusterblks, needswap)) + if ((unsigned)end >= ufs_rw32(cgp->cg_nclusterblks, needswap)) end = ufs_rw32(cgp->cg_nclusterblks, needswap); mapp = &freemapp[start / NBBY]; map = *mapp++; diff --git a/usr.sbin/makefs/ffs/mkfs.c b/usr.sbin/makefs/ffs/mkfs.c index ce9ec597cea8..924ab6cbd661 100644 --- a/usr.sbin/makefs/ffs/mkfs.c +++ b/usr.sbin/makefs/ffs/mkfs.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include "makefs.h" +#include "ffs.h" #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> @@ -61,6 +62,10 @@ __FBSDID("$FreeBSD$"); #include "ffs/ffs_extern.h" #include "ffs/newfs_extern.h" +#ifndef BBSIZE +#define BBSIZE 8192 /* size of boot area, with label */ +#endif + static void initcg(int, time_t, const fsinfo_t *); static int ilog2(int); @@ -102,6 +107,7 @@ static int opt; /* optimization preference (space or time) */ 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 */ @@ -115,21 +121,23 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts) void *space; int size, blks; int nprintcols, printcolwidth; + ffs_opt_t *ffs_opts = fsopts->fs_specific; - Oflag = fsopts->version; + Oflag = ffs_opts->version; fssize = fsopts->size / fsopts->sectorsize; sectorsize = fsopts->sectorsize; - fsize = fsopts->fsize; - bsize = fsopts->bsize; - maxbsize = fsopts->maxbsize; - maxblkspercg = fsopts->maxblkspercg; - minfree = fsopts->minfree; - opt = fsopts->optimization; - density = fsopts->density; - maxcontig = fsopts->maxcontig; - maxbpg = fsopts->maxbpg; - avgfilesize = fsopts->avgfilesize; - avgfpdir = fsopts->avgfpdir; + fsize = ffs_opts->fsize; + bsize = ffs_opts->bsize; + maxbsize = ffs_opts->maxbsize; + maxblkspercg = ffs_opts->maxblkspercg; + minfree = ffs_opts->minfree; + opt = ffs_opts->optimization; + density = ffs_opts->density; + maxcontig = ffs_opts->maxcontig; + maxbpg = ffs_opts->maxbpg; + avgfilesize = ffs_opts->avgfilesize; + avgfpdir = ffs_opts->avgfpdir; + bbsize = BBSIZE; sbsize = SBLOCKSIZE; if (Oflag == 0) { |
