Date: Sun, 21 Feb 2021 11:14:50 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: d485c77f203f - main - Remove #define _KERNEL hacks from libprocstat Message-ID: <202102211114.11LBEoni004994@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d485c77f203fb0f4cdc08dea5ff81631b51d8809 commit d485c77f203fb0f4cdc08dea5ff81631b51d8809 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-02-18 13:43:58 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-02-21 09:38:21 +0000 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 --- lib/libprocstat/common_kvm.c | 3 +- lib/libprocstat/libprocstat.c | 5 +-- lib/libprocstat/zfs_defs.c | 2 +- lib/libufs/block.c | 2 + lib/libufs/cgroup.c | 2 + lib/libufs/inode.c | 2 + lib/libufs/sblock.c | 2 + lib/libufs/type.c | 2 + sbin/dump/main.c | 2 + sbin/ffsinfo/ffsinfo.c | 2 + sbin/fsck_ffs/suj.c | 2 + sbin/mksnap_ffs/mksnap_ffs.c | 4 ++ sbin/newfs/newfs.c | 2 + sbin/tunefs/tunefs.c | 2 + sys/fs/devfs/devfs.h | 7 ++++ sys/fs/devfs/devfs_int.h | 4 +- sys/fs/msdosfs/denode.h | 1 + sys/sys/buf.h | 3 +- sys/sys/mount.h | 4 ++ sys/sys/pipe.h | 8 ++-- sys/ufs/ufs/extattr.h | 9 +++-- sys/ufs/ufs/inode.h | 6 ++- sys/ufs/ufs/ufsmount.h | 8 ++-- usr.sbin/makefs/ffs.c | 14 +++---- usr.sbin/makefs/ffs/buf.c | 18 ++++----- usr.sbin/makefs/ffs/buf.h | 16 ++++---- usr.sbin/makefs/ffs/ffs_alloc.c | 16 ++++---- usr.sbin/makefs/ffs/ffs_balloc.c | 70 ++++++++++++++++++++-------------- usr.sbin/makefs/ffs/ffs_extern.h | 2 +- usr.sbin/makefs/msdos.c | 13 ++++--- usr.sbin/makefs/msdos.h | 14 ++++++- usr.sbin/makefs/msdos/msdosfs_denode.c | 16 ++++---- usr.sbin/makefs/msdos/msdosfs_fat.c | 43 +++++++++++---------- usr.sbin/makefs/msdos/msdosfs_lookup.c | 28 ++++++++------ usr.sbin/makefs/msdos/msdosfs_vfsops.c | 27 +++++++------ usr.sbin/makefs/msdos/msdosfs_vnops.c | 20 +++++----- 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> *** 591 LINES SKIPPED ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102211114.11LBEoni004994>