Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/makefs make the buffer functions look exactly like ...
details: https://anonhg.NetBSD.org/src/rev/6edfc56ff4b1
branches: trunk
changeset: 784334:6edfc56ff4b1
user: christos <christos%NetBSD.org@localhost>
date: Sat Jan 26 00:19:39 2013 +0000
description:
make the buffer functions look exactly like the kernel ones and add other
cruft to make the kernel files compile.
diffstat:
usr.sbin/makefs/ffs.c | 6 +-
usr.sbin/makefs/ffs/buf.c | 18 +++++--
usr.sbin/makefs/ffs/buf.h | 59 +++++++++++++++++++++++++-
usr.sbin/makefs/ffs/ffs_alloc.c | 24 +++++-----
usr.sbin/makefs/ffs/ffs_balloc.c | 88 ++++++++++++++++++++--------------------
5 files changed, 127 insertions(+), 68 deletions(-)
diffs (truncated from 540 to 300 lines):
diff -r 7c15bcf6f3e9 -r 6edfc56ff4b1 usr.sbin/makefs/ffs.c
--- a/usr.sbin/makefs/ffs.c Fri Jan 25 22:37:59 2013 +0000
+++ b/usr.sbin/makefs/ffs.c Sat Jan 26 00:19:39 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs.c,v 1.53 2013/01/24 01:10:47 christos Exp $ */
+/* $NetBSD: ffs.c,v 1.54 2013/01/26 00:19:39 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs.c,v 1.53 2013/01/24 01:10:47 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.54 2013/01/26 00:19:39 christos Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -945,7 +945,7 @@
errno = bwrite(bp);
if (errno != 0)
goto bad_ffs_write_file;
- brelse(bp);
+ brelse(bp, 0);
if (!isfile)
p += chunk;
}
diff -r 7c15bcf6f3e9 -r 6edfc56ff4b1 usr.sbin/makefs/ffs/buf.c
--- a/usr.sbin/makefs/ffs/buf.c Fri Jan 25 22:37:59 2013 +0000
+++ b/usr.sbin/makefs/ffs/buf.c Sat Jan 26 00:19:39 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.c,v 1.12 2004/06/20 22:20:18 jmc Exp $ */
+/* $NetBSD: buf.c,v 1.13 2013/01/26 00:19:39 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: buf.c,v 1.12 2004/06/20 22:20:18 jmc Exp $");
+__RCSID("$NetBSD: buf.c,v 1.13 2013/01/26 00:19:39 christos Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -66,10 +66,12 @@
TAILQ_HEAD(buftailhead,buf) buftail;
int
-bread(int fd, struct fs *fs, daddr_t blkno, int size, struct buf **bpp)
+bread(struct vnode *vp, daddr_t blkno, int size, struct kauth_cred *u1 __unused,
+ int u2 __unused, struct buf **bpp)
{
off_t offset;
ssize_t rv;
+ struct fs *fs = vp->fs;
assert (fs != NULL);
assert (bpp != NULL);
@@ -77,7 +79,7 @@
if (debug & DEBUG_BUF_BREAD)
printf("bread: fs %p blkno %lld size %d\n",
fs, (long long)blkno, size);
- *bpp = getblk(fd, fs, blkno, size);
+ *bpp = getblk(vp, blkno, size, 0, 0);
offset = (*bpp)->b_blkno * sectorsize; /* XXX */
if (debug & DEBUG_BUF_BREAD)
printf("bread: bp %p blkno %lld offset %lld bcount %ld\n",
@@ -101,7 +103,7 @@
}
void
-brelse(struct buf *bp)
+brelse(struct buf *bp, int u1 __unused)
{
assert (bp != NULL);
@@ -180,12 +182,16 @@
}
struct buf *
-getblk(int fd, struct fs *fs, daddr_t blkno, int size)
+getblk(struct vnode *vp, daddr_t blkno, int size, int u1 __unused,
+ int u2 __unused)
{
static int buftailinitted;
struct buf *bp;
void *n;
+ int fd = vp->fd;
+ struct fs *fs = vp->fs;
+ blkno += vp->offset;
assert (fs != NULL);
if (debug & DEBUG_BUF_GETBLK)
printf("getblk: fs %p blkno %lld size %d\n", fs,
diff -r 7c15bcf6f3e9 -r 6edfc56ff4b1 usr.sbin/makefs/ffs/buf.h
--- a/usr.sbin/makefs/ffs/buf.h Fri Jan 25 22:37:59 2013 +0000
+++ b/usr.sbin/makefs/ffs/buf.h Sat Jan 26 00:19:39 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.h,v 1.2 2001/11/02 03:12:49 lukem Exp $ */
+/* $NetBSD: buf.h,v 1.3 2013/01/26 00:19:39 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,6 +41,28 @@
#include <sys/param.h>
#include <sys/queue.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <err.h>
+
+struct componentname {
+ char *cn_nameptr;
+ size_t cn_namelen;
+};
+
+struct vnode {
+ int fd;
+ void *fs;
+ void *v_data;
+ int offset;
+};
+
+#define vput(a) ((void)(a))
+
struct buf {
void * b_data;
long b_bufsize;
@@ -54,12 +76,41 @@
};
void bcleanup(void);
-int bread(int, struct fs *, daddr_t, int, struct buf **);
-void brelse(struct buf *);
+int bread(struct vnode *, daddr_t, int, struct kauth_cred *,
+ int, struct buf **);
+void brelse(struct buf *, int);
int bwrite(struct buf *);
-struct buf * getblk(int, struct fs *, daddr_t, int);
+struct buf * getblk(struct vnode *, daddr_t, int, int, int);
#define bdwrite(bp) bwrite(bp)
#define clrbuf(bp) memset((bp)->b_data, 0, (u_int)(bp)->b_bcount)
+#define B_MODIFY 0
+#define BC_AGE 0
+
+#define min(a, b) MIN((a), (b))
+#define microtime(tv) gettimeofday((tv), NULL)
+#define KASSERT(a)
+#define IO_SYNC 1
+
+struct pool {
+ size_t size;
+};
+
+#define pool_init(p, s, a1, a2, a3, a4, a5, a6) (p)->size = (s)
+#define pool_get(p, f) malloc((p)->size)
+#define pool_put(p, a) free(a)
+#define pool_destroy(p)
+
+#define MALLOC_DECLARE(a)
+#define malloc_type_attach(a)
+#define malloc_type_detach(a)
+
+#define mutex_enter(m)
+#define mutex_exit(m)
+#define mutex_init(m, t, i)
+#define mutex_destroy(m)
+
+#define desiredvnodes 10000
+
#endif /* _FFS_BUF_H */
diff -r 7c15bcf6f3e9 -r 6edfc56ff4b1 usr.sbin/makefs/ffs/ffs_alloc.c
--- a/usr.sbin/makefs/ffs/ffs_alloc.c Fri Jan 25 22:37:59 2013 +0000
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c Sat Jan 26 00:19:39 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_alloc.c,v 1.20 2013/01/22 09:39:19 dholland Exp $ */
+/* $NetBSD: ffs_alloc.c,v 1.21 2013/01/26 00:19:39 christos Exp $ */
/* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */
/*
@@ -47,7 +47,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs_alloc.c,v 1.20 2013/01/22 09:39:19 dholland Exp $");
+__RCSID("$NetBSD: ffs_alloc.c,v 1.21 2013/01/26 00:19:39 christos Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -304,19 +304,20 @@
int error, frags, allocsiz, i;
struct fs *fs = ip->i_fs;
const int needswap = UFS_FSNEEDSWAP(fs);
+ struct vnode vp = { ip->i_fd, ip->i_fs, NULL, 0 };
if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
return (0);
- error = bread(ip->i_fd, ip->i_fs, fsbtodb(fs, cgtod(fs, cg)),
- (int)fs->fs_cgsize, &bp);
+ error = bread(&vp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+ NULL, 0, &bp);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return (0);
}
cgp = (struct cg *)bp->b_data;
if (!cg_chkmagic(cgp, needswap) ||
(cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
- brelse(bp);
+ brelse(bp, 0);
return (0);
}
if (size == fs->fs_bsize) {
@@ -339,7 +340,7 @@
* allocated, and hacked up
*/
if (cgp->cg_cs.cs_nbfree == 0) {
- brelse(bp);
+ brelse(bp, 0);
return (0);
}
bno = ffs_alloccgblk(ip, bp, bpref);
@@ -439,6 +440,7 @@
int i, error, cg, blk, frags, bbase;
struct fs *fs = ip->i_fs;
const int needswap = UFS_FSNEEDSWAP(fs);
+ struct vnode vp = { ip->i_fd, ip->i_fs, NULL, 0 };
if (size > fs->fs_bsize || fragoff(fs, size) != 0 ||
fragnum(fs, bno) + numfrags(fs, size) > fs->fs_frag) {
@@ -451,15 +453,15 @@
(unsigned long long)ip->i_number);
return;
}
- error = bread(ip->i_fd, ip->i_fs, fsbtodb(fs, cgtod(fs, cg)),
- (int)fs->fs_cgsize, &bp);
+ error = bread(&vp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+ NULL, 0, &bp);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return;
}
cgp = (struct cg *)bp->b_data;
if (!cg_chkmagic(cgp, needswap)) {
- brelse(bp);
+ brelse(bp, 0);
return;
}
cgbno = dtogd(fs, bno);
diff -r 7c15bcf6f3e9 -r 6edfc56ff4b1 usr.sbin/makefs/ffs/ffs_balloc.c
--- a/usr.sbin/makefs/ffs/ffs_balloc.c Fri Jan 25 22:37:59 2013 +0000
+++ b/usr.sbin/makefs/ffs/ffs_balloc.c Sat Jan 26 00:19:39 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_balloc.c,v 1.14 2013/01/22 09:39:19 dholland Exp $ */
+/* $NetBSD: ffs_balloc.c,v 1.15 2013/01/26 00:19:39 christos Exp $ */
/* From NetBSD: ffs_balloc.c,v 1.25 2001/08/08 08:36:36 lukem Exp */
/*
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs_balloc.c,v 1.14 2013/01/22 09:39:19 dholland Exp $");
+__RCSID("$NetBSD: ffs_balloc.c,v 1.15 2013/01/26 00:19:39 christos Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -95,6 +95,7 @@
int32_t *allocblk, allociblk[UFS_NIADDR + 1];
int32_t *allocib;
const int needswap = UFS_FSNEEDSWAP(fs);
+ struct vnode vp = { ip->i_fd, ip->i_fs, NULL, 0 };
lbn = lblkno(fs, offset);
size = blkoff(fs, offset) + bufsize;
@@ -138,10 +139,10 @@
*/
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn,
- fs->fs_bsize, bpp);
+ error = bread(&vp, lbn, fs->fs_bsize, NULL, 0,
+ bpp);
if (error) {
- brelse(*bpp);
+ brelse(*bpp, 0);
return (error);
}
}
@@ -164,10 +165,10 @@
*/
Home |
Main Index |
Thread Index |
Old Index