Remove #define _KERNEL hacks from libprocstat

Make sys/buf.h, sys/pipe.h, sys/fs/devfs/devfs*.h headers usable in
userspace, assuming that the consumer has an idea what it is for.
Unhide more material from sys/mount.h and sys/ufs/ufs/inode.h,
sys/ufs/ufs/ufsmount.h for consumption of userspace tools, with the
same caveat.

Remove unacceptable hack from usr.sbin/makefs which relied on sys/buf.h
being unusable in userspace, where it override struct buf with its own
definition.  Instead, provide struct m_buf and struct m_vnode and adapt
code to use local variants.

Reviewed by:	mckusick
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D28679
This commit is contained in:
Konstantin Belousov 2021-02-18 15:43:58 +02:00
parent 750ea20d3f
commit d485c77f20
36 changed files with 225 additions and 156 deletions

View File

@ -42,8 +42,8 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <sys/vnode.h>
#include <sys/conf.h>
#define _KERNEL
#include <sys/pipe.h>
#define _WANT_MOUNT
#include <sys/mount.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
#include <ufs/ufs/ufsmount.h>
#include <fs/devfs/devfs.h>
#include <fs/devfs/devfs_int.h>
#undef _KERNEL
#include <nfs/nfsproto.h>
#include <nfsclient/nfs.h>
#include <nfsclient/nfsnode.h>

View File

@ -68,15 +68,12 @@ __FBSDID("$FreeBSD$");
#include <sys/mman.h>
#include <sys/capsicum.h>
#include <sys/ptrace.h>
#define _KERNEL
#define _WANT_MOUNT
#include <sys/mount.h>
#include <sys/filedesc.h>
#include <sys/pipe.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <fs/devfs/devfs.h>
#include <fs/devfs/devfs_int.h>
#undef _KERNEL
#include <nfs/nfsproto.h>
#include <nfsclient/nfs.h>
#include <nfsclient/nfsnode.h>

View File

@ -71,7 +71,7 @@ struct vattr {
long va_spare; /* remain quad aligned */
};
#define _WANT_MOUNT
#include <sys/zfs_context.h>
#include <sys/zfs_znode.h>

View File

@ -36,6 +36,8 @@ __FBSDID("$FreeBSD$");
#include <sys/disklabel.h>
#include <sys/stat.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>

View File

@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$");
#include <sys/disklabel.h>
#include <sys/stat.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>

View File

@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$");
#include <sys/disklabel.h>
#include <sys/stat.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>

View File

@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$");
#include <sys/disklabel.h>
#include <sys/stat.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>

View File

@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$");
#include <sys/disklabel.h>
#include <sys/stat.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>

View File

@ -48,6 +48,8 @@ static const char rcsid[] =
#include <sys/mount.h>
#include <sys/disklabel.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ffs/fs.h>

View File

@ -59,6 +59,8 @@ static const char rcsid[] =
#include <sys/mount.h>
#include <sys/stat.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>

View File

@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$");
#include <sys/mount.h>
#include <sys/stat.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>

View File

@ -40,7 +40,11 @@
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>

View File

@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$");
#include <ufs/ufs/dir.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <ctype.h>

View File

@ -51,6 +51,8 @@ __FBSDID("$FreeBSD$");
#include <sys/disklabel.h>
#include <sys/stat.h>
#include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>

View File

@ -124,6 +124,8 @@ struct devfs_rule {
MALLOC_DECLARE(M_DEVFS);
#endif
#endif /* _KERNEL */
struct componentname;
TAILQ_HEAD(devfs_dlist_head, devfs_dirent);
@ -156,6 +158,9 @@ struct devfs_dirent {
int de_usecount;
};
#include <sys/_lock.h>
#include <sys/_sx.h>
struct devfs_mount {
u_int dm_idx;
struct mount *dm_mount;
@ -168,6 +173,8 @@ struct devfs_mount {
#define DEVFS_ROOTINO 2
#ifdef _KERNEL
extern unsigned devfs_rule_depth;
#define VFSTODEVFS(mp) ((struct devfs_mount *)((mp)->mnt_data))

View File

@ -37,8 +37,6 @@
#include <sys/queue.h>
#ifdef _KERNEL
struct devfs_dirent;
struct devfs_mount;
@ -76,6 +74,8 @@ struct cdev_priv {
#define cdev2priv(c) __containerof(c, struct cdev_priv, cdp_c)
#ifdef _KERNEL
struct cdev *devfs_alloc(int);
int devfs_dev_exists(const char *);
void devfs_free(struct cdev *);

View File

@ -271,6 +271,7 @@ int msdosfs_reclaim(struct vop_reclaim_args *);
/*
* Internal service routine prototypes.
*/
struct componentname;
int deget(struct msdosfsmount *, u_long, u_long, struct denode **);
int uniqdosname(struct denode *, struct componentname *, u_char *);

View File

@ -132,7 +132,8 @@ struct buf {
union {
TAILQ_ENTRY(buf) b_freelist; /* (Q) */
struct {
void (*b_pgiodone)(void *, vm_page_t *, int, int);
void (*b_pgiodone)(void *, struct vm_page **,
int, int);
int b_pgbefore;
int b_pgafter;
};

View File

@ -163,7 +163,9 @@ struct ostatfs {
*/
long f_spare[2]; /* unused spare */
};
#endif /* _KERNEL */
#if defined(_WANT_MOUNT) || defined(_KERNEL)
TAILQ_HEAD(vnodelst, vnode);
/* Mount options list */
@ -243,7 +245,9 @@ struct mount {
TAILQ_ENTRY(mount) mnt_upper_link; /* (m) we in the all uppers */
TAILQ_HEAD(, mount) mnt_uppers; /* (m) upper mounts over us*/
};
#endif /* _WANT_MOUNT || _KERNEL */
#ifdef _KERNEL
/*
* Definitions for MNT_VNODE_FOREACH_ALL.
*/

View File

@ -24,10 +24,6 @@
#ifndef _SYS_PIPE_H_
#define _SYS_PIPE_H_
#ifndef _KERNEL
#error "no user-serviceable parts inside"
#endif
/*
* Pipe buffer size, keep moderate in value, pipes take kva space.
*/
@ -53,11 +49,13 @@
#define PIPENPAGES (BIG_PIPE_SIZE / PAGE_SIZE + 1)
#ifdef _KERNEL
/*
* See sys_pipe.c for info on what these limits mean.
*/
extern long maxpipekva;
extern struct fileops pipeops;
#endif
/*
* Pipe buffer information.
@ -147,7 +145,9 @@ struct pipepair {
#define PIPE_UNLOCK(pipe) mtx_unlock(PIPE_MTX(pipe))
#define PIPE_LOCK_ASSERT(pipe, type) mtx_assert(PIPE_MTX(pipe), (type))
#ifdef _KERNEL
void pipe_dtor(struct pipe *dpipe);
int pipe_named_ctor(struct pipe **ppipe, struct thread *td);
void pipeselwakeup(struct pipe *cpipe);
#endif
#endif /* !_SYS_PIPE_H_ */

View File

@ -104,10 +104,6 @@ struct extattr {
#define EXTATTR_BASE_LENGTH(eap) \
roundup2((sizeof(struct extattr) - 1 + (eap)->ea_namelength), 8)
#ifdef _KERNEL
#include <sys/_sx.h>
struct vnode;
LIST_HEAD(ufs_extattr_list_head, ufs_extattr_list_entry);
struct ufs_extattr_list_entry {
@ -118,6 +114,9 @@ struct ufs_extattr_list_entry {
struct vnode *uele_backing_vnode;
};
#include <sys/_lock.h>
#include <sys/_sx.h>
struct ucred;
struct ufs_extattr_per_mount {
struct sx uepm_lock;
@ -126,6 +125,8 @@ struct ufs_extattr_per_mount {
int uepm_flags;
};
#ifdef _KERNEL
struct vop_getextattr_args;
struct vop_deleteextattr_args;
struct vop_setextattr_args;

View File

@ -207,14 +207,14 @@ struct inode {
#define i_din1 dinode_u.din1
#define i_din2 dinode_u.din2
#ifdef _KERNEL
#define ITOUMP(ip) ((ip)->i_ump)
#define ITODEV(ip) (ITOUMP(ip)->um_dev)
#define ITODEVVP(ip) (ITOUMP(ip)->um_devvp)
#define ITOFS(ip) (ITOUMP(ip)->um_fs)
#define ITOVFS(ip) ((ip)->i_vnode->v_mount)
#ifdef _KERNEL
static inline _Bool
I_IS_UFS1(const struct inode *ip)
{
@ -228,6 +228,7 @@ I_IS_UFS2(const struct inode *ip)
return ((ip->i_flag & IN_UFS2) != 0);
}
#endif /* _KERNEL */
/*
* The DIP macro is used to access fields in the dinode that are
@ -275,6 +276,7 @@ struct ufid {
uint32_t ufid_gen; /* Generation number. */
};
#ifdef _KERNEL
#ifdef DIAGNOSTIC
void ufs_init_trackers(struct inode *ip);
void ufs_unlock_tracker(struct inode *ip);

View File

@ -43,14 +43,14 @@ struct ufs_args {
struct oexport_args export; /* network export information */
};
#ifdef _KERNEL
#include <sys/_task.h>
#ifdef _KERNEL
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_UFSMNT);
MALLOC_DECLARE(M_TRIM);
#endif
#endif /* _KERNEL */
struct buf;
struct inode;
@ -72,6 +72,9 @@ struct fsfail_task {
fsid_t fsid;
};
#include <sys/_lock.h>
#include <sys/_mutex.h>
/*
* This structure describes the UFS specific mount structure data.
* The function operators are used to support different versions of
@ -190,6 +193,5 @@ struct ufsmount {
#define MNINDIR(ump) ((ump)->um_nindir)
#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb)
#define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc)
#endif /* _KERNEL */
#endif

View File

@ -90,9 +90,6 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include <util.h>
#include "makefs.h"
#include "ffs.h"
#if HAVE_STRUCT_STATVFS_F_IOSIZE && HAVE_FSTATVFS
#include <sys/statvfs.h>
#endif
@ -101,12 +98,15 @@ __FBSDID("$FreeBSD$");
#include <ufs/ufs/dir.h>
#include <ufs/ffs/fs.h>
#include "ffs/ufs_bswap.h"
#include "ffs/ufs_inode.h"
#include "ffs/newfs_extern.h"
#include "ffs/ffs_extern.h"
#undef clrbuf
#include "makefs.h"
#include "ffs.h"
#undef DIP
#define DIP(dp, field) \
((ffs_opts->version == 1) ? \
@ -896,9 +896,9 @@ ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
off_t bufleft, chunk, offset;
ssize_t nread;
struct inode in;
struct buf * bp;
struct m_buf * bp;
ffs_opt_t *ffs_opts = fsopts->fs_specific;
struct vnode vp = { fsopts, NULL };
struct m_vnode vp = { fsopts, NULL };
assert (din != NULL);
assert (buf != NULL);
@ -911,7 +911,7 @@ ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
p = NULL;
in.i_fs = (struct fs *)fsopts->superblock;
in.i_devvp = &vp;
in.i_devvp = (void *)&vp;
if (debug & DEBUG_FS_WRITE_FILE) {
printf(

View File

@ -54,11 +54,11 @@ __FBSDID("$FreeBSD$");
#include "makefs.h"
#include "buf.h"
static TAILQ_HEAD(buftailhead,buf) buftail;
static TAILQ_HEAD(buftailhead, m_buf) buftail;
int
bread(struct vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused,
struct buf **bpp)
bread(struct m_vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused,
struct m_buf **bpp)
{
off_t offset;
ssize_t rv;
@ -93,7 +93,7 @@ bread(struct vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused,
}
void
brelse(struct buf *bp)
brelse(struct m_buf *bp)
{
assert (bp != NULL);
@ -123,7 +123,7 @@ brelse(struct buf *bp)
}
int
bwrite(struct buf *bp)
bwrite(struct m_buf *bp)
{
off_t offset;
ssize_t rv;
@ -152,7 +152,7 @@ bwrite(struct buf *bp)
void
bcleanup(void)
{
struct buf *bp;
struct m_buf *bp;
/*
* XXX this really shouldn't be necessary, but i'm curious to
@ -172,12 +172,12 @@ bcleanup(void)
printf("bcleanup: done\n");
}
struct buf *
getblk(struct vnode *vp, daddr_t blkno, int size, int u1 __unused,
struct m_buf *
getblk(struct m_vnode *vp, daddr_t blkno, int size, int u1 __unused,
int u2 __unused, int u3 __unused)
{
static int buftailinitted;
struct buf *bp;
struct m_buf *bp;
void *n;
if (debug & DEBUG_BUF_GETBLK)

View File

@ -49,12 +49,12 @@ struct componentname;
struct makefs_fsinfo;
struct ucred;
struct vnode {
struct m_vnode {
struct makefs_fsinfo *fs;
void *v_data;
};
struct buf {
struct m_buf {
char * b_data;
long b_bufsize;
long b_bcount;
@ -62,15 +62,15 @@ struct buf {
daddr_t b_lblkno;
struct makefs_fsinfo *b_fs;
TAILQ_ENTRY(buf) b_tailq;
TAILQ_ENTRY(m_buf) b_tailq;
};
void bcleanup(void);
int bread(struct vnode *, daddr_t, int, struct ucred *,
struct buf **);
void brelse(struct buf *);
int bwrite(struct buf *);
struct buf * getblk(struct vnode *, daddr_t, int, int, int, int);
int bread(struct m_vnode *, daddr_t, int, struct ucred *,
struct m_buf **);
void brelse(struct m_buf *);
int bwrite(struct m_buf *);
struct m_buf * getblk(struct m_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)

View File

@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
static int scanc(u_int, const u_char *, const u_char *, int);
static daddr_t ffs_alloccg(struct inode *, int, daddr_t, int);
static daddr_t ffs_alloccgblk(struct inode *, struct buf *, daddr_t);
static daddr_t ffs_alloccgblk(struct inode *, struct m_buf *, daddr_t);
static daddr_t ffs_hashalloc(struct inode *, u_int, daddr_t, int,
daddr_t (*)(struct inode *, int, daddr_t, int));
static int32_t ffs_mapsearch(struct fs *, struct cg *, daddr_t, int);
@ -294,7 +294,7 @@ static daddr_t
ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
{
struct cg *cgp;
struct buf *bp;
struct m_buf *bp;
daddr_t bno, blkno;
int error, frags, allocsiz, i;
struct fs *fs = ip->i_fs;
@ -302,8 +302,8 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
return (0);
error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
NULL, &bp);
error = bread((void *)ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
(int)fs->fs_cgsize, NULL, &bp);
if (error) {
brelse(bp);
return (0);
@ -377,7 +377,7 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
* blocks may be fragmented by the routine that allocates them.
*/
static daddr_t
ffs_alloccgblk(struct inode *ip, struct buf *bp, daddr_t bpref)
ffs_alloccgblk(struct inode *ip, struct m_buf *bp, daddr_t bpref)
{
struct cg *cgp;
daddr_t blkno;
@ -429,7 +429,7 @@ void
ffs_blkfree(struct inode *ip, daddr_t bno, long size)
{
struct cg *cgp;
struct buf *bp;
struct m_buf *bp;
int32_t fragno, cgbno;
int i, error, cg, blk, frags, bbase;
struct fs *fs = ip->i_fs;
@ -446,8 +446,8 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size)
(uintmax_t)ip->i_number);
return;
}
error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
NULL, &bp);
error = bread((void *)ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
(int)fs->fs_cgsize, NULL, &bp);
if (error) {
brelse(bp);
return;

View File

@ -56,8 +56,8 @@ __FBSDID("$FreeBSD$");
#include "ffs/ufs_inode.h"
#include "ffs/ffs_extern.h"
static int ffs_balloc_ufs1(struct inode *, off_t, int, struct buf **);
static int ffs_balloc_ufs2(struct inode *, off_t, int, struct buf **);
static int ffs_balloc_ufs1(struct inode *, off_t, int, struct m_buf **);
static int ffs_balloc_ufs2(struct inode *, off_t, int, struct m_buf **);
/*
* Balloc defines the structure of file system storage
@ -68,7 +68,7 @@ static int ffs_balloc_ufs2(struct inode *, off_t, int, struct buf **);
*/
int
ffs_balloc(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
ffs_balloc(struct inode *ip, off_t offset, int bufsize, struct m_buf **bpp)
{
if (ip->i_fs->fs_magic == FS_UFS2_MAGIC)
return ffs_balloc_ufs2(ip, offset, bufsize, bpp);
@ -77,12 +77,13 @@ ffs_balloc(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
}
static int
ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize,
struct m_buf **bpp)
{
daddr_t lbn, lastlbn;
int size;
int32_t nb;
struct buf *bp, *nbp;
struct m_buf *bp, *nbp;
struct fs *fs = ip->i_fs;
struct indir indirs[UFS_NIADDR + 2];
daddr_t newb, pref;
@ -135,8 +136,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
*/
if (bpp != NULL) {
error = bread(ip->i_devvp, lbn, fs->fs_bsize,
NULL, bpp);
error = bread((void *)ip->i_devvp, lbn,
fs->fs_bsize, NULL, bpp);
if (error) {
brelse(*bpp);
return (error);
@ -161,8 +162,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
*/
if (bpp != NULL) {
error = bread(ip->i_devvp, lbn, osize,
NULL, bpp);
error = bread((void *)ip->i_devvp, lbn,
osize, NULL, bpp);
if (error) {
brelse(*bpp);
return (error);
@ -191,7 +192,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
if (error)
return (error);
if (bpp != NULL) {
bp = getblk(ip->i_devvp, lbn, nsize, 0, 0, 0);
bp = getblk((void *)ip->i_devvp, lbn, nsize,
0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
clrbuf(bp);
*bpp = bp;
@ -229,7 +231,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
return error;
nb = newb;
*allocblk++ = nb;
bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0);
bp = getblk((void *)ip->i_devvp, indirs[1].in_lbn,
fs->fs_bsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, nb);
clrbuf(bp);
/*
@ -247,8 +250,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
*/
for (i = 1;;) {
error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize,
NULL, &bp);
error = bread((void *)ip->i_devvp, indirs[i].in_lbn,
fs->fs_bsize, NULL, &bp);
if (error) {
brelse(bp);
return error;
@ -271,7 +274,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
}
nb = newb;
*allocblk++ = nb;
nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0);
nbp = getblk((void *)ip->i_devvp, indirs[i].in_lbn,
fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
/*
@ -302,7 +306,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
nb = newb;
*allocblk++ = nb;
if (bpp != NULL) {
nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0, 0);
nbp = getblk((void *)ip->i_devvp, lbn, fs->fs_bsize,
0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
*bpp = nbp;
@ -318,7 +323,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
}
brelse(bp);
if (bpp != NULL) {
error = bread(ip->i_devvp, lbn, (int)fs->fs_bsize, NULL, &nbp);
error = bread((void *)ip->i_devvp, lbn, (int)fs->fs_bsize,
NULL, &nbp);
if (error) {
brelse(nbp);
return error;
@ -329,11 +335,12 @@ ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
}
static int
ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize,
struct m_buf **bpp)
{
daddr_t lbn, lastlbn;
int size;
struct buf *bp, *nbp;
struct m_buf *bp, *nbp;
struct fs *fs = ip->i_fs;
struct indir indirs[UFS_NIADDR + 2];
daddr_t newb, pref, nb;
@ -386,8 +393,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
*/
if (bpp != NULL) {
error = bread(ip->i_devvp, lbn, fs->fs_bsize,
NULL, bpp);
error = bread((void *)ip->i_devvp, lbn,
fs->fs_bsize, NULL, bpp);
if (error) {
brelse(*bpp);
return (error);
@ -412,8 +419,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
*/
if (bpp != NULL) {
error = bread(ip->i_devvp, lbn, osize,
NULL, bpp);
error = bread((void *)ip->i_devvp, lbn,
osize, NULL, bpp);
if (error) {
brelse(*bpp);
return (error);
@ -442,7 +449,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
if (error)
return (error);
if (bpp != NULL) {
bp = getblk(ip->i_devvp, lbn, nsize, 0, 0, 0);
bp = getblk((void *)ip->i_devvp, lbn, nsize,
0, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
clrbuf(bp);
*bpp = bp;
@ -480,7 +488,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
return error;
nb = newb;
*allocblk++ = nb;
bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0);
bp = getblk((void *)ip->i_devvp, indirs[1].in_lbn,
fs->fs_bsize, 0, 0, 0);
bp->b_blkno = fsbtodb(fs, nb);
clrbuf(bp);
/*
@ -498,8 +507,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
*/
for (i = 1;;) {
error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize,
NULL, &bp);
error = bread((void *)ip->i_devvp, indirs[i].in_lbn,
fs->fs_bsize, NULL, &bp);
if (error) {
brelse(bp);
return error;
@ -522,7 +531,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
}
nb = newb;
*allocblk++ = nb;
nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0);
nbp = getblk((void *)ip->i_devvp, indirs[i].in_lbn,
fs->fs_bsize, 0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
/*
@ -553,7 +563,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
nb = newb;
*allocblk++ = nb;
if (bpp != NULL) {
nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0, 0);
nbp = getblk((void *)ip->i_devvp, lbn, fs->fs_bsize,
0, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
*bpp = nbp;
@ -569,7 +580,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp)
}
brelse(bp);
if (bpp != NULL) {
error = bread(ip->i_devvp, lbn, (int)fs->fs_bsize, NULL, &nbp);
error = bread((void *)ip->i_devvp, lbn, (int)fs->fs_bsize,
NULL, &nbp);
if (error) {
brelse(nbp);
return error;

View File

@ -59,7 +59,7 @@ void ffs_blkfree(struct inode *, daddr_t, long);
void ffs_clusteracct(struct fs *, struct cg *, int32_t, int);
/* ffs_balloc.c */
int ffs_balloc(struct inode *, off_t, int, struct buf **);
int ffs_balloc(struct inode *, off_t, int, struct m_buf **);
/* ffs_bswap.c */
void ffs_sb_swap(struct fs*, struct fs *);

View File

@ -55,16 +55,17 @@ __FBSDID("$FreeBSD$");
#include <dirent.h>
#include <util.h>
#include "ffs/buf.h"
#include "makefs.h"
#include "msdos.h"
#include <mkfs_msdos.h>
#include <fs/msdosfs/bpb.h>
#include "msdos/direntry.h"
#include <fs/msdosfs/denode.h>
#include <fs/msdosfs/msdosfsmount.h>
#undef clrbuf
#include "ffs/buf.h"
#include "makefs.h"
#include "msdos.h"
static int msdos_populate_dir(const char *, struct denode *, fsnode *,
fsnode *, fsinfo_t *);
@ -146,7 +147,7 @@ void
msdos_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
{
struct msdos_options_ex *msdos_opt = fsopts->fs_specific;
struct vnode vp, rootvp;
struct m_vnode vp, rootvp;
struct timeval start;
struct msdosfsmount *pmp;
uint32_t flags;
@ -184,7 +185,7 @@ msdos_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
vp.fs = fsopts;
flags = 0;
if ((pmp = msdosfs_mount(&vp)) == NULL)
if ((pmp = m_msdosfs_mount(&vp)) == NULL)
err(1, "msdosfs_mount");
if (msdosfs_root(pmp, &rootvp) != 0)

View File

@ -51,11 +51,21 @@ struct componentname {
size_t cn_namelen;
};
struct m_vnode;
struct m_buf;
int msdosfs_fsiflush(struct msdosfsmount *);
struct msdosfsmount *msdosfs_mount(struct vnode *);
int msdosfs_root(struct msdosfsmount *, struct vnode *);
struct msdosfsmount *msdosfs_mount(struct m_vnode *);
int msdosfs_root(struct msdosfsmount *, struct m_vnode *);
struct denode *msdosfs_mkfile(const char *, struct denode *, fsnode *);
struct denode *msdosfs_mkdire(const char *, struct denode *, fsnode *);
int m_readde(struct denode *dep, struct m_buf **bpp, struct direntry **epp);
int m_readep(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset,
struct m_buf **bpp, struct direntry **epp);
int m_extendfile(struct denode *dep, u_long count, struct m_buf **bpp,
u_long *ncp, int flags);
struct msdosfsmount *m_msdosfs_mount(struct m_vnode *devvp);
#endif

View File

@ -61,14 +61,14 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <util.h>
#include "ffs/buf.h"
#include <fs/msdosfs/bpb.h>
#include <fs/msdosfs/direntry.h>
#include <fs/msdosfs/denode.h>
#include <fs/msdosfs/fat.h>
#include <fs/msdosfs/msdosfsmount.h>
#undef clrbuf
#include "ffs/buf.h"
#include "makefs.h"
#include "msdos.h"
@ -93,7 +93,7 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset,
uint64_t inode;
struct direntry *direntptr;
struct denode *ldep;
struct buf *bp;
struct m_buf *bp;
MSDOSFS_DPRINTF(("deget(pmp %p, dirclust %lu, diroffset %lx, depp %p)\n",
pmp, dirclust, diroffset, depp));
@ -155,7 +155,7 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset,
ldep->de_MDate = ldep->de_CDate;
/* leave the other fields as garbage */
} else {
error = readep(pmp, dirclust, diroffset, &bp, &direntptr);
error = m_readep(pmp, dirclust, diroffset, &bp, &direntptr);
if (error) {
ldep->de_Name[0] = SLOT_DELETED;
@ -219,7 +219,7 @@ detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred)
daddr_t bn;
int boff;
int isadir = dep->de_Attributes & ATTR_DIRECTORY;
struct buf *bp;
struct m_buf *bp;
struct msdosfsmount *pmp = dep->de_pmp;
MSDOSFS_DPRINTF(("detrunc(): file %s, length %lu, flags %x\n",
@ -277,8 +277,8 @@ detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred)
if ((boff = length & pmp->pm_crbomask) != 0) {
if (isadir) {
bn = cntobn(pmp, eofentry);
error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
0, &bp);
error = bread((void *)pmp->pm_devvp, bn,
pmp->pm_bpcluster, 0, &bp);
if (error) {
brelse(bp);
MSDOSFS_DPRINTF(("detrunc(): bread fails %d\n",
@ -359,7 +359,7 @@ deextend(struct denode *dep, u_long length, struct ucred *cred)
if (count > 0) {
if (count > pmp->pm_freeclustercount)
return (ENOSPC);
error = extendfile(dep, count, NULL, NULL, DE_CLEAR);
error = m_extendfile(dep, count, NULL, NULL, DE_CLEAR);
if (error) {
/* truncate the added clusters away again */
(void) detrunc(dep, dep->de_FileSize, 0, cred);

View File

@ -59,14 +59,14 @@
#include <string.h>
#include <strings.h>
#include "ffs/buf.h"
#include <fs/msdosfs/bpb.h>
#include "msdos/direntry.h"
#include <fs/msdosfs/denode.h>
#include <fs/msdosfs/fat.h>
#include <fs/msdosfs/msdosfsmount.h>
#undef clrbuf
#include "ffs/buf.h"
#include "makefs.h"
#include "msdos.h"
@ -84,7 +84,7 @@ static int fatchain(struct msdosfsmount *pmp, u_long start, u_long count,
u_long fillwith);
static void fc_lookup(struct denode *dep, u_long findcn, u_long *frcnp,
u_long *fsrcnp);
static void updatefats(struct msdosfsmount *pmp, struct buf *bp,
static void updatefats(struct msdosfsmount *pmp, struct m_buf *bp,
u_long fatbn);
static __inline void
usemap_alloc(struct msdosfsmount *pmp, u_long cn);
@ -142,7 +142,7 @@ pcbmap(struct denode *dep, u_long findcn, daddr_t *bnp, u_long *cnp, int *sp)
u_long byteoffset;
u_long bn;
u_long bo;
struct buf *bp = NULL;
struct m_buf *bp = NULL;
u_long bp_bn = -1;
struct msdosfsmount *pmp = dep->de_pmp;
u_long bsize;
@ -206,7 +206,8 @@ pcbmap(struct denode *dep, u_long findcn, daddr_t *bnp, u_long *cnp, int *sp)
if (bn != bp_bn) {
if (bp)
brelse(bp);
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
error = bread((void *)pmp->pm_devvp, bn, bsize,
NOCRED, &bp);
if (error) {
brelse(bp);
return (error);
@ -309,9 +310,9 @@ fc_purge(struct denode *dep, u_int frcn)
* fatbn - block number relative to begin of filesystem of the modified FAT block.
*/
static void
updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn)
updatefats(struct msdosfsmount *pmp, struct m_buf *bp, u_long fatbn)
{
struct buf *bpn;
struct m_buf *bpn;
int cleanfat, i;
#ifdef MSDOSFS_DEBUG
@ -338,8 +339,8 @@ updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn)
for (i = 1; i < pmp->pm_FATs; i++) {
fatbn += pmp->pm_FATsecs;
/* getblk() never fails */
bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount,
0, 0, 0);
bpn = getblk((void *)pmp->pm_devvp, fatbn,
bp->b_bcount, 0, 0, 0);
memcpy(bpn->b_data, bp->b_data, bp->b_bcount);
/* Force the clean bit on in the other copies. */
if (cleanfat == 16)
@ -456,7 +457,7 @@ fatentry(int function, struct msdosfsmount *pmp, u_long cn, u_long *oldcontents,
int error;
u_long readcn;
u_long bn, bo, bsize, byteoffset;
struct buf *bp;
struct m_buf *bp;
#ifdef MSDOSFS_DEBUG
printf("fatentry(func %d, pmp %p, clust %lu, oldcon %p, newcon %lx)\n",
@ -494,7 +495,7 @@ fatentry(int function, struct msdosfsmount *pmp, u_long cn, u_long *oldcontents,
byteoffset = FATOFS(pmp, cn);
fatblock(pmp, byteoffset, &bn, &bsize, &bo);
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
error = bread((void *)pmp->pm_devvp, bn, bsize, NOCRED, &bp);
if (error) {
brelse(bp);
return (error);
@ -562,7 +563,7 @@ fatchain(struct msdosfsmount *pmp, u_long start, u_long count, u_long fillwith)
{
int error;
u_long bn, bo, bsize, byteoffset, readcn, newc;
struct buf *bp;
struct m_buf *bp;
#ifdef MSDOSFS_DEBUG
printf("fatchain(pmp %p, start %lu, count %lu, fillwith %lx)\n",
@ -577,7 +578,7 @@ fatchain(struct msdosfsmount *pmp, u_long start, u_long count, u_long fillwith)
while (count > 0) {
byteoffset = FATOFS(pmp, start);
fatblock(pmp, byteoffset, &bn, &bsize, &bo);
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
error = bread((void *)pmp->pm_devvp, bn, bsize, NOCRED, &bp);
if (error) {
brelse(bp);
return (error);
@ -813,7 +814,7 @@ int
freeclusterchain(struct msdosfsmount *pmp, u_long cluster)
{
int error;
struct buf *bp = NULL;
struct m_buf *bp = NULL;
u_long bn, bo, bsize, byteoffset;
u_long readcn, lbn = -1;
@ -823,7 +824,8 @@ freeclusterchain(struct msdosfsmount *pmp, u_long cluster)
if (lbn != bn) {
if (bp)
updatefats(pmp, bp, lbn);
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
error = bread((void *)pmp->pm_devvp, bn, bsize,
NOCRED, &bp);
if (error) {
brelse(bp);
return (error);
@ -871,7 +873,7 @@ freeclusterchain(struct msdosfsmount *pmp, u_long cluster)
int
fillinusemap(struct msdosfsmount *pmp)
{
struct buf *bp;
struct m_buf *bp;
u_long bn, bo, bsize, byteoffset, cn, readcn;
int error;
@ -898,7 +900,8 @@ fillinusemap(struct msdosfsmount *pmp)
if (bp != NULL)
brelse(bp);
fatblock(pmp, byteoffset, &bn, &bsize, NULL);
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
error = bread((void *)pmp->pm_devvp, bn, bsize,
NOCRED, &bp);
if (error != 0)
return (error);
}
@ -951,14 +954,14 @@ fillinusemap(struct msdosfsmount *pmp)
* field. This is left for the caller to do.
*/
int
extendfile(struct denode *dep, u_long count, struct buf **bpp, u_long *ncp,
m_extendfile(struct denode *dep, u_long count, struct m_buf **bpp, u_long *ncp,
int flags)
{
int error;
u_long frcn;
u_long cn, got;
struct msdosfsmount *pmp = dep->de_pmp;
struct buf *bp;
struct m_buf *bp;
/*
* Don't try to extend the root directory
@ -1039,7 +1042,7 @@ extendfile(struct denode *dep, u_long count, struct buf **bpp, u_long *ncp,
if ((flags & DE_CLEAR) &&
(dep->de_Attributes & ATTR_DIRECTORY)) {
while (got-- > 0) {
bp = getblk(pmp->pm_devvp,
bp = getblk((void *)pmp->pm_devvp,
cntobn(pmp, cn++),
pmp->pm_bpcluster, 0, 0, 0);
clrbuf(bp);

View File

@ -57,13 +57,14 @@
#include <stdio.h>
#include <string.h>
#include "ffs/buf.h"
#include <fs/msdosfs/bpb.h>
#include "msdos/direntry.h"
#include <fs/msdosfs/denode.h>
#include <fs/msdosfs/fat.h>
#include <fs/msdosfs/msdosfsmount.h>
#undef clrbuf
#include "ffs/buf.h"
#include "makefs.h"
#include "msdos.h"
@ -82,7 +83,7 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp,
u_long dirclust, diroffset;
struct direntry *ndep;
struct msdosfsmount *pmp = ddep->de_pmp;
struct buf *bp;
struct m_buf *bp;
daddr_t bn;
int blsize;
@ -101,7 +102,7 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp,
diroffset = ddep->de_fndoffset + sizeof(struct direntry)
- ddep->de_FileSize;
dirclust = de_clcount(pmp, diroffset);
error = extendfile(ddep, dirclust, 0, 0, DE_CLEAR);
error = m_extendfile(ddep, dirclust, 0, 0, DE_CLEAR);
if (error) {
(void)detrunc(ddep, ddep->de_FileSize, 0, NULL);
return error;
@ -125,7 +126,8 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp,
diroffset = ddep->de_fndoffset;
if (dirclust != MSDOSFSROOT)
diroffset &= pmp->pm_crbomask;
if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) != 0) {
if ((error = bread((void *)pmp->pm_devvp, bn, blsize, NOCRED,
&bp)) != 0) {
brelse(bp);
return error;
}
@ -155,7 +157,7 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp,
if (error)
return error;
error = bread(pmp->pm_devvp, bn, blsize,
error = bread((void *)pmp->pm_devvp, bn, blsize,
NOCRED, &bp);
if (error) {
brelse(bp);
@ -200,8 +202,8 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp,
* directory entry within the block.
*/
int
readep(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset,
struct buf **bpp, struct direntry **epp)
m_readep(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset,
struct m_buf **bpp, struct direntry **epp)
{
int error;
daddr_t bn;
@ -212,7 +214,8 @@ readep(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset,
&& de_blk(pmp, diroffset + blsize) > pmp->pm_rootdirsize)
blsize = de_bn2off(pmp, pmp->pm_rootdirsize) & pmp->pm_crbomask;
bn = detobn(pmp, dirclust, diroffset);
if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, bpp)) != 0) {
if ((error = bread((void *)pmp->pm_devvp, bn, blsize, NOCRED,
bpp)) != 0) {
brelse(*bpp);
*bpp = NULL;
return (error);
@ -228,10 +231,10 @@ readep(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset,
* entry within the block.
*/
int
readde(struct denode *dep, struct buf **bpp, struct direntry **epp)
m_readde(struct denode *dep, struct m_buf **bpp, struct direntry **epp)
{
return (readep(dep->de_pmp, dep->de_dirclust, dep->de_diroffset,
return (m_readep(dep->de_pmp, dep->de_dirclust, dep->de_diroffset,
bpp, epp));
}
@ -247,7 +250,7 @@ uniqdosname(struct denode *dep, struct componentname *cnp, u_char *cp)
int blsize;
u_long cn;
daddr_t bn;
struct buf *bp;
struct m_buf *bp;
int error;
if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME)
@ -271,7 +274,8 @@ uniqdosname(struct denode *dep, struct componentname *cnp, u_char *cp)
return 0;
return error;
}
error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
error = bread((void *)pmp->pm_devvp, bn, blsize,
NOCRED, &bp);
if (error) {
brelse(bp);
return error;

View File

@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <util.h>
#include "ffs/buf.h"
#include <fs/msdosfs/bootsect.h>
#include <fs/msdosfs/bpb.h>
#include "msdos/direntry.h"
@ -71,16 +70,16 @@ __FBSDID("$FreeBSD$");
#include <mkfs_msdos.h>
#undef clrbuf
#include "ffs/buf.h"
#include "makefs.h"
#include "msdos.h"
struct msdosfsmount *
msdosfs_mount(struct vnode *devvp)
m_msdosfs_mount(struct m_vnode *devvp)
{
struct msdosfsmount *pmp = NULL;
struct buf *bp;
struct m_buf *bp;
union bootsector *bsp;
struct byte_bpb33 *b33;
struct byte_bpb50 *b50;
@ -91,7 +90,7 @@ msdosfs_mount(struct vnode *devvp)
unsigned secsize = 512;
MSDOSFS_DPRINTF(("%s(bread 0)\n", __func__));
if ((error = bread(devvp, 0, secsize, 0, &bp)) != 0)
if ((error = bread((void *)devvp, 0, secsize, 0, &bp)) != 0)
goto error_exit;
bsp = (union bootsector *)bp->b_data;
@ -273,8 +272,8 @@ msdosfs_mount(struct vnode *devvp)
* 2KB or larger sectors, is the fsinfo structure
* padded at the end or in the middle?
*/
if ((error = bread(devvp, pmp->pm_fsinfo, pmp->pm_BytesPerSec,
0, &bp)) != 0)
if ((error = bread((void *)devvp, pmp->pm_fsinfo,
pmp->pm_BytesPerSec, 0, &bp)) != 0)
goto error_exit;
fp = (struct fsinfo *)bp->b_data;
if (!memcmp(fp->fsisig1, "RRaA", 4)
@ -307,7 +306,7 @@ msdosfs_mount(struct vnode *devvp)
* fillinusemap() needs pm_devvp.
*/
pmp->pm_dev = 0;
pmp->pm_devvp = devvp;
pmp->pm_devvp = (void *)devvp;
/*
* Have the inuse map filled in.
@ -348,11 +347,11 @@ msdosfs_mount(struct vnode *devvp)
}
int
msdosfs_root(struct msdosfsmount *pmp, struct vnode *vp) {
msdosfs_root(struct msdosfsmount *pmp, struct m_vnode *vp) {
struct denode *ndep;
int error;
*vp = *pmp->pm_devvp;
*vp = *(struct m_vnode *)pmp->pm_devvp;
if ((error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, &ndep)) != 0) {
errno = error;
return -1;
@ -368,15 +367,15 @@ int
msdosfs_fsiflush(struct msdosfsmount *pmp)
{
struct fsinfo *fp;
struct buf *bp;
struct m_buf *bp;
int error;
if (pmp->pm_fsinfo == 0 || (pmp->pm_flags & MSDOSFS_FSIMOD) == 0) {
error = 0;
goto out;
}
error = bread(pmp->pm_devvp, pmp->pm_fsinfo, pmp->pm_BytesPerSec,
NOCRED, &bp);
error = bread((void *)pmp->pm_devvp, pmp->pm_fsinfo,
pmp->pm_BytesPerSec, NOCRED, &bp);
if (error != 0) {
brelse(bp);
goto out;

View File

@ -64,13 +64,14 @@ __FBSDID("$FreeBSD$");
#include <time.h>
#include <unistd.h>
#include "ffs/buf.h"
#include <fs/msdosfs/bpb.h>
#include "msdos/direntry.h"
#include <fs/msdosfs/denode.h>
#include <fs/msdosfs/fat.h>
#include <fs/msdosfs/msdosfsmount.h>
#undef clrbuf
#include "ffs/buf.h"
#include "makefs.h"
#include "msdos.h"
@ -161,7 +162,7 @@ msdosfs_findslot(struct denode *dp, struct componentname *cnp)
u_int diroff;
int blsize;
struct msdosfsmount *pmp;
struct buf *bp = 0;
struct m_buf *bp = 0;
struct direntry *dep;
u_char dosfilename[12];
int wincnt = 1;
@ -216,7 +217,7 @@ msdosfs_findslot(struct denode *dp, struct componentname *cnp)
break;
return (error);
}
error = bread(pmp->pm_devvp, bn, blsize, 0, &bp);
error = bread((void *)pmp->pm_devvp, bn, blsize, 0, &bp);
if (error) {
return (error);
}
@ -417,12 +418,12 @@ msdosfs_mkfile(const char *path, struct denode *pdep, fsnode *node)
static int
msdosfs_updatede(struct denode *dep)
{
struct buf *bp;
struct m_buf *bp;
struct direntry *dirp;
int error;
dep->de_flag &= ~DE_MODIFIED;
error = readde(dep, &bp, &dirp);
error = m_readde(dep, &bp, &dirp);
if (error)
return error;
DE_EXTERNALIZE(dirp, dep);
@ -441,7 +442,7 @@ msdosfs_wfile(const char *path, struct denode *dep, fsnode *node)
struct stat *st = &node->inode->st;
size_t nsize, offs;
struct msdosfsmount *pmp = dep->de_pmp;
struct buf *bp;
struct m_buf *bp;
char *dat;
u_long cn = 0;
@ -494,7 +495,8 @@ msdosfs_wfile(const char *path, struct denode *dep, fsnode *node)
MSDOSFS_DPRINTF(("%s(cn=%lu, bn=%llu, blsize=%d)\n",
__func__, cn, (unsigned long long)bn, blsize));
if ((error = bread(pmp->pm_devvp, bn, blsize, 0, &bp)) != 0) {
if ((error = bread((void *)pmp->pm_devvp, bn, blsize, 0,
&bp)) != 0) {
MSDOSFS_DPRINTF(("bread %d\n", error));
goto out;
}
@ -546,7 +548,7 @@ msdosfs_mkdire(const char *path, struct denode *pdep, fsnode *node) {
int error;
u_long newcluster, pcl, bn;
struct direntry *denp;
struct buf *bp;
struct m_buf *bp;
cn.cn_nameptr = node->name;
cn.cn_namelen = strlen(node->name);
@ -582,7 +584,7 @@ msdosfs_mkdire(const char *path, struct denode *pdep, fsnode *node) {
MSDOSFS_DPRINTF(("%s(newcluster %lu, bn=%lu)\n",
__func__, newcluster, bn));
/* always succeeds */
bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0, 0);
bp = getblk((void *)pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0, 0);
memset(bp->b_data, 0, pmp->pm_bpcluster);
memcpy(bp->b_data, &dosdirtemplate, sizeof dosdirtemplate);
denp = (struct direntry *)bp->b_data;