Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168905612
D8404.id21855.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D8404.id21855.diff
View Options
Index: usr.sbin/makefs/ffs.c
===================================================================
--- usr.sbin/makefs/ffs.c
+++ usr.sbin/makefs/ffs.c
@@ -977,7 +977,7 @@
errno = bwrite(bp);
if (errno != 0)
goto bad_ffs_write_file;
- brelse(bp);
+ brelse(bp, 0);
if (!isfile)
p += chunk;
}
Index: usr.sbin/makefs/ffs/buf.h
===================================================================
--- usr.sbin/makefs/ffs/buf.h
+++ usr.sbin/makefs/ffs/buf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.h,v 1.2 2001/11/02 03:12:49 lukem Exp $ */
+/* $NetBSD: buf.h,v 1.3 2001/11/02 03:12:49 lukem Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -43,6 +43,15 @@
#include <sys/param.h>
#include <sys/queue.h>
+struct ucred;
+
+struct vnode {
+ int fd;
+ void *fs;
+ void *v_data;
+ int offset;
+};
+
struct buf {
void * b_data;
long b_bufsize;
@@ -56,10 +65,11 @@
};
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 ucred *,
+ 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, int);
#define bdwrite(bp) bwrite(bp)
#define clrbuf(bp) memset((bp)->b_data, 0, (u_int)(bp)->b_bcount)
Index: usr.sbin/makefs/ffs/buf.c
===================================================================
--- usr.sbin/makefs/ffs/buf.c
+++ usr.sbin/makefs/ffs/buf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.c,v 1.12 2004/06/20 22:20:18 jmc Exp $ */
+/* $NetBSD: buf.c,v 1.13 2004/06/20 22:20:18 jmc Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -60,10 +60,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 ucred *u1 __unused,
+ struct buf **bpp)
{
off_t offset;
ssize_t rv;
+ struct fs *fs = vp->fs;
assert (fs != NULL);
assert (bpp != NULL);
@@ -71,7 +73,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, 0);
offset = (*bpp)->b_blkno * sectorsize; /* XXX */
if (debug & DEBUG_BUF_BREAD)
printf("bread: bp %p blkno %lld offset %lld bcount %ld\n",
@@ -95,7 +97,7 @@
}
void
-brelse(struct buf *bp)
+brelse(struct buf *bp, int u1 __unused)
{
assert (bp != NULL);
@@ -174,12 +176,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, int u3 __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,
Index: usr.sbin/makefs/ffs/ffs_alloc.c
===================================================================
--- usr.sbin/makefs/ffs/ffs_alloc.c
+++ usr.sbin/makefs/ffs/ffs_alloc.c
@@ -297,19 +297,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, &bp);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return (0);
}
cgp = (struct cg *)bp->b_data;
if (!cg_chkmagic_swap(cgp, needswap) ||
(cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
- brelse(bp);
+ brelse(bp, 0);
return (0);
}
if (size == fs->fs_bsize) {
@@ -332,7 +333,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);
@@ -432,6 +433,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) {
@@ -444,15 +446,15 @@
(uintmax_t)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, &bp);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return;
}
cgp = (struct cg *)bp->b_data;
if (!cg_chkmagic_swap(cgp, needswap)) {
- brelse(bp);
+ brelse(bp, 0);
return;
}
cgbno = dtogd(fs, bno);
Index: usr.sbin/makefs/ffs/ffs_balloc.c
===================================================================
--- usr.sbin/makefs/ffs/ffs_balloc.c
+++ usr.sbin/makefs/ffs/ffs_balloc.c
@@ -89,6 +89,7 @@
int32_t *allocblk, allociblk[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;
@@ -132,10 +133,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,
+ bpp);
if (error) {
- brelse(*bpp);
+ brelse(*bpp, 0);
return (error);
}
}
@@ -158,10 +159,10 @@
*/
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn,
- osize, bpp);
+ error = bread(&vp, lbn, osize, NULL,
+ bpp);
if (error) {
- brelse(*bpp);
+ brelse(*bpp, 0);
return (error);
}
}
@@ -188,7 +189,7 @@
if (error)
return (error);
if (bpp != NULL) {
- bp = getblk(ip->i_fd, ip->i_fs, lbn, nsize);
+ bp = getblk(&vp, lbn, nsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
clrbuf(bp);
*bpp = bp;
@@ -226,7 +227,7 @@
return error;
nb = newb;
*allocblk++ = nb;
- bp = getblk(ip->i_fd, ip->i_fs, indirs[1].in_lbn, fs->fs_bsize);
+ bp = getblk(&vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, nb);
clrbuf(bp);
/*
@@ -244,10 +245,9 @@
*/
for (i = 1;;) {
- error = bread(ip->i_fd, ip->i_fs, indirs[i].in_lbn,
- fs->fs_bsize, &bp);
+ error = bread(&vp, indirs[i].in_lbn, fs->fs_bsize, NULL, &bp);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
bap = (int32_t *)bp->b_data;
@@ -256,20 +256,19 @@
break;
i++;
if (nb != 0) {
- brelse(bp);
+ brelse(bp, 0);
continue;
}
if (pref == 0)
pref = ffs_blkpref_ufs1(ip, lbn, 0, (int32_t *)0);
error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
nb = newb;
*allocblk++ = nb;
- nbp = getblk(ip->i_fd, ip->i_fs, indirs[i].in_lbn,
- fs->fs_bsize);
+ nbp = getblk(&vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
/*
@@ -278,7 +277,7 @@
*/
if ((error = bwrite(nbp)) != 0) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
bap[indirs[i - 1].in_off] = ufs_rw32(nb, needswap);
@@ -294,13 +293,13 @@
pref = ffs_blkpref_ufs1(ip, lbn, indirs[num].in_off, &bap[0]);
error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
nb = newb;
*allocblk++ = nb;
if (bpp != NULL) {
- nbp = getblk(ip->i_fd, ip->i_fs, lbn, fs->fs_bsize);
+ nbp = getblk(&vp, lbn, fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
*bpp = nbp;
@@ -314,11 +313,11 @@
bwrite(bp);
return (0);
}
- brelse(bp);
+ brelse(bp, 0);
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn, (int)fs->fs_bsize, &nbp);
+ error = bread(&vp, lbn, (int)fs->fs_bsize, NULL, &nbp);
if (error) {
- brelse(nbp);
+ brelse(nbp, 0);
return error;
}
*bpp = nbp;
@@ -340,6 +339,7 @@
int64_t *allocblk, allociblk[NIADDR + 1];
int64_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;
@@ -383,10 +383,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,
+ bpp);
if (error) {
- brelse(*bpp);
+ brelse(*bpp, 0);
return (error);
}
}
@@ -409,10 +409,10 @@
*/
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn,
- osize, bpp);
+ error = bread(&vp, lbn, osize, NULL,
+ bpp);
if (error) {
- brelse(*bpp);
+ brelse(*bpp, 0);
return (error);
}
}
@@ -439,7 +439,7 @@
if (error)
return (error);
if (bpp != NULL) {
- bp = getblk(ip->i_fd, ip->i_fs, lbn, nsize);
+ bp = getblk(&vp, lbn, nsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
clrbuf(bp);
*bpp = bp;
@@ -477,7 +477,7 @@
return error;
nb = newb;
*allocblk++ = nb;
- bp = getblk(ip->i_fd, ip->i_fs, indirs[1].in_lbn, fs->fs_bsize);
+ bp = getblk(&vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, nb);
clrbuf(bp);
/*
@@ -495,10 +495,9 @@
*/
for (i = 1;;) {
- error = bread(ip->i_fd, ip->i_fs, indirs[i].in_lbn,
- fs->fs_bsize, &bp);
+ error = bread(&vp, indirs[i].in_lbn, fs->fs_bsize, NULL, &bp);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
bap = (int64_t *)bp->b_data;
@@ -507,20 +506,19 @@
break;
i++;
if (nb != 0) {
- brelse(bp);
+ brelse(bp, 0);
continue;
}
if (pref == 0)
pref = ffs_blkpref_ufs2(ip, lbn, 0, (int64_t *)0);
error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
nb = newb;
*allocblk++ = nb;
- nbp = getblk(ip->i_fd, ip->i_fs, indirs[i].in_lbn,
- fs->fs_bsize);
+ nbp = getblk(&vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
/*
@@ -529,7 +527,7 @@
*/
if ((error = bwrite(nbp)) != 0) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
bap[indirs[i - 1].in_off] = ufs_rw64(nb, needswap);
@@ -545,13 +543,13 @@
pref = ffs_blkpref_ufs2(ip, lbn, indirs[num].in_off, &bap[0]);
error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
nb = newb;
*allocblk++ = nb;
if (bpp != NULL) {
- nbp = getblk(ip->i_fd, ip->i_fs, lbn, fs->fs_bsize);
+ nbp = getblk(&vp, lbn, fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
*bpp = nbp;
@@ -565,11 +563,11 @@
bwrite(bp);
return (0);
}
- brelse(bp);
+ brelse(bp, 0);
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn, (int)fs->fs_bsize, &nbp);
+ error = bread(&vp, lbn, (int)fs->fs_bsize, NULL, &nbp);
if (error) {
- brelse(nbp);
+ brelse(nbp, 0);
return error;
}
*bpp = nbp;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Aug 31, 4:57 PM (41 m, 50 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37705276
Default Alt Text
D8404.id21855.diff (11 KB)
Attached To
Mode
D8404: makefs: make the buffer functions look exactly like the kernel ones
Attached
Detach File
Event Timeline
Log In to Comment