aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2021-02-18 13:43:58 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2021-02-21 09:38:21 +0000
commitd485c77f203fb0f4cdc08dea5ff81631b51d8809 (patch)
treeedaccf839fb300b07f445a8d463544e6f472db91
parent750ea20d3fb143a95ccf3ff84cfbe86cce9b9cac (diff)
downloadsrc-d485c77f203fb0f4cdc08dea5ff81631b51d8809.tar.gz
src-d485c77f203fb0f4cdc08dea5ff81631b51d8809.zip
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
-rw-r--r--lib/libprocstat/common_kvm.c3
-rw-r--r--lib/libprocstat/libprocstat.c5
-rw-r--r--lib/libprocstat/zfs_defs.c2
-rw-r--r--lib/libufs/block.c2
-rw-r--r--lib/libufs/cgroup.c2
-rw-r--r--lib/libufs/inode.c2
-rw-r--r--lib/libufs/sblock.c2
-rw-r--r--lib/libufs/type.c2
-rw-r--r--sbin/dump/main.c2
-rw-r--r--sbin/ffsinfo/ffsinfo.c2
-rw-r--r--sbin/fsck_ffs/suj.c2
-rw-r--r--sbin/mksnap_ffs/mksnap_ffs.c4
-rw-r--r--sbin/newfs/newfs.c2
-rw-r--r--sbin/tunefs/tunefs.c2
-rw-r--r--sys/fs/devfs/devfs.h7
-rw-r--r--sys/fs/devfs/devfs_int.h4
-rw-r--r--sys/fs/msdosfs/denode.h1
-rw-r--r--sys/sys/buf.h3
-rw-r--r--sys/sys/mount.h4
-rw-r--r--sys/sys/pipe.h8
-rw-r--r--sys/ufs/ufs/extattr.h9
-rw-r--r--sys/ufs/ufs/inode.h6
-rw-r--r--sys/ufs/ufs/ufsmount.h8
-rw-r--r--usr.sbin/makefs/ffs.c14
-rw-r--r--usr.sbin/makefs/ffs/buf.c18
-rw-r--r--usr.sbin/makefs/ffs/buf.h16
-rw-r--r--usr.sbin/makefs/ffs/ffs_alloc.c16
-rw-r--r--usr.sbin/makefs/ffs/ffs_balloc.c70
-rw-r--r--usr.sbin/makefs/ffs/ffs_extern.h2
-rw-r--r--usr.sbin/makefs/msdos.c13
-rw-r--r--usr.sbin/makefs/msdos.h14
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_denode.c16
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_fat.c43
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_lookup.c28
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_vfsops.c27
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_vnops.c20
36 files changed, 225 insertions, 156 deletions
diff --git a/lib/libprocstat/common_kvm.c b/lib/libprocstat/common_kvm.c
index 2889f802775d..0ce2a2900f66 100644
--- a/lib/libprocstat/common_kvm.c
+++ b/lib/libprocstat/common_kvm.c
@@ -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>
diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c
index a2de61855815..7ccf6c343705 100644
--- a/lib/libprocstat/libprocstat.c
+++ b/lib/libprocstat/libprocstat.c
@@ -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>
diff --git a/lib/libprocstat/zfs_defs.c b/lib/libprocstat/zfs_defs.c
index c41054f05136..66acef743dc4 100644
--- a/lib/libprocstat/zfs_defs.c
+++ b/lib/libprocstat/zfs_defs.c
@@ -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>
diff --git a/lib/libufs/block.c b/lib/libufs/block.c
index 7accc8863693..3c99d288a402 100644
--- a/lib/libufs/block.c
+++ b/lib/libufs/block.c
@@ -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>
diff --git a/lib/libufs/cgroup.c b/lib/libufs/cgroup.c
index 1c3e271c4295..90b28eadad2c 100644
--- a/lib/libufs/cgroup.c
+++ b/lib/libufs/cgroup.c
@@ -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>
diff --git a/lib/libufs/inode.c b/lib/libufs/inode.c
index 497ff4c854f6..c4a0cab9e95a 100644
--- a/lib/libufs/inode.c
+++ b/lib/libufs/inode.c
@@ -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>
diff --git a/lib/libufs/sblock.c b/lib/libufs/sblock.c
index 1d687d6d41aa..3b65e79b02b5 100644
--- a/lib/libufs/sblock.c
+++ b/lib/libufs/sblock.c
@@ -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>
diff --git a/lib/libufs/type.c b/lib/libufs/type.c
index 653ef8ceeea1..a060f8ec5abf 100644
--- a/lib/libufs/type.c
+++ b/lib/libufs/type.c
@@ -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>
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index bbc54d7ab5d7..8752f2c1bea5 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -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>
diff --git a/sbin/ffsinfo/ffsinfo.c b/sbin/ffsinfo/ffsinfo.c
index 9bd3210986a9..33ec5f175cbd 100644
--- a/sbin/ffsinfo/ffsinfo.c
+++ b/sbin/ffsinfo/ffsinfo.c
@@ -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>
diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c
index aa2085e2fa77..4ad86b0dc14d 100644
--- a/sbin/fsck_ffs/suj.c
+++ b/sbin/fsck_ffs/suj.c
@@ -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>
diff --git a/sbin/mksnap_ffs/mksnap_ffs.c b/sbin/mksnap_ffs/mksnap_ffs.c
index 5d230701de85..0e3586fcb2e2 100644
--- a/sbin/mksnap_ffs/mksnap_ffs.c
+++ b/sbin/mksnap_ffs/mksnap_ffs.c
@@ -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>
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index 232436c0aa7f..a2d97131d3a7 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -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>
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c
index 2eca8e0a3e36..e59b583ea58b 100644
--- a/sbin/tunefs/tunefs.c
+++ b/sbin/tunefs/tunefs.c
@@ -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>
diff --git a/sys/fs/devfs/devfs.h b/sys/fs/devfs/devfs.h
index aef291601289..b62438ff6730 100644
--- a/sys/fs/devfs/devfs.h
+++ b/sys/fs/devfs/devfs.h
@@ -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))
diff --git a/sys/fs/devfs/devfs_int.h b/sys/fs/devfs/devfs_int.h
index 5c3cb17eca61..e5afa311cbfd 100644
--- a/sys/fs/devfs/devfs_int.h
+++ b/sys/fs/devfs/devfs_int.h
@@ -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 *);
diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h
index b198a6a39d81..9a4de4acbe2e 100644
--- a/sys/fs/msdosfs/denode.h
+++ b/sys/fs/msdosfs/denode.h
@@ -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 *);
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index 2997560b9ab3..aacad3a057d2 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -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;
};
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
index 9ae5f58e5218..ca3261a22e62 100644
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -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.
*/
diff --git a/sys/sys/pipe.h b/sys/sys/pipe.h
index f8b008151c6a..c9f222ffb01a 100644
--- a/sys/sys/pipe.h
+++ b/sys/sys/pipe.h
@@ -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_ */
diff --git a/sys/ufs/ufs/extattr.h b/sys/ufs/ufs/extattr.h
index 781cc782f415..fa20f8c0b936 100644
--- a/sys/ufs/ufs/extattr.h
+++ b/sys/ufs/ufs/extattr.h
@@ -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;
diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h
index 4515dcbed401..e00a89b012d0 100644
--- a/sys/ufs/ufs/inode.h
+++ b/sys/ufs/ufs/inode.h
@@ -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);
diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h
index 57e163c11d77..0dfcecb178af 100644
--- a/sys/ufs/ufs/ufsmount.h
+++ b/sys/ufs/ufs/ufsmount.h
@@ -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
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
index 4dfb37889b53..dcc6eb5cbed7 100644
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -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(
diff --git a/usr.sbin/makefs/ffs/buf.c b/usr.sbin/makefs/ffs/buf.c
index 959734cacddf..ccbfd8ae1e23 100644
--- a/usr.sbin/makefs/ffs/buf.c
+++ b/usr.sbin/makefs/ffs/buf.c
@@ -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)
diff --git a/usr.sbin/makefs/ffs/buf.h b/usr.sbin/makefs/ffs/buf.h
index 3bdd7ca2a9f1..31196b8b2fbe 100644
--- a/usr.sbin/makefs/ffs/buf.h
+++ b/usr.sbin/makefs/ffs/buf.h
@@ -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)
diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c
index 88d95d6e5dda..c31106772b45 100644
--- a/usr.sbin/makefs/ffs/ffs_alloc.c
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c
@@ -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;
diff --git a/usr.sbin/makefs/ffs/ffs_balloc.c b/usr.sbin/makefs/ffs/ffs_balloc.c
index d56ed061457b..275ec4c04471 100644
--- a/usr.sbin/makefs/ffs/ffs_balloc.c
+++ b/usr.sbin/makefs/ffs/ffs_balloc.c
@@ -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;
diff --git a/usr.sbin/makefs/ffs/ffs_extern.h b/usr.sbin/makefs/ffs/ffs_extern.h
index b4d4bbaef6e9..12ba0b77989c 100644
--- a/usr.sbin/makefs/ffs/ffs_extern.h
+++ b/usr.sbin/makefs/ffs/ffs_extern.h
@@ -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 *);
diff --git a/usr.sbin/makefs/msdos.c b/usr.sbin/makefs/msdos.c
index a0e0f7174f25..567122c1db7e 100644
--- a/usr.sbin/makefs/msdos.c
+++ b/usr.sbin/makefs/msdos.c
@@ -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)
diff --git a/usr.sbin/makefs/msdos.h b/usr.sbin/makefs/msdos.h
index d9f1cc4cdb11..a51420de76e5 100644
--- a/usr.sbin/makefs/msdos.h
+++ b/usr.sbin/makefs/msdos.h
@@ -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
diff --git a/usr.sbin/makefs/msdos/msdosfs_denode.c b/usr.sbin/makefs/msdos/msdosfs_denode.c
index 283ef2e83e0b..f2faed234228 100644
--- a/usr.sbin/makefs/msdos/msdosfs_denode.c
+++ b/usr.sbin/makefs/msdos/msdosfs_denode.c
@@ -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);
diff --git a/usr.sbin/makefs/msdos/msdosfs_fat.c b/usr.sbin/makefs/msdos/msdosfs_fat.c
index eacc448b09de..a70b5741aa78 100644
--- a/usr.sbin/makefs/msdos/msdosfs_fat.c
+++ b/usr.sbin/makefs/msdos/msdosfs_fat.c
@@ -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);
diff --git a/usr.sbin/makefs/msdos/msdosfs_lookup.c b/usr.sbin/makefs/msdos/msdosfs_lookup.c
index 27ce216a488f..3fca0532468b 100644
--- a/usr.sbin/makefs/msdos/msdosfs_lookup.c
+++ b/usr.sbin/makefs/msdos/msdosfs_lookup.c
@@ -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;
diff --git a/usr.sbin/makefs/msdos/msdosfs_vfsops.c b/usr.sbin/makefs/msdos/msdosfs_vfsops.c
index 07fc91cccd4a..b6788f6876f9 100644
--- a/usr.sbin/makefs/msdos/msdosfs_vfsops.c
+++ b/usr.sbin/makefs/msdos/msdosfs_vfsops.c
@@ -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 @@ error_exit:
}
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;
diff --git a/usr.sbin/makefs/msdos/msdosfs_vnops.c b/usr.sbin/makefs/msdos/msdosfs_vnops.c
index 8bd4d3d498d8..2233c4b35eb2 100644
--- a/usr.sbin/makefs/msdos/msdosfs_vnops.c
+++ b/usr.sbin/makefs/msdos/msdosfs_vnops.c
@@ -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 @@ bad:
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;