From b8be571c6914cd5d12e8670b85db44b5fadf50b7 Mon Sep 17 00:00:00 2001
From: Chris Johns <chrisj@rtems.org>
Date: Mon, 2 Aug 2021 15:09:41 +1000
Subject: [PATCH rtems-libbsd v4 15/19] sys/kern: Add VFS support

- Refactor the libio interface

- Move syscalls into an rtemsbsd location

- Provide a root directory mount point

Update #4475
---
 README.md                                     |   19 +-
 freebsd/sys/fs/deadfs/dead_vnops.c            |    2 +
 freebsd/sys/fs/pseudofs/pseudofs.c            |    4 +-
 freebsd/sys/fs/pseudofs/pseudofs_fileno.c     |    4 +-
 freebsd/sys/fs/pseudofs/pseudofs_vncache.c    |    4 +-
 freebsd/sys/fs/pseudofs/pseudofs_vnops.c      |   24 +-
 freebsd/sys/kern/kern_descrip.c               |   68 +-
 freebsd/sys/kern/kern_event.c                 |  274 +-
 freebsd/sys/kern/kern_mib.c                   |    2 -
 freebsd/sys/kern/kern_sysctl.c                |    4 -
 freebsd/sys/kern/subr_pctrie.c                |    4 +-
 freebsd/sys/kern/subr_uio.c                   |    2 +-
 freebsd/sys/kern/sys_generic.c                |  216 +-
 freebsd/sys/kern/sys_pipe.c                   |  368 +-
 freebsd/sys/kern/sys_socket.c                 |  274 +-
 freebsd/sys/kern/uipc_socket.c                |   16 -
 freebsd/sys/kern/uipc_syscalls.c              |  527 +-
 freebsd/sys/kern/uipc_usrreq.c                |   10 +-
 freebsd/sys/kern/vfs_acl.c                    |    2 +
 freebsd/sys/kern/vfs_aio.c                    |  248 +-
 freebsd/sys/kern/vfs_bio.c                    |  142 +-
 freebsd/sys/kern/vfs_cache.c                  |   14 +-
 freebsd/sys/kern/vfs_cluster.c                |    9 +-
 freebsd/sys/kern/vfs_default.c                |   36 +-
 freebsd/sys/kern/vfs_export.c                 |   18 +-
 freebsd/sys/kern/vfs_extattr.c                |    4 +
 freebsd/sys/kern/vfs_hash.c                   |    2 +
 freebsd/sys/kern/vfs_init.c                   |   14 +
 freebsd/sys/kern/vfs_lookup.c                 |   16 +-
 freebsd/sys/kern/vfs_mount.c                  |    8 +
 freebsd/sys/kern/vfs_subr.c                   |   88 +-
 freebsd/sys/kern/vfs_syscalls.c               |   68 +-
 freebsd/sys/kern/vfs_vnops.c                  |   93 +-
 freebsd/sys/net/route.c                       |   18 -
 freebsd/sys/opencrypto/cryptodev.c            |   85 +-
 freebsd/sys/sys/bio.h                         |    2 +
 freebsd/sys/sys/capsicum.h                    |    6 +-
 freebsd/sys/sys/conf.h                        |    4 -
 freebsd/sys/sys/eventvar.h                    |    2 -
 freebsd/sys/sys/file.h                        |  184 +-
 freebsd/sys/sys/filedesc.h                    |   85 +-
 freebsd/sys/sys/jail.h                        |   11 +
 freebsd/sys/sys/mount.h                       |   22 +
 freebsd/sys/sys/proc.h                        |    2 +
 freebsd/sys/sys/resourcevar.h                 |    9 +-
 freebsd/sys/sys/sysctl.h                      |    8 -
 freebsd/sys/sys/sysent.h                      |    4 +
 freebsd/sys/sys/sysproto.h                    |   94 +-
 freebsd/sys/sys/user.h                        |    4 -
 freebsd/sys/sys/vnode.h                       |   13 +-
 freebsd/sys/vm/uma_core.c                     |    8 +-
 freebsd/sys/vm/vm_extern.h                    |   12 +
 freebsd/sys/vm/vm_meter.c                     |    6 +-
 libbsd.py                                     |   49 +-
 rtemsbsd/fs/rootfs/rootfs.c                   |   94 +
 rtemsbsd/fs/rootfs/rootvfs.c                  |  656 +++
 rtemsbsd/include/machine/atomic.h             | 1805 ++-----
 rtemsbsd/include/machine/rtems-bsd-config.h   |   12 +
 .../machine/rtems-bsd-kernel-namespace.h      |  692 +++
 .../include/machine/rtems-bsd-kernel-space.h  |  154 +-
 rtemsbsd/include/machine/rtems-bsd-libio.h    |  330 ++
 rtemsbsd/include/machine/rtems-bsd-page.h     |    2 +
 rtemsbsd/include/machine/rtems-bsd-vfs.h      |   89 +
 rtemsbsd/include/rtems/bsd/bsd.h              |   14 +
 .../include/rtems/bsd/local/opt_pseudofs.h    |    0
 rtemsbsd/include/rtems/bsd/local/opt_swap.h   |    0
 .../include/rtems/bsd/local/opt_watchdog.h    |    0
 rtemsbsd/include/rtems/bsd/local/vnode_if.h   | 1951 +++++++
 .../rtems/bsd/local/vnode_if_newproto.h       |   84 +
 .../rtems/bsd/local/vnode_if_typedef.h        |  224 +
 rtemsbsd/include/rtems/bsd/rootfs.h           |   51 +
 rtemsbsd/include/sys/bio.h                    |    1 -
 rtemsbsd/include/sys/namei.h                  |    1 -
 rtemsbsd/include/sys/sysent.h                 |    1 -
 rtemsbsd/include/vm/vm_object.h               |   17 +-
 rtemsbsd/include/vm/vm_pager.h                |   20 +
 .../rtems/rtems-bsd-allocator-domain-size.c   |    1 +
 .../rtems-bsd-get-allocator-domain-size.c     |    3 +
 rtemsbsd/rtems/rtems-bsd-libio.c              |  193 +
 rtemsbsd/rtems/rtems-bsd-mountroot.c          |  124 +
 rtemsbsd/rtems/rtems-bsd-syscall-api.c        | 1506 +++++-
 rtemsbsd/rtems/rtems-kernel-capability.c      |   71 +
 rtemsbsd/rtems/rtems-kernel-dev.c             |   64 +
 rtemsbsd/rtems/rtems-kernel-dirent.c          |   52 +
 rtemsbsd/rtems/rtems-kernel-init.c            |   95 +-
 rtemsbsd/rtems/rtems-kernel-pager.c           |  171 +
 rtemsbsd/rtems/rtems-kernel-param.c           |   40 +
 rtemsbsd/rtems/rtems-kernel-vfs.c             |  941 ++++
 rtemsbsd/rtems/rtems-kernel-vmem.c            |   55 +
 rtemsbsd/sys/fs/devfs/devfs_devs.c            |  177 +-
 rtemsbsd/sys/kern/vnode_if.c                  | 4763 +++++++++++++++++
 .../include/rtems/bsd/test/default-init.h     |    7 +
 testsuite/swi01/init.c                        |    3 -
 testsuite/syscalls01/test_main.c              |   20 +-
 testsuite/thread01/test_main.c                |   12 +-
 testsuite/timeout01/init.c                    |    3 -
 wscript                                       |    4 +-
 97 files changed, 14479 insertions(+), 3236 deletions(-)
 create mode 100644 rtemsbsd/fs/rootfs/rootfs.c
 create mode 100644 rtemsbsd/fs/rootfs/rootvfs.c
 create mode 100644 rtemsbsd/include/machine/rtems-bsd-libio.h
 create mode 100644 rtemsbsd/include/machine/rtems-bsd-vfs.h
 create mode 100644 rtemsbsd/include/rtems/bsd/local/opt_pseudofs.h
 create mode 100644 rtemsbsd/include/rtems/bsd/local/opt_swap.h
 create mode 100644 rtemsbsd/include/rtems/bsd/local/opt_watchdog.h
 create mode 100644 rtemsbsd/include/rtems/bsd/local/vnode_if.h
 create mode 100644 rtemsbsd/include/rtems/bsd/local/vnode_if_newproto.h
 create mode 100644 rtemsbsd/include/rtems/bsd/local/vnode_if_typedef.h
 create mode 100644 rtemsbsd/include/rtems/bsd/rootfs.h
 delete mode 100644 rtemsbsd/include/sys/bio.h
 delete mode 100644 rtemsbsd/include/sys/namei.h
 delete mode 100644 rtemsbsd/include/sys/sysent.h
 create mode 100644 rtemsbsd/rtems/rtems-bsd-libio.c
 create mode 100644 rtemsbsd/rtems/rtems-bsd-mountroot.c
 create mode 100644 rtemsbsd/rtems/rtems-kernel-capability.c
 create mode 100644 rtemsbsd/rtems/rtems-kernel-dev.c
 create mode 100644 rtemsbsd/rtems/rtems-kernel-dirent.c
 create mode 100644 rtemsbsd/rtems/rtems-kernel-pager.c
 create mode 100644 rtemsbsd/rtems/rtems-kernel-param.c
 create mode 100644 rtemsbsd/rtems/rtems-kernel-vfs.c
 create mode 100644 rtemsbsd/rtems/rtems-kernel-vmem.c
 create mode 100644 rtemsbsd/sys/kern/vnode_if.c

diff --git a/README.md b/README.md
index 703e35b8..c9b525cf 100644
--- a/README.md
+++ b/README.md
@@ -216,7 +216,7 @@ An example to turn on a verbose kernel boot, verbose sysinit and bus debugging
 configure with:
 
 ```
---freebsd-options=bootverbose,verbose_sysinit,bus_debug
+--freebsd-options=bootverbose,verbose_sysinit,bus_debug,debug_locks,ktr,ktr_verbose
 ```
 
 The LibBSD Waf support splits the options and converts them to uppercase and
@@ -224,12 +224,17 @@ adds them -D options on the compiler command line.
 
 The list is:
 
- bootverbose:     Verbose boot of the kernel
- verbose_sysinit: Verbose printing of all the SYSINIT calls
- bus_debug:       Bus debugging support
- ktr:             Kernel trace
- ktr_verbose:     Verbose kernel trace
- invariants:      Invariants build of the kernel
+ bootverbose:             Verbose boot of the kernel
+ verbose_sysinit:         Verbose printing of all the SYSINIT calls
+ bus_debug:               Bus debugging support
+ ktr:                     Kernel trace
+ ktr_verbose:             Verbose kernel trace
+ debug_locks:             FreeBSD locks debugging
+ invariants:              Invariants build of the kernel
+ invariant_support:       Support for Invariants (needed with invariants)
+ rtems_bsd_descrip_trace: RTEMS BSD descriptor maping trace
+ rtems_bsd_syscall_trace: RTEMS BSD system call trace
+ rtems_bsd_vfs_trace      RTEMS VFS to libio trace
 
 SMP Requirements
 ----------------
diff --git a/freebsd/sys/fs/deadfs/dead_vnops.c b/freebsd/sys/fs/deadfs/dead_vnops.c
index a3153aed..3fdf252a 100644
--- a/freebsd/sys/fs/deadfs/dead_vnops.c
+++ b/freebsd/sys/fs/deadfs/dead_vnops.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
diff --git a/freebsd/sys/fs/pseudofs/pseudofs.c b/freebsd/sys/fs/pseudofs/pseudofs.c
index 73d3c7cb..519a2df5 100644
--- a/freebsd/sys/fs/pseudofs/pseudofs.c
+++ b/freebsd/sys/fs/pseudofs/pseudofs.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -31,7 +33,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_pseudofs.h"
+#include <rtems/bsd/local/opt_pseudofs.h>
 
 #include <sys/param.h>
 #include <sys/kernel.h>
diff --git a/freebsd/sys/fs/pseudofs/pseudofs_fileno.c b/freebsd/sys/fs/pseudofs/pseudofs_fileno.c
index 2c6b2d1f..908c89be 100644
--- a/freebsd/sys/fs/pseudofs/pseudofs_fileno.c
+++ b/freebsd/sys/fs/pseudofs/pseudofs_fileno.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -31,7 +33,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_pseudofs.h"
+#include <rtems/bsd/local/opt_pseudofs.h>
 
 #include <sys/param.h>
 #include <sys/kernel.h>
diff --git a/freebsd/sys/fs/pseudofs/pseudofs_vncache.c b/freebsd/sys/fs/pseudofs/pseudofs_vncache.c
index 05dd6569..c7361332 100644
--- a/freebsd/sys/fs/pseudofs/pseudofs_vncache.c
+++ b/freebsd/sys/fs/pseudofs/pseudofs_vncache.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -31,7 +33,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_pseudofs.h"
+#include <rtems/bsd/local/opt_pseudofs.h>
 
 #include <sys/param.h>
 #include <sys/kernel.h>
diff --git a/freebsd/sys/fs/pseudofs/pseudofs_vnops.c b/freebsd/sys/fs/pseudofs/pseudofs_vnops.c
index da35f062..3953430a 100644
--- a/freebsd/sys/fs/pseudofs/pseudofs_vnops.c
+++ b/freebsd/sys/fs/pseudofs/pseudofs_vnops.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -31,7 +33,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_pseudofs.h"
+#include <rtems/bsd/local/opt_pseudofs.h>
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -95,6 +97,7 @@ pfs_visible_proc(struct thread *td, struct pfs_node *pn, struct proc *proc)
 
 	PROC_LOCK_ASSERT(proc, MA_OWNED);
 
+#ifndef __rtems__
 	visible = ((proc->p_flag & P_WEXIT) == 0);
 	if (visible)
 		visible = (p_cansee(td, proc) == 0);
@@ -102,6 +105,7 @@ pfs_visible_proc(struct thread *td, struct pfs_node *pn, struct proc *proc)
 		visible = pn_vis(td, proc, pn);
 	if (!visible)
 		return (0);
+#endif /* __rtems__ */
 	return (1);
 }
 
@@ -118,7 +122,11 @@ pfs_visible(struct thread *td, struct pfs_node *pn, pid_t pid,
 		*p = NULL;
 	if (pid == NO_PID)
 		PFS_RETURN (1);
+#ifndef __rtems__
 	proc = allproc_locked ? pfind_locked(pid) : pfind(pid);
+#else /* __rtems__ */
+	proc = &proc0;
+#endif /* __rtems__ */
 	if (proc == NULL)
 		PFS_RETURN (0);
 	if (pfs_visible_proc(td, pn, proc)) {
@@ -177,7 +185,11 @@ pfs_close(struct vop_close_args *va)
 		PFS_RETURN (0);
 
 	if (pvd->pvd_pid != NO_PID) {
+#ifndef __rtems__
 		proc = pfind(pvd->pvd_pid);
+#else /* __rtems__ */
+		proc = &proc0;
+#endif /* __rtems__ */
 	} else {
 		proc = NULL;
 	}
@@ -241,13 +253,17 @@ pfs_getattr(struct vop_getattr_args *va)
 		break;
 	}
 
+#ifndef __rtems__
 	if (proc != NULL) {
 		vap->va_uid = proc->p_ucred->cr_ruid;
 		vap->va_gid = proc->p_ucred->cr_rgid;
 	} else {
+#endif /* __rtems__ */
 		vap->va_uid = 0;
 		vap->va_gid = 0;
+#ifndef __rtems__
 	}
+#endif /* __rtems__ */
 
 	if (pn->pn_attr != NULL)
 		error = pn_attr(curthread, proc, pn, vap);
@@ -713,10 +729,14 @@ pfs_iterate(struct thread *td, struct proc *proc, struct pfs_node *pd,
 	}
 	if (*pn != NULL && (*pn)->pn_type == pfstype_procdir) {
 		/* next process */
+#ifndef __rtems__
 		if (*p == NULL)
 			*p = LIST_FIRST(&allproc);
 		else
 			*p = LIST_NEXT(*p, p_list);
+#else /* __rtems__ */
+		*p = &proc0;
+#endif /* __rtems__ */
 		/* out of processes: next node */
 		if (*p == NULL)
 			*pn = (*pn)->pn_next;
@@ -895,6 +915,7 @@ pfs_readlink(struct vop_readlink_args *va)
 	if (pn->pn_fill == NULL)
 		PFS_RETURN (EIO);
 
+#ifndef __rtems__
 	if (pvd->pvd_pid != NO_PID) {
 		if ((proc = pfind(pvd->pvd_pid)) == NULL)
 			PFS_RETURN (EIO);
@@ -905,6 +926,7 @@ pfs_readlink(struct vop_readlink_args *va)
 		_PHOLD(proc);
 		PROC_UNLOCK(proc);
 	}
+#endif /* __rtems__ */
 	vhold(vn);
 	locked = VOP_ISLOCKED(vn);
 	VOP_UNLOCK(vn, 0);
diff --git a/freebsd/sys/kern/kern_descrip.c b/freebsd/sys/kern/kern_descrip.c
index 423968b2..ddc50633 100644
--- a/freebsd/sys/kern/kern_descrip.c
+++ b/freebsd/sys/kern/kern_descrip.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -39,9 +41,9 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_capsicum.h"
-#include "opt_ddb.h"
-#include "opt_ktrace.h"
+#include <rtems/bsd/local/opt_capsicum.h>
+#include <rtems/bsd/local/opt_ddb.h>
+#include <rtems/bsd/local/opt_ktrace.h>
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -74,7 +76,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/syscallsubr.h>
 #include <sys/sysctl.h>
 #include <sys/sysproto.h>
-#include <sys/unistd.h>
+#include <rtems/bsd/sys/unistd.h>
 #include <sys/user.h>
 #include <sys/vnode.h>
 #ifdef KTRACE
@@ -360,6 +362,7 @@ sys_getdtablesize(struct thread *td, struct getdtablesize_args *uap)
 	return (0);
 }
 
+#ifndef __rtems__
 /*
  * Duplicate a file descriptor to a particular value.
  *
@@ -480,6 +483,7 @@ kern_fcntl_freebsd(struct thread *td, int fd, int cmd, long arg)
 	}
 	return (error);
 }
+#endif /* __rtems__ */
 
 int
 kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
@@ -502,6 +506,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
 	AUDIT_ARG_FD(cmd);
 	AUDIT_ARG_CMD(cmd);
 	switch (cmd) {
+#ifndef __rtems__
 	case F_DUPFD:
 		tmp = arg;
 		error = kern_dup(td, FDDUP_FCNTL, 0, fd, tmp);
@@ -521,6 +526,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
 		tmp = arg;
 		error = kern_dup(td, FDDUP_FIXED, FDDUP_FLAG_CLOEXEC, fd, tmp);
 		break;
+#endif /* __rtems__ */
 
 	case F_GETFD:
 		error = EBADF;
@@ -581,6 +587,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
 		fdrop(fp, td);
 		break;
 
+#ifndef __rtems__
 	case F_GETOWN:
 		error = fget_fcntl(td, fd, &cap_fcntl_rights, F_GETOWN, &fp);
 		if (error != 0)
@@ -797,6 +804,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
 		VOP_UNLOCK(vp, 0);
 		fdrop(fp, td);
 		break;
+#endif /* __rtems__ */
 
 	default:
 		error = EINVAL;
@@ -812,6 +820,7 @@ getmaxfd(struct thread *td)
 	return (min((int)lim_cur(td, RLIMIT_NOFILE), maxfilesperproc));
 }
 
+#ifndef __rtems__
 /*
  * Common code for dup, dup2, fcntl(F_DUPFD) and fcntl(F_DUP2FD).
  */
@@ -1173,6 +1182,7 @@ fgetown(struct sigio **sigiop)
 	SIGIO_UNLOCK();
 	return (pgid);
 }
+#endif /* __rtems__ */
 
 /*
  * Function drops the filedesc lock on return.
@@ -1263,6 +1273,7 @@ kern_close(struct thread *td, int fd)
 	return (closefp(fdp, fd, fp, td, 1));
 }
 
+#ifndef __rtems__
 /*
  * Close open file descriptors.
  */
@@ -1298,6 +1309,7 @@ sys_closefrom(struct thread *td, struct closefrom_args *uap)
 	FILEDESC_SUNLOCK(fdp);
 	return (0);
 }
+#endif /* __rtems__ */
 
 #if defined(COMPAT_43)
 /*
@@ -1424,6 +1436,7 @@ freebsd11_nfstat(struct thread *td, struct freebsd11_nfstat_args *uap)
 }
 #endif /* COMPAT_FREEBSD11 */
 
+#ifndef __rtems__
 /*
  * Return pathconf information about a file descriptor.
  */
@@ -1480,6 +1493,7 @@ out:
 	fdrop(fp, td);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Initialize filecaps structure.
@@ -1614,6 +1628,7 @@ static void
 filecaps_validate(const struct filecaps *fcaps, const char *func)
 {
 
+#ifndef __rtems__
 	KASSERT(cap_rights_is_valid(&fcaps->fc_rights),
 	    ("%s: invalid rights", func));
 	KASSERT((fcaps->fc_fcntls & ~CAP_FCNTL_ALL) == 0,
@@ -1627,6 +1642,7 @@ filecaps_validate(const struct filecaps *fcaps, const char *func)
 	KASSERT(fcaps->fc_nioctls == 0 ||
 	    cap_rights_is_set(&fcaps->fc_rights, CAP_IOCTL),
 	    ("%s: ioctls without CAP_IOCTL", func));
+#endif /* __rtems__ */
 }
 
 static void
@@ -1875,10 +1891,12 @@ falloc_noinstall(struct thread *td, struct file **resultfp)
 	    priv_check(td, PRIV_MAXFILES) != 0) ||
 	    openfiles_new >= maxfiles) {
 		atomic_subtract_int(&openfiles, 1);
+#ifndef __rtems__
 		if (ppsratecheck(&lastfail, &curfail, 1)) {
 			printf("kern.maxfiles limit exceeded by uid %i, (%s) "
 			    "please see tuning(7).\n", td->td_ucred->cr_ruid, td->td_proc->p_comm);
 		}
+#endif /* __rtems__ */
 		return (ENFILE);
 	}
 	fp = uma_zalloc(file_zone, M_WAITOK);
@@ -2032,6 +2050,7 @@ fdshare(struct filedesc *fdp)
 	return (fdp);
 }
 
+#ifndef __rtems__
 /*
  * Unshare a filedesc structure, if necessary by making a copy
  */
@@ -2385,6 +2404,7 @@ fdsetugidsafety(struct thread *td)
 		}
 	}
 }
+#endif /* __rtems__ */
 
 /*
  * If a specific file object occupies a specific file descriptor, close the
@@ -2407,6 +2427,7 @@ fdclose(struct thread *td, struct file *fp, int idx)
 		FILEDESC_XUNLOCK(fdp);
 }
 
+#ifndef __rtems__
 /*
  * Close any files on exec?
  */
@@ -2432,6 +2453,7 @@ fdcloseexec(struct thread *td)
 		}
 	}
 }
+#endif /* __rtems__ */
 
 /*
  * It is unsafe for set[ug]id processes to be started with file
@@ -2500,6 +2522,7 @@ closef(struct file *fp, struct thread *td)
 	 */
 	if (fp->f_type == DTYPE_VNODE && td != NULL) {
 		vp = fp->f_vnode;
+#ifndef __rtems__
 		if ((td->td_proc->p_leader->p_flag & P_ADVLOCK) != 0) {
 			lf.l_whence = SEEK_SET;
 			lf.l_start = 0;
@@ -2508,6 +2531,7 @@ closef(struct file *fp, struct thread *td)
 			(void) VOP_ADVLOCK(vp, (caddr_t)td->td_proc->p_leader,
 			    F_UNLCK, &lf, F_POSIX);
 		}
+#endif /* __rtems__ */
 		fdtol = td->td_proc->p_fdtol;
 		if (fdtol != NULL) {
 			/*
@@ -2519,8 +2543,10 @@ closef(struct file *fp, struct thread *td)
 			for (fdtol = fdtol->fdl_next;
 			    fdtol != td->td_proc->p_fdtol;
 			    fdtol = fdtol->fdl_next) {
+#ifndef __rtems__
 				if ((fdtol->fdl_leader->p_flag &
 				    P_ADVLOCK) == 0)
+#endif /* __rtems__ */
 					continue;
 				fdtol->fdl_holdcount++;
 				FILEDESC_XUNLOCK(fdp);
@@ -2720,6 +2746,18 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
 		*seqp = seq;
 #endif
 	}
+#ifdef __rtems__
+	if (fp->f_io != NULL) {
+		rtems_libio_iop_hold(fp->f_io);
+		if (RTEMS_BSD_DESCRIP_TRACE)
+			printf("bsd:  fb: fget_unlocked: iop=%p %d (%d)  fp=%p (%d) by %p\n",
+			       fp->f_io, fp->f_io->data0, fp->f_io->flags >> 12,
+			       fp, fp->f_count, __builtin_return_address(0));
+	} else if (RTEMS_BSD_DESCRIP_TRACE) {
+		printf("bsd:  fb: fget_unlocked: iop=NULL -1 (0) fp=%p (%d) by %p\n",
+		       fp, fp->f_count, __builtin_return_address(0));
+	}
+#endif /* __rtems__ */
 	return (0);
 }
 
@@ -2764,11 +2802,13 @@ _fget(struct thread *td, int fd, struct file **fpp, int flags,
 		if ((fp->f_flag & flags) == 0)
 			error = EBADF;
 		break;
+#ifndef __rtems__
 	case FEXEC:
 	    	if ((fp->f_flag & (FREAD | FEXEC)) == 0 ||
 		    ((fp->f_flag & FWRITE) != 0))
 			error = EBADF;
 		break;
+#endif /* __rtems__ */
 	case 0:
 		break;
 	default:
@@ -2791,6 +2831,7 @@ fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp)
 	return (_fget(td, fd, fpp, 0, rightsp, NULL));
 }
 
+#ifndef __rtems__
 int
 fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp, u_char *maxprotp,
     struct file **fpp)
@@ -2825,6 +2866,7 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp, u_char *maxprotp,
 #endif
 	return (error);
 }
+#endif /* __rtems__ */
 
 int
 fget_read(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp)
@@ -2944,12 +2986,14 @@ fgetvp_read(struct thread *td, int fd, cap_rights_t *rightsp, struct vnode **vpp
 	return (_fgetvp(td, fd, FREAD, rightsp, vpp));
 }
 
+#ifndef __rtems__
 int
 fgetvp_exec(struct thread *td, int fd, cap_rights_t *rightsp, struct vnode **vpp)
 {
 
 	return (_fgetvp(td, fd, FEXEC, rightsp, vpp));
 }
+#endif /* __rtems__ */
 
 #ifdef notyet
 int
@@ -2977,12 +3021,15 @@ _fdrop(struct file *fp, struct thread *td)
 	error = fo_close(fp, td);
 	atomic_subtract_int(&openfiles, 1);
 	crfree(fp->f_cred);
+#ifndef __rtems__
 	free(fp->f_advice, M_FADVISE);
+#endif /* __rtems__ */
 	uma_zfree(file_zone, fp);
 
 	return (error);
 }
 
+#ifndef __rtems__
 /*
  * Apply an advisory lock on a file descriptor.
  *
@@ -3201,6 +3248,7 @@ pwd_chroot(struct thread *td, struct vnode *vp)
 	vrele(oldvp);
 	return (0);
 }
+#endif /* __rtems__ */
 
 void
 pwd_chdir(struct thread *td, struct vnode *vp)
@@ -3225,6 +3273,7 @@ pwd_chdir(struct thread *td, struct vnode *vp)
 void
 mountcheckdirs(struct vnode *olddp, struct vnode *newdp)
 {
+#ifndef __rtems__
 	struct filedesc *fdp;
 	struct prison *pr;
 	struct proc *p;
@@ -3285,6 +3334,7 @@ mountcheckdirs(struct vnode *olddp, struct vnode *newdp)
 	sx_sunlock(&allprison_lock);
 	while (nrele--)
 		vrele(olddp);
+#endif /* __rtems__ */
 }
 
 struct filedesc_to_leader *
@@ -3312,6 +3362,7 @@ filedesc_to_leader_alloc(struct filedesc_to_leader *old, struct filedesc *fdp, s
 	return (fdtol);
 }
 
+#ifndef __rtems__
 static int
 sysctl_kern_proc_nfds(SYSCTL_HANDLER_ARGS)
 {
@@ -3810,6 +3861,7 @@ static SYSCTL_NODE(_kern_proc, KERN_PROC_OFILEDESC, ofiledesc,
     CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_ofiledesc,
     "Process ofiledesc entries");
 #endif	/* COMPAT_FREEBSD7 */
+#endif /* __rtems__ */
 
 int
 vntype_to_kinfo(int vtype)
@@ -3840,6 +3892,7 @@ vntype_to_kinfo(int vtype)
 	return (KF_VTYPE_UNKNOWN);
 }
 
+#ifndef __rtems__
 static SYSCTL_NODE(_kern_proc, KERN_PROC_FILEDESC, filedesc,
     CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_filedesc,
     "Process filedesc entries");
@@ -3911,6 +3964,7 @@ sysctl_kern_proc_cwd(SYSCTL_HANDLER_ARGS)
 
 static SYSCTL_NODE(_kern_proc, KERN_PROC_CWD, cwd, CTLFLAG_RD|CTLFLAG_MPSAFE,
     sysctl_kern_proc_cwd, "Process current working directory");
+#endif /* __rtems__ */
 
 #ifdef DDB
 /*
@@ -4059,7 +4113,11 @@ filelistinit(void *dummy)
 	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
 	mtx_init(&sigio_lock, "sigio lock", NULL, MTX_DEF);
 }
+#ifndef __rtems__
 SYSINIT(select, SI_SUB_LOCK, SI_ORDER_FIRST, filelistinit, NULL);
+#else /* __rtems__ */
+SYSINIT(select_sub_lock, SI_SUB_LOCK, SI_ORDER_FIRST, filelistinit, NULL);
+#endif /* __rtems__ */
 
 /*-------------------------------------------------------------------*/
 
@@ -4228,6 +4286,7 @@ invfo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
 	return (EINVAL);
 }
 
+#ifndef __rtems__
 /*-------------------------------------------------------------------*/
 
 /*
@@ -4281,3 +4340,4 @@ fildesc_drvinit(void *unused)
 }
 
 SYSINIT(fildescdev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, fildesc_drvinit, NULL);
+#endif /* __rtems__ */
diff --git a/freebsd/sys/kern/kern_event.c b/freebsd/sys/kern/kern_event.c
index d9ec03c8..1c79ace8 100644
--- a/freebsd/sys/kern/kern_event.c
+++ b/freebsd/sys/kern/kern_event.c
@@ -81,8 +81,6 @@ __FBSDID("$FreeBSD$");
 
 #include <vm/uma.h>
 #ifdef __rtems__
-#include <machine/rtems-bsd-syscall-api.h>
-
 /* Maintain a global kqueue list on RTEMS */
 static struct kqlist fd_kqlist;
 #endif /* __rtems__ */
@@ -131,7 +129,6 @@ static int	kern_kevent_generic(struct thread *td,
 		    struct g_kevent_args *uap,
 		    struct kevent_copyops *k_ops, const char *struct_name);
 
-#ifndef __rtems__
 static fo_rdwr_t	kqueue_read;
 static fo_rdwr_t	kqueue_write;
 static fo_truncate_t	kqueue_truncate;
@@ -156,9 +153,6 @@ static struct fileops kqueueops = {
 	.fo_sendfile = invfo_sendfile,
 	.fo_fill_kinfo = kqueue_fill_kinfo,
 };
-#else /* __rtems__ */
-static const rtems_filesystem_file_handlers_r kqueueops;
-#endif /* __rtems__ */
 
 static int 	knote_attach(struct knote *kn, struct kqueue *kq);
 static void 	knote_drop(struct knote *kn, struct thread *td);
@@ -399,14 +393,27 @@ static int
 filt_fileattach(struct knote *kn)
 {
 
+#ifndef __rtems__
 	return (fo_kqfilter(kn->kn_fp, kn));
+#else /* __rtems__ */
+	if ((kn->kn_status & KN_FP_IS_IOP) == 0) {
+		return (fo_kqfilter(kn->kn_fp, kn));
+	} else {
+		rtems_libio_t* iop = (rtems_libio_t*) kn->kn_fp;
+		return ((*iop->pathinfo.handlers->kqfilter_h)(iop, kn));
+	}
+#endif /* __rtems__ */
 }
 
 /*ARGSUSED*/
 static int
 kqueue_kqfilter(struct file *fp, struct knote *kn)
 {
+#ifndef __rtems__
 	struct kqueue *kq = kn->kn_fp->f_data;
+#else /* __rtems__ */
+	struct kqueue *kq = rtems_bsd_libio_knote_to_kq(kn);
+#endif /* __rtems__ */
 
 	if (kn->kn_filter != EVFILT_READ)
 		return (EINVAL);
@@ -417,20 +424,15 @@ kqueue_kqfilter(struct file *fp, struct knote *kn)
 
 	return (0);
 }
-#ifdef __rtems__
-static int
-rtems_bsd_kqueue_kqfilter(rtems_libio_t *iop, struct knote *kn)
-{
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-
-	return kqueue_kqfilter(fp, kn);
-}
-#endif /* __rtems__ */
 
 static void
 filt_kqdetach(struct knote *kn)
 {
+#ifndef __rtems__
 	struct kqueue *kq = kn->kn_fp->f_data;
+#else /* __rtems__ */
+	struct kqueue *kq = rtems_bsd_libio_knote_to_kq(kn);
+#endif /* __rtems__ */
 
 	knlist_remove(&kq->kq_sel.si_note, kn, 0);
 }
@@ -439,7 +441,11 @@ filt_kqdetach(struct knote *kn)
 static int
 filt_kqueue(struct knote *kn, long hint)
 {
+#ifndef __rtems__
 	struct kqueue *kq = kn->kn_fp->f_data;
+#else /* __rtems__ */
+	struct kqueue *kq = rtems_bsd_libio_knote_to_kq(kn);
+#endif /* __rtems__ */
 
 	kn->kn_data = kq->kq_count;
 	return (kn->kn_data > 0);
@@ -991,12 +997,6 @@ filt_usertouch(struct knote *kn, struct kevent *kev, u_long type)
 	}
 }
 
-#ifdef __rtems__
-static int
-kern_kqueue(struct thread *td, int flags, struct filecaps *fcaps);
-
-static
-#endif /* __rtems__ */
 int
 sys_kqueue(struct thread *td, struct kqueue_args *uap)
 {
@@ -1023,15 +1023,10 @@ kern_kqueue(struct thread *td, int flags, struct filecaps *fcaps)
 	struct ucred *cred;
 	int fd, error;
 
-#ifndef __rtems__
 	fdp = td->td_proc->p_fd;
 	cred = td->td_ucred;
 	if (!chgkqcnt(cred->cr_ruidinfo, 1, lim_cur(td, RLIMIT_KQUEUES)))
 		return (ENOMEM);
-#else /* __rtems__ */
-	(void)fdp;
-	(void)cred;
-#endif /* __rtems__ */
 
 	error = falloc_caps(td, &fp, &fd, flags, fcaps);
 	if (error != 0) {
@@ -1042,50 +1037,19 @@ kern_kqueue(struct thread *td, int flags, struct filecaps *fcaps)
 	/* An extra reference on `fp' has been held for us by falloc(). */
 	kq = malloc(sizeof *kq, M_KQUEUE, M_WAITOK | M_ZERO);
 	kqueue_init(kq);
-#ifndef __rtems__
 	kq->kq_fdp = fdp;
 	kq->kq_cred = crhold(cred);
-#endif /* __rtems__ */
 
-#ifndef __rtems__
 	FILEDESC_XLOCK(fdp);
 	TAILQ_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_list);
 	FILEDESC_XUNLOCK(fdp);
-#else /* __rtems__ */
-	rtems_libio_lock();
-	TAILQ_INSERT_HEAD(&fd_kqlist, kq, kq_list);
-	rtems_libio_unlock();
-#endif /* __rtems__ */
 
 	finit(fp, FREAD | FWRITE, DTYPE_KQUEUE, kq, &kqueueops);
-#ifndef __rtems__
 	fdrop(fp, td);
-#endif /* __rtems__ */
 
 	td->td_retval[0] = fd;
 	return (0);
 }
-#ifdef __rtems__
-int
-kqueue(void)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct kqueue_args ua;
-	int error;
-
-	if (td != NULL) {
-		error = sys_kqueue(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
 struct g_kevent_args {
 	int	fd;
@@ -1096,15 +1060,6 @@ struct g_kevent_args {
 	const struct timespec *timeout;
 };
 
-#ifdef __rtems__
-static int kern_kevent(struct thread *td, int fd, int nchanges, int nevents,
-    struct kevent_copyops *k_ops, const struct timespec *timeout);
-
-static int kern_kevent_fp(struct thread *td, struct file *fp, int nchanges,
-    int nevents, struct kevent_copyops *k_ops, const struct timespec *timeout);
-
-static
-#endif /* __rtems__ */
 int
 sys_kevent(struct thread *td, struct kevent_args *uap)
 {
@@ -1161,38 +1116,6 @@ kern_kevent_generic(struct thread *td, struct g_kevent_args *uap,
 
 	return (error);
 }
-#ifdef __rtems__
-__weak_reference(kevent, _kevent);
-
-int
-kevent(int kq, const struct kevent *changelist, int nchanges,
-    struct kevent *eventlist, int nevents,
-    const struct timespec *timeout)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct kevent_args ua = {
-		.fd = kq,
-		.changelist = changelist,
-		.nchanges = nchanges,
-		.eventlist = eventlist,
-		.nevents = nevents,
-		.timeout = timeout
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_kevent(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
 /*
  * Copy 'count' items into the destination list pointed to by uap->eventlist.
@@ -1503,6 +1426,9 @@ kqueue_register(struct kqueue *kq, struct kevent *kev, struct thread *td,
 {
 	struct filterops *fops;
 	struct file *fp;
+#ifdef __rtems__
+	rtems_libio_t* iop = NULL;
+#endif /* __rtems__ */
 	struct knote *kn, *tkn;
 	struct knlist *knl;
 	int error, filt, event;
@@ -1540,15 +1466,39 @@ findkn:
 		if (kev->ident > INT_MAX)
 			error = EBADF;
 		else
+#ifndef __rtems__
 			error = fget(td, kev->ident, &cap_event_rights, &fp);
+#else /* __rtems__ */
+		{
+			int ffd = rtems_bsd_libio_iop_hold(kev->ident, &iop);
+			if (ffd < 0)
+				error = EBADF;
+			else {
+				if (iop == NULL)
+					error = fget(td, ffd, &cap_event_rights, &fp);
+				else
+					fp = NULL;
+			}
+		}
+#endif /* __rtems__ */
 		if (error)
 			goto done;
 
 		if ((kev->flags & EV_ADD) == EV_ADD && kqueue_expand(kq, fops,
 		    kev->ident, M_NOWAIT) != 0) {
+#ifndef __rtems__
 			/* try again */
 			fdrop(fp, td);
 			fp = NULL;
+#else /* __rtems__ */
+			if (fp != NULL) {
+				fdrop(fp, td);
+				fp = NULL;
+			} else if (iop != NULL) {
+				rtems_libio_iop_drop(iop);
+				iop = NULL;
+			}
+#endif /* __rtems__ */
 			error = kqueue_expand(kq, fops, kev->ident, mflag);
 			if (error)
 				goto done;
@@ -1558,7 +1508,7 @@ findkn:
 #ifndef __rtems__
 		if (fp->f_type == DTYPE_KQUEUE) {
 #else /* __rtems__ */
-		if (fp->f_io.pathinfo.handlers == &kqueueops) {
+		if (fp != NULL && fp->f_type == DTYPE_KQUEUE) {
 #endif /* __rtems__ */
 			/*
 			 * If we add some intelligence about what we are doing,
@@ -1632,6 +1582,12 @@ findkn:
 			fdrop(fp, td);
 			fp = NULL;
 		}
+#ifdef __rtems__
+		if (iop != NULL) {
+			rtems_libio_iop_drop(iop);
+			iop = NULL;
+		}
+#endif /* __rtems__ */
 		goto findkn;
 	}
 
@@ -1647,7 +1603,17 @@ findkn:
 				error = ENOMEM;
 				goto done;
 			}
+#ifndef __rtems__
 			kn->kn_fp = fp;
+#else /* __rtems__ */
+			if (fp != NULL) {
+				kn->kn_fp = fp;
+				kn->kn_status = 0;
+			} else if (iop != NULL) {
+				rtems_bsd_libio_iop_to_knote(kn, iop);
+				kn->kn_status = KN_FP_IS_IOP;
+			}
+#endif /* __rtems__ */
 			kn->kn_kq = kq;
 			kn->kn_fop = fops;
 			/*
@@ -1656,6 +1622,9 @@ findkn:
 			 */
 			fops = NULL;
 			fp = NULL;
+#ifdef __rtems__
+			iop = NULL;
+#endif /* __rtems__ */
 
 			kn->kn_sfflags = kev->fflags;
 			kn->kn_sdata = kev->data;
@@ -1664,7 +1633,11 @@ findkn:
 			kn->kn_kevent = *kev;
 			kn->kn_kevent.flags &= ~(EV_ADD | EV_DELETE |
 			    EV_ENABLE | EV_DISABLE | EV_FORCEONESHOT);
+#ifndef __rtems__
 			kn->kn_status = KN_DETACHED;
+#else /* __rtems__ */
+			kn->kn_status |= KN_DETACHED;
+#endif /* __rtems__ */
 			if ((kev->flags & EV_DISABLE) != 0)
 				kn->kn_status |= KN_DISABLED;
 			kn_enter_flux(kn);
@@ -1757,6 +1730,10 @@ done:
 		FILEDESC_XUNLOCK(td->td_proc->p_fd);
 	if (fp != NULL)
 		fdrop(fp, td);
+#ifdef __rtems__
+	if (iop != NULL)
+		rtems_libio_iop_drop(iop);
+#endif /* __rtems__ */
 	knote_free(tkn);
 	if (fops != NULL)
 		kqueue_fo_release(filt);
@@ -1772,11 +1749,7 @@ kqueue_acquire(struct file *fp, struct kqueue **kqp)
 	error = 0;
 
 	kq = fp->f_data;
-#ifndef __rtems__
 	if (fp->f_type != DTYPE_KQUEUE || kq == NULL)
-#else /* __rtems__ */
-	if (fp->f_io.pathinfo.handlers != &kqueueops || kq == NULL)
-#endif /* __rtems__ */
 		return (EBADF);
 	*kqp = kq;
 	KQ_LOCK(kq);
@@ -2117,7 +2090,6 @@ done_nl:
 	return (error);
 }
 
-#ifndef __rtems__
 /*ARGSUSED*/
 static int
 kqueue_ioctl(struct file *fp, u_long cmd, void *data,
@@ -2165,7 +2137,6 @@ kqueue_ioctl(struct file *fp, u_long cmd, void *data,
 
 	return (ENOTTY);
 }
-#endif /* __rtems__ */
 
 /*ARGSUSED*/
 static int
@@ -2193,39 +2164,14 @@ kqueue_poll(struct file *fp, int events, struct ucred *active_cred,
 	KQ_UNLOCK(kq);
 	return (revents);
 }
-#ifdef __rtems__
-static int
-rtems_bsd_kqueue_poll(rtems_libio_t *iop, int events)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	int error;
-
-	if (td != NULL) {
-		error = kqueue_poll(fp, events, NULL, td);
-	} else {
-		error = ENOMEM;
-	}
-
-	return error;
-}
-#endif /* __rtems__ */
 
 /*ARGSUSED*/
-#ifndef __rtems__
 static int
 kqueue_stat(struct file *fp, struct stat *st, struct ucred *active_cred,
 	struct thread *td)
 {
 
 	bzero((void *)st, sizeof *st);
-#else /* __rtems__ */
-static int
-rtems_bsd_kqueue_stat(const rtems_filesystem_location_info_t *loc,
-    struct stat *st)
-{
-	(void) loc;
-#endif /* __rtems__ */
 	/*
 	 * We no longer return kq_count because the unlocked value is useless.
 	 * If you spent all this time getting the count, why not spend your
@@ -2304,10 +2250,8 @@ static void
 kqueue_destroy(struct kqueue *kq)
 {
 
-#ifndef __rtems__
 	KASSERT(kq->kq_fdp == NULL,
 	    ("kqueue still attached to a file descriptor"));
-#endif /* __rtems__ */
 	seldrain(&kq->kq_sel);
 	knlist_destroy(&kq->kq_sel.si_note);
 	mtx_destroy(&kq->kq_lock);
@@ -2333,7 +2277,6 @@ kqueue_close(struct file *fp, struct thread *td)
 		return error;
 	kqueue_drain(kq, td);
 
-#ifndef __rtems__
 	/*
 	 * We could be called due to the knote_drop() doing fdrop(),
 	 * called from kqueue_register().  In this case the global
@@ -2350,12 +2293,6 @@ kqueue_close(struct file *fp, struct thread *td)
 	TAILQ_REMOVE(&fdp->fd_kqlist, kq, kq_list);
 	if (filedesc_unlock)
 		FILEDESC_XUNLOCK(fdp);
-#else /* __rtems__ */
-	(void)filedesc_unlock;
-	rtems_libio_lock();
-	TAILQ_REMOVE(&fd_kqlist, kq, kq_list);
-	rtems_libio_unlock();
-#endif /* __rtems__ */
 
 	kqueue_destroy(kq);
 	chgkqcnt(kq->kq_cred->cr_ruidinfo, -1, 0);
@@ -2365,25 +2302,7 @@ kqueue_close(struct file *fp, struct thread *td)
 
 	return (0);
 }
-#ifdef __rtems__
-static int
-rtems_bsd_kqueue_close(rtems_libio_t *iop)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	int error;
-
-	if (td != NULL) {
-		error = kqueue_close(fp, td);
-	} else {
-		error = ENOMEM;
-	}
 
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
-
-#ifndef __rtems__
 static int
 kqueue_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
 {
@@ -2391,7 +2310,6 @@ kqueue_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
 	kif->kf_type = KF_TYPE_KQUEUE;
 	return (0);
 }
-#endif /* __rtems__ */
 
 static void
 kqueue_wakeup(struct kqueue *kq)
@@ -2756,28 +2674,18 @@ again:		/* need to reacquire lock since we have dropped it */
 void
 knote_fdclose(struct thread *td, int fd)
 {
-#ifndef __rtems__
 	struct filedesc *fdp = td->td_proc->p_fd;
-#endif /* __rtems__ */
 	struct kqueue *kq;
 	struct knote *kn;
 	int influx;
 
-#ifndef __rtems__
 	FILEDESC_XLOCK_ASSERT(fdp);
-#endif /* __rtems__ */
 
 	/*
 	 * We shouldn't have to worry about new kevents appearing on fd
 	 * since filedesc is locked.
 	 */
-#ifndef __rtems__
 	TAILQ_FOREACH(kq, &fdp->fd_kqlist, kq_list) {
-#else /* __rtems__ */
-	/* FIXME: Use separate lock? */
-	rtems_libio_lock();
-	TAILQ_FOREACH(kq, &fd_kqlist, kq_list) {
-#endif /* __rtems__ */
 		KQ_LOCK(kq);
 
 again:
@@ -2800,9 +2708,6 @@ again:
 		}
 		KQ_UNLOCK_FLUX(kq);
 	}
-#ifdef __rtems__
-	rtems_libio_unlock();
-#endif /* __rtems__ */
 }
 
 static int
@@ -2865,7 +2770,14 @@ knote_drop_detached(struct knote *kn, struct thread *td)
 	KQ_UNLOCK_FLUX(kq);
 
 	if (kn->kn_fop->f_isfd) {
+#ifndef __rtems__
 		fdrop(kn->kn_fp, td);
+#else /* __rtems__ */
+		if ((kn->kn_status & KN_FP_IS_IOP) == 0)
+		fdrop(kn->kn_fp, td);
+		else
+			rtems_libio_iop_drop((rtems_libio_t*) kn->kn_fp);
+#endif /* __rtems__ */
 		kn->kn_fp = NULL;
 	}
 	kqueue_fo_release(kn->kn_kevent.filter);
@@ -2947,23 +2859,3 @@ noacquire:
 	fdrop(fp, td);
 	return (error);
 }
-#ifdef __rtems__
-static const rtems_filesystem_file_handlers_r kqueueops = {
-	.open_h = rtems_filesystem_default_open,
-	.close_h = rtems_bsd_kqueue_close,
-	.read_h = rtems_filesystem_default_read,
-	.write_h = rtems_filesystem_default_write,
-	.ioctl_h = rtems_filesystem_default_ioctl,
-	.lseek_h = rtems_filesystem_default_lseek,
-	.fstat_h = rtems_bsd_kqueue_stat,
-	.ftruncate_h = rtems_filesystem_default_ftruncate,
-	.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fcntl_h = rtems_filesystem_default_fcntl,
-	.poll_h = rtems_bsd_kqueue_poll,
-	.kqfilter_h = rtems_bsd_kqueue_kqfilter,
-	.readv_h = rtems_filesystem_default_readv,
-	.writev_h = rtems_filesystem_default_writev,
-	.mmap_h = rtems_filesystem_default_mmap
-};
-#endif /* __rtems__ */
diff --git a/freebsd/sys/kern/kern_mib.c b/freebsd/sys/kern/kern_mib.c
index d7d8a356..0cdc8515 100644
--- a/freebsd/sys/kern/kern_mib.c
+++ b/freebsd/sys/kern/kern_mib.c
@@ -71,10 +71,8 @@ SYSCTL_ROOT_NODE(CTL_KERN,	  kern,   CTLFLAG_RW|CTLFLAG_CAPRD, 0,
 	"High kernel, proc, limits &c");
 SYSCTL_ROOT_NODE(CTL_VM,	  vm,     CTLFLAG_RW, 0,
 	"Virtual memory");
-#ifndef __rtems__
 SYSCTL_ROOT_NODE(CTL_VFS,	  vfs,     CTLFLAG_RW, 0,
 	"File system");
-#endif /* __rtems__ */
 SYSCTL_ROOT_NODE(CTL_NET,	  net,    CTLFLAG_RW, 0,
 	"Network, (see socket.h)");
 SYSCTL_ROOT_NODE(CTL_DEBUG,  debug,  CTLFLAG_RW, 0,
diff --git a/freebsd/sys/kern/kern_sysctl.c b/freebsd/sys/kern/kern_sysctl.c
index f529704a..71cbd2d8 100644
--- a/freebsd/sys/kern/kern_sysctl.c
+++ b/freebsd/sys/kern/kern_sysctl.c
@@ -1773,11 +1773,7 @@ sysctl_new_kernel(struct sysctl_req *req, void *p, size_t l)
 
 int
 kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
-#ifndef __rtems__
     size_t *oldlenp, void *new, size_t newlen, size_t *retval, int flags)
-#else /* __rtems__ */
-    size_t *oldlenp, const void *new, size_t newlen, size_t *retval, int flags)
-#endif /* __rtems__ */
 {
 	int error = 0;
 	struct sysctl_req req;
diff --git a/freebsd/sys/kern/subr_pctrie.c b/freebsd/sys/kern/subr_pctrie.c
index c5f2c06e..0077aa7a 100644
--- a/freebsd/sys/kern/subr_pctrie.c
+++ b/freebsd/sys/kern/subr_pctrie.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
@@ -49,7 +51,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_ddb.h"
+#include <rtems/bsd/local/opt_ddb.h>
 
 #include <sys/param.h>
 #include <sys/systm.h>
diff --git a/freebsd/sys/kern/subr_uio.c b/freebsd/sys/kern/subr_uio.c
index c14aea8d..2fdaef4e 100644
--- a/freebsd/sys/kern/subr_uio.c
+++ b/freebsd/sys/kern/subr_uio.c
@@ -296,7 +296,6 @@ out:
 	return (error);
 }
 
-#ifndef __rtems__
 /*
  * Wrapper for uiomove() that validates the arguments against a known-good
  * kernel buffer.  Currently, uiomove accepts a signed (n) argument, which
@@ -319,6 +318,7 @@ uiomove_frombuf(void *buf, int buflen, struct uio *uio)
 	return (uiomove((char *)buf + offset, n, uio));
 }
 
+#ifndef __rtems__
 /*
  * Give next character to user as result of read.
  */
diff --git a/freebsd/sys/kern/sys_generic.c b/freebsd/sys/kern/sys_generic.c
index 611e3166..827380ce 100644
--- a/freebsd/sys/kern/sys_generic.c
+++ b/freebsd/sys/kern/sys_generic.c
@@ -77,12 +77,6 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include <security/audit/audit.h>
-#ifdef __rtems__
-#include <machine/rtems-bsd-syscall-api.h>
-
-static int kern_select(struct thread *, int, fd_set *, fd_set *,
-    fd_set *, struct timeval *, int);
-#endif /* __rtems__ */
 
 /*
  * The following macro defines how many bytes will be allocated from
@@ -98,7 +92,6 @@ static int kern_select(struct thread *, int, fd_set *, fd_set *,
 #define	SYS_IOCTL_SMALL_SIZE	128	/* bytes */
 #define	SYS_IOCTL_SMALL_ALIGN	8	/* bytes */
 
-#ifndef __rtems__
 #ifdef __LP64__
 static int iosize_max_clamp = 0;
 SYSCTL_INT(_debug, OID_AUTO, iosize_max_clamp, CTLFLAG_RW,
@@ -108,6 +101,7 @@ SYSCTL_INT(_debug, OID_AUTO, devfs_iosize_max_clamp, CTLFLAG_RW,
     &devfs_iosize_max_clamp, 0, "Clamp max i/o size to INT_MAX for devices");
 #endif
 
+#ifndef __rtems__
 /*
  * Assert that the return value of read(2) and write(2) syscalls fits
  * into a register.  If not, an architecture will need to provide the
@@ -130,12 +124,10 @@ static int	selscan(struct thread *, fd_mask **, fd_mask **, int);
 static int	selrescan(struct thread *, fd_mask **, fd_mask **);
 static void	selfdalloc(struct thread *, void *);
 static void	selfdfree(struct seltd *, struct selfd *);
-#ifndef __rtems__
 static int	dofileread(struct thread *, int, struct file *, struct uio *,
 		    off_t, int);
 static int	dofilewrite(struct thread *, int, struct file *, struct uio *,
 		    off_t, int);
-#endif /* __rtems__ */
 static void	doselwakeup(struct selinfo *, int);
 static void	seltdinit(struct thread *);
 static int	seltdwait(struct thread *, sbintime_t, sbintime_t);
@@ -176,7 +168,6 @@ struct selfd {
 static uma_zone_t selfd_zone;
 static struct mtx_pool *mtxpool_select;
 
-#ifndef __rtems__
 #ifdef __LP64__
 size_t
 devfs_iosize_max(void)
@@ -221,6 +212,7 @@ sys_read(struct thread *td, struct read_args *uap)
 	return (error);
 }
 
+#ifndef __rtems__
 /*
  * Positioned read system call
  */
@@ -267,6 +259,7 @@ freebsd6_pread(struct thread *td, struct freebsd6_pread_args *uap)
 	return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
 }
 #endif
+#endif /* __rtems__ */
 
 /*
  * Scatter read system call.
@@ -306,6 +299,7 @@ kern_readv(struct thread *td, int fd, struct uio *auio)
 	return (error);
 }
 
+#ifndef __rtems__
 /*
  * Scatter positioned read system call.
  */
@@ -350,6 +344,7 @@ kern_preadv(struct thread *td, int fd, struct uio *auio, off_t offset)
 	fdrop(fp, td);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Common code for readv and preadv that reads data in
@@ -422,6 +417,7 @@ sys_write(struct thread *td, struct write_args *uap)
 	return (error);
 }
 
+#ifndef __rtems__
 /*
  * Positioned write system call.
  */
@@ -469,6 +465,7 @@ freebsd6_pwrite(struct thread *td, struct freebsd6_pwrite_args *uap)
 	return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
 }
 #endif
+#endif /* __rtems__ */
 
 /*
  * Gather write system call.
@@ -508,6 +505,7 @@ kern_writev(struct thread *td, int fd, struct uio *auio)
 	return (error);
 }
 
+#ifndef __rtems__
 /*
  * Gather positioned write system call.
  */
@@ -552,6 +550,7 @@ kern_pwritev(struct thread *td, int fd, struct uio *auio, off_t offset)
 	fdrop(fp, td);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Common code for writev and pwritev that writes data to
@@ -583,12 +582,14 @@ dofilewrite(struct thread *td, int fd, struct file *fp, struct uio *auio,
 		if (auio->uio_resid != cnt && (error == ERESTART ||
 		    error == EINTR || error == EWOULDBLOCK))
 			error = 0;
+#ifndef __rtems__
 		/* Socket layer is responsible for issuing SIGPIPE. */
 		if (fp->f_type != DTYPE_SOCKET && error == EPIPE) {
 			PROC_LOCK(td->td_proc);
 			tdsignal(td, SIGPIPE);
 			PROC_UNLOCK(td->td_proc);
 		}
+#endif /* __rtems__ */
 	}
 	cnt -= auio->uio_resid;
 #ifdef KTRACE
@@ -678,7 +679,11 @@ sys_ioctl(struct thread *td, struct ioctl_args *uap)
 	if (uap->com > 0xffffffff) {
 		printf(
 		    "WARNING pid %d (%s): ioctl sign-extension ioctl %lx\n",
+#ifndef __rtems__
 		    td->td_proc->p_pid, td->td_name, uap->com);
+#else /* __rtems__ */
+		    1, "BSD", uap->com);
+#endif /* __rtems__ */
 		uap->com &= 0xffffffff;
 	}
 	com = uap->com;
@@ -706,7 +711,11 @@ sys_ioctl(struct thread *td, struct ioctl_args *uap)
 			size = 0;
 		} else {
 			if (size > SYS_IOCTL_SMALL_SIZE)
+#ifndef __rtems__
 				data = malloc((u_long)size, M_IOCTLOPS, M_WAITOK);
+#else /* __rtems__ */
+				panic("libbsd: ioctl size too big");
+#endif /* __rtems__ */
 			else
 				data = smalldata;
 		}
@@ -730,8 +739,10 @@ sys_ioctl(struct thread *td, struct ioctl_args *uap)
 		error = copyout(data, uap->data, (u_int)size);
 
 out:
+#ifndef __rtems__
 	if (size > SYS_IOCTL_SMALL_SIZE)
 		free(data, M_IOCTLOPS);
+#endif /* __rtems__ */
 	return (error);
 }
 
@@ -835,7 +846,6 @@ out:
 		fdrop(fp, td);
 	return (error);
 }
-#endif /* __rtems__ */
 
 int
 poll_no_poll(int events)
@@ -853,7 +863,6 @@ poll_no_poll(int events)
 	return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
 }
 
-#ifndef __rtems__
 int
 sys_pselect(struct thread *td, struct pselect_args *uap)
 {
@@ -887,6 +896,7 @@ kern_pselect(struct thread *td, int nd, fd_set *in, fd_set *ou, fd_set *ex,
 {
 	int error;
 
+#ifndef __rtems__
 	if (uset != NULL) {
 		error = kern_sigprocmask(td, SIG_SETMASK, uset,
 		    &td->td_oldsigmask, 0);
@@ -902,6 +912,7 @@ kern_pselect(struct thread *td, int nd, fd_set *in, fd_set *ou, fd_set *ex,
 		td->td_flags |= TDF_ASTPENDING;
 		thread_unlock(td);
 	}
+#endif /* __rtems__ */
 	error = kern_select(td, nd, in, ou, ex, tvp, abi_nfdbits);
 	return (error);
 }
@@ -930,7 +941,6 @@ sys_select(struct thread *td, struct select_args *uap)
 	return (kern_select(td, uap->nd, uap->in, uap->ou, uap->ex, tvp,
 	    NFDBITS));
 }
-#endif /* __rtems__ */
 
 /*
  * In the unlikely case when user specified n greater then the last
@@ -1000,14 +1010,11 @@ kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,
 
 	if (nd < 0)
 		return (EINVAL);
-#ifndef __rtems__
 	fdp = td->td_proc->p_fd;
-#endif /* __rtems__ */
 	ndu = nd;
 #ifndef __rtems__
 	lf = fdp->fd_lastfile;
 #else /* __rtems__ */
-	(void) fdp;
 	lf = rtems_libio_number_iops;
 #endif /* __rtems__ */
 	if (nd > lf + 1)
@@ -1162,65 +1169,6 @@ done:
 
 	return (error);
 }
-#ifdef __rtems__
-int
-select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds,
-    struct timeval *timeout)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	int error;
-
-	if (td != NULL) {
-		error = kern_select(td, nfds, readfds, writefds, errorfds,
-		    timeout, NFDBITS);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-
-int
-pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds,
-    const struct timespec *timeout, const sigset_t *set)
-{
-	struct thread *td;
-	int error;
-
-	if (set != NULL) {
-		rtems_set_errno_and_return_minus_one(ENOSYS);
-	}
-
-	td = rtems_bsd_get_curthread_or_null();
-
-	if (td != NULL) {
-		struct timeval tv;
-		struct timeval *tvp;
-
-		if (timeout != NULL) {
-			TIMESPEC_TO_TIMEVAL(&tv, timeout);
-			tvp = &tv;
-		} else {
-			tvp = NULL;
-		}
-
-		error = kern_select(td, nfds, readfds, writefds, errorfds,
-		    tvp, NFDBITS);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
 /* 
  * Convert a select bit set to poll flags.
@@ -1291,6 +1239,17 @@ selsetbits(fd_mask **ibits, fd_mask **obits, int idx, fd_mask bit, int events)
 static __inline int
 getselfd_cap(struct filedesc *fdp, int fd, struct file **fpp)
 {
+#ifdef __rtems__
+	rtems_libio_t *iop;
+	int ffd = rtems_bsd_libio_iop_hold(fd, &iop);
+	if (ffd < 0)
+		return EBADF;
+	if (iop != NULL) {
+		*fpp = NULL;
+		return 0;
+	}
+	fd = ffd;
+#endif /* __rtems__ */
 
 	return (fget_unlocked(fdp, fd, &cap_event_rights, fpp, NULL));
 }
@@ -1312,11 +1271,7 @@ selrescan(struct thread *td, fd_mask **ibits, fd_mask **obits)
 	int fd, ev, n, idx;
 	int error;
 
-#ifndef __rtems__
 	fdp = td->td_proc->p_fd;
-#else /* __rtems__ */
-	fdp = NULL;
-#endif /* __rtems__ */
 	stp = td->td_sel;
 	n = 0;
 	STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) {
@@ -1331,8 +1286,15 @@ selrescan(struct thread *td, fd_mask **ibits, fd_mask **obits)
 			return (error);
 		idx = fd / NFDBITS;
 		bit = (fd_mask)1 << (fd % NFDBITS);
+#ifndef __rtems__
 		ev = fo_poll(fp, selflags(ibits, idx, bit), td->td_ucred, td);
 		fdrop(fp, td);
+#else /* __rtems__ */
+		ev = rtems_bsd_libio_fo_poll(fd, fp, selflags(ibits, idx, bit),
+					     td->td_ucred, td);
+		if (fp != NULL)
+			fdrop(fp, td);
+#endif /* __rtems__ */
 		if (ev != 0)
 			n += selsetbits(ibits, obits, idx, bit, ev);
 	}
@@ -1355,11 +1317,7 @@ selscan(struct thread *td, fd_mask **ibits, fd_mask **obits, int nfd)
 	int n, idx;
 	int error;
 
-#ifndef __rtems__
 	fdp = td->td_proc->p_fd;
-#else /* __rtems__ */
-	fdp = NULL;
-#endif /* __rtems__ */
 	n = 0;
 	for (idx = 0, fd = 0; fd < nfd; idx++) {
 		end = imin(fd + NFDBITS, nfd);
@@ -1372,8 +1330,16 @@ selscan(struct thread *td, fd_mask **ibits, fd_mask **obits, int nfd)
 			if (error)
 				return (error);
 			selfdalloc(td, (void *)(uintptr_t)fd);
+#ifndef __rtems__
 			ev = fo_poll(fp, flags, td->td_ucred, td);
 			fdrop(fp, td);
+#else /* __rtems__ */
+			ev = rtems_bsd_libio_fo_poll(fd, fp,
+						     selflags(ibits, idx, bit),
+						     td->td_ucred, td);
+			if (fp != NULL)
+				fdrop(fp, td);
+#endif /* __rtems__ */
 			if (ev != 0)
 				n += selsetbits(ibits, obits, idx, bit, ev);
 		}
@@ -1383,12 +1349,6 @@ selscan(struct thread *td, fd_mask **ibits, fd_mask **obits, int nfd)
 	return (0);
 }
 
-#ifdef __rtems__
-static int kern_poll(struct thread *td, struct pollfd *fds, u_int nfds,
-    struct timespec *tsp, sigset_t *uset);
-
-static
-#endif /* __rtems__ */
 int
 sys_poll(struct thread *td, struct poll_args *uap)
 {
@@ -1507,31 +1467,6 @@ out:
 		free(bits, M_TEMP);
 	return (error);
 }
-#ifdef __rtems__
-int
-poll(struct pollfd fds[], nfds_t nfds, int timeout)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct poll_args ua = {
-		.fds = &fds[0],
-		.nfds = nfds,
-		.timeout = timeout
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_poll(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
 #ifndef __rtems__
 int
@@ -1577,11 +1512,7 @@ pollrescan(struct thread *td)
 	int n;
 
 	n = 0;
-#ifndef __rtems__
 	fdp = td->td_proc->p_fd;
-#else /* __rtems__ */
-	fdp = NULL;
-#endif /* __rtems__ */
 	stp = td->td_sel;
 	FILEDESC_SLOCK(fdp);
 	STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) {
@@ -1593,15 +1524,24 @@ pollrescan(struct thread *td)
 			continue;
 #ifndef __rtems__
 		fp = fdp->fd_ofiles[fd->fd].fde_file;
-#else /* __rtems__ */
-		fget_unlocked(fdp, fd->fd, NULL, &fp, NULL);
-#endif /* __rtems__ */
 #ifdef CAPABILITIES
 		if (fp == NULL ||
 		    cap_check(cap_rights(fdp, fd->fd), &cap_event_rights) != 0)
 #else
 		if (fp == NULL)
 #endif
+#else /* __rtems__ */
+		rtems_libio_t* iop;
+		int ffd = rtems_bsd_libio_iop_hold(fd->fd, &iop);
+		if (ffd >= 0) {
+			if (iop == NULL) {
+				fp = fdp->fd_ofiles[ffd].fde_file;
+			} else {
+				fp = NULL;
+			}
+		}
+		else
+#endif /* __rtems__ */
 		{
 			fd->revents = POLLNVAL;
 			n++;
@@ -1612,9 +1552,10 @@ pollrescan(struct thread *td)
 		 * Note: backend also returns POLLHUP and
 		 * POLLERR if appropriate.
 		 */
+#ifndef __rtems__
 		fd->revents = fo_poll(fp, fd->events, td->td_ucred, td);
-#ifdef __rtems__
-		rtems_libio_iop_drop(&fp->f_io);
+#else /* __rtems__ */
+		fd->revents = rtems_bsd_libio_fo_poll(ffd, fp, fd->events, td->td_ucred, td);
 #endif /* __rtems__ */
 		if (fd->revents != 0)
 			n++;
@@ -1650,11 +1591,7 @@ pollout(struct thread *td, struct pollfd *fds, struct pollfd *ufds, u_int nfd)
 static int
 pollscan(struct thread *td, struct pollfd *fds, u_int nfd)
 {
-#ifndef __rtems__
 	struct filedesc *fdp = td->td_proc->p_fd;
-#else /* __rtems__ */
-	struct filedesc *fdp = NULL;
-#endif /* __rtems__ */
 	struct file *fp;
 	int i, n = 0;
 
@@ -1663,7 +1600,7 @@ pollscan(struct thread *td, struct pollfd *fds, u_int nfd)
 #ifndef __rtems__
 		if (fds->fd > fdp->fd_lastfile) {
 #else /* __rtems__ */
-		if ((uint32_t)fds->fd >= rtems_libio_number_iops) {
+		if (fds->fd >= (int) rtems_libio_number_iops) {
 #endif /* __rtems__ */
 			fds->revents = POLLNVAL;
 			n++;
@@ -1672,15 +1609,24 @@ pollscan(struct thread *td, struct pollfd *fds, u_int nfd)
 		} else {
 #ifndef __rtems__
 			fp = fdp->fd_ofiles[fds->fd].fde_file;
-#else /* __rtems__ */
-			fget_unlocked(fdp, fds->fd, NULL, &fp, NULL);
-#endif /* __rtems__ */
 #ifdef CAPABILITIES
 			if (fp == NULL ||
 			    cap_check(cap_rights(fdp, fds->fd), &cap_event_rights) != 0)
 #else
 			if (fp == NULL)
 #endif
+#else /* __rtems__ */
+			rtems_libio_t* iop;
+			int ffd = rtems_bsd_libio_iop_hold(fds->fd, &iop);
+			if (ffd >= 0) {
+				if (iop == NULL) {
+					fp = fdp->fd_ofiles[ffd].fde_file;
+				} else {
+					fp = NULL;
+				}
+			}
+			if (ffd < 0)
+#endif /* __rtems__ */
 			{
 				fds->revents = POLLNVAL;
 				n++;
@@ -1690,10 +1636,12 @@ pollscan(struct thread *td, struct pollfd *fds, u_int nfd)
 				 * POLLERR if appropriate.
 				 */
 				selfdalloc(td, fds);
+#ifndef __rtems__
 				fds->revents = fo_poll(fp, fds->events,
 				    td->td_ucred, td);
-#ifdef __rtems__
-				rtems_libio_iop_drop(&fp->f_io);
+#else /* __rtems__ */
+				fds->revents = rtems_bsd_libio_fo_poll(ffd, fp, fds->events,
+				    td->td_ucred, td);
 #endif /* __rtems__ */
 				/*
 				 * POSIX requires POLLOUT to be never
@@ -2038,6 +1986,8 @@ kern_posix_error(struct thread *td, int error)
 #include <rtems/score/objectimpl.h>
 #include <rtems/score/threadimpl.h>
 
+#include <sys/socket.h>
+
 #include <rtems/bsd/util.h>
 
 static void
diff --git a/freebsd/sys/kern/sys_pipe.c b/freebsd/sys/kern/sys_pipe.c
index aef35fc1..1da1c3a9 100755
--- a/freebsd/sys/kern/sys_pipe.c
+++ b/freebsd/sys/kern/sys_pipe.c
@@ -147,7 +147,6 @@ __FBSDID("$FreeBSD$");
 /*
  * interfaces to the outside world
  */
-#ifndef __rtems__
 static fo_rdwr_t	pipe_read;
 static fo_rdwr_t	pipe_write;
 static fo_truncate_t	pipe_truncate;
@@ -175,52 +174,9 @@ struct fileops pipeops = {
 	.fo_fill_kinfo = pipe_fill_kinfo,
 	.fo_flags = DFLAG_PASSABLE
 };
-#else /* __rtems__ */
-#define PIPE_NODIRECT
-#define	PRIBIO			(0)
-
-static int rtems_bsd_pipe_open(rtems_libio_t *iop, const char *path,
-    int oflag, mode_t mode);
-static int rtems_bsd_pipe_close(rtems_libio_t *iop);
-static ssize_t rtems_bsd_pipe_read(rtems_libio_t *iop, void *buffer,
-    size_t count);
-static ssize_t rtems_bsd_pipe_readv(rtems_libio_t *iop,
-    const struct iovec *iov, int iovcnt, ssize_t total);
-static ssize_t rtems_bsd_pipe_write(rtems_libio_t *iop, const void *buffer,
-    size_t count);
-static ssize_t rtems_bsd_pipe_writev(rtems_libio_t *iop,
-    const struct iovec *iov, int iovcnt, ssize_t total);
-static int rtems_bsd_pipe_ioctl(rtems_libio_t *iop, ioctl_command_t request,
-    void *buffer);
-static int rtems_bsd_pipe_stat(const rtems_filesystem_location_info_t *loc,
-    struct stat *buf);
-static int rtems_bsd_pipe_fcntl(rtems_libio_t *iop, int cmd);
-static int rtems_bsd_pipe_poll(rtems_libio_t *iop, int events);
-int rtems_bsd_pipe_kqfilter(rtems_libio_t *iop, struct knote *kn);
-
-static const rtems_filesystem_file_handlers_r pipeops = {
-	.open_h = rtems_bsd_pipe_open,
-	.close_h = rtems_bsd_pipe_close,
-	.read_h = rtems_bsd_pipe_read,
-	.write_h = rtems_bsd_pipe_write,
-	.ioctl_h = rtems_bsd_pipe_ioctl,
-	.lseek_h = rtems_filesystem_default_lseek,
-	.fstat_h = rtems_bsd_pipe_stat,
-	.ftruncate_h = rtems_filesystem_default_ftruncate,
-	.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fcntl_h = rtems_bsd_pipe_fcntl,
-	.poll_h = rtems_bsd_pipe_poll,
-	.kqfilter_h = rtems_bsd_pipe_kqfilter,
-	.readv_h = rtems_bsd_pipe_readv,
-	.writev_h = rtems_bsd_pipe_writev,
-	.mmap_h = rtems_filesystem_default_mmap
-};
 
+#ifdef __rtems__
 long	maxpipekva;			/* Limit on pipe KVA */
-
-static int kern_pipe(struct thread *, int [2], int, struct filecaps *,
-    struct filecaps *);
 #endif /* __rtems__ */
 
 static void	filt_pipedetach(struct knote *kn);
@@ -297,7 +253,11 @@ static uma_zone_t pipe_zone;
 static struct unrhdr64 pipeino_unr;
 static dev_t pipedev_ino;
 
+#ifndef __rtems__
 SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_ANY, pipeinit, NULL);
+#else /* __rtems__ */
+SYSINIT(vfspip, SI_SUB_VFS, SI_ORDER_ANY, pipeinit, NULL);
+#endif /* __rtems__ */
 
 static void
 pipeinit(void *dummy __unused)
@@ -329,11 +289,7 @@ pipe_zone_ctor(void *mem, int size, void *arg, int flags)
 	 */
 	rpipe = &pp->pp_rpipe;
 	bzero(rpipe, sizeof(*rpipe));
-#ifndef __rtems__
 	vfs_timestamp(&rpipe->pipe_ctime);
-#else /* __rtems__ */
-	rpipe->pipe_ctime.tv_sec = time(NULL);
-#endif /* __rtems__ */
 	rpipe->pipe_atime = rpipe->pipe_mtime = rpipe->pipe_ctime;
 
 	wpipe = &pp->pp_wpipe;
@@ -484,22 +440,16 @@ kern_pipe(struct thread *td, int fildes[2], int flags, struct filecaps *fcaps1,
 	error = falloc_caps(td, &wf, &fd, flags, fcaps2);
 	if (error) {
 		fdclose(td, rf, fildes[0]);
-#ifndef __rtems__
 		fdrop(rf, td);
-#endif /* __rtems__ */
 		/* rpipe has been closed by fdrop(). */
 		pipeclose(wpipe);
 		return (error);
 	}
 	/* An extra reference on `wf' has been held for us by falloc_caps(). */
 	finit(wf, fflags, DTYPE_PIPE, wpipe, &pipeops);
-#ifndef __rtems__
 	fdrop(wf, td);
-#endif /* __rtems__ */
 	fildes[1] = fd;
-#ifndef __rtems__
 	fdrop(rf, td);
-#endif /* __rtems__ */
 
 	return (0);
 }
@@ -523,7 +473,6 @@ freebsd10_pipe(struct thread *td, struct freebsd10_pipe_args *uap __unused)
 }
 #endif
 
-#ifndef __rtems__
 int
 sys_pipe2(struct thread *td, struct pipe2_args *uap)
 {
@@ -541,28 +490,7 @@ sys_pipe2(struct thread *td, struct pipe2_args *uap)
 	}
 	return (error);
 }
-#endif /* __rtems__ */
 
-#ifdef __rtems__
-int
-pipe(int fildes[2])
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	int error;
-
-	if (td != NULL) {
-		error = kern_pipe(td, fildes, 0, NULL, NULL);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return error;
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
 /*
  * Allocate kva for pipe circular buffer, the space is pageable
@@ -852,11 +780,7 @@ pipe_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
 			 * Handle non-blocking mode operation or
 			 * wait for more data.
 			 */
-#ifndef __rtems__
 			if (fp->f_flag & FNONBLOCK) {
-#else /* __rtems__ */
-			if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FNONBLOCK) {
-#endif /* __rtems__ */
 				error = EAGAIN;
 			} else {
 				rpipe->pipe_state |= PIPE_WANTR;
@@ -876,11 +800,7 @@ locked_error:
 
 	/* XXX: should probably do this before getting any locks. */
 	if (error == 0)
-#ifndef __rtems__
 		vfs_timestamp(&rpipe->pipe_atime);
-#else /* __rtems__ */
-		rpipe->pipe_atime.tv_sec = time(NULL);
-#endif /* __rtems__ */
 unlocked_error:
 	--rpipe->pipe_busy;
 
@@ -906,70 +826,6 @@ unlocked_error:
 	PIPE_UNLOCK(rpipe);
 	return (error);
 }
-#ifdef __rtems__
-static ssize_t
-rtems_bsd_pipe_read(rtems_libio_t *iop, void *buffer, size_t count)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	struct iovec iov = {
-		.iov_base = buffer,
-		.iov_len = count
-	};
-	struct uio auio = {
-		.uio_iov = &iov,
-		.uio_iovcnt = 1,
-		.uio_offset = 0,
-		.uio_resid = count,
-		.uio_segflg = UIO_USERSPACE,
-		.uio_rw = UIO_READ,
-		.uio_td = td
-	};
-	int error;
-
-	if (td != NULL) {
-		error = pipe_read(fp, &auio, NULL, 0, NULL);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return (count - auio.uio_resid);
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-
-static ssize_t
-rtems_bsd_pipe_readv(rtems_libio_t *iop, const struct iovec *iov,
-    int iovcnt, ssize_t total)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	struct uio auio = {
-		.uio_iov = __DECONST(struct iovec *, iov),
-		.uio_iovcnt = iovcnt,
-		.uio_offset = 0,
-		.uio_resid = total,
-		.uio_segflg = UIO_USERSPACE,
-		.uio_rw = UIO_READ,
-		.uio_td = td
-	};
-	int error;
-
-	if (td != NULL) {
-		error = pipe_read(fp, &auio, NULL, 0, NULL);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return (total - auio.uio_resid);
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
 #ifndef PIPE_NODIRECT
 /*
@@ -1388,11 +1244,7 @@ pipe_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
 			/*
 			 * don't block on non-blocking I/O
 			 */
-#ifndef __rtems__
 			if (fp->f_flag & FNONBLOCK) {
-#else /* __rtems__ */
-			if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FNONBLOCK) {
-#endif /* __rtems__ */
 				error = EAGAIN;
 				pipeunlock(wpipe);
 				break;
@@ -1440,11 +1292,7 @@ pipe_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
 		error = 0;
 
 	if (error == 0)
-#ifndef __rtems__
 		vfs_timestamp(&wpipe->pipe_mtime);
-#else /* __rtems__ */
-		wpipe->pipe_mtime.tv_sec = time(NULL);
-#endif /* __rtems__ */
 
 	/*
 	 * We have something to offer,
@@ -1457,73 +1305,8 @@ pipe_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
 	PIPE_UNLOCK(rpipe);
 	return (error);
 }
-#ifdef __rtems__
-static ssize_t
-rtems_bsd_pipe_write(rtems_libio_t *iop, const void *buffer, size_t count)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	struct iovec iov = {
-		.iov_base = __DECONST(void *, buffer),
-		.iov_len = count
-	};
-	struct uio auio = {
-		.uio_iov = &iov,
-		.uio_iovcnt = 1,
-		.uio_offset = 0,
-		.uio_resid = count,
-		.uio_segflg = UIO_USERSPACE,
-		.uio_rw = UIO_WRITE,
-		.uio_td = td
-	};
-	int error;
-
-	if (td != NULL) {
-		error = pipe_write(fp, &auio, NULL, 0, NULL);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return (count - auio.uio_resid);
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-
-static ssize_t
-rtems_bsd_pipe_writev(rtems_libio_t *iop, const struct iovec *iov,
-    int iovcnt, ssize_t total)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	struct uio auio = {
-		.uio_iov = __DECONST(struct iovec *, iov),
-		.uio_iovcnt = iovcnt,
-		.uio_offset = 0,
-		.uio_resid = total,
-		.uio_segflg = UIO_USERSPACE,
-		.uio_rw = UIO_WRITE,
-		.uio_td = td
-	};
-	int error;
-
-	if (td != NULL) {
-		error = pipe_write(fp, &auio, NULL, 0, NULL);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return (total - auio.uio_resid);
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
 /* ARGSUSED */
-#ifndef __rtems__
 static int
 pipe_truncate(struct file *fp, off_t length, struct ucred *active_cred,
     struct thread *td)
@@ -1538,7 +1321,6 @@ pipe_truncate(struct file *fp, off_t length, struct ucred *active_cred,
 		error = invfo_truncate(fp, length, active_cred, td);
 	return (error);
 }
-#endif /* __rtems__ */
 
 /*
  * we implement a very minimal set of ioctls for compatibility with sockets.
@@ -1575,11 +1357,7 @@ pipe_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
 		break;
 
 	case FIONREAD:
-#ifndef __rtems__
 		if (!(fp->f_flag & FREAD)) {
-#else /* __rtems__ */
-		if (!(rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FREAD)) {
-#endif /* __rtems__ */
 			*(int *)data = 0;
 			PIPE_UNLOCK(mpipe);
 			return (0);
@@ -1618,23 +1396,6 @@ pipe_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
 out_unlocked:
 	return (error);
 }
-#ifdef __rtems__
-static int
-rtems_bsd_pipe_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	int error;
-
-	if (td != NULL) {
-		error = pipe_ioctl(fp, request, buffer, NULL, td);
-	} else {
-		error = ENOMEM;
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
 static int
 pipe_poll(struct file *fp, int events, struct ucred *active_cred,
@@ -1656,19 +1417,11 @@ pipe_poll(struct file *fp, int events, struct ucred *active_cred,
 	if (error)
 		goto locked_error;
 #endif
-#ifndef __rtems__
 	if (fp->f_flag & FREAD && events & (POLLIN | POLLRDNORM))
-#else /* __rtems__ */
-	if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FREAD && events & (POLLIN | POLLRDNORM))
-#endif /* __rtems__ */
 		if (rpipe->pipe_map.cnt > 0 || rpipe->pipe_buffer.cnt > 0)
 			revents |= events & (POLLIN | POLLRDNORM);
 
-#ifndef __rtems__
 	if (fp->f_flag & FWRITE && events & (POLLOUT | POLLWRNORM))
-#else /* __rtems__ */
-	if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FWRITE && events & (POLLOUT | POLLWRNORM))
-#endif /* __rtems__ */
 		if (wpipe->pipe_present != PIPE_ACTIVE ||
 		    (wpipe->pipe_state & PIPE_EOF) ||
 		    ((wpipe->pipe_state & PIPE_DIRECTW) == 0 &&
@@ -1678,12 +1431,8 @@ pipe_poll(struct file *fp, int events, struct ucred *active_cred,
 
 	levents = events &
 	    (POLLIN | POLLINIGNEOF | POLLPRI | POLLRDNORM | POLLRDBAND);
-#ifndef __rtems__
 	if (rpipe->pipe_state & PIPE_NAMED && fp->f_flag & FREAD && levents &&
 	    fp->f_pipegen == rpipe->pipe_wgen)
-#else /* __rtems__ */
-	if (rpipe->pipe_state & PIPE_NAMED && rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FREAD && levents)
-#endif /* __rtems__ */
 		events |= POLLINIGNEOF;
 
 	if ((events & POLLINIGNEOF) == 0) {
@@ -1696,21 +1445,13 @@ pipe_poll(struct file *fp, int events, struct ucred *active_cred,
 	}
 
 	if (revents == 0) {
-#ifndef __rtems__
 		if (fp->f_flag & FREAD && events & (POLLIN | POLLRDNORM)) {
-#else /* __rtems__ */
-		if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FREAD && events & (POLLIN | POLLRDNORM)) {
-#endif /* __rtems__ */
 			selrecord(td, &rpipe->pipe_sel);
 			if (SEL_WAITING(&rpipe->pipe_sel))
 				rpipe->pipe_state |= PIPE_SEL;
 		}
 
-#ifndef __rtems__
 		if (fp->f_flag & FWRITE && events & (POLLOUT | POLLWRNORM)) {
-#else /* __rtems__ */
-		if (rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FWRITE && events & (POLLOUT | POLLWRNORM)) {
-#endif /* __rtems__ */
 			selrecord(td, &wpipe->pipe_sel);
 			if (SEL_WAITING(&wpipe->pipe_sel))
 				wpipe->pipe_state |= PIPE_SEL;
@@ -1723,46 +1464,21 @@ locked_error:
 
 	return (revents);
 }
-#ifdef __rtems__
-static int
-rtems_bsd_pipe_poll(rtems_libio_t *iop, int events)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	int error;
-
-	if (td != NULL) {
-		error = pipe_poll(fp, events, NULL, td);
-	} else {
-		error = ENOMEM;
-	}
-
-	return error;
-}
-#endif /* __rtems__ */
 
 /*
  * We shouldn't need locks here as we're doing a read and this should
  * be a natural race.
  */
-#ifndef __rtems__
 static int
 pipe_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
     struct thread *td)
 {
 	struct pipe *pipe;
-#else /* __rtems__ */
-static int
-pipe_stat(struct pipe *pipe, struct stat *ub)
-{
-#endif /* __rtems__ */
 #ifdef MAC
 	int error;
 #endif
 
-#ifndef __rtems__
 	pipe = fp->f_data;
-#endif /* __rtems__ */
 	PIPE_LOCK(pipe);
 #ifdef MAC
 	error = mac_pipe_check_stat(active_cred, pipe->pipe_pair);
@@ -1775,18 +1491,12 @@ pipe_stat(struct pipe *pipe, struct stat *ub)
 	/* For named pipes ask the underlying filesystem. */
 	if (pipe->pipe_state & PIPE_NAMED) {
 		PIPE_UNLOCK(pipe);
-#ifndef __rtems__
 		return (vnops.fo_stat(fp, ub, active_cred, td));
-#else /* __rtems__ */
-		return (ENXIO);
-#endif /* __rtems__ */
 	}
 
 	PIPE_UNLOCK(pipe);
 
-#ifndef __rtems__
 	bzero(ub, sizeof(*ub));
-#endif /* __rtems__ */
 	ub->st_mode = S_IFIFO;
 	ub->st_blksize = PAGE_SIZE;
 	if (pipe->pipe_map.cnt != 0)
@@ -1813,38 +1523,20 @@ pipe_stat(struct pipe *pipe, struct stat *ub)
 	 */
 	return (0);
 }
-#ifdef __rtems__
-static int
-rtems_bsd_pipe_stat(
-	const rtems_filesystem_location_info_t *loc,
-	struct stat *buf
-)
-{
-	struct pipe *pipe = rtems_bsd_loc_to_f_data(loc);
-	int error = pipe_stat(pipe, buf);
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
 /* ARGSUSED */
 static int
 pipe_close(struct file *fp, struct thread *td)
 {
 
-#ifndef __rtems__
 	if (fp->f_vnode != NULL) 
 		return vnops.fo_close(fp, td);
 	fp->f_ops = &badfileops;
-#else /* __rtems__ */
-	fp->f_io.pathinfo.handlers = &rtems_filesystem_handlers_default;
-#endif /* __rtems__ */
 	pipe_dtor(fp->f_data);
 	fp->f_data = NULL;
 	return (0);
 }
 
-#ifndef __rtems__
 static int
 pipe_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
 {
@@ -1888,7 +1580,6 @@ pipe_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
 	kif->kf_un.kf_pipe.kf_pipe_buffer_cnt = pi->pipe_buffer.cnt;
 	return (0);
 }
-#endif /* __rtems__ */
 
 static void
 pipe_free_kmem(struct pipe *cpipe)
@@ -2007,19 +1698,11 @@ pipe_kqfilter(struct file *fp, struct knote *kn)
 	 * descriptor, don't return an error, but also don't ever generate an
 	 * event.
 	 */
-#ifndef __rtems__
 	if ((kn->kn_filter == EVFILT_READ) && !(fp->f_flag & FREAD)) {
-#else /* __rtems__ */
-	if ((kn->kn_filter == EVFILT_READ) && !(rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FREAD)) {
-#endif /* __rtems__ */
 		kn->kn_fop = &pipe_nfiltops;
 		return (0);
 	}
-#ifndef __rtems__
 	if ((kn->kn_filter == EVFILT_WRITE) && !(fp->f_flag & FWRITE)) {
-#else /* __rtems__ */
-	if ((kn->kn_filter == EVFILT_WRITE) && !(rtems_bsd_libio_flags_to_fflag(fp->f_io.flags) & FWRITE)) {
-#endif /* __rtems__ */
 		kn->kn_fop = &pipe_nfiltops;
 		return (0);
 	}
@@ -2048,15 +1731,6 @@ pipe_kqfilter(struct file *fp, struct knote *kn)
 	PIPE_UNLOCK(cpipe);
 	return (0);
 }
-#ifdef __rtems__
-int
-rtems_bsd_pipe_kqfilter(rtems_libio_t *iop, struct knote *kn)
-{
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-
-	return pipe_kqfilter(fp, kn);
-}
-#endif /* __rtems__ */
 
 static void
 filt_pipedetach(struct knote *kn)
@@ -2129,35 +1803,3 @@ filt_pipenotsup(struct knote *kn, long hint)
 
 	return (0);
 }
-#ifdef __rtems__
-static int
-rtems_bsd_pipe_open(rtems_libio_t *iop, const char *path, int oflag,
-    mode_t mode)
-{
-	return rtems_bsd_error_to_status_and_errno(ENXIO);
-}
-
-static int
-rtems_bsd_pipe_close(rtems_libio_t *iop)
-{
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	int error = pipe_close(fp, NULL);
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-
-static int
-rtems_bsd_pipe_fcntl(rtems_libio_t *iop, int cmd)
-{
-	int error = 0;
-
-	if (cmd == F_SETFL) {
-		struct file *fp = rtems_bsd_iop_to_fp(iop);
-		int nbio = iop->flags & LIBIO_FLAGS_NO_DELAY;
-
-		error = pipe_ioctl(fp, FIONBIO, &nbio, NULL, NULL);
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
diff --git a/freebsd/sys/kern/sys_socket.c b/freebsd/sys/kern/sys_socket.c
index 4f4ce99e..2fde0dd1 100644
--- a/freebsd/sys/kern/sys_socket.c
+++ b/freebsd/sys/kern/sys_socket.c
@@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/pmap.h>
 #include <vm/vm_extern.h>
 #include <vm/vm_map.h>
+#endif /* __rtems__ */
 
 static SYSCTL_NODE(_kern_ipc, OID_AUTO, aio, CTLFLAG_RD, NULL,
     "socket AIO stats");
@@ -119,13 +120,8 @@ struct fileops	socketops = {
 	.fo_aio_queue = soo_aio_queue,
 	.fo_flags = DFLAG_PASSABLE
 };
-#endif /* __rtems__ */
 
-#ifdef __rtems__
-int
-#else /* __rtems__ */
 static int
-#endif /* __rtems__ */
 soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
     int flags, struct thread *td)
 {
@@ -140,76 +136,8 @@ soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
 	error = soreceive(so, 0, uio, 0, 0, 0);
 	return (error);
 }
-#ifdef __rtems__
-static ssize_t
-rtems_bsd_soo_read(rtems_libio_t *iop, void *buffer, size_t count)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	struct iovec iov = {
-		.iov_base = buffer,
-		.iov_len = count
-	};
-	struct uio auio = {
-		.uio_iov = &iov,
-		.uio_iovcnt = 1,
-		.uio_offset = 0,
-		.uio_resid = count,
-		.uio_segflg = UIO_USERSPACE,
-		.uio_rw = UIO_READ,
-		.uio_td = td
-	};
-	int error;
-
-	if (td != NULL) {
-		error = soo_read(fp, &auio, NULL, 0, NULL);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return (count - auio.uio_resid);
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-
-static ssize_t
-rtems_bsd_soo_readv(rtems_libio_t *iop, const struct iovec *iov,
-    int iovcnt, ssize_t total)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	struct uio auio = {
-		.uio_iov = __DECONST(struct iovec *, iov),
-		.uio_iovcnt = iovcnt,
-		.uio_offset = 0,
-		.uio_resid = total,
-		.uio_segflg = UIO_USERSPACE,
-		.uio_rw = UIO_READ,
-		.uio_td = td
-	};
-	int error;
-
-	if (td != NULL) {
-		error = soo_read(fp, &auio, NULL, 0, NULL);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return (total - auio.uio_resid);
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
-#ifdef __rtems__
-int
-#else /* __rtems__ */
 static int
-#endif /* __rtems__ */
 soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
     int flags, struct thread *td)
 {
@@ -233,76 +161,8 @@ soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
 	}
 	return (error);
 }
-#ifdef __rtems__
-static ssize_t
-rtems_bsd_soo_write(rtems_libio_t *iop, const void *buffer, size_t count)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	struct iovec iov = {
-		.iov_base = __DECONST(void *, buffer),
-		.iov_len = count
-	};
-	struct uio auio = {
-		.uio_iov = &iov,
-		.uio_iovcnt = 1,
-		.uio_offset = 0,
-		.uio_resid = count,
-		.uio_segflg = UIO_USERSPACE,
-		.uio_rw = UIO_WRITE,
-		.uio_td = td
-	};
-	int error;
-
-	if (td != NULL) {
-		error = soo_write(fp, &auio, NULL, 0, NULL);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return (count - auio.uio_resid);
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-
-static ssize_t
-rtems_bsd_soo_writev(rtems_libio_t *iop, const struct iovec *iov,
-    int iovcnt, ssize_t total)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	struct uio auio = {
-		.uio_iov = __DECONST(struct iovec *, iov),
-		.uio_iovcnt = iovcnt,
-		.uio_offset = 0,
-		.uio_resid = total,
-		.uio_segflg = UIO_USERSPACE,
-		.uio_rw = UIO_WRITE,
-		.uio_td = td
-	};
-	int error;
-
-	if (td != NULL) {
-		error = soo_write(fp, &auio, NULL, 0, NULL);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return (total - auio.uio_resid);
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
-#ifdef __rtems__
-int
-#else /* __rtems__ */
 static int
-#endif /* __rtems__ */
 soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
     struct thread *td)
 {
@@ -414,29 +274,8 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
 	}
 	return (error);
 }
-#ifdef __rtems__
-static int
-rtems_bsd_soo_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	int error;
-
-	if (td != NULL) {
-		error = soo_ioctl(fp, request, buffer, NULL, td);
-	} else {
-		error = ENOMEM;
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
-#ifdef __rtems__
-int
-#else /* __rtems__ */
 static int
-#endif /* __rtems__ */
 soo_poll(struct file *fp, int events, struct ucred *active_cred,
     struct thread *td)
 {
@@ -448,48 +287,19 @@ soo_poll(struct file *fp, int events, struct ucred *active_cred,
 	if (error)
 		return (error);
 #endif
-#ifndef __rtems__
 	return (sopoll(so, events, fp->f_cred, td));
-#else /* __rtems__ */
-	return (sopoll(so, events, NULL, td));
-#endif /* __rtems__ */
-}
-#ifdef __rtems__
-static int
-rtems_bsd_soo_poll(rtems_libio_t *iop, int events)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	int error;
-
-	if (td != NULL) {
-		error = soo_poll(fp, events, NULL, td);
-	} else {
-		error = ENOMEM;
-	}
-
-	return (error);
 }
-#endif /* __rtems__ */
 
-#ifndef __rtems__
 int
 soo_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
     struct thread *td)
 {
 	struct socket *so = fp->f_data;
-#else /* __rtems__ */
-static int
-soo_stat(struct socket *so, struct stat *ub)
-{
-#endif /* __rtems__ */
 #ifdef MAC
 	int error;
 #endif
 
-#ifndef __rtems__
 	bzero((caddr_t)ub, sizeof (*ub));
-#endif /* __rtems__ */
 	ub->st_mode = S_IFSOCK;
 #ifdef MAC
 	error = mac_socket_check_stat(active_cred, so);
@@ -525,19 +335,6 @@ soo_stat(struct socket *so, struct stat *ub)
 #endif /* __rtems__ */
 	return (*so->so_proto->pr_usrreqs->pru_sense)(so, ub);
 }
-#ifdef __rtems__
-static int
-rtems_bsd_soo_stat(
-	const rtems_filesystem_location_info_t *loc,
-	struct stat *buf
-)
-{
-	struct socket *so = rtems_bsd_loc_to_f_data(loc);
-	int error = soo_stat(so, buf);
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
 /*
  * API socket close on file pointer.  We call soclose() to close the socket
@@ -545,27 +342,15 @@ rtems_bsd_soo_stat(
  * file reference but the actual socket will not go away until the socket's
  * ref count hits 0.
  */
-#ifdef __rtems__
-int
-#else /* __rtems__ */
 static int
-#endif /* __rtems__ */
 soo_close(struct file *fp, struct thread *td)
 {
 	int error = 0;
 	struct socket *so;
 
-#ifdef __rtems__
-	/* FIXME: Move this to the RTEMS close() function */
-	knote_fdclose(td, rtems_bsd_fp_to_fd(fp));
-#endif /* __rtems__ */
 
 	so = fp->f_data;
-#ifndef __rtems__
 	fp->f_ops = &badfileops;
-#else /* __rtems__ */
-	fp->f_io.pathinfo.handlers = &rtems_filesystem_handlers_default;
-#endif /* __rtems__ */
 	fp->f_data = NULL;
 
 	if (so)
@@ -573,7 +358,6 @@ soo_close(struct file *fp, struct thread *td)
 	return (error);
 }
 
-#ifndef __rtems__
 static int
 soo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
 {
@@ -642,6 +426,7 @@ soo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
 	return (0);	
 }
 
+#ifndef __rtems__
 /*
  * Use the 'backend3' field in AIO jobs to store the amount of data
  * completed by the AIO job so far.
@@ -1014,10 +799,12 @@ soo_aio_cancel(struct kaiocb *job)
 	else
 		aio_cancel(job);
 }
+#endif /* __rtems__ */
 
 static int
 soo_aio_queue(struct file *fp, struct kaiocb *job)
 {
+#ifndef __rtems__
 	struct socket *so;
 	struct sockbuf *sb;
 	int error;
@@ -1050,56 +837,7 @@ soo_aio_queue(struct file *fp, struct kaiocb *job)
 	}
 	SOCKBUF_UNLOCK(sb);
 	return (0);
-}
+#else /* __rtems__ */
+	return (EIO);
 #endif /* __rtems__ */
-#ifdef __rtems__
-static int
-rtems_bsd_soo_open(rtems_libio_t *iop, const char *path, int oflag,
-    mode_t mode)
-{
-	return rtems_bsd_error_to_status_and_errno(ENXIO);
-}
-
-static int
-rtems_bsd_soo_close(rtems_libio_t *iop)
-{
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-	int error = soo_close(fp, NULL);
-
-	return rtems_bsd_error_to_status_and_errno(error);
 }
-
-static int
-rtems_bsd_soo_fcntl(rtems_libio_t *iop, int cmd)
-{
-	int error = 0;
-
-	if (cmd == F_SETFL) {
-		struct file *fp = rtems_bsd_iop_to_fp(iop);
-		int nbio = iop->flags & LIBIO_FLAGS_NO_DELAY;
-
-		error = soo_ioctl(fp, FIONBIO, &nbio, NULL, NULL);
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-
-const rtems_filesystem_file_handlers_r socketops = {
-	.open_h = rtems_bsd_soo_open,
-	.close_h = rtems_bsd_soo_close,
-	.read_h = rtems_bsd_soo_read,
-	.write_h = rtems_bsd_soo_write,
-	.ioctl_h = rtems_bsd_soo_ioctl,
-	.lseek_h = rtems_filesystem_default_lseek,
-	.fstat_h = rtems_bsd_soo_stat,
-	.ftruncate_h = rtems_filesystem_default_ftruncate,
-	.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fcntl_h = rtems_bsd_soo_fcntl,
-	.poll_h = rtems_bsd_soo_poll,
-	.kqfilter_h = rtems_bsd_soo_kqfilter,
-	.readv_h = rtems_bsd_soo_readv,
-	.writev_h = rtems_bsd_soo_writev,
-	.mmap_h = rtems_filesystem_default_mmap
-};
-#endif /* __rtems__ */
diff --git a/freebsd/sys/kern/uipc_socket.c b/freebsd/sys/kern/uipc_socket.c
index dc265e38..60f9a69d 100644
--- a/freebsd/sys/kern/uipc_socket.c
+++ b/freebsd/sys/kern/uipc_socket.c
@@ -155,10 +155,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysent.h>
 #include <compat/freebsd32/freebsd32.h>
 #endif
-#ifdef __rtems__
-#include <rtems/libio.h>
-#define maxfiles rtems_libio_number_iops
-#endif /* __rtems__ */
 
 static int	soreceive_rcvoob(struct socket *so, struct uio *uio,
 		    int flags);
@@ -177,9 +173,6 @@ static void	filt_sowdetach(struct knote *kn);
 static int	filt_sowrite(struct knote *kn, long hint);
 static int	filt_soempty(struct knote *kn, long hint);
 static int inline hhook_run_socket(struct socket *so, void *hctx, int32_t h_id);
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 fo_kqfilter_t	soo_kqfilter;
 
 static struct filterops soread_filtops = {
@@ -3427,15 +3420,6 @@ soo_kqfilter(struct file *fp, struct knote *kn)
 	SOCK_UNLOCK(so);
 	return (0);
 }
-#ifdef __rtems__
-int
-rtems_bsd_soo_kqfilter(rtems_libio_t *iop, struct knote *kn)
-{
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
-
-	return soo_kqfilter(fp, kn);
-}
-#endif /* __rtems__ */
 
 /*
  * Some routines that return EOPNOTSUPP for entry points that are not
diff --git a/freebsd/sys/kern/uipc_syscalls.c b/freebsd/sys/kern/uipc_syscalls.c
index 251f2bbb..a2f7d6f8 100644
--- a/freebsd/sys/kern/uipc_syscalls.c
+++ b/freebsd/sys/kern/uipc_syscalls.c
@@ -78,9 +78,9 @@ __FBSDID("$FreeBSD$");
 static int sendit(struct thread *td, int s, struct msghdr *mp, int flags);
 static int recvit(struct thread *td, int s, struct msghdr *mp, void *namelenp);
 
-#ifndef __rtems__
 static int accept1(struct thread *td, int s, struct sockaddr *uname,
 		   socklen_t *anamelen, int flags);
+#ifndef __rtems__
 static int getsockname1(struct thread *td, struct getsockname_args *uap,
 			int compat);
 static int getpeername1(struct thread *td, struct getpeername_args *uap,
@@ -90,20 +90,29 @@ struct getsockaddr_sockaddr {
 	struct sockaddr	header;
 	char		data[SOCK_MAXADDRLEN - sizeof(struct sockaddr)];
 } __aligned(sizeof(long));
+/*
+ * The getsockaddr is used else where with an allocation. Having a version
+ * local that does not alloc is a nice optimisation but we need to maintain
+ * the exported version. See nfs_mount in nfs_clvfsops.c.
+ */
+static int
+getsockaddr_noalloc(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len)
+{
+	struct sockaddr *sa;
 
-static int getsockaddr(struct sockaddr **, const struct sockaddr *, size_t);
-static int kern_getsockname(struct thread *, int, struct sockaddr **,
-    socklen_t *);
-static int kern_listen(struct thread *, int, int);
-static int kern_setsockopt(struct thread *, int, int, int, const void *,
-    enum uio_seg, socklen_t);
-static int kern_shutdown(struct thread *, int, int);
-static int kern_socket(struct thread *, int, int, int);
-static int kern_socketpair(struct thread *, int, int, int, int *);
+	if (len > SOCK_MAXADDRLEN)
+		return (ENAMETOOLONG);
+	if (len < offsetof(struct sockaddr, sa_data[0]))
+		return (EINVAL);
+	sa = memcpy(*namp, uaddr, len);
+	sa->sa_len = len;
+	return (0);
+}
+#define getsockaddr_hold getsockadd
+#define getsockaddr getsockaddr_noalloc
 #endif /* __rtems__ */
 static int sockargs(struct mbuf **, char *, socklen_t, int);
 
-#ifndef __rtems__
 /*
  * Convert a user file descriptor to a kernel file entry and check if required
  * capability rights are present.
@@ -131,46 +140,6 @@ getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp,
 	*fpp = fp;
 	return (0);
 }
-#else /* __rtems__ */
-static int
-rtems_bsd_getsock(int fd, struct file **fpp, u_int *fflagp)
-{
-	struct file *fp;
-	int error;
-
-	if ((uint32_t) fd < rtems_libio_number_iops) {
-		unsigned int flags;
-
-		fp = rtems_bsd_fd_to_fp(fd);
-		flags = rtems_libio_iop_hold(&fp->f_io);
-		if ((flags & LIBIO_FLAGS_OPEN) == 0) {
-			rtems_libio_iop_drop(&fp->f_io);
-			fp = NULL;
-			error = EBADF;
-		} else if (fp->f_io.pathinfo.handlers != &socketops) {
-			rtems_libio_iop_drop(&fp->f_io);
-			fp = NULL;
-			error = ENOTSOCK;
-		} else {
-			if (fflagp != NULL) {
-				*fflagp = rtems_bsd_libio_flags_to_fflag(
-				    fp->f_io.flags);
-			}
-
-			error = 0;
-		}
-	} else {
-		fp = NULL;
-		error = EBADF;
-	}
-
-	*fpp = fp;
-
-	return (error);
-}
-
-#define	getsock_cap(td, fd, rights, fpp, fflagp, havecapsp) rtems_bsd_getsock(fd, fpp, fflagp)
-#endif /* __rtems__ */
 
 /*
  * System call interface to the socket abstraction.
@@ -179,9 +148,6 @@ rtems_bsd_getsock(int fd, struct file **fpp, u_int *fflagp)
 #define COMPAT_OLDSOCK
 #endif
 
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 sys_socket(struct thread *td, struct socket_args *uap)
 {
@@ -227,43 +193,10 @@ kern_socket(struct thread *td, int domain, int type, int protocol)
 			(void) fo_ioctl(fp, FIONBIO, &fflag, td->td_ucred, td);
 		td->td_retval[0] = fd;
 	}
-#ifndef __rtems__
 	fdrop(fp, td);
-#endif /* __rtems__ */
 	return (error);
 }
-#ifdef __rtems__
-int
-socket(int domain, int type, int protocol)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct socket_args ua = {
-		.domain = domain,
-		.type = type,
-		.protocol = protocol
-	};
-	int error;
 
-	if (td != NULL) {
-		error = sys_socket(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
-
-#ifdef __rtems__
-static int kern_bindat(struct thread *td, int dirfd, int fd,
-    struct sockaddr *sa);
-
-static
-#endif /* __rtems__ */
 int
 sys_bind(struct thread *td, struct bind_args *uap)
 {
@@ -283,27 +216,6 @@ sys_bind(struct thread *td, struct bind_args *uap)
 	}
 	return (error);
 }
-#ifdef __rtems__
-int
-bind(int socket, const struct sockaddr *address, socklen_t address_len)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct bind_args ua = {
-		.s = socket,
-		.name = address,
-		.namelen = address_len
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_bind(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
 int
 kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
@@ -366,9 +278,6 @@ sys_bindat(struct thread *td, struct bindat_args *uap)
 }
 #endif /* __rtems__ */
 
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 sys_listen(struct thread *td, struct listen_args *uap)
 {
@@ -397,31 +306,7 @@ kern_listen(struct thread *td, int s, int backlog)
 	}
 	return (error);
 }
-#ifdef __rtems__
-int
-listen(int socket, int backlog)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct listen_args ua = {
-		.s = socket,
-		.backlog = backlog
-	};
-	int error;
 
-	if (td != NULL) {
-		error = sys_listen(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
-
-#ifdef __rtems__
-static int kern_accept4(struct thread *td, int s, struct sockaddr **name,
-    socklen_t *namelen, int flags, struct file **fp);
-#endif /* __rtems__ */
 /*
  * accept1()
  */
@@ -464,43 +349,17 @@ accept1(td, s, uname, anamelen, flags)
 		    sizeof(namelen));
 	if (error != 0)
 		fdclose(td, fp, td->td_retval[0]);
-#ifndef __rtems__
 	fdrop(fp, td);
-#endif /* __rtems__ */
 	free(name, M_SONAME);
 	return (error);
 }
-#ifdef __rtems__
-int
-accept(int socket, struct sockaddr *__restrict address,
-    socklen_t *__restrict address_len)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	int error;
-
-	if (td != NULL) {
-		error = accept1(td, socket, address, address_len,
-		    ACCEPT4_INHERIT);
-	} else {
-		error = ENOMEM;
-	}
 
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
-
-#ifndef __rtems__
 int
 kern_accept(struct thread *td, int s, struct sockaddr **name,
     socklen_t *namelen, struct file **fp)
 {
 	return (kern_accept4(td, s, name, namelen, ACCEPT4_INHERIT, fp));
 }
-#endif /* __rtems__ */
 
 int
 kern_accept4(struct thread *td, int s, struct sockaddr **name,
@@ -613,15 +472,12 @@ done:
 		} else
 			*fp = NULL;
 	}
-#ifndef __rtems__
 	if (nfp != NULL)
 		fdrop(nfp, td);
-#endif /* __rtems__ */
 	fdrop(headfp, td);
 	return (error);
 }
 
-#ifndef __rtems__
 int
 sys_accept(td, uap)
 	struct thread *td;
@@ -654,14 +510,7 @@ oaccept(td, uap)
 	    ACCEPT4_INHERIT | ACCEPT4_COMPAT));
 }
 #endif /* COMPAT_OLDSOCK */
-#endif /* __rtems__ */
-
-#ifdef __rtems__
-static int kern_connectat(struct thread *td, int dirfd, int fd,
-    struct sockaddr *sa);
 
-static
-#endif /* __rtems__ */
 int
 sys_connect(struct thread *td, struct connect_args *uap)
 {
@@ -681,27 +530,6 @@ sys_connect(struct thread *td, struct connect_args *uap)
 	}
 	return (error);
 }
-#ifdef __rtems__
-int
-connect(int socket, const struct sockaddr *address, socklen_t address_len)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct connect_args ua = {
-		.s = socket,
-		.name = address,
-		.namelen = address_len
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_connect(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
 int
 kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
@@ -864,21 +692,15 @@ kern_socketpair(struct thread *td, int domain, int type, int protocol,
 		(void) fo_ioctl(fp1, FIONBIO, &fflag, td->td_ucred, td);
 		(void) fo_ioctl(fp2, FIONBIO, &fflag, td->td_ucred, td);
 	}
-#ifndef __rtems__
 	fdrop(fp1, td);
 	fdrop(fp2, td);
-#endif /* __rtems__ */
 	return (0);
 free4:
 	fdclose(td, fp2, rsv[1]);
-#ifndef __rtems__
 	fdrop(fp2, td);
-#endif /* __rtems__ */
 free3:
 	fdclose(td, fp1, rsv[0]);
-#ifndef __rtems__
 	fdrop(fp1, td);
-#endif /* __rtems__ */
 free2:
 	if (so2 != NULL)
 		(void)soclose(so2);
@@ -888,9 +710,6 @@ free1:
 	return (error);
 }
 
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 sys_socketpair(struct thread *td, struct socketpair_args *uap)
 {
@@ -914,34 +733,7 @@ sys_socketpair(struct thread *td, struct socketpair_args *uap)
 #endif /* __rtems__ */
 	return (error);
 }
-#ifdef __rtems__
-int
-socketpair(int domain, int type, int protocol, int *socket_vector)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct socketpair_args ua = {
-		.domain = domain,
-		.type = type,
-		.protocol = protocol,
-		.rsv = socket_vector
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_socketpair(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
 
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
-
-#ifdef __rtems__
-static int
-kern_sendit( struct thread *td, int s, struct msghdr *mp, int flags,
-    struct mbuf *control, enum uio_seg segflg);
-#endif /* __rtems__ */
 static int
 sendit(struct thread *td, int s, struct msghdr *mp, int flags)
 {
@@ -1016,9 +808,7 @@ kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags,
 	struct uio auio;
 	struct iovec *iov;
 	struct socket *so;
-#ifndef __rtems__
 	cap_rights_t *rights;
-#endif /* __rtems__ */
 #ifdef KTRACE
 	struct uio *ktruio = NULL;
 #endif
@@ -1033,6 +823,8 @@ kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags,
 		AUDIT_ARG_SOCKADDR(td, AT_FDCWD, mp->msg_name);
 		rights = &cap_send_connect_rights;
 	}
+#else /* __rtems__ */
+	rights = NULL;
 #endif /* __rtems__ */
 	error = getsock_cap(td, s, rights, &fp, NULL, NULL);
 	if (error != 0) {
@@ -1111,9 +903,6 @@ bad:
 	return (error);
 }
 
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 sys_sendto(struct thread *td, struct sendto_args *uap)
 {
@@ -1138,34 +927,6 @@ sys_sendto(struct thread *td, struct sendto_args *uap)
 	return (sendit(td, uap->s, &msg, uap->flags));
 }
 #ifdef __rtems__
-ssize_t
-sendto(int socket, const void *message, size_t length, int flags,
-    const struct sockaddr *dest_addr, socklen_t dest_len)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct sendto_args ua = {
-		.s = socket,
-		.buf = (caddr_t) message,
-		.len = length,
-		.flags = flags,
-		.to = dest_addr,
-		.tolen = dest_len
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_sendto(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-
 int
 rtems_bsd_sendto(int socket, struct mbuf *m, int flags,
     const struct sockaddr *dest_addr)
@@ -1175,7 +936,7 @@ rtems_bsd_sendto(int socket, struct mbuf *m, int flags,
 	struct socket *so;
 	int error;
 
-	error = getsock_cap(td->td_proc->p_fd, socket, CAP_WRITE, &fp, NULL, NULL);
+	error = getsock_cap(td, socket, CAP_WRITE, &fp, NULL, NULL);
 	if (error)
 		return (error);
 	so = (struct socket *)fp->f_data;
@@ -1232,9 +993,6 @@ osendmsg(struct thread *td, struct osendmsg_args *uap)
 #endif
 #endif /* __rtems__ */
 
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 sys_sendmsg(struct thread *td, struct sendmsg_args *uap)
 {
@@ -1257,35 +1015,7 @@ sys_sendmsg(struct thread *td, struct sendmsg_args *uap)
 	free(iov, M_IOV);
 	return (error);
 }
-#ifdef __rtems__
-ssize_t
-sendmsg(int socket, const struct msghdr *message, int flags)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct sendmsg_args ua = {
-		.s = socket,
-		.msg = message,
-		.flags = flags
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_sendmsg(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 kern_recvit(struct thread *td, int s, struct msghdr *mp, enum uio_seg fromseg,
     struct mbuf **controlp)
@@ -1460,9 +1190,6 @@ recvit(struct thread *td, int s, struct msghdr *mp, void *namelenp)
 	return (error);
 }
 
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 sys_recvfrom(struct thread *td, struct recvfrom_args *uap)
 {
@@ -1489,35 +1216,6 @@ sys_recvfrom(struct thread *td, struct recvfrom_args *uap)
 done2:
 	return (error);
 }
-#ifdef __rtems__
-ssize_t
-recvfrom(int socket, void *__restrict buffer, size_t length, int flags,
-    struct sockaddr *__restrict address, socklen_t *__restrict address_len)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct recvfrom_args ua = {
-		.s = socket,
-		.buf = buffer,
-		.len = length,
-		.flags = flags,
-		.from = address,
-		.fromlenaddr = address_len
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_recvfrom(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
 
 #ifndef __rtems__
 #ifdef COMPAT_OLDSOCK
@@ -1578,9 +1276,6 @@ orecvmsg(struct thread *td, struct orecvmsg_args *uap)
 #endif
 #endif /* __rtems__ */
 
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 sys_recvmsg(struct thread *td, struct recvmsg_args *uap)
 {
@@ -1609,35 +1304,7 @@ sys_recvmsg(struct thread *td, struct recvmsg_args *uap)
 	free(iov, M_IOV);
 	return (error);
 }
-#ifdef __rtems__
-ssize_t
-recvmsg(int socket, struct msghdr *message, int flags)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct recvmsg_args ua = {
-		.s = socket,
-		.msg = message,
-		.flags = flags
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_recvmsg(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
 
-	if (error == 0) {
-		return td->td_retval[0];
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
-#endif /* __rtems__ */
-
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 sys_shutdown(struct thread *td, struct shutdown_args *uap)
 {
@@ -1673,23 +1340,7 @@ kern_shutdown(struct thread *td, int s, int how)
 	}
 	return (error);
 }
-#ifdef __rtems__
-int
-shutdown(int socket, int how)
-{
-	struct shutdown_args ua = {
-		.s = socket,
-		.how = how
-	};
-	int error = sys_shutdown(NULL, &ua);
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 sys_setsockopt(struct thread *td, struct setsockopt_args *uap)
 {
@@ -1697,39 +1348,10 @@ sys_setsockopt(struct thread *td, struct setsockopt_args *uap)
 	return (kern_setsockopt(td, uap->s, uap->level, uap->name,
 	    uap->val, UIO_USERSPACE, uap->valsize));
 }
-#ifdef __rtems__
-int
-setsockopt(int socket, int level, int option_name, const void *option_value,
-    socklen_t option_len)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct setsockopt_args ua = {
-		.s = socket,
-		.level = level,
-		.name = option_name,
-		.val = __DECONST(void *, option_value),
-		.valsize = option_len
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_setsockopt(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
 int
-#ifndef __rtems__
 kern_setsockopt(struct thread *td, int s, int level, int name, void *val,
     enum uio_seg valseg, socklen_t valsize)
-#else /* __rtems__ */
-kern_setsockopt(struct thread *td, int s, int level, int name, const void *val,
-    enum uio_seg valseg, socklen_t valsize)
-#endif /* __rtems__ */
 {
 	struct socket *so;
 	struct file *fp;
@@ -1744,11 +1366,7 @@ kern_setsockopt(struct thread *td, int s, int level, int name, const void *val,
 	sopt.sopt_dir = SOPT_SET;
 	sopt.sopt_level = level;
 	sopt.sopt_name = name;
-#ifndef __rtems__
 	sopt.sopt_val = val;
-#else /* __rtems__ */
-	sopt.sopt_val = __DECONST(void *, val);
-#endif /* __rtems__ */
 	sopt.sopt_valsize = valsize;
 	switch (valseg) {
 	case UIO_USERSPACE:
@@ -1772,12 +1390,6 @@ kern_setsockopt(struct thread *td, int s, int level, int name, const void *val,
 	return(error);
 }
 
-#ifdef __rtems__
-static int kern_getsockopt( struct thread *td, int s, int level, int name,
-    void *val, enum uio_seg valseg, socklen_t *valsize);
-
-static
-#endif /* __rtems__ */
 int
 sys_getsockopt(struct thread *td, struct getsockopt_args *uap)
 {
@@ -1797,30 +1409,6 @@ sys_getsockopt(struct thread *td, struct getsockopt_args *uap)
 		error = copyout(&valsize, uap->avalsize, sizeof (valsize));
 	return (error);
 }
-#ifdef __rtems__
-int
-getsockopt(int socket, int level, int option_name, void *__restrict
-    option_value, socklen_t *__restrict option_len)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct getsockopt_args ua = {
-		.s = socket,
-		.level = level,
-		.name = option_name,
-		.val = (caddr_t) option_value,
-		.avalsize = option_len
-	};
-	int error;
-
-	if (td != NULL) {
-		error = sys_getsockopt(td, &ua);
-	} else {
-		error = ENOMEM;
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
 /*
  * Kernel version of getsockopt.
@@ -1898,28 +1486,6 @@ getsockname1(struct thread *td, struct getsockname_args *uap, int compat)
 		error = copyout(&len, uap->alen, sizeof(len));
 	return (error);
 }
-#ifdef __rtems__
-int
-getsockname(int socket, struct sockaddr *__restrict address,
-    socklen_t *__restrict address_len)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct getsockname_args ua = {
-		.fdes = socket,
-		.asa = address,
-		.alen = address_len
-	};
-	int error;
-
-	if (td != NULL) {
-		error = getsockname1(td, &ua, 0);
-	} else {
-		error = ENOMEM;
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
 int
 kern_getsockname(struct thread *td, int fd, struct sockaddr **sa,
@@ -1960,7 +1526,6 @@ bad:
 	return (error);
 }
 
-#ifndef __rtems__
 int
 sys_getsockname(struct thread *td, struct getsockname_args *uap)
 {
@@ -1976,13 +1541,7 @@ ogetsockname(struct thread *td, struct getsockname_args *uap)
 	return (getsockname1(td, uap, 1));
 }
 #endif /* COMPAT_OLDSOCK */
-#endif /* __rtems__ */
 
-#ifdef __rtems__
-static int
-kern_getpeername(struct thread *td, int fd, struct sockaddr **sa,
-    socklen_t *alen);
-#endif /* __rtems__ */
 /*
  * getpeername1() - Get name of peer for connected socket.
  */
@@ -2013,28 +1572,6 @@ getpeername1(struct thread *td, struct getpeername_args *uap, int compat)
 		error = copyout(&len, uap->alen, sizeof(len));
 	return (error);
 }
-#ifdef __rtems__
-int
-getpeername(int socket, struct sockaddr *__restrict address,
-    socklen_t *__restrict address_len)
-{
-	struct thread *td = rtems_bsd_get_curthread_or_null();
-	struct getpeername_args ua = {
-		.fdes = socket,
-		.asa = address,
-		.alen = address_len
-	};
-	int error;
-
-	if (td != NULL) {
-		error = getpeername1(td, &ua, 0);
-	} else {
-		error = ENOMEM;
-	}
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
 int
 kern_getpeername(struct thread *td, int fd, struct sockaddr **sa,
@@ -2080,7 +1617,6 @@ done:
 	return (error);
 }
 
-#ifndef __rtems__
 int
 sys_getpeername(struct thread *td, struct getpeername_args *uap)
 {
@@ -2097,7 +1633,6 @@ ogetpeername(struct thread *td, struct ogetpeername_args *uap)
 	return (getpeername1(td, (struct getpeername_args *)uap, 1));
 }
 #endif /* COMPAT_OLDSOCK */
-#endif /* __rtems__ */
 
 static int
 sockargs(struct mbuf **mp, char *buf, socklen_t buflen, int type)
@@ -2137,23 +1672,22 @@ sockargs(struct mbuf **mp, char *buf, socklen_t buflen, int type)
 	return (error);
 }
 
+#ifdef __rtems__
+#undef getsockaddr
 int
-#ifndef __rtems__
-getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len)
+_bsd_getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len)
 #else /* __rtems__ */
-getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len)
+int
+getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len)
 #endif /* __rtems__ */
 {
 	struct sockaddr *sa;
-#ifndef __rtems__
 	int error;
-#endif /* __rtems__ */
 
 	if (len > SOCK_MAXADDRLEN)
 		return (ENAMETOOLONG);
 	if (len < offsetof(struct sockaddr, sa_data[0]))
 		return (EINVAL);
-#ifndef __rtems__
 	sa = malloc(len, M_SONAME, M_WAITOK);
 	error = copyin(uaddr, sa, len);
 	if (error != 0) {
@@ -2168,11 +1702,6 @@ getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len)
 		*namp = sa;
 	}
 	return (error);
-#else /* __rtems__ */
-	sa = memcpy(*namp, uaddr, len);
-	sa->sa_len = len;
-	return (0);
-#endif /* __rtems__ */
 }
 
 /*
diff --git a/freebsd/sys/kern/uipc_usrreq.c b/freebsd/sys/kern/uipc_usrreq.c
index 13fca66d..db07ce8a 100644
--- a/freebsd/sys/kern/uipc_usrreq.c
+++ b/freebsd/sys/kern/uipc_usrreq.c
@@ -608,7 +608,8 @@ rtems_uipc_imfs_destroy(IMFS_jnode_t *node)
 }
 
 static const IMFS_node_control rtems_uipc_imfs_control =
-    IMFS_GENERIC_INITIALIZER(&socketops, rtems_uipc_imfs_initialize,
+	IMFS_GENERIC_INITIALIZER(&rtems_bsd_sysgen_imfsnodeops,
+		rtems_uipc_imfs_initialize,
     rtems_uipc_imfs_destroy);
 
 static const IMFS_node_control rtems_uipc_imfs_zombi_control =
@@ -616,12 +617,13 @@ static const IMFS_node_control rtems_uipc_imfs_zombi_control =
     IMFS_node_destroy_default);
 
 static void
-VOP_UNP_DETACH(IMFS_generic_t *vp)
+VOP_UNP_DETACH_rtems(IMFS_generic_t *vp)
 {
-
 	vp->Node.control = &rtems_uipc_imfs_zombi_control;
 	vp->context = NULL;
 }
+#undef VOP_UNP_DETACH
+#define VOP_UNP_DETACH VOP_UNP_DETACH_rtems
 #endif /* __rtems__ */
 static int
 uipc_bindat(int fd, struct socket *so, struct sockaddr *nam, struct thread *td)
@@ -1725,7 +1727,7 @@ unp_connectat(int fd, struct socket *so, struct sockaddr *nam,
 	    &ctx, &soun->sun_path[0], (size_t)len, eval_flags,
 	    &rtems_filesystem_root, &rtems_filesystem_current);
 
-	if (currentloc->handlers == &socketops) {
+	if (currentloc->handlers == &rtems_bsd_sysgen_imfsnodeops) {
 		vp = currentloc->node_access;
 	} else {
 		vp = NULL;
diff --git a/freebsd/sys/kern/vfs_acl.c b/freebsd/sys/kern/vfs_acl.c
index 56192cfb..f069a8c9 100644
--- a/freebsd/sys/kern/vfs_acl.c
+++ b/freebsd/sys/kern/vfs_acl.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
diff --git a/freebsd/sys/kern/vfs_aio.c b/freebsd/sys/kern/vfs_aio.c
index 350c51a0..c90dbf0a 100644
--- a/freebsd/sys/kern/vfs_aio.c
+++ b/freebsd/sys/kern/vfs_aio.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
@@ -40,7 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/limits.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
-#include <sys/unistd.h>
+#include <rtems/bsd/sys/unistd.h>
 #include <sys/posix4.h>
 #include <sys/proc.h>
 #include <sys/resourcevar.h>
@@ -48,10 +50,14 @@ __FBSDID("$FreeBSD$");
 #include <sys/syscallsubr.h>
 #include <sys/protosw.h>
 #include <sys/rwlock.h>
+#ifndef __rtems__
 #include <sys/sema.h>
+#endif /* __rtems__ */
 #include <sys/socket.h>
 #include <sys/socketvar.h>
+#ifndef __rtems__
 #include <sys/syscall.h>
+#endif /* __rtems__ */
 #include <sys/sysent.h>
 #include <sys/sysctl.h>
 #include <sys/syslog.h>
@@ -302,10 +308,15 @@ struct aiocb_ops {
 };
 
 static TAILQ_HEAD(,aioproc) aio_freeproc;		/* (c) Idle daemons */
+#ifndef __rtems__
 static struct sema aio_newproc_sem;
+#endif /* __rtems__ */
 static struct mtx aio_job_mtx;
 static TAILQ_HEAD(,kaiocb) aio_jobs;			/* (c) Async job list */
 static struct unrhdr *aiod_unr;
+#ifdef __rtems__
+static struct kaioinfo *aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 
 void		aio_init_aioinfo(struct proc *p);
 static int	aio_onceonly(void);
@@ -407,7 +418,9 @@ aio_onceonly(void)
 	kqueue_add_filteropts(EVFILT_AIO, &aio_filtops);
 	kqueue_add_filteropts(EVFILT_LIO, &lio_filtops);
 	TAILQ_INIT(&aio_freeproc);
+#ifndef __rtems__
 	sema_init(&aio_newproc_sem, 0, "aio_new_proc");
+#endif /* __rtems__ */
 	mtx_init(&aio_job_mtx, "aio_job", NULL, MTX_DEF);
 	TAILQ_INIT(&aio_jobs);
 	aiod_unr = new_unrhdr(1, INT_MAX, NULL);
@@ -451,6 +464,7 @@ aio_init_aioinfo(struct proc *p)
 	TAILQ_INIT(&ki->kaio_syncready);
 	TASK_INIT(&ki->kaio_task, 0, aio_kick_helper, p);
 	TASK_INIT(&ki->kaio_sync_task, 0, aio_schedule_fsync, ki);
+#ifndef __rtems__
 	PROC_LOCK(p);
 	if (p->p_aioinfo == NULL) {
 		p->p_aioinfo = ki;
@@ -460,14 +474,25 @@ aio_init_aioinfo(struct proc *p)
 		mtx_destroy(&ki->kaio_mtx);
 		uma_zfree(kaio_zone, ki);
 	}
+#else /* __rtems__ */
+	if (aio_proc_p_aioinfo == NULL) {
+		aio_proc_p_aioinfo = ki;
+	} else {
+		mtx_destroy(&ki->kaio_mtx);
+		uma_zfree(kaio_zone, ki);
+	}
+#endif /* __rtems__ */
 
+#ifndef __rtems__
 	while (num_aio_procs < MIN(target_aio_procs, max_aio_procs))
 		aio_newproc(NULL);
+#endif /* __rtems__ */
 }
 
 static int
 aio_sendsig(struct proc *p, struct sigevent *sigev, ksiginfo_t *ksi)
 {
+#ifndef __rtems__
 	struct thread *td;
 	int error;
 
@@ -482,6 +507,9 @@ aio_sendsig(struct proc *p, struct sigevent *sigev, ksiginfo_t *ksi)
 	}
 	PROC_UNLOCK(p);
 	return (error);
+#else /* __rtems__ */
+	return 0;
+#endif /* __rtems__ */
 }
 
 /*
@@ -494,11 +522,15 @@ aio_free_entry(struct kaiocb *job)
 {
 	struct kaioinfo *ki;
 	struct aioliojob *lj;
+#ifndef __rtems__
 	struct proc *p;
 
 	p = job->userproc;
 	MPASS(curproc == p);
 	ki = p->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	MPASS(ki != NULL);
 
 	AIO_LOCK_ASSERT(ki, MA_OWNED);
@@ -521,18 +553,22 @@ aio_free_entry(struct kaiocb *job)
 			TAILQ_REMOVE(&ki->kaio_liojoblist, lj, lioj_list);
 			/* lio is going away, we need to destroy any knotes */
 			knlist_delete(&lj->klist, curthread, 1);
+#ifndef __rtems__
 			PROC_LOCK(p);
 			sigqueue_take(&lj->lioj_ksi);
 			PROC_UNLOCK(p);
+#endif /* __rtems__ */
 			uma_zfree(aiolio_zone, lj);
 		}
 	}
 
 	/* job is going away, we need to destroy any knotes */
 	knlist_delete(&job->klist, curthread, 1);
+#ifndef __rtems__
 	PROC_LOCK(p);
 	sigqueue_take(&job->ksi);
 	PROC_UNLOCK(p);
+#endif /* __rtems__ */
 
 	AIO_UNLOCK(ki);
 
@@ -635,7 +671,11 @@ aio_proc_rundown(void *arg, struct proc *p)
 
 	KASSERT(curthread->td_proc == p,
 	    ("%s: called on non-curproc", __func__));
+#ifndef __rtems__
 	ki = p->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	if (ki == NULL)
 		return;
 
@@ -655,7 +695,11 @@ restart:
 	/* Wait for all running I/O to be finished */
 	if (TAILQ_FIRST(&ki->kaio_jobqueue) || ki->kaio_active_count != 0) {
 		ki->kaio_flags |= KAIO_WAKEUP;
+#ifndef __rtems__
 		msleep(&p->p_aioinfo, AIO_MTX(ki), PRIBIO, "aioprn", hz);
+#else /* __rtems__ */
+		msleep(&aio_proc_p_aioinfo, AIO_MTX(ki), PRIBIO, "aioprn", hz);
+#endif /* __rtems__ */
 		goto restart;
 	}
 
@@ -667,9 +711,11 @@ restart:
 		if (lj->lioj_count == 0) {
 			TAILQ_REMOVE(&ki->kaio_liojoblist, lj, lioj_list);
 			knlist_delete(&lj->klist, curthread, 1);
+#ifndef __rtems__
 			PROC_LOCK(p);
 			sigqueue_take(&lj->lioj_ksi);
 			PROC_UNLOCK(p);
+#endif /* __rtems__ */
 			uma_zfree(aiolio_zone, lj);
 		} else {
 			panic("LIO job not cleaned up: C:%d, FC:%d\n",
@@ -681,7 +727,11 @@ restart:
 	taskqueue_drain(taskqueue_aiod_kick, &ki->kaio_sync_task);
 	mtx_destroy(&ki->kaio_mtx);
 	uma_zfree(kaio_zone, ki);
+#ifndef __rtems__
 	p->p_aioinfo = NULL;
+#else /* __rtems__ */
+	aio_proc_p_aioinfo = NULL;
+#endif /* __rtems__ */
 }
 
 /*
@@ -698,7 +748,11 @@ aio_selectjob(struct aioproc *aiop)
 restart:
 	TAILQ_FOREACH(job, &aio_jobs, list) {
 		userp = job->userproc;
+#ifndef __rtems__
 		ki = userp->p_aioinfo;
+#else /* __rtems__ */
+		ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 
 		if (ki->kaio_active_count < max_aio_per_proc) {
 			TAILQ_REMOVE(&aio_jobs, job, list);
@@ -785,10 +839,12 @@ aio_process_rw(struct kaiocb *job)
 	auio.uio_segflg = UIO_USERSPACE;
 	auio.uio_td = td;
 
+#ifndef __rtems__
 	msgrcv_st = td->td_ru.ru_msgrcv;
 	msgsnd_st = td->td_ru.ru_msgsnd;
 	inblock_st = td->td_ru.ru_inblock;
 	oublock_st = td->td_ru.ru_oublock;
+#endif /* __rtems__ */
 
 	/*
 	 * aio_aqueue() acquires a reference to the file that is
@@ -806,6 +862,7 @@ aio_process_rw(struct kaiocb *job)
 		auio.uio_rw = UIO_WRITE;
 		error = fo_write(fp, &auio, fp->f_cred, FOF_OFFSET, td);
 	}
+#ifndef __rtems__
 	msgrcv_end = td->td_ru.ru_msgrcv;
 	msgsnd_end = td->td_ru.ru_msgsnd;
 	inblock_end = td->td_ru.ru_inblock;
@@ -815,14 +872,17 @@ aio_process_rw(struct kaiocb *job)
 	job->msgsnd = msgsnd_end - msgsnd_st;
 	job->inblock = inblock_end - inblock_st;
 	job->outblock = oublock_end - oublock_st;
+#endif /* __rtems__ */
 
 	if ((error) && (auio.uio_resid != cnt)) {
 		if (error == ERESTART || error == EINTR || error == EWOULDBLOCK)
 			error = 0;
 		if ((error == EPIPE) && (cb->aio_lio_opcode == LIO_WRITE)) {
+#ifndef __rtems__
 			PROC_LOCK(job->userproc);
 			kern_psignal(job->userproc, SIGPIPE);
 			PROC_UNLOCK(job->userproc);
+#endif /* __rtems__ */
 		}
 	}
 
@@ -879,7 +939,11 @@ aio_bio_done_notify(struct proc *userp, struct kaiocb *job)
 	int lj_done;
 	bool schedule_fsync;
 
+#ifndef __rtems__
 	ki = userp->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	AIO_LOCK_ASSERT(ki, MA_OWNED);
 	lj = job->lio;
 	lj_done = 0;
@@ -894,12 +958,15 @@ aio_bio_done_notify(struct proc *userp, struct kaiocb *job)
 	if (ki->kaio_flags & KAIO_RUNDOWN)
 		goto notification_done;
 
+#ifndef __rtems__
 	if (job->uaiocb.aio_sigevent.sigev_notify == SIGEV_SIGNAL ||
 	    job->uaiocb.aio_sigevent.sigev_notify == SIGEV_THREAD_ID)
 		aio_sendsig(userp, &job->uaiocb.aio_sigevent, &job->ksi);
+#endif /* __rtems__ */
 
 	KNOTE_LOCKED(&job->klist, 1);
 
+#ifndef __rtems__
 	if (lj_done) {
 		if (lj->lioj_signal.sigev_notify == SIGEV_KEVENT) {
 			lj->lioj_flags |= LIOJ_KEVENT_POSTED;
@@ -913,6 +980,7 @@ aio_bio_done_notify(struct proc *userp, struct kaiocb *job)
 			lj->lioj_flags |= LIOJ_SIGNAL_POSTED;
 		}
 	}
+#endif /* __rtems__ */
 
 notification_done:
 	if (job->jobflags & KAIOCB_CHECKSYNC) {
@@ -935,7 +1003,12 @@ notification_done:
 	}
 	if (ki->kaio_flags & KAIO_WAKEUP) {
 		ki->kaio_flags &= ~KAIO_WAKEUP;
+
+#ifndef __rtems__
 		wakeup(&userp->p_aioinfo);
+#else /* __rtems__ */
+		wakeup(&aio_proc_p_aioinfo);
+#endif /* __rtems__ */
 	}
 }
 
@@ -974,7 +1047,9 @@ static bool
 aio_clear_cancel_function_locked(struct kaiocb *job)
 {
 
+#ifndef __rtems__
 	AIO_LOCK_ASSERT(job->userproc->p_aioinfo, MA_OWNED);
+#endif /* __rtems__ */
 	MPASS(job->cancel_fn != NULL);
 	if (job->jobflags & KAIOCB_CANCELLING) {
 		job->jobflags |= KAIOCB_CLEARED;
@@ -990,7 +1065,11 @@ aio_clear_cancel_function(struct kaiocb *job)
 	struct kaioinfo *ki;
 	bool ret;
 
+#ifndef __rtems__
 	ki = job->userproc->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	AIO_LOCK(ki);
 	ret = aio_clear_cancel_function_locked(job);
 	AIO_UNLOCK(ki);
@@ -1001,7 +1080,9 @@ static bool
 aio_set_cancel_function_locked(struct kaiocb *job, aio_cancel_fn_t *func)
 {
 
+#ifndef __rtems__
 	AIO_LOCK_ASSERT(job->userproc->p_aioinfo, MA_OWNED);
+#endif /* __rtems__ */
 	if (job->jobflags & KAIOCB_CANCELLED)
 		return (false);
 	job->cancel_fn = func;
@@ -1014,7 +1095,11 @@ aio_set_cancel_function(struct kaiocb *job, aio_cancel_fn_t *func)
 	struct kaioinfo *ki;
 	bool ret;
 
+#ifndef __rtems__
 	ki = job->userproc->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	AIO_LOCK(ki);
 	ret = aio_set_cancel_function_locked(job, func);
 	AIO_UNLOCK(ki);
@@ -1030,8 +1115,13 @@ aio_complete(struct kaiocb *job, long status, int error)
 	job->uaiocb._aiocb_private.error = error;
 	job->uaiocb._aiocb_private.status = status;
 
+#ifndef __rtems__
 	userp = job->userproc;
 	ki = userp->p_aioinfo;
+#else /* __rtems__ */
+	userp = NULL;
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 
 	AIO_LOCK(ki);
 	KASSERT(!(job->jobflags & KAIOCB_FINISHED),
@@ -1055,7 +1145,9 @@ void
 aio_switch_vmspace(struct kaiocb *job)
 {
 
+#ifndef __rtems__
 	vmspace_switch_aio(job->userproc->p_vmspace);
+#endif /* __rtems__ */
 }
 
 /*
@@ -1078,24 +1170,30 @@ aio_daemon(void *_id)
 	 * doesn't get freed by jobs that switch to a different
 	 * vmspace.
 	 */
+#ifndef __rtems__
 	p = td->td_proc;
 	myvm = vmspace_acquire_ref(p);
 
 	KASSERT(p->p_textvp == NULL, ("kthread has a textvp"));
+#endif /* __rtems__ */
 
 	/*
 	 * Allocate and ready the aio control info.  There is one aiop structure
 	 * per daemon.
 	 */
 	aiop = uma_zalloc(aiop_zone, M_WAITOK);
+#ifndef __rtems__
 	aiop->aioproc = p;
+#endif /* __rtems__ */
 	aiop->aioprocflags = 0;
 
 	/*
 	 * Wakeup parent process.  (Parent sleeps to keep from blasting away
 	 * and creating too many daemons.)
 	 */
+#ifndef __rtems__
 	sema_post(&aio_newproc_sem);
+#endif /* __rtems__ */
 
 	mtx_lock(&aio_job_mtx);
 	for (;;) {
@@ -1113,7 +1211,11 @@ aio_daemon(void *_id)
 		while ((job = aio_selectjob(aiop)) != NULL) {
 			mtx_unlock(&aio_job_mtx);
 
+#ifndef __rtems__
 			ki = job->userproc->p_aioinfo;
+#else /* __rtems__ */
+			ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 			job->handle_fn(job);
 
 			mtx_lock(&aio_job_mtx);
@@ -1124,6 +1226,7 @@ aio_daemon(void *_id)
 		/*
 		 * Disconnect from user address space.
 		 */
+#ifndef __rtems__
 		if (p->p_vmspace != myvm) {
 			mtx_unlock(&aio_job_mtx);
 			vmspace_switch_aio(myvm);
@@ -1134,6 +1237,7 @@ aio_daemon(void *_id)
 			 */
 			continue;
 		}
+#endif /* __rtems__ */
 
 		mtx_assert(&aio_job_mtx, MA_OWNED);
 
@@ -1155,12 +1259,14 @@ aio_daemon(void *_id)
 	mtx_unlock(&aio_job_mtx);
 	uma_zfree(aiop_zone, aiop);
 	free_unr(aiod_unr, id);
+#ifndef __rtems__
 	vmspace_free(myvm);
 
 	KASSERT(p->p_vmspace == myvm,
 	    ("AIOD: bad vmspace for exiting daemon"));
 	KASSERT(myvm->vm_refcnt > 1,
 	    ("AIOD: bad vm refcnt for exiting daemon: %d", myvm->vm_refcnt));
+#endif /* __rtems__ */
 	kproc_exit(0);
 }
 
@@ -1182,7 +1288,9 @@ aio_newproc(int *start)
 		/*
 		 * Wait until daemon is started.
 		 */
+#ifndef __rtems__
 		sema_wait(&aio_newproc_sem);
+#endif /* __rtems__ */
 		mtx_lock(&aio_job_mtx);
 		num_aio_procs++;
 		if (start != NULL)
@@ -1248,7 +1356,11 @@ aio_qbio(struct proc *p, struct kaiocb *job)
 		goto unref;
 	}
 
+#ifndef __rtems__
 	ki = p->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	poff = (vm_offset_t)cb->aio_buf & PAGE_MASK;
 	if ((dev->si_flags & SI_UNMAPPED) && unmapped_buf_allowed) {
 		if (cb->aio_nbytes > MAXPHYS) {
@@ -1287,7 +1399,11 @@ aio_qbio(struct proc *p, struct kaiocb *job)
 	prot = VM_PROT_READ;
 	if (cb->aio_lio_opcode == LIO_READ)
 		prot |= VM_PROT_WRITE;	/* Less backwards than it looks */
+#ifndef __rtems__
 	job->npages = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map,
+#else /* __rtems__ */
+	job->npages = vm_fault_quick_hold_pages(NULL,
+#endif /* __rtems__ */
 	    (vm_offset_t)bp->bio_data, bp->bio_length, prot, job->pages,
 	    nitems(job->pages));
 	if (job->npages < 0) {
@@ -1309,7 +1425,9 @@ aio_qbio(struct proc *p, struct kaiocb *job)
 	}
 
 	/* Perform transfer. */
+#ifndef __rtems__
 	csw->d_strategy(bp);
+#endif /* __rtems__ */
 	dev_relthread(dev, ref);
 	return (0);
 
@@ -1449,7 +1567,9 @@ int
 aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
     int type, struct aiocb_ops *ops)
 {
+#ifndef __rtems__
 	struct proc *p = td->td_proc;
+#endif /* __rtems__ */
 	struct file *fp;
 	struct kaiocb *job;
 	struct kaioinfo *ki;
@@ -1460,10 +1580,14 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
 	int jid;
 	u_short evflags;
 
+#ifndef __rtems__
 	if (p->p_aioinfo == NULL)
 		aio_init_aioinfo(p);
 
 	ki = p->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 
 	ops->store_status(ujob, -1);
 	ops->store_error(ujob, 0);
@@ -1490,6 +1614,7 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
 		return (EINVAL);
 	}
 
+#ifndef __rtems__
 	if (job->uaiocb.aio_sigevent.sigev_notify != SIGEV_KEVENT &&
 	    job->uaiocb.aio_sigevent.sigev_notify != SIGEV_SIGNAL &&
 	    job->uaiocb.aio_sigevent.sigev_notify != SIGEV_THREAD_ID &&
@@ -1505,6 +1630,7 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
 		uma_zfree(aiocb_zone, job);
 		return (EINVAL);
 	}
+#endif /* __rtems__ */
 
 	ksiginfo_init(&job->ksi);
 
@@ -1581,6 +1707,15 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
 		return (0);
 	}
 
+#ifdef __rtems__
+	/*
+	 * Note: the following has been removed because kqueue and signals
+	 * meet here and for reasons I cannot explain signal support in libbsd
+	 * has not been supported but it needs to be.
+	 */
+	error = EINVAL;
+	goto aqueue_fail;
+#else /* __rtems__ */
 	if (job->uaiocb.aio_sigevent.sigev_notify != SIGEV_KEVENT)
 		goto no_kqueue;
 	evflags = job->uaiocb.aio_sigevent.sigev_notify_kevent_flags;
@@ -1598,12 +1733,15 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
 	error = kqfd_register(kqfd, &kev, td, M_WAITOK);
 	if (error)
 		goto aqueue_fail;
+#endif /* __rtems__ */
 
 no_kqueue:
 
 	ops->store_error(ujob, EINPROGRESS);
 	job->uaiocb._aiocb_private.error = EINPROGRESS;
+#ifndef __rtems__
 	job->userproc = p;
+#endif /* __rtems__ */
 	job->cred = crhold(td->td_ucred);
 	job->jobflags = KAIOCB_QUEUEING;
 	job->lio = lj;
@@ -1631,7 +1769,11 @@ no_kqueue:
 		 * The bulk of the completion is deferred in that case
 		 * until this point.
 		 */
+#ifndef __rtems__
 		aio_bio_done_notify(p, job);
+#else /* __rtems__ */
+		aio_bio_done_notify(NULL, job);
+#endif /* __rtems__ */
 	} else
 		TAILQ_INSERT_TAIL(&ki->kaio_jobqueue, job, plist);
 	AIO_UNLOCK(ki);
@@ -1678,7 +1820,11 @@ aio_cancel_sync(struct kaiocb *job)
 {
 	struct kaioinfo *ki;
 
+#ifndef __rtems__
 	ki = job->userproc->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	AIO_LOCK(ki);
 	if (!aio_cancel_cleared(job))
 		TAILQ_REMOVE(&ki->kaio_syncqueue, job, list);
@@ -1696,7 +1842,11 @@ aio_queue_file(struct file *fp, struct kaiocb *job)
 	int error;
 	bool safe;
 
+#ifndef __rtems__
 	ki = job->userproc->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	error = aio_qbio(job->userproc, job);
 	if (error >= 0)
 		return (error);
@@ -1755,7 +1905,11 @@ aio_queue_file(struct file *fp, struct kaiocb *job)
 static void
 aio_kick_nowait(struct proc *userp)
 {
+#ifndef __rtems__
 	struct kaioinfo *ki = userp->p_aioinfo;
+#else /* __rtems__ */
+	struct kaioinfo *ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	struct aioproc *aiop;
 
 	mtx_assert(&aio_job_mtx, MA_OWNED);
@@ -1772,7 +1926,11 @@ aio_kick_nowait(struct proc *userp)
 static int
 aio_kick(struct proc *userp)
 {
+#ifndef __rtems__
 	struct kaioinfo *ki = userp->p_aioinfo;
+#else /* __rtems__ */
+	struct kaioinfo *ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	struct aioproc *aiop;
 	int error, ret = 0;
 
@@ -1818,12 +1976,18 @@ aio_kick_helper(void *context, int pending)
 static int
 kern_aio_return(struct thread *td, struct aiocb *ujob, struct aiocb_ops *ops)
 {
+#ifndef __rtems__
 	struct proc *p = td->td_proc;
+#endif /* __rtems__ */
 	struct kaiocb *job;
 	struct kaioinfo *ki;
 	long status, error;
 
+#ifndef __rtems__
 	ki = p->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	if (ki == NULL)
 		return (EINVAL);
 	AIO_LOCK(ki);
@@ -1836,10 +2000,12 @@ kern_aio_return(struct thread *td, struct aiocb *ujob, struct aiocb_ops *ops)
 		status = job->uaiocb._aiocb_private.status;
 		error = job->uaiocb._aiocb_private.error;
 		td->td_retval[0] = status;
+#ifndef __rtems__
 		td->td_ru.ru_oublock += job->outblock;
 		td->td_ru.ru_inblock += job->inblock;
 		td->td_ru.ru_msgsnd += job->msgsnd;
 		td->td_ru.ru_msgrcv += job->msgrcv;
+#endif /* __rtems__ */
 		aio_free_entry(job);
 		AIO_UNLOCK(ki);
 		ops->store_error(ujob, error);
@@ -1865,7 +2031,9 @@ static int
 kern_aio_suspend(struct thread *td, int njoblist, struct aiocb **ujoblist,
     struct timespec *ts)
 {
+#ifndef __rtems__
 	struct proc *p = td->td_proc;
+#endif /* __rtems__ */
 	struct timeval atv;
 	struct kaioinfo *ki;
 	struct kaiocb *firstjob, *job;
@@ -1882,7 +2050,11 @@ kern_aio_suspend(struct thread *td, int njoblist, struct aiocb **ujoblist,
 		timo = tvtohz(&atv);
 	}
 
+#ifndef __rtems__
 	ki = p->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	if (ki == NULL)
 		return (EAGAIN);
 
@@ -1908,8 +2080,13 @@ kern_aio_suspend(struct thread *td, int njoblist, struct aiocb **ujoblist,
 			break;
 
 		ki->kaio_flags |= KAIO_WAKEUP;
+#ifndef __rtems__
 		error = msleep(&p->p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH,
 		    "aiospn", timo);
+#else /* __rtems__ */
+		error = msleep(&aio_proc_p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH,
+		    "aiospn", timo);
+#endif /* __rtems__ */
 		if (error == ERESTART)
 			error = EINTR;
 		if (error)
@@ -1952,7 +2129,11 @@ sys_aio_suspend(struct thread *td, struct aio_suspend_args *uap)
 int
 sys_aio_cancel(struct thread *td, struct aio_cancel_args *uap)
 {
+#ifndef __rtems__
 	struct proc *p = td->td_proc;
+#else /* __rtems__ */
+	struct proc *p = NULL;
+#endif /* __rtems__ */
 	struct kaioinfo *ki;
 	struct kaiocb *job, *jobn;
 	struct file *fp;
@@ -1966,7 +2147,11 @@ sys_aio_cancel(struct thread *td, struct aio_cancel_args *uap)
 	if (error)
 		return (error);
 
+#ifndef __rtems__
 	ki = p->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	if (ki == NULL)
 		goto done;
 
@@ -2028,12 +2213,18 @@ done:
 static int
 kern_aio_error(struct thread *td, struct aiocb *ujob, struct aiocb_ops *ops)
 {
+#ifndef __rtems__
 	struct proc *p = td->td_proc;
+#endif /* __rtems__ */
 	struct kaiocb *job;
 	struct kaioinfo *ki;
 	int status;
 
+#ifndef __rtems__
 	ki = p->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	if (ki == NULL) {
 		td->td_retval[0] = EINVAL;
 		return (0);
@@ -2121,7 +2312,9 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
     struct aiocb **acb_list, int nent, struct sigevent *sig,
     struct aiocb_ops *ops)
 {
+#ifndef __rtems__
 	struct proc *p = td->td_proc;
+#endif /* __rtems__ */
 	struct aiocb *job;
 	struct kaioinfo *ki;
 	struct aioliojob *lj;
@@ -2136,10 +2329,19 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
 	if (nent < 0 || nent > max_aio_queue_per_proc)
 		return (EINVAL);
 
+#ifndef __rtems__
 	if (p->p_aioinfo == NULL)
 		aio_init_aioinfo(p);
+#else /* __rtems__ */
+	if (aio_proc_p_aioinfo == NULL)
+		aio_init_aioinfo(NULL);
+#endif /* __rtems__ */
 
+#ifndef __rtems__
 	ki = p->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 
 	lj = uma_zalloc(aiolio_zone, M_WAITOK);
 	lj->lioj_flags = 0;
@@ -2152,6 +2354,14 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
 	 * Setup signal.
 	 */
 	if (sig && (mode == LIO_NOWAIT)) {
+#ifdef __rtems__
+	/*
+	 * Note: the following has been removed because kqueue and signals
+	 * meet here and for reasons I cannot explain signal support in libbsd
+	 * has not been supported but it needs to be.
+	 */
+		return EINVAL;
+#else /* __rtems__ */
 		bcopy(sig, &lj->lioj_signal, sizeof(lj->lioj_signal));
 		if (lj->lioj_signal.sigev_notify == SIGEV_KEVENT) {
 			/* Assume only new style KEVENT */
@@ -2182,6 +2392,7 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
 			uma_zfree(aiolio_zone, lj);
 			return EINVAL;
 		}
+#endif /* __rtems__ */
 	}
 
 	AIO_LOCK(ki);
@@ -2216,7 +2427,11 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
 	if (mode == LIO_WAIT) {
 		while (lj->lioj_count - 1 != lj->lioj_finished_count) {
 			ki->kaio_flags |= KAIO_WAKEUP;
+#ifndef __rtems__
 			error = msleep(&p->p_aioinfo, AIO_MTX(ki),
+#else /* __rtems__ */
+			error = msleep(&aio_proc_p_aioinfo, AIO_MTX(ki),
+#endif /* __rtems__ */
 			    PRIBIO | PCATCH, "aiospn", 0);
 			if (error == ERESTART)
 				error = EINTR;
@@ -2225,6 +2440,15 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
 		}
 	} else {
 		if (lj->lioj_count - 1 == lj->lioj_finished_count) {
+#ifdef __rtems__
+			/*
+			 * Note: the following has been removed because kqueue
+			 * and signals meet here and for reasons I cannot
+			 * explain signal support in libbsd has not been
+			 * supported but it needs to be.
+			 */
+			return EINVAL;
+#else /* __rtems__ */
 			if (lj->lioj_signal.sigev_notify == SIGEV_KEVENT) {
 				lj->lioj_flags |= LIOJ_KEVENT_POSTED;
 				KNOTE_LOCKED(&lj->klist, 1);
@@ -2237,15 +2461,18 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
 					    &lj->lioj_ksi);
 				lj->lioj_flags |= LIOJ_SIGNAL_POSTED;
 			}
+#endif /* __rtems__ */
 		}
 	}
 	lj->lioj_count--;
 	if (lj->lioj_count == 0) {
 		TAILQ_REMOVE(&ki->kaio_liojoblist, lj, lioj_list);
 		knlist_delete(&lj->klist, curthread, 1);
+#ifndef __rtems__
 		PROC_LOCK(p);
 		sigqueue_take(&lj->lioj_ksi);
 		PROC_UNLOCK(p);
+#endif /* __rtems__ */
 		AIO_UNLOCK(ki);
 		uma_zfree(aiolio_zone, lj);
 	} else
@@ -2341,7 +2568,11 @@ aio_biowakeup(struct bio *bp)
 
 	/* Release mapping into kernel space. */
 	userp = job->userproc;
+#ifndef __rtems__
 	ki = userp->p_aioinfo;
+#else /* __rtems__ */
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 	if (job->pbuf) {
 		pmap_qremove((vm_offset_t)job->pbuf->b_data, job->npages);
 		relpbuf(job->pbuf, NULL);
@@ -2379,7 +2610,9 @@ static int
 kern_aio_waitcomplete(struct thread *td, struct aiocb **ujobp,
     struct timespec *ts, struct aiocb_ops *ops)
 {
+#ifndef __rtems__
 	struct proc *p = td->td_proc;
+#endif /* __rtems__ */
 	struct timeval atv;
 	struct kaioinfo *ki;
 	struct kaiocb *job;
@@ -2403,9 +2636,15 @@ kern_aio_waitcomplete(struct thread *td, struct aiocb **ujobp,
 		timo = tvtohz(&atv);
 	}
 
+#ifndef __rtems__
 	if (p->p_aioinfo == NULL)
 		aio_init_aioinfo(p);
 	ki = p->p_aioinfo;
+#else /* __rtems__ */
+	if (aio_proc_p_aioinfo == NULL)
+		aio_init_aioinfo(NULL);
+	ki = aio_proc_p_aioinfo;
+#endif /* __rtems__ */
 
 	error = 0;
 	job = NULL;
@@ -2416,8 +2655,13 @@ kern_aio_waitcomplete(struct thread *td, struct aiocb **ujobp,
 			break;
 		}
 		ki->kaio_flags |= KAIO_WAKEUP;
+#ifndef __rtems__
 		error = msleep(&p->p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH,
 		    "aiowc", timo);
+#else /* __rtems__ */
+		error = msleep(&aio_proc_p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH,
+		    "aiowc", timo);
+#endif /* __rtems__ */
 		if (timo && error == ERESTART)
 			error = EINTR;
 		if (error)
@@ -2430,10 +2674,12 @@ kern_aio_waitcomplete(struct thread *td, struct aiocb **ujobp,
 		status = job->uaiocb._aiocb_private.status;
 		error = job->uaiocb._aiocb_private.error;
 		td->td_retval[0] = status;
+#ifndef __rtems__
 		td->td_ru.ru_oublock += job->outblock;
 		td->td_ru.ru_inblock += job->inblock;
 		td->td_ru.ru_msgsnd += job->msgsnd;
 		td->td_ru.ru_msgrcv += job->msgrcv;
+#endif /* __rtems__ */
 		aio_free_entry(job);
 		AIO_UNLOCK(ki);
 		ops->store_aiocb(ujobp, ujob);
diff --git a/freebsd/sys/kern/vfs_bio.c b/freebsd/sys/kern/vfs_bio.c
index 2277bf67..50e87ff8 100644
--- a/freebsd/sys/kern/vfs_bio.c
+++ b/freebsd/sys/kern/vfs_bio.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
@@ -54,7 +56,9 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <sys/counter.h>
 #include <sys/buf.h>
+#ifndef __rtems__
 #include <sys/devicestat.h>
+#endif /* __rtems__ */
 #include <sys/eventhandler.h>
 #include <sys/fail.h>
 #include <sys/limits.h>
@@ -85,8 +89,10 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_pager.h>
 #include <vm/vm_extern.h>
 #include <vm/vm_map.h>
+#ifndef __rtems__
 #include <vm/swap_pager.h>
-#include "opt_swap.h"
+#endif /* __rtems__ */
+#include <rtems/bsd/local/opt_swap.h>
 
 static MALLOC_DEFINE(M_BIOBUF, "biobuf", "BIO buffer");
 
@@ -147,7 +153,15 @@ struct bufdomain {
 #define	BD_DOMAIN(bd)		(bd - bdomain)
 
 static struct buf *buf;		/* buffer header pool */
+#ifndef __rtems__
 extern struct buf *swbuf;	/* Swap buffer header pool. */
+#else /* __rtems__ */
+#define VPR_NOREUSE 0
+#define VPR_TRYFREE 0
+#define bogus_page (NULL + 1)
+#define num_pages(x) \
+        ((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) >> PAGE_SHIFT))
+#endif /* __rtems__ */
 caddr_t __read_mostly unmapped_buf;
 
 /* Used below and for softdep flushing threads in ufs/ffs/ffs_softdep.c */
@@ -791,12 +805,16 @@ bufspace_daemon(void *arg)
 {
 	struct bufdomain *bd;
 
+#ifndef __rtems__
 	EVENTHANDLER_REGISTER(shutdown_pre_sync, kthread_shutdown, curthread,
 	    SHUTDOWN_PRI_LAST + 100);
+#endif /* __rtems__ */
 
 	bd = arg;
 	for (;;) {
+#ifndef __rtems__
 		kthread_suspend_check();
+#endif /* __rtems__ */
 
 		/*
 		 * Free buffers from the clean queue until we meet our
@@ -844,7 +862,9 @@ bufspace_daemon(void *arg)
 				} else
 					BD_UNLOCK(bd);
 			}
+#ifndef __rtems__
 			maybe_yield();
+#endif /* __rtems__ */
 		}
 		bufspace_daemon_wait(bd);
 	}
@@ -953,6 +973,7 @@ static __inline void
 vfs_buf_test_cache(struct buf *bp, vm_ooffset_t foff, vm_offset_t off,
     vm_offset_t size, vm_page_t m)
 {
+#ifndef __rtems__
 
 	VM_OBJECT_ASSERT_LOCKED(m->object);
 	if (bp->b_flags & B_CACHE) {
@@ -960,6 +981,7 @@ vfs_buf_test_cache(struct buf *bp, vm_ooffset_t foff, vm_offset_t off,
 		if (vm_page_is_valid(m, base, size) == 0)
 			bp->b_flags &= ~B_CACHE;
 	}
+#endif /* __rtems__ */
 }
 
 /* Wake up the buffer daemon if necessary */
@@ -1017,9 +1039,11 @@ bd_speedup(void)
 	mtx_unlock(&bdlock);
 }
 
+#ifndef __rtems__
 #ifndef NSWBUF_MIN
 #define	NSWBUF_MIN	16
 #endif
+#endif /* __rtems__ */
 
 #ifdef __i386__
 #define	TRANSIENT_DENOM	5
@@ -1129,6 +1153,7 @@ kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est)
 			nbuf = buf_sz / BKVASIZE;
 	}
 
+#ifndef __rtems__
 	/*
 	 * swbufs are used as temporary holders for I/O, such as paging I/O.
 	 * We have no less then 16 and no more then 256.
@@ -1137,12 +1162,15 @@ kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est)
 	TUNABLE_INT_FETCH("kern.nswbuf", &nswbuf);
 	if (nswbuf < NSWBUF_MIN)
 		nswbuf = NSWBUF_MIN;
+#endif /* __rtems__ */
 
 	/*
 	 * Reserve space for the buffer cache buffers
 	 */
+#ifndef __rtems__
 	swbuf = (void *)v;
 	v = (caddr_t)(swbuf + nswbuf);
+#endif /* __rtems__ */
 	buf = (void *)v;
 	v = (caddr_t)(buf + nbuf);
 
@@ -1164,7 +1192,12 @@ bufinit(void)
 	mtx_init(&bdlock, "buffer daemon lock", NULL, MTX_DEF);
 	mtx_init(&bdirtylock, "dirty buf lock", NULL, MTX_DEF);
 
+#ifndef __rtems__
 	unmapped_buf = (caddr_t)kva_alloc(MAXPHYS);
+#else /* __rtems__ */
+	extern caddr_t unmapped_base;
+	unmapped_buf = (caddr_t)unmapped_base;
+#endif /* __rtems__ */
 
 	/* finally, initialize each buffer header and stick on empty q */
 	for (i = 0; i < nbuf; i++) {
@@ -1252,7 +1285,9 @@ bufinit(void)
 	numfreebuffers = nbuf;
 
 	/* Setup the kva and free list allocators. */
+#ifndef __rtems__
 	vmem_set_reclaim(buffer_arena, bufkva_reclaim);
+#endif /* __rtems__ */
 	buf_zone = uma_zcache_create("buf free cache", sizeof(struct buf),
 	    NULL, NULL, NULL, NULL, buf_import, buf_release, NULL, 0);
 
@@ -1335,6 +1370,7 @@ isbufbusy(struct buf *bp)
 void
 bufshutdown(int show_busybufs)
 {
+#ifndef __rtems__
 	static int first_buf_printf = 1;
 	struct buf *bp;
 	int iter, nbusy, pbusy;
@@ -1441,6 +1477,7 @@ bufshutdown(int show_busybufs)
 	}
 	swapoff_all();
 	DELAY(100000);		/* wait for console output to finish */
+#endif /* __rtems__ */
 }
 
 static void
@@ -1454,7 +1491,9 @@ bpmap_qenter(struct buf *bp)
 	 * bp->b_offset may be offset into the first page.
 	 */
 	bp->b_data = (caddr_t)trunc_page((vm_offset_t)bp->b_data);
+#ifndef __rtems__
 	pmap_qenter((vm_offset_t)bp->b_data, bp->b_pages, bp->b_npages);
+#endif /* __rtems__ */
 	bp->b_data = (caddr_t)((vm_offset_t)bp->b_data |
 	    (vm_offset_t)(bp->b_offset & PAGE_MASK));
 }
@@ -2103,7 +2142,9 @@ breada(struct vnode * vp, daddr_t * rablkno, int * rabsize, int cnt,
 			PROC_UNLOCK(curproc);
 		}
 #endif /* RACCT */
+#ifndef __rtems__
 		td->td_ru.ru_inblock++;
+#endif /* __rtems__ */
 		rabp->b_flags |= B_ASYNC;
 		rabp->b_flags &= ~B_INVAL;
 		if ((flags & GB_CKHASH) != 0) {
@@ -2166,7 +2207,9 @@ breadn_flags(struct vnode *vp, daddr_t blkno, int size, daddr_t *rablkno,
 			PROC_UNLOCK(td->td_proc);
 		}
 #endif /* RACCT */
+#ifndef __rtems__
 		td->td_ru.ru_inblock++;
+#endif /* __rtems__ */
 		bp->b_iocmd = BIO_READ;
 		bp->b_flags &= ~B_INVAL;
 		if ((flags & GB_CKHASH) != 0) {
@@ -2274,7 +2317,9 @@ bufwrite(struct buf *bp)
 		PROC_UNLOCK(curproc);
 	}
 #endif /* RACCT */
+#ifndef __rtems__
 	curthread->td_ru.ru_oublock++;
+#endif /* __rtems__ */
 	if (oldflags & B_ASYNC)
 		BUF_KERNPROC(bp);
 	bp->b_iooffset = dbtob(bp->b_blkno);
@@ -2835,6 +2880,9 @@ out:
 static void
 vfs_vmio_iodone(struct buf *bp)
 {
+#ifdef __rtems__
+  panic(__func__);
+#else /* __rtems__ */
 	vm_ooffset_t foff;
 	vm_page_t m;
 	vm_object_t obj;
@@ -2901,6 +2949,7 @@ vfs_vmio_iodone(struct buf *bp)
 		pmap_qenter(trunc_page((vm_offset_t)bp->b_data),
 		    bp->b_pages, bp->b_npages);
 	}
+#endif /* __rtems__ */
 }
 
 /*
@@ -2916,7 +2965,9 @@ vfs_vmio_invalidate(struct buf *bp)
 
 	if (buf_mapped(bp)) {
 		BUF_CHECK_MAPPED(bp);
+#ifndef __rtems__
 		pmap_qremove(trunc_page((vm_offset_t)bp->b_data), bp->b_npages);
+#endif /* _-rtems__ */
 	} else
 		BUF_CHECK_UNMAPPED(bp);
 	/*
@@ -2942,6 +2993,7 @@ vfs_vmio_invalidate(struct buf *bp)
 			panic("vfs_vmio_invalidate: Unexpected bogus page.");
 		bp->b_pages[i] = NULL;
 
+#ifndef __rtems__
 		presid = resid > (PAGE_SIZE - poffset) ?
 		    (PAGE_SIZE - poffset) : resid;
 		KASSERT(presid >= 0, ("brelse: extra page"));
@@ -2954,6 +3006,7 @@ vfs_vmio_invalidate(struct buf *bp)
 		if (pmap_page_wired_mappings(m) == 0)
 			vm_page_set_invalid(m, poffset, presid);
 		vm_page_release_locked(m, flags);
+#endif /* __rtems__ */
 		resid -= presid;
 		poffset = 0;
 	}
@@ -2976,8 +3029,10 @@ vfs_vmio_truncate(struct buf *bp, int desiredpages)
 
 	if (buf_mapped(bp)) {
 		BUF_CHECK_MAPPED(bp);
+#ifndef __rtems__
 		pmap_qremove((vm_offset_t)trunc_page((vm_offset_t)bp->b_data) +
 		    (desiredpages << PAGE_SHIFT), bp->b_npages - desiredpages);
+#endif /* __rtems__ */
 	} else
 		BUF_CHECK_UNMAPPED(bp);
 
@@ -2996,10 +3051,12 @@ vfs_vmio_truncate(struct buf *bp, int desiredpages)
 		m = bp->b_pages[i];
 		KASSERT(m != bogus_page, ("allocbuf: bogus page found"));
 		bp->b_pages[i] = NULL;
+#ifndef __rtems__
 		if (obj != NULL)
 			vm_page_release_locked(m, flags);
 		else
 			vm_page_release(m, flags);
+#endif /* __rtems__ */
 	}
 	if (obj != NULL)
 		VM_OBJECT_WUNLOCK(obj);
@@ -3039,11 +3096,13 @@ vfs_vmio_extend(struct buf *bp, int desiredpages, int size)
 		 * deadlocks once allocbuf() is called after
 		 * pages are vfs_busy_pages().
 		 */
+#ifndef __rtems__
 		(void)vm_page_grab_pages(obj,
 		    OFF_TO_IDX(bp->b_offset) + bp->b_npages,
 		    VM_ALLOC_SYSTEM | VM_ALLOC_IGN_SBUSY |
 		    VM_ALLOC_NOBUSY | VM_ALLOC_WIRED,
 		    &bp->b_pages[bp->b_npages], desiredpages - bp->b_npages);
+#endif /* __rtems__ */
 		bp->b_npages = desiredpages;
 	}
 
@@ -3079,9 +3138,11 @@ vfs_vmio_extend(struct buf *bp, int desiredpages, int size)
 	/*
 	 * Step 3, fixup the KVA pmap.
 	 */
+#ifdef __rtems__
 	if (buf_mapped(bp))
 		bpmap_qenter(bp);
 	else
+#endif /* __rtems__ */
 		BUF_CHECK_UNMAPPED(bp);
 }
 
@@ -3178,9 +3239,13 @@ vfs_bio_awrite(struct buf *bp)
 		 */
 		if (ncl != 1) {
 			BUF_UNLOCK(bp);
+#ifndef __rtems__
 			nwritten = cluster_wbuild(vp, size, lblkno - j, ncl,
 			    gbflags);
 			return (nwritten);
+#else /* __rtems__ */
+			panic("no cluster support");
+#endif /* __rtems__ */
 		}
 	}
 	bremfree(bp);
@@ -3330,8 +3395,10 @@ buf_daemon()
 	/*
 	 * This process needs to be suspended prior to shutdown sync.
 	 */
+#ifndef __rtems__
 	EVENTHANDLER_REGISTER(shutdown_pre_sync, kthread_shutdown, curthread,
 	    SHUTDOWN_PRI_LAST + 100);
+#endif /* __rtems__ */
 
 	/*
 	 * Start the buf clean daemons as children threads.
@@ -3354,7 +3421,9 @@ buf_daemon()
 		bd_request = 0;
 		mtx_unlock(&bdlock);
 
+#ifndef __rtems__
 		kthread_suspend_check();
+#endif /* __rtems__ */
 
 		/*
 		 * Save speedupreq for this pass and reset to capture new
@@ -3453,7 +3522,9 @@ flushbufqueues(struct vnode *lvp, struct bufdomain *bd, int target,
 	TAILQ_INSERT_HEAD(&bq->bq_queue, sentinel, b_freelist);
 	BQ_UNLOCK(bq);
 	while (flushed != target) {
+#ifndef __rtems__
 		maybe_yield();
+#endif /* __rtems__ */
 		BQ_LOCK(bq);
 		bp = TAILQ_NEXT(sentinel, b_freelist);
 		if (bp != NULL) {
@@ -3532,9 +3603,13 @@ flushbufqueues(struct vnode *lvp, struct bufdomain *bd, int target,
 		if (error == 0) {
 			CTR3(KTR_BUF, "flushbufqueue(%p) vp %p flags %X",
 			    bp, bp->b_vp, bp->b_flags);
+#ifndef __rtems__
 			if (curproc == bufdaemonproc) {
 				vfs_bio_awrite(bp);
 			} else {
+#else /* __rtems__ */
+			{
+#endif /* __rtems__ */
 				bremfree(bp);
 				bwrite(bp);
 				counter_u64_add(notbufdflushes, 1);
@@ -3549,7 +3624,11 @@ flushbufqueues(struct vnode *lvp, struct bufdomain *bd, int target,
 			 * Sleeping on runningbufspace while holding
 			 * vnode lock leads to deadlock.
 			 */
+#ifndef __rtems__
 			if (curproc == bufdaemonproc &&
+#else /* __rtems__ */
+			if (
+#endif /* __rtems__ */
 			    runningbufspace > hirunningspace)
 				waitrunningbufspace();
 			continue;
@@ -3587,6 +3666,7 @@ incore(struct bufobj *bo, daddr_t blkno)
 static int
 inmem(struct vnode * vp, daddr_t blkno)
 {
+#ifndef __rtems__
 	vm_object_t obj;
 	vm_offset_t toff, tinc, size;
 	vm_page_t m;
@@ -3625,6 +3705,9 @@ inmem(struct vnode * vp, daddr_t blkno)
 notinmem:
 	VM_OBJECT_RUNLOCK(obj);
 	return (0);
+#else /* __rtems__ */
+	return 1;
+#endif /* __rtems__ */
 }
 
 /*
@@ -3672,6 +3755,7 @@ vfs_clean_pages_dirty_buf(struct buf *bp)
 static void
 vfs_setdirty_locked_object(struct buf *bp)
 {
+#ifndef __rtems__
 	vm_object_t object;
 	int i;
 
@@ -3730,6 +3814,7 @@ vfs_setdirty_locked_object(struct buf *bp)
 				bp->b_dirtyend = eoffset;
 		}
 	}
+#endif /* __rtems__ */
 }
 
 /*
@@ -4470,6 +4555,7 @@ bufdone(struct buf *bp)
 void
 vfs_unbusy_pages(struct buf *bp)
 {
+#ifndef __rtems__
 	int i;
 	vm_object_t obj;
 	vm_page_t m;
@@ -4498,6 +4584,7 @@ vfs_unbusy_pages(struct buf *bp)
 	}
 	vm_object_pip_wakeupn(obj, bp->b_npages);
 	VM_OBJECT_WUNLOCK(obj);
+#endif /* __rtems__ */
 }
 
 /*
@@ -4511,6 +4598,7 @@ vfs_unbusy_pages(struct buf *bp)
 static void
 vfs_page_set_valid(struct buf *bp, vm_ooffset_t off, vm_page_t m)
 {
+#ifndef __rtems__
 	vm_ooffset_t eoff;
 
 	/*
@@ -4529,6 +4617,7 @@ vfs_page_set_valid(struct buf *bp, vm_ooffset_t off, vm_page_t m)
 	 */
 	if (eoff > off)
 		vm_page_set_valid_range(m, off & PAGE_MASK, eoff - off);
+#endif /* __rtems__ */
 }
 
 /*
@@ -4540,6 +4629,7 @@ vfs_page_set_valid(struct buf *bp, vm_ooffset_t off, vm_page_t m)
 static void
 vfs_page_set_validclean(struct buf *bp, vm_ooffset_t off, vm_page_t m)
 {
+#ifndef __rtems__
 	vm_ooffset_t soff, eoff;
 
 	/*
@@ -4564,6 +4654,7 @@ vfs_page_set_validclean(struct buf *bp, vm_ooffset_t off, vm_page_t m)
 		   (vm_offset_t) (eoff - soff)
 		);
 	}
+#endif /* __rtems__ */
 }
 
 /*
@@ -4573,6 +4664,7 @@ vfs_page_set_validclean(struct buf *bp, vm_ooffset_t off, vm_page_t m)
 void
 vfs_drain_busy_pages(struct buf *bp)
 {
+#ifndef __rtems__
 	vm_page_t m;
 	int i, last_busied;
 
@@ -4593,6 +4685,7 @@ vfs_drain_busy_pages(struct buf *bp)
 	}
 	for (i = 0; i < last_busied; i++)
 		vm_page_sunbusy(bp->b_pages[i]);
+#endif /* __rtems__ */
 }
 
 /*
@@ -4610,6 +4703,7 @@ vfs_drain_busy_pages(struct buf *bp)
 void
 vfs_busy_pages(struct buf *bp, int clear_modify)
 {
+#ifndef __rtems__
 	vm_object_t obj;
 	vm_ooffset_t foff;
 	vm_page_t m;
@@ -4666,6 +4760,7 @@ vfs_busy_pages(struct buf *bp, int clear_modify)
 		pmap_qenter(trunc_page((vm_offset_t)bp->b_data),
 		    bp->b_pages, bp->b_npages);
 	}
+#endif /* __rtems__ */
 }
 
 /*
@@ -4679,6 +4774,7 @@ vfs_busy_pages(struct buf *bp, int clear_modify)
 void   
 vfs_bio_set_valid(struct buf *bp, int base, int size)
 {
+#ifndef __rtems__
 	int i, n;
 	vm_page_t m;
 
@@ -4704,6 +4800,7 @@ vfs_bio_set_valid(struct buf *bp, int base, int size)
 		n = PAGE_SIZE;
 	}
 	VM_OBJECT_WUNLOCK(bp->b_bufobj->bo_object);
+#endif /* __rtems__ */
 }
 
 /*
@@ -4721,12 +4818,15 @@ vfs_bio_set_valid(struct buf *bp, int base, int size)
 void
 vfs_bio_clrbuf(struct buf *bp) 
 {
+#ifndef __rtems__
 	int i, j, mask, sa, ea, slide;
+#endif /* __rtems__ */
 
 	if ((bp->b_flags & (B_VMIO | B_MALLOC)) != B_VMIO) {
 		clrbuf(bp);
 		return;
 	}
+#ifndef __rtems__
 	bp->b_flags &= ~B_INVAL;
 	bp->b_ioflags &= ~BIO_ERROR;
 	VM_OBJECT_WLOCK(bp->b_bufobj->bo_object);
@@ -4773,6 +4873,7 @@ vfs_bio_clrbuf(struct buf *bp)
 unlock:
 	VM_OBJECT_WUNLOCK(bp->b_bufobj->bo_object);
 	bp->b_resid = 0;
+#endif /* __rtems__ */
 }
 
 void
@@ -4785,6 +4886,7 @@ vfs_bio_bzero_buf(struct buf *bp, int base, int size)
 		BUF_CHECK_MAPPED(bp);
 		bzero(bp->b_data + base, size);
 	} else {
+#ifndef __rtems__
 		BUF_CHECK_UNMAPPED(bp);
 		n = PAGE_SIZE - (base & PAGE_MASK);
 		for (i = base / PAGE_SIZE; size > 0 && i < bp->b_npages; ++i) {
@@ -4796,6 +4898,7 @@ vfs_bio_bzero_buf(struct buf *bp, int base, int size)
 			size -= n;
 			n = PAGE_SIZE;
 		}
+#endif /* __rtems__ */
 	}
 }
 
@@ -4848,6 +4951,7 @@ vfs_bio_set_flags(struct buf *bp, int ioflag)
 static void
 vm_hold_load_pages(struct buf *bp, vm_offset_t from, vm_offset_t to)
 {
+#ifndef __rtems__
 	vm_offset_t pg;
 	vm_page_t p;
 	int index;
@@ -4871,12 +4975,14 @@ vm_hold_load_pages(struct buf *bp, vm_offset_t from, vm_offset_t to)
 		bp->b_pages[index] = p;
 	}
 	bp->b_npages = index;
+#endif /* __rtems__ */
 }
 
 /* Return pages associated with this buf to the vm system */
 static void
 vm_hold_free_pages(struct buf *bp, int newbsize)
 {
+#ifndef __rtems__
 	vm_offset_t from;
 	vm_page_t p;
 	int index, newnpages;
@@ -4895,6 +5001,7 @@ vm_hold_free_pages(struct buf *bp, int newbsize)
 	}
 	vm_wire_sub(bp->b_npages - newnpages);
 	bp->b_npages = newnpages;
+#endif /* __rtems__ */
 }
 
 /*
@@ -4914,6 +5021,7 @@ vm_hold_free_pages(struct buf *bp, int newbsize)
 int
 vmapbuf(struct buf *bp, int mapbuf)
 {
+#ifndef __rtems__
 	vm_prot_t prot;
 	int pidx;
 
@@ -4933,6 +5041,7 @@ vmapbuf(struct buf *bp, int mapbuf)
 		bp->b_data = bp->b_kvabase + bp->b_offset;
 	} else
 		bp->b_data = unmapped_buf;
+#endif /* __rtems__ */
 	return(0);
 }
 
@@ -4945,6 +5054,7 @@ vmapbuf(struct buf *bp, int mapbuf)
 void
 vunmapbuf(struct buf *bp)
 {
+#ifndef __rtems__
 	int npages;
 
 	npages = bp->b_npages;
@@ -4953,6 +5063,7 @@ vunmapbuf(struct buf *bp)
 	vm_page_unhold_pages(bp->b_pages, npages);
 
 	bp->b_data = unmapped_buf;
+#endif /* __rtems__ */
 }
 
 void
@@ -5136,6 +5247,7 @@ vfs_bio_getpages(struct vnode *vp, vm_page_t *ma, int count,
     int *rbehind, int *rahead, vbg_get_lblkno_t get_lblkno,
     vbg_get_blksize_t get_blksize)
 {
+#ifndef __rtems__
 	vm_page_t m;
 	vm_object_t object;
 	struct buf *bp;
@@ -5282,11 +5394,23 @@ end_pages:
 		goto again;
 	VM_OBJECT_WUNLOCK(object);
 	return (error != 0 ? VM_PAGER_ERROR : VM_PAGER_OK);
+#else /* __rtems__ */
+	return (0);
+#endif /* __rtems__ */
 }
 
-#include "opt_ddb.h"
+#include <rtems/bsd/local/opt_ddb.h>
+#ifdef __rtems__
+#define DB_SHOW_COMMAND(cmd_name, func_name) \
+   void rtems_bsd_cmd_ ## func_name(caddr_t addr, bool have_addr, int count, char* modif)
+#define db_printf printf
+#define db_show_buffer rtems_bsd_cmd_db_show_buffer
+#define DDB
+#endif /* __rtems__ */
 #ifdef DDB
+#ifndef __rtems__
 #include <ddb/ddb.h>
+#endif /* __rtems__ */
 
 /* DDB command to show buffer data */
 DB_SHOW_COMMAND(buffer, db_show_buffer)
@@ -5322,9 +5446,13 @@ DB_SHOW_COMMAND(buffer, db_show_buffer)
 			vm_page_t m;
 			m = bp->b_pages[i];
 			if (m != NULL)
+#ifndef __rtems__
 				db_printf("(%p, 0x%lx, 0x%lx)", m->object,
 				    (u_long)m->pindex,
 				    (u_long)VM_PAGE_TO_PHYS(m));
+#else /* __rtems__ */
+				db_printf("(%p)", m);
+#endif /* __rtems__ */
 			else
 				db_printf("( ??? )");
 			if ((i + 1) < bp->b_npages)
@@ -5421,8 +5549,10 @@ DB_SHOW_COMMAND(lockedbufs, lockedbufs)
 		if (BUF_ISLOCKED(bp)) {
 			db_show_buffer((uintptr_t)bp, 1, 0, NULL);
 			db_printf("\n");
+#ifndef __rtems__
 			if (db_pager_quit)
 				break;
+#endif /* __rtems__ */
 		}
 	}
 }
@@ -5449,6 +5579,7 @@ DB_SHOW_COMMAND(vnodebufs, db_show_vnodebufs)
 	}
 }
 
+#ifndef __rtems__
 DB_COMMAND(countfreebufs, db_coundfreebufs)
 {
 	struct buf *bp;
@@ -5471,4 +5602,11 @@ DB_COMMAND(countfreebufs, db_coundfreebufs)
 	    nfree + used);
 	db_printf("numfreebuffers is %d\n", numfreebuffers);
 }
+#endif /* __rtems__ */
 #endif /* DDB */
+#ifdef __rtems__
+void rtems_bsd_bio_dump(void)
+{
+  rtems_bsd_cmd_bufqueues(0, true, 0, NULL);
+}
+#endif /* __rtems__ */
diff --git a/freebsd/sys/kern/vfs_cache.c b/freebsd/sys/kern/vfs_cache.c
index 7c14b080..7ae1de1d 100644
--- a/freebsd/sys/kern/vfs_cache.c
+++ b/freebsd/sys/kern/vfs_cache.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -37,8 +39,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_ddb.h"
-#include "opt_ktrace.h"
+#include <rtems/bsd/local/opt_ddb.h>
+#include <rtems/bsd/local/opt_ktrace.h>
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -339,12 +341,14 @@ cache_out_ts(struct namecache *ncp, struct timespec *tsp, int *ticksp)
 }
 
 static int __read_mostly	doingcache = 1;	/* 1 => enable the cache */
+#ifndef __rtems__
 SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0,
     "VFS namecache enabled");
 
 /* Export size information to userland */
 SYSCTL_INT(_debug_sizeof, OID_AUTO, namecache, CTLFLAG_RD, SYSCTL_NULL_INT_PTR,
     sizeof(struct namecache), "sizeof(struct namecache)");
+#endif /* __rtems__ */
 
 /*
  * The new name cache statistics
@@ -397,10 +401,12 @@ static void
 cache_maybe_yield(void)
 {
 
+#ifndef __rtems__
 	if (should_yield()) {
 		cache_yield++;
 		kern_yield(PRI_USER);
 	}
+#endif /* __rtems__ */
 }
 
 static inline void
@@ -1918,7 +1924,11 @@ nchinit(void *dummy __unused)
 	numfullpathfail4 = counter_u64_alloc(M_WAITOK);
 	numfullpathfound = counter_u64_alloc(M_WAITOK);
 }
+#ifndef __rtems__
 SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nchinit, NULL);
+#else /* __rtems__ */
+SYSINIT(vfs_c, SI_SUB_VFS, SI_ORDER_SECOND, nchinit, NULL);
+#endif /* __rtems__ */
 
 void
 cache_changesize(int newmaxvnodes)
diff --git a/freebsd/sys/kern/vfs_cluster.c b/freebsd/sys/kern/vfs_cluster.c
index 1ebe4a56..cae35911 100644
--- a/freebsd/sys/kern/vfs_cluster.c
+++ b/freebsd/sys/kern/vfs_cluster.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -36,7 +38,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_debug_cluster.h"
+#include <rtems/bsd/local/opt_debug_cluster.h>
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -254,7 +256,9 @@ cluster_read(struct vnode *vp, u_quad_t filesize, daddr_t lblkno, long size,
 			PROC_UNLOCK(td->td_proc);
 		}
 #endif /* RACCT */
+#ifndef __rtems__
 		td->td_ru.ru_inblock++;
+#endif /* __rtems__ */
 	}
 
 	/*
@@ -314,7 +318,9 @@ cluster_read(struct vnode *vp, u_quad_t filesize, daddr_t lblkno, long size,
 			PROC_UNLOCK(td->td_proc);
 		}
 #endif /* RACCT */
+#ifndef __rtems__
 		td->td_ru.ru_inblock++;
+#endif /* __rtems__ */
 	}
 
 	if (reqbp) {
@@ -447,6 +453,7 @@ cluster_rbuild(struct vnode *vp, u_quad_t filesize, daddr_t lbn,
 			 * take part in the cluster.  If it is partially valid
 			 * then we stop.
 			 */
+#ifndef __rtems__
 			off = tbp->b_offset;
 			tsize = size;
 			VM_OBJECT_WLOCK(tbp->b_bufobj->bo_object);
diff --git a/freebsd/sys/kern/vfs_default.c b/freebsd/sys/kern/vfs_default.c
index 40041c9d..6aabb760 100644
--- a/freebsd/sys/kern/vfs_default.c
+++ b/freebsd/sys/kern/vfs_default.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -46,13 +48,15 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/limits.h>
 #include <sys/lock.h>
+#ifndef __rtems__
 #include <sys/lockf.h>
+#endif /* __rtems__ */
 #include <sys/malloc.h>
 #include <sys/mount.h>
 #include <sys/namei.h>
 #include <sys/rwlock.h>
 #include <sys/fcntl.h>
-#include <sys/unistd.h>
+#include <rtems/bsd/sys/unistd.h>
 #include <sys/vnode.h>
 #include <sys/dirent.h>
 #include <sys/poll.h>
@@ -66,7 +70,9 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_map.h>
 #include <vm/vm_page.h>
 #include <vm/vm_pager.h>
+#ifndef __rtems__
 #include <vm/vnode_pager.h>
+#endif /* __rtems__ */
 
 static int	vop_nolookup(struct vop_lookup_args *);
 static int	vop_norename(struct vop_rename_args *);
@@ -401,6 +407,7 @@ vop_stdaccessx(struct vop_accessx_args *ap)
 int
 vop_stdadvlock(struct vop_advlock_args *ap)
 {
+#ifndef __rtems__
 	struct vnode *vp;
 	struct vattr vattr;
 	int error;
@@ -422,11 +429,15 @@ vop_stdadvlock(struct vop_advlock_args *ap)
 		vattr.va_size = 0;
 
 	return (lf_advlock(ap, &(vp->v_lockf), vattr.va_size));
+#else /* __rtems__ */
+	return (EINVAL);
+#endif /* __rtems__ */
 }
 
 int
 vop_stdadvlockasync(struct vop_advlockasync_args *ap)
 {
+#ifndef __rtems__
 	struct vnode *vp;
 	struct vattr vattr;
 	int error;
@@ -443,16 +454,23 @@ vop_stdadvlockasync(struct vop_advlockasync_args *ap)
 		vattr.va_size = 0;
 
 	return (lf_advlockasync(ap, &(vp->v_lockf), vattr.va_size));
+#else /* __rtems__ */
+	return (EINVAL);
+#endif /* __rtems__ */
 }
 
 int
 vop_stdadvlockpurge(struct vop_advlockpurge_args *ap)
 {
+#ifndef __rtems__
 	struct vnode *vp;
 
 	vp = ap->a_vp;
 	lf_purgelocks(vp, &vp->v_lockf);
 	return (0);
+#else /* __rtems__ */
+	return (EINVAL);
+#endif /* __rtems__ */
 }
 
 /*
@@ -670,20 +688,28 @@ vop_stdgetpages(ap)
 		int *a_rahead;
 	} */ *ap;
 {
+#ifndef __rtems__
 
 	return vnode_pager_generic_getpages(ap->a_vp, ap->a_m,
 	    ap->a_count, ap->a_rbehind, ap->a_rahead, NULL, NULL);
+#else /* __rtems__ */
+	return EINVAL;
+#endif /* __rtems__ */
 }
 
 static int
 vop_stdgetpages_async(struct vop_getpages_async_args *ap)
 {
+#ifndef __rtems__
 	int error;
 
 	error = VOP_GETPAGES(ap->a_vp, ap->a_m, ap->a_count, ap->a_rbehind,
 	    ap->a_rahead);
 	ap->a_iodone(ap->a_arg, ap->a_m, ap->a_count, error);
 	return (error);
+#else /* __rtems__ */
+	return EINVAL;
+#endif /* __rtems__ */
 }
 
 int
@@ -703,9 +729,13 @@ vop_stdputpages(ap)
 		int *a_rtvals;
 	} */ *ap;
 {
+#ifndef __rtems__
 
 	return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
 	     ap->a_sync, ap->a_rtvals);
+#else /* __rtems__ */
+	return EINVAL;
+#endif /* __rtems__ */
 }
 
 int
@@ -962,8 +992,10 @@ vop_stdallocate(struct vop_allocate_args *ap)
 		offset += cur;
 		if (len == 0)
 			break;
+#ifndef __rtems__
 		if (should_yield())
 			break;
+#endif /* __rtems__ */
 	}
 
  out:
@@ -984,6 +1016,7 @@ vop_stdadvise(struct vop_advise_args *ap)
 
 	vp = ap->a_vp;
 	switch (ap->a_advice) {
+#ifndef __rtems__
 	case POSIX_FADV_WILLNEED:
 		/*
 		 * Do nothing for now.  Filesystems should provide a
@@ -1026,6 +1059,7 @@ vop_stdadvise(struct vop_advise_args *ap)
 		BO_RUNLOCK(bo);
 		VOP_UNLOCK(vp, 0);
 		break;
+#endif /* __rtems__ */
 	default:
 		error = EINVAL;
 		break;
diff --git a/freebsd/sys/kern/vfs_export.c b/freebsd/sys/kern/vfs_export.c
index 669d4e9f..511ab05d 100644
--- a/freebsd/sys/kern/vfs_export.c
+++ b/freebsd/sys/kern/vfs_export.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -39,8 +41,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_inet.h"
-#include "opt_inet6.h"
+#include <rtems/bsd/local/opt_inet.h>
+#include <rtems/bsd/local/opt_inet6.h>
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -61,7 +63,12 @@ __FBSDID("$FreeBSD$");
 #include <netinet/in.h>
 #include <net/radix.h>
 
+#ifndef __rtems__
 static MALLOC_DEFINE(M_NETADDR, "export_host", "Export host address structure");
+#else /* __rtems__ */
+static MALLOC_DEFINE(M_NETADDR_e, "export_host", "Export host address structure");
+#define M_NETADDR M_NETADDR_e
+#endif /* __rtems__ */
 
 #if defined(INET) || defined(INET6)
 static struct radix_node_head *vfs_create_addrlist_af(
@@ -119,11 +126,13 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep,
 	 * with fields like cr_uidinfo and cr_prison?  Currently, this
 	 * routine does not touch them (leaves them as NULL).
 	 */
+#ifndef __rtems__
 	if (argp->ex_anon.cr_version != XUCRED_VERSION) {
 		vfs_mount_error(mp, "ex_anon.cr_version: %d != %d",
 		    argp->ex_anon.cr_version, XUCRED_VERSION);
 		return (EINVAL);
 	}
+#endif /* __rtems__ */
 
 	if (argp->ex_addrlen == 0) {
 		if (mp->mnt_flag & MNT_DEFEXPORTED) {
@@ -134,11 +143,13 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep,
 		np = &nep->ne_defexported;
 		np->netc_exflags = argp->ex_flags;
 		np->netc_anon = crget();
+#ifndef __rtems__
 		np->netc_anon->cr_uid = argp->ex_anon.cr_uid;
 		crsetgroups(np->netc_anon, argp->ex_anon.cr_ngroups,
 		    argp->ex_anon.cr_groups);
 		np->netc_anon->cr_prison = &prison0;
 		prison_hold(np->netc_anon->cr_prison);
+#endif /* __rtems__ */
 		np->netc_numsecflavors = argp->ex_numsecflavors;
 		bcopy(argp->ex_secflavors, np->netc_secflavors,
 		    sizeof(np->netc_secflavors));
@@ -213,11 +224,13 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep,
 	}
 	np->netc_exflags = argp->ex_flags;
 	np->netc_anon = crget();
+#ifndef __rtems__
 	np->netc_anon->cr_uid = argp->ex_anon.cr_uid;
 	crsetgroups(np->netc_anon, argp->ex_anon.cr_ngroups,
 	    argp->ex_anon.cr_groups);
 	np->netc_anon->cr_prison = &prison0;
 	prison_hold(np->netc_anon->cr_prison);
+#endif /* __rtems__ */
 	np->netc_numsecflavors = argp->ex_numsecflavors;
 	bcopy(argp->ex_secflavors, np->netc_secflavors,
 	    sizeof(np->netc_secflavors));
@@ -525,4 +538,3 @@ vfs_stdcheckexp(struct mount *mp, struct sockaddr *nam, int *extflagsp,
 	lockmgr(&mp->mnt_explock, LK_RELEASE, NULL);
 	return (0);
 }
-
diff --git a/freebsd/sys/kern/vfs_extattr.c b/freebsd/sys/kern/vfs_extattr.c
index 2903fd37..6d3181e9 100644
--- a/freebsd/sys/kern/vfs_extattr.c
+++ b/freebsd/sys/kern/vfs_extattr.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
@@ -491,6 +493,8 @@ kern_extattr_get_path(struct thread *td, const char *path, int attrnamespace,
  * References: vp must be a valid reference for the duration of the call
  */
 static int
+
+
 extattr_delete_vp(struct vnode *vp, int attrnamespace, const char *attrname,
     struct thread *td)
 {
diff --git a/freebsd/sys/kern/vfs_hash.c b/freebsd/sys/kern/vfs_hash.c
index b938f485..5fa50a5e 100644
--- a/freebsd/sys/kern/vfs_hash.c
+++ b/freebsd/sys/kern/vfs_hash.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
diff --git a/freebsd/sys/kern/vfs_init.c b/freebsd/sys/kern/vfs_init.c
index 5eb38e6d..f58d90c2 100644
--- a/freebsd/sys/kern/vfs_init.c
+++ b/freebsd/sys/kern/vfs_init.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -69,7 +71,11 @@ int maxvfsconf = VFS_GENERIC + 1;
  */
 struct vfsconfhead vfsconf = TAILQ_HEAD_INITIALIZER(vfsconf);
 struct sx vfsconf_sx;
+#ifndef __rtems__
 SX_SYSINIT(vfsconf, &vfsconf_sx, "vfsconf");
+#else /* __rtems__ */
+SX_SYSINIT_FLAGS(vfsconf, &vfsconf_sx, "vfsconf", SX_RECURSE);
+#endif /* __rtems__ */
 
 /*
  * Loader.conf variable vfs.typenumhash enables setting vfc_typenum using a hash
@@ -147,18 +153,22 @@ vfs_byname_kld(const char *fstype, struct thread *td, int *error)
 		return (vfsp);
 
 	/* Try to load the respective module. */
+#ifndef __rtems__
 	*error = kern_kldload(td, fstype, &fileid);
 	loaded = (*error == 0);
 	if (*error == EEXIST)
 		*error = 0;
 	if (*error)
 		return (NULL);
+#endif /* __rtems__ */
 
 	/* Look up again to see if the VFS was loaded. */
 	vfsp = vfs_byname(fstype);
 	if (vfsp == NULL) {
+#ifndef __rtems__
 		if (loaded)
 			(void)kern_kldunload(td, fileid, LINKER_UNLOAD_FORCE);
+#endif /* __rtems__ */
 		*error = ENODEV;
 		return (NULL);
 	}
@@ -278,8 +288,10 @@ vfs_register(struct vfsconf *vfc)
 	if (vfsops->vfs_sysctl == NULL)
 		vfsops->vfs_sysctl = vfs_stdsysctl;
 
+#ifndef __rtems__
 	if (vfc->vfc_flags & VFCF_JAIL)
 		prison_add_vfs(vfc);
+#endif /* __rtems__ */
 
 	/*
 	 * Call init function for this VFS...
@@ -297,6 +309,7 @@ vfs_register(struct vfsconf *vfc)
 	 * preserved by re-registering the oid after modifying its
 	 * number.
 	 */
+#ifndef __rtems__
 	sysctl_wlock();
 	SLIST_FOREACH(oidp, SYSCTL_CHILDREN(&sysctl___vfs), oid_link) {
 		if (strcmp(oidp->oid_name, vfc->vfc_name) == 0) {
@@ -307,6 +320,7 @@ vfs_register(struct vfsconf *vfc)
 		}
 	}
 	sysctl_wunlock();
+#endif /* __rtems__ */
 
 	return (0);
 }
diff --git a/freebsd/sys/kern/vfs_lookup.c b/freebsd/sys/kern/vfs_lookup.c
index 5ee3f219..656ec51d 100644
--- a/freebsd/sys/kern/vfs_lookup.c
+++ b/freebsd/sys/kern/vfs_lookup.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -39,8 +41,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_capsicum.h"
-#include "opt_ktrace.h"
+#include <rtems/bsd/local/opt_capsicum.h>
+#include <rtems/bsd/local/opt_ktrace.h>
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -158,7 +160,11 @@ nameiinit(void *dummy __unused)
 	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
 	getnewvnode("crossmp", NULL, &crossmp_vnodeops, &vp_crossmp);
 }
+#ifndef __rtems__
 SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL);
+#else /* __rtems__ */
+SYSINIT(vfs_l, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL);
+#endif /* __rtems__ */
 
 static int lookup_cap_dotdot = 1;
 SYSCTL_INT(_vfs, OID_AUTO, lookup_cap_dotdot, CTLFLAG_RWTUN,
@@ -557,6 +563,7 @@ static int
 compute_cn_lkflags(struct mount *mp, int lkflags, int cnflags)
 {
 
+#ifndef __rtems__
 	if (mp == NULL || ((lkflags & LK_SHARED) &&
 	    (!(mp->mnt_kern_flag & MNTK_LOOKUP_SHARED) ||
 	    ((cnflags & ISDOTDOT) &&
@@ -565,6 +572,7 @@ compute_cn_lkflags(struct mount *mp, int lkflags, int cnflags)
 		lkflags |= LK_EXCLUSIVE;
 	}
 	lkflags |= LK_NODDLKTREAT;
+#endif /* __rtems__ */
 	return (lkflags);
 }
 
@@ -820,10 +828,14 @@ dirloop:
 			goto bad;
 		}
 		for (;;) {
+#ifndef __rtems__
 			for (pr = cnp->cn_cred->cr_prison; pr != NULL;
 			     pr = pr->pr_parent)
 				if (dp == pr->pr_root)
 					break;
+#else /* __rtems__ */
+			pr = NULL;
+#endif /* __rtems__ */
 			if (dp == ndp->ni_rootdir || 
 			    dp == ndp->ni_topdir || 
 			    dp == rootvnode ||
diff --git a/freebsd/sys/kern/vfs_mount.c b/freebsd/sys/kern/vfs_mount.c
index 3610763f..4635857e 100644
--- a/freebsd/sys/kern/vfs_mount.c
+++ b/freebsd/sys/kern/vfs_mount.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -796,16 +798,22 @@ sys_mount(struct thread *td, struct mount_args *uap)
 	 */
 	flags &= ~MNT_ROOTFS;
 
+#ifndef __rtems__
 	fstype = malloc(MFSNAMELEN, M_TEMP, M_WAITOK);
 	error = copyinstr(uap->type, fstype, MFSNAMELEN, NULL);
 	if (error) {
 		free(fstype, M_TEMP);
 		return (error);
 	}
+#else /* __rtems__ */
+	fstype = uap->type;
+#endif /* __rtems__ */
 
 	AUDIT_ARG_TEXT(fstype);
 	vfsp = vfs_byname_kld(fstype, td, &error);
+#ifndef __rtems__
 	free(fstype, M_TEMP);
+#endif /* __rtems__ */
 	if (vfsp == NULL)
 		return (ENOENT);
 	if (vfsp->vfc_vfsops->vfs_cmount == NULL)
diff --git a/freebsd/sys/kern/vfs_subr.c b/freebsd/sys/kern/vfs_subr.c
index f84caac0..bc38e770 100644
--- a/freebsd/sys/kern/vfs_subr.c
+++ b/freebsd/sys/kern/vfs_subr.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -43,8 +45,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_ddb.h"
-#include "opt_watchdog.h"
+#include <rtems/bsd/local/opt_ddb.h>
+#include <rtems/bsd/local/opt_watchdog.h>
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -57,14 +59,18 @@ __FBSDID("$FreeBSD$");
 #include <sys/dirent.h>
 #include <sys/event.h>
 #include <sys/eventhandler.h>
+#ifndef __rtems__
 #include <sys/extattr.h>
+#endif /* __rtems__ */
 #include <sys/file.h>
 #include <sys/fcntl.h>
 #include <sys/jail.h>
 #include <sys/kdb.h>
 #include <sys/kernel.h>
 #include <sys/kthread.h>
+#ifndef __rtems__
 #include <sys/lockf.h>
+#endif /* __rtems__ */
 #include <sys/malloc.h>
 #include <sys/mount.h>
 #include <sys/namei.h>
@@ -388,6 +394,7 @@ out:
 	return (error);
 }
 
+#ifndef __rtems__
 static int
 sysctl_ftry_reclaim_vnode(SYSCTL_HANDLER_ARGS)
 {
@@ -427,6 +434,7 @@ SYSCTL_PROC(_debug, OID_AUTO, ftry_reclaim_vnode,
     CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_WR, NULL, 0,
     sysctl_ftry_reclaim_vnode, "I",
     "Try to reclaim a vnode by its file descriptor");
+#endif /* __rtems__ */
 
 /* Shift count for (uintptr_t)vp to initialize vp->v_hash. */
 static int vnsz2log;
@@ -492,7 +500,9 @@ vnode_init(void *mem, int size, int flags)
 	/*
 	 * Initialize rangelocks.
 	 */
+#ifndef __rtems__
 	rangelock_init(&vp->v_rl);
+#endif /* __rtems__ */
 	return (0);
 }
 
@@ -506,7 +516,9 @@ vnode_fini(void *mem, int size)
 	struct bufobj *bo;
 
 	vp = mem;
+#ifndef __rtems__
 	rangelock_destroy(&vp->v_rl);
+#endif /* __rtems__ */
 	lockdestroy(vp->v_vnlock);
 	mtx_destroy(&vp->v_interlock);
 	bo = &vp->v_bufobj;
@@ -551,10 +563,18 @@ vntblinit(void *dummy __unused)
 	 * size.  The memory required by desiredvnodes vnodes and vm objects
 	 * must not exceed 1/10th of the kernel's heap size.
 	 */
+#ifndef __rtems__
 	physvnodes = maxproc + pgtok(vm_cnt.v_page_count) / 64 +
 	    3 * min(98304 * 16, pgtok(vm_cnt.v_page_count)) / 64;
 	virtvnodes = vm_kmem_size / (10 * (sizeof(struct vm_object) +
 	    sizeof(struct vnode) + NC_SZ * ncsizefactor + NFS_NCLNODE_SZ));
+#else /* __rtems__ */
+	/*
+	 * Make a fixed number until someone decided on a better solution for RTEMS
+	 */
+	physvnodes = 128;
+	virtvnodes = 128;
+#endif /* __rtems__ */
 	desiredvnodes = min(physvnodes, virtvnodes);
 	if (desiredvnodes > MAXVNODES_MAX) {
 		if (bootverbose)
@@ -1005,7 +1025,11 @@ vlrureclaim(struct mount *mp, bool reclaim_nc_src, int trigger)
 		    (!reclaim_nc_src && !LIST_EMPTY(&vp->v_cache_src)) ||
 		    ((vp->v_iflag & VI_FREE) != 0) ||
 		    (vp->v_iflag & VI_DOOMED) != 0 || (vp->v_object != NULL &&
+#ifndef __rtems__
 		    vp->v_object->resident_page_count > trigger)) {
+#else /* __rtems__ */
+		    false)) {
+#endif /* __rtems__ */
 			VI_UNLOCK(vp);
 			goto next_iter;
 		}
@@ -1032,7 +1056,11 @@ vlrureclaim(struct mount *mp, bool reclaim_nc_src, int trigger)
 		    (!reclaim_nc_src && !LIST_EMPTY(&vp->v_cache_src)) ||
 		    (vp->v_iflag & VI_FREE) != 0 ||
 		    (vp->v_object != NULL &&
+#ifndef __rtems__
 		    vp->v_object->resident_page_count > trigger)) {
+#else /* __rtems__ */
+		    false)) {
+#endif /* __rtems__ */
 			VOP_UNLOCK(vp, LK_INTERLOCK);
 			vdrop(vp);
 			goto next_iter_mntunlocked;
@@ -1045,15 +1073,21 @@ vlrureclaim(struct mount *mp, bool reclaim_nc_src, int trigger)
 		vdropl(vp);
 		done++;
 next_iter_mntunlocked:
+#ifndef __rtems__
 		if (!should_yield())
 			goto relock_mnt;
+#endif /* __rtems__ */
 		goto yield;
 next_iter:
+#ifndef __rtems__
 		if (!should_yield())
 			continue;
+#endif /* __rtems__ */
 		MNT_IUNLOCK(mp);
 yield:
+#ifndef __rtems__
 		kern_yield(PRI_USER);
+#endif /* __rtems__ */
 relock_mnt:
 		MNT_ILOCK(mp);
 	}
@@ -1247,12 +1281,16 @@ vnlru_proc(void)
 	int done, force, trigger, usevnodes, vsp;
 	bool reclaim_nc_src;
 
+#ifndef __rtems__
 	EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, vnlruproc,
 	    SHUTDOWN_PRI_FIRST);
+#endif /* __rtems__ */
 
 	force = 0;
 	for (;;) {
+#ifndef __rtems__
 		kproc_suspend_check(vnlruproc);
+#endif /* __rtems__ */
 		mtx_lock(&vnode_free_list_mtx);
 		/*
 		 * If numvnodes is too large (due to desiredvnodes being
@@ -1304,7 +1342,11 @@ vnlru_proc(void)
 		 * misconfigured cases, and this is necessary.  Normally
 		 * it is about 8 to 100 (pages), which is quite large.
 		 */
+#ifndef __rtems__
 		trigger = vm_cnt.v_page_count * 2 / usevnodes;
+#else /* __rtems__ */
+		trigger = 32000 / usevnodes;
+#endif /* __rtems__ */
 		if (force < 2)
 			trigger = vsmalltrigger;
 		reclaim_nc_src = force >= 3;
@@ -1789,6 +1831,7 @@ bufobj_invalbuf(struct bufobj *bo, int flags, int slpflag, int slptimeo)
 	 */
 	do {
 		bufobj_wwait(bo, 0, 0);
+#ifndef __rtems__
 		if ((flags & V_VMIO) == 0) {
 			BO_UNLOCK(bo);
 			if (bo->bo_object != NULL) {
@@ -1798,12 +1841,14 @@ bufobj_invalbuf(struct bufobj *bo, int flags, int slpflag, int slptimeo)
 			}
 			BO_LOCK(bo);
 		}
+#endif /* __rtems__ */
 	} while (bo->bo_numoutput > 0);
 	BO_UNLOCK(bo);
 
 	/*
 	 * Destroy the copy in the VM cache, too.
 	 */
+#ifndef __rtems__
 	if (bo->bo_object != NULL &&
 	    (flags & (V_ALT | V_NORMAL | V_CLEANONLY | V_VMIO)) == 0) {
 		VM_OBJECT_WLOCK(bo->bo_object);
@@ -1811,6 +1856,7 @@ bufobj_invalbuf(struct bufobj *bo, int flags, int slpflag, int slptimeo)
 		    OBJPR_CLEANONLY : 0);
 		VM_OBJECT_WUNLOCK(bo->bo_object);
 	}
+#endif /* __rtems__ */
 
 #ifdef INVARIANTS
 	BO_LOCK(bo);
@@ -1836,8 +1882,10 @@ vinvalbuf(struct vnode *vp, int flags, int slpflag, int slptimeo)
 
 	CTR3(KTR_VFS, "%s: vp %p with flags %d", __func__, vp, flags);
 	ASSERT_VOP_LOCKED(vp, "vinvalbuf");
+#ifndef __rtems__
 	if (vp->v_object != NULL && vp->v_object->handle != vp)
 		return (0);
+#endif /* __rtems__ */
 	return (bufobj_invalbuf(&vp->v_bufobj, flags, slpflag, slptimeo));
 }
 
@@ -2005,7 +2053,9 @@ restartsync:
 
 	bufobj_wwait(bo, 0, 0);
 	BO_UNLOCK(bo);
+#ifndef __rtems__
 	vnode_pager_setsize(vp, length);
+#endif /* __rtems__ */
 
 	return (0);
 }
@@ -2354,15 +2404,19 @@ sched_sync(void)
 	starttime = time_uptime;
 	td->td_pflags |= TDP_NORUNNINGBUF;
 
+#ifndef __rtems__
 	EVENTHANDLER_REGISTER(shutdown_pre_sync, syncer_shutdown, td->td_proc,
 	    SHUTDOWN_PRI_LAST);
+#endif /* __rtems__ */
 
 	mtx_lock(&sync_mtx);
 	for (;;) {
 		if (syncer_state == SYNCER_FINAL_DELAY &&
 		    syncer_final_iter == 0) {
 			mtx_unlock(&sync_mtx);
+#ifndef __rtems__
 			kproc_suspend_check(td->td_proc);
+#endif /* __rtems__ */
 			mtx_lock(&sync_mtx);
 		}
 		net_worklist_len = syncer_worklist_len - sync_vnode_count;
@@ -2427,7 +2481,9 @@ sched_sync(void)
 				 * drivers need to sleep while patting
 				 */
 				mtx_unlock(&sync_mtx);
+#ifndef __rtems__
 				wdog_kern_pat(WD_LASTVAL);
+#endif /* __rtems__ */
 				mtx_lock(&sync_mtx);
 			}
 
@@ -2460,12 +2516,14 @@ sched_sync(void)
 		 * matter as we are just trying to generally pace the
 		 * filesystem activity.
 		 */
+#ifndef __rtems__
 		if (syncer_state != SYNCER_RUNNING ||
 		    time_uptime == starttime) {
 			thread_lock(td);
 			sched_prio(td, PPAUSE);
 			thread_unlock(td);
 		}
+#endif /* __rtems__ */
 		if (syncer_state != SYNCER_RUNNING)
 			cv_timedwait(&sync_wakeup, &sync_mtx,
 			    hz / SYNCER_SHUTDOWN_SPEEDUP);
@@ -3127,8 +3185,10 @@ _vdrop(struct vnode *vp, bool locked)
 	VNASSERT(TAILQ_EMPTY(&vp->v_cache_dst), vp, ("vp has namecache dst"));
 	VNASSERT(LIST_EMPTY(&vp->v_cache_src), vp, ("vp has namecache src"));
 	VNASSERT(vp->v_cache_dd == NULL, vp, ("vp has namecache for .."));
+#ifndef __rtems__
 	VNASSERT(TAILQ_EMPTY(&vp->v_rl.rl_waiters), vp,
 	    ("Dangling rangelock waiters"));
+#endif /* __rtems__ */
 	VI_UNLOCK(vp);
 #ifdef MAC
 	mac_vnode_destroy(vp);
@@ -3181,12 +3241,14 @@ vinactive(struct vnode *vp, struct thread *td)
 	 * point that VOP_INACTIVE() is called, there could still be
 	 * pending I/O and dirty pages in the object.
 	 */
+#ifndef __rtems__
 	if ((obj = vp->v_object) != NULL && (vp->v_vflag & VV_NOSYNC) == 0 &&
 	    (obj->flags & OBJ_MIGHTBEDIRTY) != 0) {
 		VM_OBJECT_WLOCK(obj);
 		vm_object_page_clean(obj, 0, 0, 0);
 		VM_OBJECT_WUNLOCK(obj);
 	}
+#endif /* __rtems__ */
 	VOP_INACTIVE(vp, td);
 	VI_LOCK(vp);
 	VNASSERT(vp->v_iflag & VI_DOINGINACT, vp,
@@ -3266,9 +3328,11 @@ loop:
 		 */
 		if (flags & WRITECLOSE) {
 			if (vp->v_object != NULL) {
+#ifndef __rtems__
 				VM_OBJECT_WLOCK(vp->v_object);
 				vm_object_page_clean(vp->v_object, 0, 0, 0);
 				VM_OBJECT_WUNLOCK(vp->v_object);
+#endif /* __rtems__ */
 			}
 			error = VOP_FSYNC(vp, MNT_WAIT, td);
 			if (error != 0) {
@@ -3490,7 +3554,11 @@ vgonel(struct vnode *vp)
 		VI_UNLOCK(vp);
 	}
 	if (vp->v_type == VSOCK)
+#ifndef __rtems__
 		vfs_unp_reclaim(vp);
+#else /* __rtems__ */
+		panic("vgonel with sock");
+#endif /* __rtems__ */
 
 	/*
 	 * Clean out any buffers associated with the vnode.
@@ -3671,6 +3739,7 @@ vn_printf(struct vnode *vp, const char *fmt, ...)
 	printf("    flags (%s)\n", buf + 1);
 	if (mtx_owned(VI_MTX(vp)))
 		printf(" VI_LOCKed");
+#ifndef __rtems__
 	if (vp->v_object != NULL)
 		printf("    v_object %p ref %d pages %d "
 		    "cleanbuf %d dirtybuf %d\n",
@@ -3678,6 +3747,7 @@ vn_printf(struct vnode *vp, const char *fmt, ...)
 		    vp->v_object->resident_page_count,
 		    vp->v_bufobj.bo_clean.bv_cnt,
 		    vp->v_bufobj.bo_dirty.bv_cnt);
+#endif /* __rtems__ */
 	printf("    ");
 	lockmgr_printinfo(vp->v_vnlock);
 	if (vp->v_data != NULL)
@@ -4216,6 +4286,7 @@ vfs_unmountall(void)
 void
 vfs_msync(struct mount *mp, int flags)
 {
+#ifndef __rtems__
 	struct vnode *vp, *mvp;
 	struct vm_object *obj;
 
@@ -4248,6 +4319,7 @@ vfs_msync(struct mount *mp, int flags)
 		} else
 			VI_UNLOCK(vp);
 	}
+#endif /* __rtems__ */
 }
 
 static void
@@ -4452,10 +4524,14 @@ sync_fsync(struct vop_fsync_args *ap)
 		vfs_unbusy(mp);
 		return (0);
 	}
+#ifndef __rtems__
 	save = curthread_pflags_set(TDP_SYNCIO);
+#endif /* __rtems__ */
 	vfs_msync(mp, MNT_NOWAIT);
 	error = VFS_SYNC(mp, MNT_LAZY);
+#ifndef __rtems__
 	curthread_pflags_restore(save);
+#endif /* __rtems__ */
 	vn_finished_write(mp);
 	vfs_unbusy(mp);
 	return (error);
@@ -4656,6 +4732,7 @@ int
 extattr_check_cred(struct vnode *vp, int attrnamespace, struct ucred *cred,
     struct thread *td, accmode_t accmode)
 {
+#ifndef __rtems__
 
 	/*
 	 * Kernel-invoked always succeeds.
@@ -4676,6 +4753,9 @@ extattr_check_cred(struct vnode *vp, int attrnamespace, struct ucred *cred,
 	default:
 		return (EPERM);
 	}
+#else /* __rtems__ */
+	return (0);
+#endif /* __rtems__ */
 }
 
 #ifdef DEBUG_VFS_LOCKS
@@ -5438,8 +5518,10 @@ __mnt_vnode_next_all(struct vnode **mvp, struct mount *mp)
 {
 	struct vnode *vp;
 
+#ifndef __rtems__
 	if (should_yield())
 		kern_yield(PRI_USER);
+#endif /* __rtems__ */
 	MNT_ILOCK(mp);
 	KASSERT((*mvp)->v_mount == mp, ("marker vnode mount list mismatch"));
 	for (vp = TAILQ_NEXT(*mvp, v_nmntvnodes); vp != NULL;
@@ -5664,8 +5746,10 @@ struct vnode *
 __mnt_vnode_next_active(struct vnode **mvp, struct mount *mp)
 {
 
+#ifndef __rtems__
 	if (should_yield())
 		kern_yield(PRI_USER);
+#endif /* __rtems__ */
 	mtx_lock(&mp->mnt_listmtx);
 	return (mnt_vnode_next_active(mvp, mp));
 }
diff --git a/freebsd/sys/kern/vfs_syscalls.c b/freebsd/sys/kern/vfs_syscalls.c
index 06aaa935..0b7e054a 100644
--- a/freebsd/sys/kern/vfs_syscalls.c
+++ b/freebsd/sys/kern/vfs_syscalls.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -39,8 +41,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_capsicum.h"
-#include "opt_ktrace.h"
+#include <rtems/bsd/local/opt_capsicum.h>
+#include <rtems/bsd/local/opt_ktrace.h>
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -65,7 +67,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sdt.h>
 #include <sys/stat.h>
 #include <sys/sx.h>
-#include <sys/unistd.h>
+#include <rtems/bsd/sys/unistd.h>
 #include <sys/vnode.h>
 #include <sys/priv.h>
 #include <sys/proc.h>
@@ -87,7 +89,9 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_page.h>
 #include <vm/uma.h>
 
+#ifndef __rtems__
 #include <ufs/ufs/quota.h>
+#endif /* __rtems__ */
 
 MALLOC_DEFINE(M_FADVISE, "fadvise", "posix_fadvise(2) information");
 
@@ -151,6 +155,7 @@ sys_sync(struct thread *td, struct sync_args *uap)
 	return (0);
 }
 
+#ifndef __rtems__
 /*
  * Change filesystem quotas.
  */
@@ -203,6 +208,7 @@ sys_quotactl(struct thread *td, struct quotactl_args *uap)
 		vfs_unbusy(mp);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Used by statfs conversion routines to scale the block size up if
@@ -904,6 +910,7 @@ kern_chdir(struct thread *td, char *path, enum uio_seg pathseg)
 	return (0);
 }
 
+#ifndef __rtems__
 /*
  * Change notion of root (``/'') directory.
  */
@@ -945,6 +952,7 @@ error:
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Common routine for chroot and chdir.  Callers must provide a locked vnode
@@ -999,8 +1007,10 @@ flags_to_rights(int flags, cap_rights_t *rightsp)
 	if (flags & (O_SYNC | O_FSYNC))
 		cap_rights_set(rightsp, CAP_FSYNC);
 
+#ifndef __rtems__
 	if (flags & (O_EXLOCK | O_SHLOCK))
 		cap_rights_set(rightsp, CAP_FLOCK);
+#endif /* __rtems__ */
 }
 
 /*
@@ -1061,9 +1071,13 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
 	 * Only one of the O_EXEC, O_RDONLY, O_WRONLY and O_RDWR flags
 	 * may be specified.
 	 */
+#ifndef __rtems__
 	if (flags & O_EXEC) {
 		if (flags & O_ACCMODE)
 			return (EINVAL);
+#else /* __rtems__ */
+	if (false) {
+#endif /* __rtems__ */
 	} else if ((flags & O_ACCMODE) == O_ACCMODE) {
 		return (EINVAL);
 	} else {
@@ -1083,10 +1097,16 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
 	 */
 	/* Set the flags early so the finit in devfs can pick them up. */
 	fp->f_flag = flags & FMASK;
+#ifndef __rtems__
 	cmode = ((mode & ~fdp->fd_cmask) & ALLPERMS) & ~S_ISTXT;
+#else /* __rtems__ */
+	cmode = (mode & ~fdp->fd_cmask) & ALLPERMS;
+#endif /* __rtems__ */
 	NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, fd,
 	    &rights, td);
+#ifndef __rtems__
 	td->td_dupfd = -1;		/* XXX check for fdopen */
+#endif /* __rtems__ */
 	error = vn_open(&nd, &flags, cmode, fp);
 	if (error != 0) {
 		/*
@@ -1106,16 +1126,23 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
 		 */
 		if ((nd.ni_lcf & NI_LCF_STRICTRELATIVE) == 0 &&
 		    (error == ENODEV || error == ENXIO) &&
+#ifndef __rtems__
 		    td->td_dupfd >= 0) {
 			error = dupfdopen(td, fdp, td->td_dupfd, flags, error,
 			    &indx);
 			if (error == 0)
 				goto success;
+#else /* __rtems__ */
+		    true) {
+			panic("fdopen() dup");
+#endif /* __rtems__ */
 		}
 
 		goto bad;
 	}
+#ifndef __rtems__
 	td->td_dupfd = 0;
+#endif /* __rtems__ */
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 	vp = nd.ni_vp;
 
@@ -1255,12 +1282,16 @@ kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
 		if (error == 0 && dev == VNOVAL)
 			error = EINVAL;
 		break;
+#ifndef __rtems__
 	case S_IFWHT:
 		error = priv_check(td, PRIV_VFS_MKNOD_WHT);
 		break;
+#endif /* __rtems__ */
 	case S_IFIFO:
+#ifndef __rtems__
 		if (dev == 0)
 			return (kern_mkfifoat(td, fd, path, pathseg, mode));
+#endif /* __rtems__ */
 		/* FALLTHROUGH */
 	default:
 		error = EINVAL;
@@ -1298,9 +1329,11 @@ restart:
 		case S_IFBLK:
 			vattr.va_type = VBLK;
 			break;
+#ifndef __rtems__
 		case S_IFWHT:
 			whiteout = 1;
 			break;
+#endif /* __rtems__ */
 		default:
 			panic("kern_mknod: invalid mode");
 		}
@@ -1333,6 +1366,7 @@ restart:
 	return (error);
 }
 
+#ifndef __rtems__
 /*
  * Create a named pipe.
  */
@@ -1418,6 +1452,7 @@ out:
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Make a hard file link.
@@ -1459,15 +1494,19 @@ sys_linkat(struct thread *td, struct linkat_args *uap)
 }
 
 int hardlink_check_uid = 0;
+#ifndef __rtems__
 SYSCTL_INT(_security_bsd, OID_AUTO, hardlink_check_uid, CTLFLAG_RW,
     &hardlink_check_uid, 0,
     "Unprivileged processes cannot create hard links to files owned by other "
     "users");
+#endif /* __rtems__ */
 static int hardlink_check_gid = 0;
+#ifndef __rtems__
 SYSCTL_INT(_security_bsd, OID_AUTO, hardlink_check_gid, CTLFLAG_RW,
     &hardlink_check_gid, 0,
     "Unprivileged processes cannot create hard links to files owned by other "
     "groups");
+#endif /* __rtems__ */
 
 static int
 can_hardlink(struct vnode *vp, struct ucred *cred)
@@ -1689,6 +1728,7 @@ out:
 	return (error);
 }
 
+#ifndef __rtems__
 /*
  * Delete a whiteout from the filesystem.
  */
@@ -1735,6 +1775,7 @@ restart:
 	vn_finished_write(mp);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Delete a name from the filesystem.
@@ -1952,6 +1993,7 @@ sys_access(struct thread *td, struct access_args *uap)
 	    0, uap->amode));
 }
 
+#ifndef __rtems__
 #ifndef _SYS_SYSPROTO_H_
 struct faccessat_args {
 	int	dirfd;
@@ -2014,7 +2056,9 @@ out:
 	}
 	return (error);
 }
+#endif /* __rtems__ */
 
+#ifndef __rtems__
 /*
  * Check access permissions using "effective" credentials.
  */
@@ -2031,7 +2075,9 @@ sys_eaccess(struct thread *td, struct eaccess_args *uap)
 	return (kern_accessat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
 	    AT_EACCESS, uap->amode));
 }
+#endif /* __rtems__ */
 
+#ifndef __rtems__
 #if defined(COMPAT_43)
 /*
  * Get file status; this version follows links.
@@ -2256,6 +2302,7 @@ freebsd11_fstatat(struct thread *td, struct freebsd11_fstatat_args* uap)
 	return (error);
 }
 #endif	/* COMPAT_FREEBSD11 */
+#endif /* __rtems__ */
 
 /*
  * Get file status
@@ -2398,6 +2445,7 @@ freebsd11_nlstat(struct thread *td, struct freebsd11_nlstat_args *uap)
 }
 #endif /* COMPAT_FREEBSD11 */
 
+#ifndef __rtems__
 /*
  * Get configurable pathname variables.
  */
@@ -2456,6 +2504,7 @@ kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name,
 	vput(nd.ni_vp);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Return target name of a symbolic link.
@@ -2607,6 +2656,7 @@ sys_chflags(struct thread *td, struct chflags_args *uap)
 	    uap->flags, 0));
 }
 
+#ifndef __rtems__
 #ifndef _SYS_SYSPROTO_H_
 struct chflagsat_args {
 	int	fd;
@@ -2695,6 +2745,7 @@ sys_fchflags(struct thread *td, struct fchflags_args *uap)
 	fdrop(fp, td);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Common implementation code for chmod(), lchmod() and fchmod().
@@ -2954,6 +3005,7 @@ sys_fchown(struct thread *td, struct fchown_args *uap)
 	return (error);
 }
 
+#ifndef __rtems__
 /*
  * Common implementation code for utimes(), lutimes(), and futimes().
  */
@@ -3272,6 +3324,7 @@ kern_utimensat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
 	vrele(nd.ni_vp);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Truncate a file given its path name.
@@ -3396,11 +3449,13 @@ kern_fsync(struct thread *td, int fd, bool fullsync)
 	}
 	vn_lock(vp, lock_flags | LK_RETRY);
 	AUDIT_ARG_VNODE1(vp);
+#ifndef __rtems__
 	if (vp->v_object != NULL) {
 		VM_OBJECT_WLOCK(vp->v_object);
 		vm_object_page_clean(vp->v_object, 0, 0, 0);
 		VM_OBJECT_WUNLOCK(vp->v_object);
 	}
+#endif /* __rtems__ */
 	error = fullsync ? VOP_FSYNC(vp, MNT_WAIT, td) : VOP_FDATASYNC(vp, td);
 	VOP_UNLOCK(vp, 0);
 	vn_finished_write(mp);
@@ -3481,6 +3536,7 @@ again:
 	    AUDITVNODE1, pathseg, old, oldfd,
 	    &cap_renameat_source_rights, td);
 #else
+
 	NDINIT_ATRIGHTS(&fromnd, DELETE, WANTPARENT | SAVESTART | AUDITVNODE1,
 	    pathseg, old, oldfd,
 	    &cap_renameat_source_rights, td);
@@ -4035,6 +4091,7 @@ fail:
 	return (error);
 }
 
+#ifndef __rtems__
 /*
  * Set the mode mask for creation of filesystem nodes.
  */
@@ -4102,6 +4159,7 @@ out:
 	vput(vp);
 	return (error);
 }
+#endif /* __rtems__ */
 
 /*
  * Convert a user file descriptor to a kernel file entry and check that, if it
@@ -4139,6 +4197,7 @@ getvnode(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp)
 }
 
 
+#ifndef __rtems__
 /*
  * Get an (NFS) file handle.
  */
@@ -4515,6 +4574,7 @@ out:
 	vfs_unbusy(mp);
 	return (error);
 }
+#endif /* __rtems__ */
 
 int
 kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len)
@@ -4600,6 +4660,7 @@ kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len)
 	return (error);
 }
 
+#ifndef __rtems__
 int
 sys_posix_fallocate(struct thread *td, struct posix_fallocate_args *uap)
 {
@@ -4746,3 +4807,4 @@ sys_posix_fadvise(struct thread *td, struct posix_fadvise_args *uap)
 	    uap->advice);
 	return (kern_posix_error(td, error));
 }
+#endif /* __rtems__ */
diff --git a/freebsd/sys/kern/vfs_vnops.c b/freebsd/sys/kern/vfs_vnops.c
index bdd6692d..023d387d 100644
--- a/freebsd/sys/kern/vfs_vnops.c
+++ b/freebsd/sys/kern/vfs_vnops.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -45,7 +47,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_hwpmc_hooks.h"
+#include <rtems/bsd/local/opt_hwpmc_hooks.h>
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -74,7 +76,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/ttycom.h>
 #include <sys/conf.h>
 #include <sys/syslog.h>
-#include <sys/unistd.h>
+#include <rtems/bsd/sys/unistd.h>
 #include <sys/user.h>
 
 #include <security/audit/audit.h>
@@ -114,10 +116,14 @@ struct 	fileops vnops = {
 	.fo_close = vn_closefile,
 	.fo_chmod = vn_chmod,
 	.fo_chown = vn_chown,
+#ifndef __rtems__
 	.fo_sendfile = vn_sendfile,
+#endif /* __rtems__ */
 	.fo_seek = vn_seek,
+#ifndef __rtems__
 	.fo_fill_kinfo = vn_fill_kinfo,
 	.fo_mmap = vn_mmap,
+#endif /* __rtems__ */
 	.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
 };
 
@@ -353,8 +359,10 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred,
 	}
 	if (fmode & FREAD)
 		accmode |= VREAD;
+#ifndef __rtems__
 	if (fmode & FEXEC)
 		accmode |= VEXEC;
+#endif /* __rtems__ */
 	if ((fmode & O_APPEND) && (fmode & FWRITE))
 		accmode |= VAPPEND;
 #ifdef MAC
@@ -394,7 +402,9 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred,
 	 * Arrange for that by having fdrop() to use vn_closefile().
 	 */
 	if (error != 0) {
+#ifndef __rtems__
 		fp->f_flag |= FOPENFAILED;
+#endif /* __rtems__ */
 		fp->f_vnode = vp;
 		if (fp->f_ops == &badfileops) {
 			fp->f_type = DTYPE_VNODE;
@@ -448,7 +458,11 @@ vn_close1(struct vnode *vp, int flags, struct ucred *file_cred,
 	vn_start_write(vp, &mp, V_WAIT);
 	vn_lock(vp, lock_flags | LK_RETRY);
 	AUDIT_ARG_VNODE1(vp);
+#ifndef __rtems__
 	if ((flags & (FWRITE | FOPENFAILED)) == FWRITE) {
+#else /* __rtems__ */
+	if ((flags & FWRITE) == FWRITE) {
+#endif /* __rtems__ */
 		VOP_ADD_WRITECOUNT_CHECKED(vp, -1);
 		CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d",
 		    __func__, vp, vp->v_writecount);
@@ -478,8 +492,10 @@ sequential_heuristic(struct uio *uio, struct file *fp)
 {
 
 	ASSERT_VOP_LOCKED(fp->f_vnode, __func__);
+#ifndef __rtems__
 	if (fp->f_flag & FRDAHEAD)
 		return (fp->f_seqcount << IO_SEQSHIFT);
+#endif /* __rtems__ */
 
 	/*
 	 * Offset 0 is handled specially.  open() sets f_seqcount to 1 so
@@ -752,6 +768,7 @@ foffset_unlock_uio(struct file *fp, struct uio *uio, int flags)
 static int
 get_advice(struct file *fp, struct uio *uio)
 {
+#ifndef __rtems__
 	struct mtx *mtxp;
 	int ret;
 
@@ -767,6 +784,9 @@ get_advice(struct file *fp, struct uio *uio)
 		ret = fp->f_advice->fa_advice;
 	mtx_unlock(mtxp);
 	return (ret);
+#else /* __rtems__ */
+	return (POSIX_FADV_NORMAL);
+#endif /* __rtems__ */
 }
 
 /*
@@ -946,7 +966,9 @@ vn_io_fault_doio(struct vn_io_fault_args *args, struct uio *uio,
 	int error, save;
 
 	error = 0;
+#ifndef __rtems__
 	save = vm_fault_disable_pagefaults();
+#endif /* __rtems__ */
 	switch (args->kind) {
 	case VN_IO_FAULT_FOP:
 		error = (args->args.fop_args.doio)(args->args.fop_args.fp,
@@ -965,24 +987,31 @@ vn_io_fault_doio(struct vn_io_fault_args *args, struct uio *uio,
 		panic("vn_io_fault_doio: unknown kind of io %d %d",
 		    args->kind, uio->uio_rw);
 	}
+#ifndef __rtems__
 	vm_fault_enable_pagefaults(save);
+#endif /* __rtems__ */
 	return (error);
 }
 
 static int
 vn_io_fault_touch(char *base, const struct uio *uio)
 {
+#ifndef __rtems__
 	int r;
 
 	r = fubyte(base);
 	if (r == -1 || (uio->uio_rw == UIO_READ && subyte(base, r) == -1))
 		return (EFAULT);
 	return (0);
+#else /* __rtems__ */
+	return (EFAULT);
+#endif /* __rtems__ */
 }
 
 static int
 vn_io_fault_prefault_user(const struct uio *uio)
 {
+#ifndef __rtems__
 	char *base;
 	const struct iovec *iov;
 	size_t len;
@@ -1020,6 +1049,9 @@ vn_io_fault_prefault_user(const struct uio *uio)
 		}
 	}
 	return (error);
+#else /* __rtems__ */
+	return (EFAULT);
+#endif /* __rtems__ */
 }
 
 /*
@@ -1042,6 +1074,9 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
 	size_t len, resid;
 	ssize_t adv;
 	int error, cnt, saveheld, prev_td_ma_cnt;
+#ifdef __rtems__
+	struct uio uio_clone_;
+#endif /* __rtems__ */
 
 	if (vn_io_fault_prefault) {
 		error = vn_io_fault_prefault_user(uio);
@@ -1060,7 +1095,12 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
 	 * Cache a copy of the original uio, which is advanced to the redo
 	 * point using UIO_NOCOPY below.
 	 */
+#ifndef __rtems__
 	uio_clone = cloneuio(uio);
+#else /* __rtems__ */
+	uio_clone_ = *uio;
+	uio_clone = &uio_clone_;
+#endif /* __rtems__ */
 	resid = uio->uio_resid;
 
 	short_uio.uio_segflg = UIO_USERSPACE;
@@ -1076,9 +1116,11 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
 	uiomove(NULL, resid - uio->uio_resid, uio_clone);
 	uio_clone->uio_segflg = uio->uio_segflg;
 
+#ifndef __rtems__
 	saveheld = curthread_pflags_set(TDP_UIOHELD);
 	prev_td_ma = td->td_ma;
 	prev_td_ma_cnt = td->td_ma_cnt;
+#endif /* __rtems__ */
 
 	while (uio_clone->uio_resid != 0) {
 		len = uio_clone->uio_iov->iov_len;
@@ -1098,6 +1140,7 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
 			break;
 		}
 		cnt = atop(end - trunc_page(addr));
+#ifndef __rtems__
 		/*
 		 * A perfectly misaligned address and length could cause
 		 * both the start and the end of the chunk to use partial
@@ -1109,16 +1152,21 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
 			error = EFAULT;
 			break;
 		}
+#endif /* __rtems__ */
 		short_uio.uio_iov = &short_iovec[0];
 		short_iovec[0].iov_base = (void *)addr;
 		short_uio.uio_iovcnt = 1;
 		short_uio.uio_resid = short_iovec[0].iov_len = len;
 		short_uio.uio_offset = uio_clone->uio_offset;
+#ifndef __rtems__
 		td->td_ma = ma;
 		td->td_ma_cnt = cnt;
+#endif /* __rtems__ */
 
 		error = vn_io_fault_doio(args, &short_uio, td);
+#ifndef __rtems__
 		vm_page_unhold_pages(ma, cnt);
+#endif /* __rtems__ */
 		adv = len - short_uio.uio_resid;
 
 		uio_clone->uio_iov->iov_base =
@@ -1133,11 +1181,15 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args,
 		if (error != 0 || adv == 0)
 			break;
 	}
+#ifndef __rtems__
 	td->td_ma = prev_td_ma;
 	td->td_ma_cnt = prev_td_ma_cnt;
 	curthread_pflags_restore(saveheld);
+#endif /* __rtems__ */
 out:
+#ifndef __rtems__
 	free(uio_clone, M_IOV);
+#endif /* __rtems__ */
 	return (error);
 }
 
@@ -1145,6 +1197,7 @@ static int
 vn_io_fault(struct file *fp, struct uio *uio, struct ucred *active_cred,
     int flags, struct thread *td)
 {
+#ifdef __rtems__
 	fo_rdwr_t *doio;
 	struct vnode *vp;
 	void *rl_cookie;
@@ -1178,6 +1231,9 @@ vn_io_fault(struct file *fp, struct uio *uio, struct ucred *active_cred,
 	}
 	foffset_unlock_uio(fp, uio, flags);
 	return (error);
+#else /* __rtems__ */
+	return (EFAULT);
+#endif /* __rtems__ */
 }
 
 /*
@@ -1195,6 +1251,8 @@ vn_io_fault(struct file *fp, struct uio *uio, struct ucred *active_cred,
 int
 vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio)
 {
+#ifndef __rtems__
+	return (EFAULT);
 	struct uio transp_uio;
 	struct iovec transp_iov[1];
 	struct thread *td;
@@ -1204,8 +1262,10 @@ vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio)
 	td = curthread;
 	if ((td->td_pflags & TDP_UIOHELD) == 0 ||
 	    uio->uio_segflg != UIO_USERSPACE)
+#endif /* __rtems__ */
 		return (uiomove(data, xfersize, uio));
 
+#ifndef __rtems__
 	KASSERT(uio->uio_iovcnt == 1, ("uio_iovcnt %d", uio->uio_iovcnt));
 	transp_iov[0].iov_base = data;
 	transp_uio.uio_iov = &transp_iov[0];
@@ -1246,12 +1306,14 @@ vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio)
 	uio->uio_resid -= adv;
 	uio->uio_offset += adv;
 	return (error);
+#endif /* __rtems__ */
 }
 
 int
 vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,
     struct uio *uio)
 {
+#ifndef __rtems__
 	struct thread *td;
 	vm_offset_t iov_base;
 	int cnt, pgadv;
@@ -1284,6 +1346,9 @@ vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,
 	uio->uio_resid -= cnt;
 	uio->uio_offset += cnt;
 	return (0);
+#else /* __rtems__ */
+	return (EFAULT);
+#endif /* __rtems__ */
 }
 
 
@@ -1440,7 +1505,9 @@ vn_stat(struct vnode *vp, struct stat *sb, struct ucred *active_cred,
 	sb->st_atim = vap->va_atime;
 	sb->st_mtim = vap->va_mtime;
 	sb->st_ctim = vap->va_ctime;
+#ifndef __rtems__
 	sb->st_birthtim = vap->va_birthtime;
+#endif /* __rtems__ */
 
         /*
 	 * According to www.opengroup.org, the meaning of st_blksize is 
@@ -1452,11 +1519,13 @@ vn_stat(struct vnode *vp, struct stat *sb, struct ucred *active_cred,
 
 	sb->st_blksize = max(PAGE_SIZE, vap->va_blocksize);
 	
+#ifndef __rtems__
 	sb->st_flags = vap->va_flags;
 	if (priv_check(td, PRIV_VFS_GENERATION))
 		sb->st_gen = 0;
 	else
 		sb->st_gen = vap->va_gen;
+#endif /* __rtems__ */
 
 	sb->st_blocks = vap->va_bytes / S_BLKSIZE;
 	return (0);
@@ -1486,6 +1555,7 @@ vn_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred,
 			if (error == 0)
 				*(int *)data = vattr.va_size - fp->f_offset;
 			return (error);
+#ifndef __rtems__
 		case FIOBMAP2:
 			bmarg = (struct fiobmap2_arg *)data;
 			vn_lock(vp, LK_SHARED | LK_RETRY);
@@ -1498,6 +1568,7 @@ vn_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred,
 				    &bmarg->bn, &bmarg->runp, &bmarg->runb);
 			VOP_UNLOCK(vp, 0);
 			return (error);
+#endif /* __rtems__ */
 		case FIONBIO:
 		case FIOASYNC:
 			return (0);
@@ -1578,7 +1649,11 @@ vn_closefile(struct file *fp, struct thread *td)
 
 	vp = fp->f_vnode;
 	fp->f_ops = &badfileops;
+#ifndef __rtems__
 	ref= (fp->f_flag & FHASLOCK) != 0 && fp->f_type == DTYPE_VNODE;
+#else /* __rtems__ */
+	ref = false;
+#endif /* __rtems__ */
 
 	error = vn_close1(vp, fp->f_flag, fp->f_cred, td, ref);
 
@@ -1617,7 +1692,11 @@ vn_start_write_locked(struct mount *mp, int flags)
 	/*
 	 * Check on status of suspension.
 	 */
+#ifndef __rtems__
 	if ((curthread->td_pflags & TDP_IGNSUSP) == 0 ||
+#else /* __rtems__ */
+	if (
+#endif /* __rtems__ */
 	    mp->mnt_susp_owner != curthread) {
 		mflags = ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0 ?
 		    (flags & PCATCH) : 0) | (PUSER - 1);
@@ -1864,7 +1943,9 @@ vfs_write_resume(struct mount *mp, int flags)
 		mp->mnt_susp_owner = NULL;
 		wakeup(&mp->mnt_writeopcount);
 		wakeup(&mp->mnt_flag);
+#ifndef __rtems__
 		curthread->td_pflags &= ~TDP_IGNSUSP;
+#endif /* __rtems__ */
 		if ((flags & VR_START_WRITE) != 0) {
 			MNT_REF(mp);
 			mp->mnt_writeopcount++;
@@ -1910,7 +1991,9 @@ vfs_write_suspend_umnt(struct mount *mp)
 	mp->mnt_kern_flag &= ~(MNTK_SUSPENDED | MNTK_SUSPEND2);
 	wakeup(&mp->mnt_flag);
 	MNT_IUNLOCK(mp);
+#ifndef __rtems__
 	curthread->td_pflags |= TDP_IGNSUSP;
+#endif /* __rtems__ */
 	return (0);
 }
 
@@ -2106,9 +2189,11 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio,
 		return (0);
 	if ((uoff_t)uio->uio_offset + uio->uio_resid >
 	    lim_cur(td, RLIMIT_FSIZE)) {
+#ifndef __rtems__
 		PROC_LOCK(td->td_proc);
 		kern_psignal(td->td_proc, SIGXFSZ);
 		PROC_UNLOCK(td->td_proc);
+#endif /* __rtems__ */
 		return (EFBIG);
 	}
 	return (0);
@@ -2147,6 +2232,7 @@ vn_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred,
 void
 vn_pages_remove(struct vnode *vp, vm_pindex_t start, vm_pindex_t end)
 {
+#ifndef __rtems__
 	vm_object_t object;
 
 	if ((object = vp->v_object) == NULL)
@@ -2154,6 +2240,7 @@ vn_pages_remove(struct vnode *vp, vm_pindex_t start, vm_pindex_t end)
 	VM_OBJECT_WLOCK(object);
 	vm_object_page_remove(object, start, end, 0);
 	VM_OBJECT_WUNLOCK(object);
+#endif /* __rtems__ */
 }
 
 int
@@ -2386,6 +2473,7 @@ vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif)
 	return (0);
 }
 
+#ifndef __rtems__
 int
 vn_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size,
     vm_prot_t prot, vm_prot_t cap_maxprot, int flags, vm_ooffset_t foff,
@@ -2499,6 +2587,7 @@ vn_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size,
 #endif
 	return (error);
 }
+#endif /* __rtems__ */
 
 void
 vn_fsid(struct vnode *vp, struct vattr *va)
diff --git a/freebsd/sys/net/route.c b/freebsd/sys/net/route.c
index adbf91bd..2e9883a1 100644
--- a/freebsd/sys/net/route.c
+++ b/freebsd/sys/net/route.c
@@ -407,9 +407,6 @@ struct setfib_args {
 	int     fibnum;
 };
 #endif
-#ifdef __rtems__
-static
-#endif /* __rtems__ */
 int
 sys_setfib(struct thread *td, struct setfib_args *uap)
 {
@@ -423,20 +420,6 @@ sys_setfib(struct thread *td, struct setfib_args *uap)
 #endif /* __rtems__ */
 	return (0);
 }
-#ifdef __rtems__
-int
-setfib(int fibnum)
-{
-	struct setfib_args ua = {
-		.fibnum = fibnum
-	};
-	int error;
-
-	error = sys_setfib(NULL, &ua);
-
-	return rtems_bsd_error_to_status_and_errno(error);
-}
-#endif /* __rtems__ */
 
 /*
  * Packet routing routines.
@@ -2302,4 +2285,3 @@ rt_newaddrmsg_fib(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt,
 		rt_addrmsg(cmd, ifa, fibnum);
 	}
 }
-
diff --git a/freebsd/sys/opencrypto/cryptodev.c b/freebsd/sys/opencrypto/cryptodev.c
index d3f4ad1c..71872532 100644
--- a/freebsd/sys/opencrypto/cryptodev.c
+++ b/freebsd/sys/opencrypto/cryptodev.c
@@ -303,8 +303,6 @@ SYSCTL_TIMEVAL_SEC(_kern, OID_AUTO, cryptodev_warn_interval, CTLFLAG_RW,
     &warninterval,
     "Delay in seconds between warnings of deprecated /dev/crypto algorithms");
 
-#ifndef __rtems__
->>>>>>> e79fbf70f7e... RTEMS
 static	int cryptof_ioctl(struct file *, u_long, void *,
 		    struct ucred *, struct thread *);
 static	int cryptof_stat(struct file *, struct stat *,
@@ -327,9 +325,6 @@ static struct fileops cryptofops = {
     .fo_sendfile = invfo_sendfile,
     .fo_fill_kinfo = cryptof_fill_kinfo,
 };
-#else /* __rtems__ */
-static const rtems_filesystem_file_handlers_r cryptofops;
-#endif /* __rtems__ */
 
 static struct csession *csefind(struct fcrypt *, u_int);
 static bool csedelete(struct fcrypt *, u_int);
@@ -773,27 +768,6 @@ bail:
 	return (error);
 #undef SES2
 }
-#ifdef __rtems__
-static int
-rtems_bsd_cryptof_ioctl(rtems_libio_t *iop, ioctl_command_t request,
-    void *buffer)
-{
-	struct thread *td;
-	int error;
-
-	td = rtems_bsd_get_curthread_or_null();
-	if (td != NULL) {
-		struct file *fp;
-
-		fp = rtems_bsd_iop_to_fp(iop);
-		error = cryptof_ioctl(fp, request, buffer, NULL, td);
-	} else {
-		error = ENOMEM;
-	}
-
-	return (rtems_bsd_error_to_status_and_errno(error));
-}
-#endif /* __rtems__ */
 
 static int cryptodev_cb(struct cryptop *);
 
@@ -1384,17 +1358,11 @@ cryptodev_find(struct crypt_find_op *find)
 
 /* ARGSUSED */
 static int
-#ifndef __rtems__
 cryptof_stat(
 	struct file *fp,
 	struct stat *sb,
 	struct ucred *active_cred,
 	struct thread *td)
-#else /* __rtems__ */
-rtems_bsd_cryptof_stat(const rtems_filesystem_location_info_t *loc,
-    struct stat *buf
-#endif /* __rtems__ */
-)
 {
 
 	return (EOPNOTSUPP);
@@ -1418,28 +1386,7 @@ cryptof_close(struct file *fp, struct thread *td)
 	fp->f_data = NULL;
 	return 0;
 }
-#ifdef __rtems__
-static int
-rtems_bsd_cryptof_close(rtems_libio_t *iop)
-{
-	struct thread *td;
-	int error;
-
-	td = rtems_bsd_get_curthread_or_null();
-	if (td != NULL) {
-		struct file *fp;
 
-		fp = rtems_bsd_iop_to_fp(iop);
-		error = cryptof_close(fp, td);
-	} else {
-		error = ENOMEM;
-	}
-
-	return (rtems_bsd_error_to_status_and_errno(error));
-}
-#endif /* __rtems__ */
-
-#ifndef __rtems__
 static int
 cryptof_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
 {
@@ -1447,7 +1394,6 @@ cryptof_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp
 	kif->kf_type = KF_TYPE_CRYPTO;
 	return (0);
 }
-#endif /* __rtems__ */
 
 static struct csession *
 csefind(struct fcrypt *fcr, u_int ses)
@@ -1567,10 +1513,17 @@ cryptoioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread
 		}
 		/* falloc automatically provides an extra reference to 'f'. */
 		finit(f, FREAD | FWRITE, DTYPE_CRYPTO, fcr, &cryptofops);
+#ifdef __rtems__
+		fd = rtems_bsd_libio_iop_allocate_with_file(td, fd, &rtems_bsd_sysgen_nodeops);
+		if (fd < 0) {
+			fdclose(td, f, fd);
+			mtx_destroy(&fcr->lock);
+			free(fcr, M_XDATA);
+			return (error);
+		}
+#endif /* __rtems__ */
 		*(u_int32_t *)data = fd;
-#ifndef __rtems__
 		fdrop(f, td);
-#endif /* __rtems__ */
 		break;
 	case CRIOFINDDEV:
 		error = cryptodev_find((struct crypt_find_op *)data);
@@ -1627,23 +1580,3 @@ MODULE_VERSION(cryptodev, 1);
 DECLARE_MODULE(cryptodev, cryptodev_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
 MODULE_DEPEND(cryptodev, crypto, 1, 1, 1);
 MODULE_DEPEND(cryptodev, zlib, 1, 1, 1);
-#ifdef __rtems__
-static const rtems_filesystem_file_handlers_r cryptofops = {
-	.open_h = rtems_filesystem_default_open,
-	.close_h = rtems_bsd_cryptof_close,
-	.read_h = rtems_filesystem_default_read,
-	.write_h = rtems_filesystem_default_write,
-	.ioctl_h = rtems_bsd_cryptof_ioctl,
-	.lseek_h = rtems_filesystem_default_lseek,
-	.fstat_h = rtems_bsd_cryptof_stat,
-	.ftruncate_h = rtems_filesystem_default_ftruncate,
-	.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
-	.fcntl_h = rtems_filesystem_default_fcntl,
-	.poll_h = rtems_filesystem_default_poll,
-	.kqfilter_h = rtems_filesystem_default_kqfilter,
-	.readv_h = rtems_filesystem_default_readv,
-	.writev_h = rtems_filesystem_default_writev,
-	.mmap_h = rtems_filesystem_default_mmap
-};
-#endif /* __rtems__ */
diff --git a/freebsd/sys/sys/bio.h b/freebsd/sys/sys/bio.h
index 1dab6155..b361437f 100644
--- a/freebsd/sys/sys/bio.h
+++ b/freebsd/sys/sys/bio.h
@@ -102,9 +102,11 @@ struct bio {
 	void	*bio_caller2;		/* Private use by the consumer. */
 	TAILQ_ENTRY(bio) bio_queue;	/* Disksort queue. */
 	const char *bio_attribute;	/* Attribute for BIO_[GS]ETATTR */
+#ifndef __rtems__
 	struct  disk_zone_args bio_zone;/* Used for BIO_ZONE */
 	struct g_consumer *bio_from;	/* GEOM linkage */
 	struct g_provider *bio_to;	/* GEOM linkage */
+#endif /* __rtems__ */
 	off_t	bio_length;		/* Like bio_bcount */
 	off_t	bio_completed;		/* Inverse of bio_resid */
 	u_int	bio_children;		/* Number of spawned bios */
diff --git a/freebsd/sys/sys/capsicum.h b/freebsd/sys/sys/capsicum.h
index ee5e4267..9fcd3cc1 100644
--- a/freebsd/sys/sys/capsicum.h
+++ b/freebsd/sys/sys/capsicum.h
@@ -336,9 +336,9 @@ cap_rights_t *__cap_rights_set(cap_rights_t *rights, ...);
 	__cap_rights_clear(__VA_ARGS__, 0ULL)
 cap_rights_t *__cap_rights_clear(cap_rights_t *rights, ...);
 #else /* __rtems__ */
-#define	cap_rights_init(...) (void)0
-#define	cap_rights_set(...) (void)0
-#define	cap_rights_clear(...) (void)0
+#define	cap_rights_init(...) NULL
+#define	cap_rights_set(...) NULL
+#define	cap_rights_clear(...) NULL
 #endif /* __rtems__ */
 
 #define	cap_rights_is_set(...)						\
diff --git a/freebsd/sys/sys/conf.h b/freebsd/sys/sys/conf.h
index d6215ba9..556b3f2e 100644
--- a/freebsd/sys/sys/conf.h
+++ b/freebsd/sys/sys/conf.h
@@ -90,15 +90,11 @@ struct cdev {
 	LIST_HEAD(, cdev)	si_children;
 	LIST_ENTRY(cdev)	si_siblings;
 	struct cdev *si_parent;
-#ifndef __rtems__
 	struct mount	*si_mountpt;
-#endif /* __rtems__ */
 	void		*si_drv1, *si_drv2;
 	struct cdevsw	*si_devsw;
-#ifndef __rtems__
 	int		si_iosize_max;	/* maximum I/O size (for physio &al) */
 	u_long		si_usecount;
-#endif /* __rtems__ */
 	u_long		si_threadcount;
 #ifndef __rtems__
 	union {
diff --git a/freebsd/sys/sys/eventvar.h b/freebsd/sys/sys/eventvar.h
index 8afaa1aa..1ed6e9fc 100644
--- a/freebsd/sys/sys/eventvar.h
+++ b/freebsd/sys/sys/eventvar.h
@@ -48,9 +48,7 @@ struct kqueue {
 	int		kq_count;		/* number of pending events */
 	struct		selinfo kq_sel;
 	struct		sigio *kq_sigio;
-#ifndef __rtems__
 	struct		filedesc *kq_fdp;
-#endif /* __rtems__ */
 	int		kq_state;
 #define KQ_SEL		0x01
 #define KQ_SLEEP	0x02
diff --git a/freebsd/sys/sys/file.h b/freebsd/sys/sys/file.h
index 0e7c296a..d48ca0e9 100644
--- a/freebsd/sys/sys/file.h
+++ b/freebsd/sys/sys/file.h
@@ -172,7 +172,6 @@ struct fadvise_info {
 };
 
 struct file {
-#ifndef __rtems__
 	void		*f_data;	/* file descriptor specific data */
 	struct fileops	*f_ops;		/* File operations */
 	struct ucred	*f_cred;	/* associated credentials. */
@@ -202,93 +201,13 @@ struct file {
 	 * Mandatory Access control information.
 	 */
 	void		*f_label;	/* Place-holder for MAC label. */
-#else /* __rtems__ */
-	rtems_libio_t	f_io;
-#endif /* __rtems__ */
-};
 #ifdef __rtems__
-#define f_data f_io.pathinfo.node_access_2
-#define	f_cdevpriv	f_io.data1
-
-static inline struct file *
-rtems_bsd_iop_to_fp(rtems_libio_t *iop)
-{
-	return (struct file *) iop;
-}
-
-static inline struct file *
-rtems_bsd_fd_to_fp(int fd)
-{
-	return rtems_bsd_iop_to_fp(&rtems_libio_iops[fd]);
-}
-
-static inline int
-rtems_bsd_fp_to_fd(struct file *fp)
-{
-	return fp - rtems_bsd_iop_to_fp(&rtems_libio_iops[0]);
-}
-
-static inline void *
-rtems_bsd_loc_to_f_data(const rtems_filesystem_location_info_t *loc)
-{
-	return loc->node_access_2;
-}
-
-static inline uint32_t
-rtems_bsd_fflag_to_libio_flags(u_int fflag)
-{
-	uint32_t libio_flags = 0;
-
-	if ((fflag & FREAD) == FREAD) {
-		libio_flags |= LIBIO_FLAGS_READ;
-	}
-
-	if ((fflag & FWRITE) == FWRITE) {
-		libio_flags |= LIBIO_FLAGS_WRITE;
-	}
-
-	if ((fflag & FNONBLOCK) == FNONBLOCK) {
-		libio_flags |= LIBIO_FLAGS_NO_DELAY;
-	}
-
-	return (libio_flags);
-}
-
-static inline u_int
-rtems_bsd_libio_flags_to_fflag(uint32_t libio_flags)
-{
-	u_int fflag = 0;
-
-	if ((libio_flags & LIBIO_FLAGS_READ) == LIBIO_FLAGS_READ) {
-		fflag |= FREAD;
-	}
-
-	if ((libio_flags & LIBIO_FLAGS_WRITE) == LIBIO_FLAGS_WRITE) {
-		fflag |= FWRITE;
-	}
-
-	if ((libio_flags & LIBIO_FLAGS_NO_DELAY) == LIBIO_FLAGS_NO_DELAY) {
-		fflag |= FNONBLOCK;
-	}
-
-	return (fflag);
-}
-
-static int inline
-rtems_bsd_error_to_status_and_errno(int error)
-{
-	if (error == 0) {
-		return 0;
-	} else {
-		rtems_set_errno_and_return_minus_one(error);
-	}
-}
+	rtems_libio_t	*f_io;
 #endif /* __rtems__ */
+};
 
-#ifndef __rtems__
 #define	f_cdevpriv	f_vnun.fvn_cdevpriv
 #define	f_advice	f_vnun.fvn_advice
-#endif /* __rtems__ */
 
 #define	FOFFSET_LOCKED       0x1
 #define	FOFFSET_LOCK_WAITING 0x2
@@ -323,32 +242,12 @@ struct xfile {
 
 extern struct fileops vnops;
 extern struct fileops badfileops;
-#ifndef __rtems__
 extern struct fileops socketops;
-#else /* __rtems__ */
-extern const rtems_filesystem_file_handlers_r socketops;
-#endif /* __rtems__ */
 extern int maxfiles;		/* kernel limit on number of open files */
 extern int maxfilesperproc;	/* per process limit on number of open files */
 extern volatile int openfiles;	/* actual number of open files */
 
-#ifndef __rtems__
 int fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp);
-#else /* __rtems__ */
-struct file *rtems_bsd_get_file(int fd);
-
-static inline int
-rtems_bsd_do_fget(int fd, struct file **fpp)
-{
-	struct file *fp;
-
-	fp = rtems_bsd_get_file(fd);
-	*fpp = fp;
-	return (fp != NULL ? 0 : EBADF);
-}
-
-#define	fget(td, fd, rights, fpp)	rtems_bsd_do_fget(fd, fpp)
-#endif /* __rtems__ */
 int fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp,
     u_char *maxprotp, struct file **fpp);
 int fget_read(struct thread *td, int fd, cap_rights_t *rightsp,
@@ -359,7 +258,6 @@ int fget_fcntl(struct thread *td, int fd, cap_rights_t *rightsp,
     int needfcntl, struct file **fpp);
 int _fdrop(struct file *fp, struct thread *td);
 
-#ifndef __rtems__
 fo_rdwr_t	invfo_rdwr;
 fo_truncate_t	invfo_truncate;
 fo_ioctl_t	invfo_ioctl;
@@ -371,27 +269,12 @@ fo_sendfile_t	invfo_sendfile;
 
 fo_sendfile_t	vn_sendfile;
 fo_seek_t	vn_seek;
+#ifndef __rtems__
 fo_fill_kinfo_t	vn_fill_kinfo;
 int vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif);
-#else /* __rtems__ */
-int rtems_bsd_soo_kqfilter(rtems_libio_t *iop, struct knote *kn);
 #endif /* __rtems__ */
 
-#ifndef __rtems__
 void finit(struct file *, u_int, short, void *, struct fileops *);
-#else /* __rtems__ */
-static inline void
-finit(struct file *fp, u_int fflag, short type, void *data,
-    const rtems_filesystem_file_handlers_r *ops)
-{
-
-	(void)type;
-	fp->f_data = data;
-	fp->f_io.pathinfo.handlers = ops;
-	rtems_libio_iop_flags_set(&fp->f_io, LIBIO_FLAGS_OPEN |
-	    rtems_bsd_fflag_to_libio_flags(fflag));
-}
-#endif /* __rtems__ */
 int fgetvp(struct thread *td, int fd, cap_rights_t *rightsp,
     struct vnode **vpp);
 int fgetvp_exec(struct thread *td, int fd, cap_rights_t *rightsp,
@@ -410,36 +293,32 @@ _fnoop(void)
 	return (0);
 }
 
-#ifndef __rtems__
 static __inline __result_use_check bool
 fhold(struct file *fp)
 {
 	return (refcount_acquire_checked(&fp->f_count));
 }
-#endif /* __rtems__ */
 
 #ifndef __rtems__
 #define	fdrop(fp, td)							\
 	(refcount_release(&(fp)->f_count) ? _fdrop((fp), (td)) : _fnoop())
 #else /* __rtems__ */
-static inline void
-rtems_bsd_fdrop(struct file *fp)
+static inline int fdrop(struct file *fp, struct thread *td)
 {
-
-	rtems_libio_iop_drop(&fp->f_io);
+	if (fp->f_io != NULL) {
+		if (RTEMS_BSD_DESCRIP_TRACE)
+		  printf("bsd:  fb: fdrop: iop=%p %d (%d) fp=%p (%d) by %p\n",
+			 fp->f_io, fp->f_io->data0, fp->f_io->flags >> 12,
+			 fp, fp->f_count, __builtin_return_address(0));
+		rtems_libio_iop_drop(fp->f_io);
+	} else if (RTEMS_BSD_DESCRIP_TRACE) {
+		printf("bsd:  fb: fdrop: %d %p %d by %p\n",
+		       -1, fp, fp->f_count, __builtin_return_address(0));
+	}
+	return (refcount_release(&(fp)->f_count) ? _fdrop((fp), (td)) : _fnoop());
 }
-
-/*
- * WARNING: fdalloc() and falloc_caps() do not increment the reference count of
- * the file descriptor in contrast to FreeBSD.  We must not call the fdrop()
- * corresponding to a fdalloc() or falloc_caps().  The reason for this is that
- * FreeBSD performs a lazy cleanup once the reference count reaches zero.
- * RTEMS uses the reference count to determine if a cleanup is allowed.
- */
-#define	fdrop(fp, td) rtems_bsd_fdrop(fp)
 #endif /* __rtems__ */
 
-#ifndef __rtems__
 static __inline fo_rdwr_t	fo_read;
 static __inline fo_rdwr_t	fo_write;
 static __inline fo_truncate_t	fo_truncate;
@@ -475,29 +354,13 @@ fo_truncate(struct file *fp, off_t length, struct ucred *active_cred,
 
 	return ((*fp->f_ops->fo_truncate)(fp, length, active_cred, td));
 }
-#endif /* __rtems__ */
 
 static __inline int
 fo_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred,
     struct thread *td)
 {
 
-#ifndef __rtems__
 	return ((*fp->f_ops->fo_ioctl)(fp, com, data, active_cred, td));
-#else /* __rtems__ */
-	int rv;
-
-	(void) active_cred;
-	(void) td;
-
-	errno = 0;
-	rv = ((*fp->f_io.pathinfo.handlers->ioctl_h)(&fp->f_io, com, data));
-	if (rv == 0) {
-		return (0);
-	} else {
-		return (errno);
-	}
-#endif /* __rtems__ */
 }
 
 static __inline int
@@ -505,17 +368,9 @@ fo_poll(struct file *fp, int events, struct ucred *active_cred,
     struct thread *td)
 {
 
-#ifndef __rtems__
 	return ((*fp->f_ops->fo_poll)(fp, events, active_cred, td));
-#else /* __rtems__ */
-	(void) active_cred;
-	(void) td;
-
-	return ((*fp->f_io.pathinfo.handlers->poll_h)(&fp->f_io, events));
-#endif /* __rtems__ */
 }
 
-#ifndef __rtems__
 static __inline int
 fo_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
     struct thread *td)
@@ -530,20 +385,14 @@ fo_close(struct file *fp, struct thread *td)
 
 	return ((*fp->f_ops->fo_close)(fp, td));
 }
-#endif /* __rtems__ */
 
 static __inline int
 fo_kqfilter(struct file *fp, struct knote *kn)
 {
 
-#ifndef __rtems__
 	return ((*fp->f_ops->fo_kqfilter)(fp, kn));
-#else /* __rtems__ */
-	return ((*fp->f_io.pathinfo.handlers->kqfilter_h)(&fp->f_io, kn));
-#endif /* __rtems__ */
 }
 
-#ifndef __rtems__
 static __inline int
 fo_chmod(struct file *fp, mode_t mode, struct ucred *active_cred,
     struct thread *td)
@@ -602,6 +451,9 @@ fo_aio_queue(struct file *fp, struct kaiocb *job)
 
 	return ((*fp->f_ops->fo_aio_queue)(fp, job));
 }
+
+#ifdef __rtems__
+#include <machine/rtems-bsd-libio.h>
 #endif /* __rtems__ */
 
 #endif /* _KERNEL */
diff --git a/freebsd/sys/sys/filedesc.h b/freebsd/sys/sys/filedesc.h
index a3224f42..dc132677 100644
--- a/freebsd/sys/sys/filedesc.h
+++ b/freebsd/sys/sys/filedesc.h
@@ -76,7 +76,6 @@ struct fdescenttbl {
  */
 #define NDSLOTTYPE	u_long
 
-#ifndef __rtems__
 struct filedesc {
 	struct	fdescenttbl *fd_files;	/* open files table */
 	struct	vnode *fd_cdir;		/* current directory */
@@ -93,9 +92,6 @@ struct filedesc {
 	int	fd_holdleaderscount;	/* block fdfree() for shared close() */
 	int	fd_holdleaderswakeup;	/* fdfree() needs wakeup */
 };
-#else /* __rtems__ */
-struct filedesc;
-#endif /* __rtems__ */
 
 /*
  * Structure to keep track of (process leader, struct fildedesc) tuples.
@@ -106,7 +102,6 @@ struct filedesc;
  *
  * fdl_refcount and fdl_holdcount are protected by struct filedesc mtx.
  */
-#ifndef __rtems__
 struct filedesc_to_leader {
 	int		fdl_refcount;	/* references from struct proc */
 	int		fdl_holdcount;	/* temporary hold during closef */
@@ -118,9 +113,6 @@ struct filedesc_to_leader {
 };
 #define	fd_nfiles	fd_files->fdt_nfiles
 #define	fd_ofiles	fd_files->fdt_ofiles
-#else /* __rtems__ */
-struct filedesc_to_leader;
-#endif /* __rtems__ */
 
 /*
  * Per-process open flags.
@@ -128,26 +120,15 @@ struct filedesc_to_leader;
 #define	UF_EXCLOSE	0x01		/* auto-close on exec */
 
 #ifdef _KERNEL
-#ifdef __rtems__
-#include <sys/file.h>
-#include <rtems/libio_.h>
-#endif /* __rtems__ */
 
 /* Lock a file descriptor table. */
 #define	FILEDESC_LOCK_INIT(fdp)	sx_init(&(fdp)->fd_sx, "filedesc structure")
 #define	FILEDESC_LOCK_DESTROY(fdp)	sx_destroy(&(fdp)->fd_sx)
 #define	FILEDESC_LOCK(fdp)	(&(fdp)->fd_sx)
-#ifndef __rtems__
 #define	FILEDESC_XLOCK(fdp)	sx_xlock(&(fdp)->fd_sx)
 #define	FILEDESC_XUNLOCK(fdp)	sx_xunlock(&(fdp)->fd_sx)
 #define	FILEDESC_SLOCK(fdp)	sx_slock(&(fdp)->fd_sx)
 #define	FILEDESC_SUNLOCK(fdp)	sx_sunlock(&(fdp)->fd_sx)
-#else /* __rtems__ */
-#define	FILEDESC_XLOCK(fdp)	do { } while (0)
-#define	FILEDESC_XUNLOCK(fdp)	do { } while (0)
-#define	FILEDESC_SLOCK(fdp)	do { } while (0)
-#define	FILEDESC_SUNLOCK(fdp)	do { } while (0)
-#endif /* __rtems__ */
 
 #define	FILEDESC_LOCK_ASSERT(fdp)	sx_assert(&(fdp)->fd_sx, SX_LOCKED | \
 					    SX_NOTRECURSED)
@@ -177,42 +158,13 @@ void	filecaps_init(struct filecaps *fcaps);
 bool	filecaps_copy(const struct filecaps *src, struct filecaps *dst,
 	    bool locked);
 void	filecaps_move(struct filecaps *src, struct filecaps *dst);
-#ifndef __rtems__
 void	filecaps_free(struct filecaps *fcaps);
-#else /* __rtems__ */
-#define	filecaps_free(fcaps) do { } while (0)
-#endif /* __rtems__ */
 
 int	closef(struct file *fp, struct thread *td);
 int	dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode,
 	    int openerror, int *indxp);
-#ifndef __rtems__
 int	falloc_caps(struct thread *td, struct file **resultfp, int *resultfd,
 	    int flags, struct filecaps *fcaps);
-#else /* __rtems__ */
-static inline int
-falloc_caps(struct thread *td, struct file **resultfp, int *resultfd,
-    int flags, struct filecaps *fcaps)
-{
-	rtems_libio_t *iop;
-
-	(void)td;
-	(void)flags;
-	(void)fcaps;
-
-	iop = rtems_libio_allocate();
-	*resultfp = rtems_bsd_iop_to_fp(iop);
-
-	if (iop != NULL) {
-		iop->pathinfo.mt_entry = &rtems_filesystem_null_mt_entry;
-		rtems_filesystem_location_add_to_mt_entry(&iop->pathinfo);
-		*resultfd = rtems_libio_iop_to_descriptor(iop);
-		return (0);
-	} else {
-		return (ENFILE);
-	}
-}
-#endif /* __rtems__ */
 int	falloc_noinstall(struct thread *td, struct file **resultfp);
 void	_finstall(struct filedesc *fdp, struct file *fp, int fd, int flags,
 	    struct filecaps *fcaps);
@@ -221,22 +173,7 @@ int	finstall(struct thread *td, struct file *fp, int *resultfd, int flags,
 int	fdalloc(struct thread *td, int minfd, int *result);
 int	fdallocn(struct thread *td, int minfd, int *fds, int n);
 int	fdcheckstd(struct thread *td);
-#ifndef __rtems__
 void	fdclose(struct thread *td, struct file *fp, int idx);
-#else /* __rtems__ */
-/*
- * WARNING: Use of fdrop() after fclose() corrupts the file descriptor.  See
- * fdrop() comment.
- */
-static inline void
-fdclose(struct thread *td, struct file *fp, int idx)
-{
-	(void)td;
-	(void)idx;
-
-	rtems_libio_free(&fp->f_io);
-}
-#endif /* __rtems__ */
 void	fdcloseexec(struct thread *td);
 void	fdsetugidsafety(struct thread *td);
 struct	filedesc *fdcopy(struct filedesc *fdp);
@@ -261,27 +198,9 @@ int	fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp,
 	    struct file **fpp, struct filecaps *havecapsp);
 
 /* Return a referenced file from an unlocked descriptor. */
-#ifndef __rtems__
 int	fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
 	    struct file **fpp, seq_t *seqp);
-#else /* __rtems__ */
-static inline int
-do_fget_unlocked(struct filedesc *fdp, int fd, struct file **fpp, seq_t *seqp)
-{
-	struct file *fp;
-
-	(void)fdp;
-	(void)seqp;
-	fp = rtems_bsd_get_file(fd);
-	*fpp = fp;
-	return (fp != NULL ? 0 : EBADF);
-}
 
-#define	fget_unlocked(fdp, fd, needrightsp, fpp, seqp) \
-    do_fget_unlocked(fdp, fd, fpp, seqp)
-#endif /* __rtems__ */
-
-#ifndef __rtems__
 /* Requires a FILEDESC_{S,X}LOCK held and returns without a ref. */
 static __inline struct file *
 fget_locked(struct filedesc *fdp, int fd)
@@ -320,13 +239,15 @@ fd_modified(struct filedesc *fdp, int fd, seq_t seq)
 	return (!seq_consistent(fd_seq(fdp->fd_files, fd), seq));
 }
 #endif
-#endif /* __rtems__ */
 
 /* cdir/rdir/jdir manipulation functions. */
 void	pwd_chdir(struct thread *td, struct vnode *vp);
 int	pwd_chroot(struct thread *td, struct vnode *vp);
 void	pwd_ensure_dirs(void);
 
+#ifdef __rtems__
+#include <machine/rtems-bsd-libio.h>
+#endif /* __rtems__ */
 #endif /* _KERNEL */
 
 #endif /* !_SYS_FILEDESC_H_ */
diff --git a/freebsd/sys/sys/jail.h b/freebsd/sys/sys/jail.h
index b772e91c..8168ff2c 100644
--- a/freebsd/sys/sys/jail.h
+++ b/freebsd/sys/sys/jail.h
@@ -399,7 +399,18 @@ getcredhostid(struct ucred *cred, unsigned long *hostid)
 }
 #endif /* __rtems__ */
 void prison0_init(void);
+#ifndef __rtems__
 int prison_allow(struct ucred *, unsigned);
+#else /* __rtems__ */
+static inline int
+prison_allow(struct ucred *cred1, unsigned i)
+{
+
+	(void)cred1;
+	(void)i;
+	return (0);
+}
+#endif /* __rtems__ */
 #ifndef __rtems__
 int prison_check(struct ucred *cred1, struct ucred *cred2);
 #else /* __rtems__ */
diff --git a/freebsd/sys/sys/mount.h b/freebsd/sys/sys/mount.h
index 698716f5..ed6eccd3 100644
--- a/freebsd/sys/sys/mount.h
+++ b/freebsd/sys/sys/mount.h
@@ -696,6 +696,7 @@ struct vfsops {
 
 vfs_statfs_t	__vfs_statfs;
 
+#ifndef __rtems__
 #define	VFS_PROLOGUE(MP)	do {					\
 	struct mount *mp__;						\
 	int _prev_stops;						\
@@ -708,6 +709,10 @@ vfs_statfs_t	__vfs_statfs;
 #define	VFS_EPILOGUE(MP)						\
 	sigallowstop(_prev_stops);					\
 } while (0)
+#else /* __rtems__ */
+#define	VFS_PROLOGUE(MP)
+#define	VFS_EPILOGUE(MP)
+#endif /* __rtems__ */
 
 #define	VFS_MOUNT(MP) ({						\
 	int _rc;							\
@@ -857,6 +862,7 @@ vfs_statfs_t	__vfs_statfs;
 #define VFS_VERSION_02	0x20180504
 #define VFS_VERSION	VFS_VERSION_02
 
+#ifndef __rtems__
 #define VFS_SET(vfsops, fsname, flags) \
 	static struct vfsconf fsname ## _vfsconf = {		\
 		.vfc_version = VFS_VERSION,			\
@@ -871,6 +877,22 @@ vfs_statfs_t	__vfs_statfs;
 		& fsname ## _vfsconf				\
 	};							\
 	DECLARE_MODULE(fsname, fsname ## _mod, SI_SUB_VFS, SI_ORDER_MIDDLE)
+#else /* __rtems__ */
+#define VFS_SET(vfsops, fsname, flags) \
+	struct vfsconf fsname ## _vfsconf = {			\
+		.vfc_version = VFS_VERSION,			\
+		.vfc_name = #fsname,				\
+		.vfc_vfsops = &vfsops,				\
+		.vfc_typenum = -1,				\
+		.vfc_flags = flags,				\
+	};							\
+	moduledata_t fsname ## _mod = {				\
+		#fsname,					\
+		vfs_modevent,					\
+		& fsname ## _vfsconf				\
+	};							\
+	DECLARE_MODULE(fsname, fsname ## _mod, SI_SUB_VFS, SI_ORDER_MIDDLE)
+#endif /* __rtems__ */
 
 /*
  * exported vnode operations
diff --git a/freebsd/sys/sys/proc.h b/freebsd/sys/sys/proc.h
index bb9e91ce..6ac1025d 100644
--- a/freebsd/sys/sys/proc.h
+++ b/freebsd/sys/sys/proc.h
@@ -718,7 +718,9 @@ struct proc {
 	int		p_osrel;	/* (x) osreldate for the
 					       binary (from ELF note, if any) */
 	char		p_comm[MAXCOMLEN + 1];	/* (x) Process name. */
+#endif /* __rtems__ */
 	struct sysentvec *p_sysent;	/* (b) Syscall dispatch info. */
+#ifndef __rtems__
 	struct pargs	*p_args;	/* (c) Process arguments. */
 	rlim_t		p_cpulimit;	/* (c) Current CPU limit in seconds. */
 	signed char	p_nice;		/* (c) Process "nice" value. */
diff --git a/freebsd/sys/sys/resourcevar.h b/freebsd/sys/sys/resourcevar.h
index 7c7e8458..ea038887 100644
--- a/freebsd/sys/sys/resourcevar.h
+++ b/freebsd/sys/sys/resourcevar.h
@@ -123,7 +123,7 @@ void	 calcru(struct proc *p, struct timeval *up, struct timeval *sp);
 #ifndef __rtems__
 int	 chgkqcnt(struct uidinfo *uip, int diff, rlim_t max);
 #else /* __rtems__ */
-#define	 chgkqcnt(uip, diff, max) 0
+#define	 chgkqcnt(uip, diff, max) 1
 #endif /* __rtems__ */
 int	 chgproccnt(struct uidinfo *uip, int diff, rlim_t maxval);
 #ifndef __rtems__
@@ -146,7 +146,14 @@ int	 kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which,
 struct plimit
 	*lim_alloc(void);
 void	 lim_copy(struct plimit *dst, struct plimit *src);
+#ifndef __rtems__
 rlim_t	 lim_cur(struct thread *td, int which);
+#else /* __rtems__ */
+static inline rlim_t  lim_cur(struct thread *td, int which)
+{
+	return INT64_MAX;
+}
+#endif /* __rtems__ */
 rlim_t	 lim_cur_proc(struct proc *p, int which);
 void	 lim_fork(struct proc *p1, struct proc *p2);
 void	 lim_free(struct plimit *limp);
diff --git a/freebsd/sys/sys/sysctl.h b/freebsd/sys/sys/sysctl.h
index c21f19d3..fa9779f3 100644
--- a/freebsd/sys/sys/sysctl.h
+++ b/freebsd/sys/sys/sysctl.h
@@ -1129,18 +1129,10 @@ int	sysctl_ctx_entry_del(struct sysctl_ctx_list *clist,
 	    struct sysctl_oid *oidp);
 
 int	kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
-#ifndef __rtems__
 	    size_t *oldlenp, void *new, size_t newlen, size_t *retval,
-#else /* __rtems__ */
-	    size_t *oldlenp, const void *newp, size_t newlen, size_t *retval,
-#endif /* __rtems__ */
 	    int flags);
 int	kernel_sysctlbyname(struct thread *td, char *name, void *old,
-#ifndef __rtems__
 	    size_t *oldlenp, void *new, size_t newlen, size_t *retval,
-#else /* __rtems__ */
-	    size_t *oldlenp, const void *newp, size_t newlen, size_t *retval,
-#endif /* __rtems__ */
 	    int flags);
 #ifndef __rtems__
 int	userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
diff --git a/freebsd/sys/sys/sysent.h b/freebsd/sys/sys/sysent.h
index d1d9e99b..2a2e63a1 100644
--- a/freebsd/sys/sys/sysent.h
+++ b/freebsd/sys/sys/sysent.h
@@ -93,6 +93,7 @@ struct trapframe;
 struct vnode;
 
 struct sysentvec {
+#ifndef __rtems__
 	int		sv_size;	/* number of entries */
 	struct sysent	*sv_table;	/* pointer to sysent */
 	u_int		sv_mask;	/* optional mask to index */
@@ -123,7 +124,9 @@ struct sysentvec {
 			    u_long);
 	void		(*sv_fixlimit)(struct rlimit *, int);
 	u_long		*sv_maxssiz;
+#endif /* __rtems__ */
 	u_int		sv_flags;
+#ifndef __rtems__
 	void		(*sv_set_syscall_retval)(struct thread *, int);
 	int		(*sv_fetch_syscall_args)(struct thread *);
 	const char	**sv_syscallnames;
@@ -137,6 +140,7 @@ struct sysentvec {
 	int		(*sv_trap)(struct thread *);
 	u_long		*sv_hwcap;	/* Value passed in AT_HWCAP. */
 	u_long		*sv_hwcap2;	/* Value passed in AT_HWCAP2. */
+#endif /* __rtems__ */
 };
 
 #define	SV_ILP32	0x000100	/* 32-bit executable. */
diff --git a/freebsd/sys/sys/sysproto.h b/freebsd/sys/sys/sysproto.h
index 5ebcdde3..a1ab7e44 100644
--- a/freebsd/sys/sys/sysproto.h
+++ b/freebsd/sys/sys/sysproto.h
@@ -44,6 +44,7 @@ struct sys_exit_args {
 struct fork_args {
 	register_t dummy;
 };
+#endif /* __rtems__ */
 struct read_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)];
@@ -62,12 +63,14 @@ struct open_args {
 struct close_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 };
+#ifndef __rtems__
 struct wait4_args {
 	char pid_l_[PADL_(int)]; int pid; char pid_r_[PADR_(int)];
 	char status_l_[PADL_(int *)]; int * status; char status_r_[PADR_(int *)];
 	char options_l_[PADL_(int)]; int options; char options_r_[PADR_(int)];
 	char rusage_l_[PADL_(struct rusage *)]; struct rusage * rusage; char rusage_r_[PADR_(struct rusage *)];
 };
+#endif /* __rtems__ */
 struct link_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char link_l_[PADL_(char *)]; char * link; char link_r_[PADR_(char *)];
@@ -90,12 +93,14 @@ struct chown_args {
 	char uid_l_[PADL_(int)]; int uid; char uid_r_[PADR_(int)];
 	char gid_l_[PADL_(int)]; int gid; char gid_r_[PADR_(int)];
 };
+#ifndef __rtems__
 struct break_args {
 	char nsize_l_[PADL_(char *)]; char * nsize; char nsize_r_[PADR_(char *)];
 };
 struct getpid_args {
 	register_t dummy;
 };
+#endif /* __rtems__ */
 struct mount_args {
 	char type_l_[PADL_(char *)]; char * type; char type_r_[PADR_(char *)];
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
@@ -106,6 +111,7 @@ struct unmount_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
 };
+#ifndef __rtems__
 struct setuid_args {
 	char uid_l_[PADL_(uid_t)]; uid_t uid; char uid_r_[PADR_(uid_t)];
 };
@@ -159,7 +165,6 @@ struct getsockname_args {
 	char asa_l_[PADL_(struct sockaddr *__restrict)]; struct sockaddr *__restrict asa; char asa_r_[PADR_(struct sockaddr *__restrict)];
 	char alen_l_[PADL_(__socklen_t *__restrict)]; __socklen_t *__restrict alen; char alen_r_[PADR_(__socklen_t *__restrict)];
 };
-#ifndef __rtems__
 struct access_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char amode_l_[PADL_(int)]; int amode; char amode_r_[PADR_(int)];
@@ -172,6 +177,7 @@ struct fchflags_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char flags_l_[PADL_(u_long)]; u_long flags; char flags_r_[PADR_(u_long)];
 };
+#ifndef __rtems__
 struct sync_args {
 	register_t dummy;
 };
@@ -223,17 +229,20 @@ struct sigaltstack_args {
 	char ss_l_[PADL_(stack_t *)]; stack_t * ss; char ss_r_[PADR_(stack_t *)];
 	char oss_l_[PADL_(stack_t *)]; stack_t * oss; char oss_r_[PADR_(stack_t *)];
 };
+#endif /* __rtems__ */
 struct ioctl_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char com_l_[PADL_(u_long)]; u_long com; char com_r_[PADR_(u_long)];
 	char data_l_[PADL_(caddr_t)]; caddr_t data; char data_r_[PADR_(caddr_t)];
 };
+#ifndef __rtems__
 struct reboot_args {
 	char opt_l_[PADL_(int)]; int opt; char opt_r_[PADR_(int)];
 };
 struct revoke_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 };
+#endif /* __rtems__ */
 struct symlink_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char link_l_[PADL_(char *)]; char * link; char link_r_[PADR_(char *)];
@@ -243,6 +252,7 @@ struct readlink_args {
 	char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
 	char count_l_[PADL_(size_t)]; size_t count; char count_r_[PADR_(size_t)];
 };
+#ifndef __rtems__
 struct execve_args {
 	char fname_l_[PADL_(char *)]; char * fname; char fname_r_[PADR_(char *)];
 	char argv_l_[PADL_(char **)]; char ** argv; char argv_r_[PADR_(char **)];
@@ -332,6 +342,7 @@ struct fcntl_args {
 	char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)];
 	char arg_l_[PADL_(long)]; long arg; char arg_r_[PADR_(long)];
 };
+#endif /* __rtems__ */
 struct select_args {
 	char nd_l_[PADL_(int)]; int nd; char nd_r_[PADR_(int)];
 	char in_l_[PADL_(fd_set *)]; fd_set * in; char in_r_[PADR_(fd_set *)];
@@ -342,6 +353,7 @@ struct select_args {
 struct fsync_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 };
+#ifndef __rtems__
 struct setpriority_args {
 	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
 	char who_l_[PADL_(int)]; int who; char who_r_[PADR_(int)];
@@ -417,7 +429,6 @@ struct getsockopt_args {
 	char avalsize_l_[PADL_(__socklen_t *)]; __socklen_t * avalsize; char avalsize_r_[PADR_(__socklen_t *)];
 #endif /* __rtems__ */
 };
-#ifndef __rtems__
 struct readv_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];
@@ -428,10 +439,12 @@ struct writev_args {
 	char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];
 	char iovcnt_l_[PADL_(u_int)]; u_int iovcnt; char iovcnt_r_[PADR_(u_int)];
 };
+#ifndef __rtems__
 struct settimeofday_args {
 	char tv_l_[PADL_(struct timeval *)]; struct timeval * tv; char tv_r_[PADR_(struct timeval *)];
 	char tzp_l_[PADL_(struct timezone *)]; struct timezone * tzp; char tzp_r_[PADR_(struct timezone *)];
 };
+#endif /* __rtems__ */
 struct fchown_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char uid_l_[PADL_(int)]; int uid; char uid_r_[PADR_(int)];
@@ -441,6 +454,7 @@ struct fchmod_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)];
 };
+#ifndef __rtems__
 struct setreuid_args {
 	char ruid_l_[PADL_(int)]; int ruid; char ruid_r_[PADR_(int)];
 	char euid_l_[PADL_(int)]; int euid; char euid_r_[PADR_(int)];
@@ -449,10 +463,12 @@ struct setregid_args {
 	char rgid_l_[PADL_(int)]; int rgid; char rgid_r_[PADR_(int)];
 	char egid_l_[PADL_(int)]; int egid; char egid_r_[PADR_(int)];
 };
+#endif /* __rtems__ */
 struct rename_args {
 	char from_l_[PADL_(char *)]; char * from; char from_r_[PADR_(char *)];
 	char to_l_[PADL_(char *)]; char * to; char to_r_[PADR_(char *)];
 };
+#ifndef __rtems__
 struct flock_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char how_l_[PADL_(int)]; int how; char how_r_[PADR_(int)];
@@ -485,7 +501,6 @@ struct socketpair_args {
 	char protocol_l_[PADL_(int)]; int protocol; char protocol_r_[PADR_(int)];
 	char rsv_l_[PADL_(int *)]; int * rsv; char rsv_r_[PADR_(int *)];
 };
-#ifndef __rtems__
 struct mkdir_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)];
@@ -493,6 +508,7 @@ struct mkdir_args {
 struct rmdir_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 };
+#ifndef __rtems__
 struct utimes_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char tptr_l_[PADL_(struct timeval *)]; struct timeval * tptr; char tptr_r_[PADR_(struct timeval *)];
@@ -522,10 +538,12 @@ struct nlm_syscall_args {
 	char addr_count_l_[PADL_(int)]; int addr_count; char addr_count_r_[PADR_(int)];
 	char addrs_l_[PADL_(char **)]; char ** addrs; char addrs_r_[PADR_(char **)];
 };
+#endif /* __rtems__ */
 struct nfssvc_args {
 	char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
 	char argp_l_[PADL_(caddr_t)]; caddr_t argp; char argp_r_[PADR_(caddr_t)];
 };
+#ifndef __rtems__
 struct lgetfh_args {
 	char fname_l_[PADL_(char *)]; char * fname; char fname_r_[PADR_(char *)];
 	char fhp_l_[PADL_(struct fhandle *)]; struct fhandle * fhp; char fhp_r_[PADR_(struct fhandle *)];
@@ -741,6 +759,7 @@ struct rfork_args {
 struct issetugid_args {
 	register_t dummy;
 };
+#endif /* __rtems__ */
 struct lchown_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char uid_l_[PADL_(int)]; int uid; char uid_r_[PADR_(int)];
@@ -762,6 +781,7 @@ struct lchmod_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char mode_l_[PADL_(mode_t)]; mode_t mode; char mode_r_[PADR_(mode_t)];
 };
+#ifndef __rtems__
 struct lutimes_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char tptr_l_[PADL_(struct timeval *)]; struct timeval * tptr; char tptr_r_[PADR_(struct timeval *)];
@@ -827,6 +847,7 @@ struct setresgid_args {
 	char egid_l_[PADL_(gid_t)]; gid_t egid; char egid_r_[PADR_(gid_t)];
 	char sgid_l_[PADL_(gid_t)]; gid_t sgid; char sgid_r_[PADR_(gid_t)];
 };
+#endif /* __rtems__ */
 struct aio_return_args {
 	char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
 };
@@ -842,6 +863,7 @@ struct aio_cancel_args {
 struct aio_error_args {
 	char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
 };
+#ifndef __rtems__
 struct yield_args {
 	register_t dummy;
 };
@@ -851,10 +873,12 @@ struct mlockall_args {
 struct munlockall_args {
 	register_t dummy;
 };
+#endif /* __rtems__ */
 struct __getcwd_args {
 	char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
 	char buflen_l_[PADL_(size_t)]; size_t buflen; char buflen_r_[PADR_(size_t)];
 };
+#ifndef __rtems__
 struct sched_setparam_args {
 	char pid_l_[PADL_(pid_t)]; pid_t pid; char pid_r_[PADR_(pid_t)];
 	char param_l_[PADL_(const struct sched_param *)]; const struct sched_param * param; char param_r_[PADR_(const struct sched_param *)];
@@ -923,6 +947,7 @@ struct sigwaitinfo_args {
 	char set_l_[PADL_(const sigset_t *)]; const sigset_t * set; char set_r_[PADR_(const sigset_t *)];
 	char info_l_[PADL_(siginfo_t *)]; siginfo_t * info; char info_r_[PADR_(siginfo_t *)];
 };
+#endif /* __rtems__ */
 struct __acl_get_file_args {
 	char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
 	char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
@@ -961,6 +986,7 @@ struct __acl_aclcheck_fd_args {
 	char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
 	char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
 };
+#ifndef __rtems__
 struct extattrctl_args {
 	char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
 	char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)];
@@ -987,10 +1013,12 @@ struct extattr_delete_file_args {
 	char attrnamespace_l_[PADL_(int)]; int attrnamespace; char attrnamespace_r_[PADR_(int)];
 	char attrname_l_[PADL_(const char *)]; const char * attrname; char attrname_r_[PADR_(const char *)];
 };
+#endif /* __rtems__ */
 struct aio_waitcomplete_args {
 	char aiocbp_l_[PADL_(struct aiocb **)]; struct aiocb ** aiocbp; char aiocbp_r_[PADR_(struct aiocb **)];
 	char timeout_l_[PADL_(struct timespec *)]; struct timespec * timeout; char timeout_r_[PADR_(struct timespec *)];
 };
+#ifndef __rtems__
 struct getresuid_args {
 	char ruid_l_[PADL_(uid_t *)]; uid_t * ruid; char ruid_r_[PADR_(uid_t *)];
 	char euid_l_[PADL_(uid_t *)]; uid_t * euid; char euid_r_[PADR_(uid_t *)];
@@ -1041,11 +1069,13 @@ struct afs3_syscall_args {
 	char parm5_l_[PADL_(long)]; long parm5; char parm5_r_[PADR_(long)];
 	char parm6_l_[PADL_(long)]; long parm6; char parm6_r_[PADR_(long)];
 };
+#endif /* __rtems__ */
 struct nmount_args {
 	char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];
 	char iovcnt_l_[PADL_(unsigned int)]; unsigned int iovcnt; char iovcnt_r_[PADR_(unsigned int)];
 	char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
 };
+#ifndef __rtems__
 struct __mac_get_proc_args {
 	char mac_p_l_[PADL_(struct mac *)]; struct mac * mac_p; char mac_p_r_[PADR_(struct mac *)];
 };
@@ -1074,10 +1104,12 @@ struct kenv_args {
 	char value_l_[PADL_(char *)]; char * value; char value_r_[PADR_(char *)];
 	char len_l_[PADL_(int)]; int len; char len_r_[PADR_(int)];
 };
+#endif /* __rtems__ */
 struct lchflags_args {
 	char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
 	char flags_l_[PADL_(u_long)]; u_long flags; char flags_r_[PADR_(u_long)];
 };
+#ifndef __rtems__
 struct uuidgen_args {
 	char store_l_[PADL_(struct uuid *)]; struct uuid * store; char store_r_[PADR_(struct uuid *)];
 	char count_l_[PADL_(int)]; int count; char count_r_[PADR_(int)];
@@ -1187,6 +1219,7 @@ struct swapcontext_args {
 struct swapoff_args {
 	char name_l_[PADL_(const char *)]; const char * name; char name_r_[PADR_(const char *)];
 };
+#endif /* __rtems__ */
 struct __acl_get_link_args {
 	char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
 	char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
@@ -1206,6 +1239,7 @@ struct __acl_aclcheck_link_args {
 	char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
 	char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
 };
+#ifndef __rtems__
 struct sigwait_args {
 	char set_l_[PADL_(const sigset_t *)]; const sigset_t * set; char set_r_[PADR_(const sigset_t *)];
 	char sig_l_[PADL_(int *)]; int * sig; char sig_r_[PADR_(int *)];
@@ -1349,10 +1383,12 @@ struct thr_set_name_args {
 	char id_l_[PADL_(long)]; long id; char id_r_[PADR_(long)];
 	char name_l_[PADL_(const char *)]; const char * name; char name_r_[PADR_(const char *)];
 };
+#endif /* __rtems__ */
 struct aio_fsync_args {
 	char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)];
 	char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
 };
+#ifndef __rtems__
 struct rtprio_thread_args {
 	char function_l_[PADL_(int)]; int function; char function_r_[PADR_(int)];
 	char lwpid_l_[PADL_(lwpid_t)]; lwpid_t lwpid; char lwpid_r_[PADR_(lwpid_t)];
@@ -1409,6 +1445,7 @@ struct mmap_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char pos_l_[PADL_(off_t)]; off_t pos; char pos_r_[PADR_(off_t)];
 };
+#endif /* __rtems__ */
 struct lseek_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)];
@@ -1422,6 +1459,7 @@ struct ftruncate_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char length_l_[PADL_(off_t)]; off_t length; char length_r_[PADR_(off_t)];
 };
+#ifndef __rtems__
 struct thr_kill2_args {
 	char pid_l_[PADL_(pid_t)]; pid_t pid; char pid_r_[PADR_(pid_t)];
 	char id_l_[PADL_(long)]; long id; char id_r_[PADR_(long)];
@@ -1469,6 +1507,7 @@ struct faccessat_args {
 	char amode_l_[PADL_(int)]; int amode; char amode_r_[PADR_(int)];
 	char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
 };
+#endif /* __rtems__ */
 struct fchmodat_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
@@ -1482,6 +1521,7 @@ struct fchownat_args {
 	char gid_l_[PADL_(gid_t)]; gid_t gid; char gid_r_[PADR_(gid_t)];
 	char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
 };
+#ifndef __rtems__
 struct fexecve_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char argv_l_[PADL_(char **)]; char ** argv; char argv_r_[PADR_(char **)];
@@ -1492,6 +1532,7 @@ struct futimesat_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char times_l_[PADL_(struct timeval *)]; struct timeval * times; char times_r_[PADR_(struct timeval *)];
 };
+#endif /* __rtems__ */
 struct linkat_args {
 	char fd1_l_[PADL_(int)]; int fd1; char fd1_r_[PADR_(int)];
 	char path1_l_[PADL_(char *)]; char * path1; char path1_r_[PADR_(char *)];
@@ -1504,11 +1545,13 @@ struct mkdirat_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char mode_l_[PADL_(mode_t)]; mode_t mode; char mode_r_[PADR_(mode_t)];
 };
+#ifndef __rtems__
 struct mkfifoat_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char mode_l_[PADL_(mode_t)]; mode_t mode; char mode_r_[PADR_(mode_t)];
 };
+#endif /* __rtems__ */
 struct openat_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
@@ -1537,6 +1580,7 @@ struct unlinkat_args {
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
 };
+#ifndef __rtems__
 struct posix_openpt_args {
 	char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
 };
@@ -1602,6 +1646,7 @@ struct pdgetpid_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char pidp_l_[PADL_(pid_t *)]; pid_t * pidp; char pidp_r_[PADR_(pid_t *)];
 };
+#endif /* __rtems__ */
 struct pselect_args {
 	char nd_l_[PADL_(int)]; int nd; char nd_r_[PADR_(int)];
 	char in_l_[PADL_(fd_set *)]; fd_set * in; char in_r_[PADR_(fd_set *)];
@@ -1610,6 +1655,7 @@ struct pselect_args {
 	char ts_l_[PADL_(const struct timespec *)]; const struct timespec * ts; char ts_r_[PADR_(const struct timespec *)];
 	char sm_l_[PADL_(const sigset_t *)]; const sigset_t * sm; char sm_r_[PADR_(const sigset_t *)];
 };
+#ifndef __rtems__
 struct getloginclass_args {
 	char namebuf_l_[PADL_(char *)]; char * namebuf; char namebuf_r_[PADR_(char *)];
 	char namelen_l_[PADL_(size_t)]; size_t namelen; char namelen_r_[PADR_(size_t)];
@@ -1706,6 +1752,7 @@ struct chflagsat_args {
 	char flags_l_[PADL_(u_long)]; u_long flags; char flags_r_[PADR_(u_long)];
 	char atflag_l_[PADL_(int)]; int atflag; char atflag_r_[PADR_(int)];
 };
+#endif /* __rtems__ */
 struct accept4_args {
 	char s_l_[PADL_(int)]; int s; char s_r_[PADR_(int)];
 	char name_l_[PADL_(struct sockaddr *__restrict)]; struct sockaddr *__restrict name; char name_r_[PADR_(struct sockaddr *__restrict)];
@@ -1719,6 +1766,7 @@ struct pipe2_args {
 struct aio_mlock_args {
 	char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
 };
+#ifndef __rtems__
 struct procctl_args {
 	char idtype_l_[PADL_(idtype_t)]; idtype_t idtype; char idtype_r_[PADR_(idtype_t)];
 	char id_l_[PADL_(id_t)]; id_t id; char id_r_[PADR_(id_t)];
@@ -1741,6 +1789,7 @@ struct utimensat_args {
 	char times_l_[PADL_(struct timespec *)]; struct timespec * times; char times_r_[PADR_(struct timespec *)];
 	char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
 };
+#endif /* __rtems__ */
 struct fdatasync_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 };
@@ -1754,10 +1803,12 @@ struct fstatat_args {
 	char buf_l_[PADL_(struct stat *)]; struct stat * buf; char buf_r_[PADR_(struct stat *)];
 	char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)];
 };
+#ifndef __rtems__
 struct fhstat_args {
 	char u_fhp_l_[PADL_(const struct fhandle *)]; const struct fhandle * u_fhp; char u_fhp_r_[PADR_(const struct fhandle *)];
 	char sb_l_[PADL_(struct stat *)]; struct stat * sb; char sb_r_[PADR_(struct stat *)];
 };
+#endif /* __rtems__ */
 struct getdirentries_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
@@ -1777,17 +1828,18 @@ struct getfsstat_args {
 	char bufsize_l_[PADL_(long)]; long bufsize; char bufsize_r_[PADR_(long)];
 	char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)];
 };
+#ifndef __rtems__
 struct fhstatfs_args {
 	char u_fhp_l_[PADL_(const struct fhandle *)]; const struct fhandle * u_fhp; char u_fhp_r_[PADR_(const struct fhandle *)];
 	char buf_l_[PADL_(struct statfs *)]; struct statfs * buf; char buf_r_[PADR_(struct statfs *)];
 };
+#endif /* __rtems__ */
 struct mknodat_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
 	char mode_l_[PADL_(mode_t)]; mode_t mode; char mode_r_[PADR_(mode_t)];
 	char dev_l_[PADL_(dev_t)]; dev_t dev; char dev_r_[PADR_(dev_t)];
 };
-#endif /* __rtems__ */
 struct kevent_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 #ifndef __rtems__
@@ -1845,25 +1897,32 @@ struct fhreadlink_args {
 int	nosys(struct thread *, struct nosys_args *);
 void	sys_sys_exit(struct thread *, struct sys_exit_args *);
 int	sys_fork(struct thread *, struct fork_args *);
+#endif /* __rtems__ */
 int	sys_read(struct thread *, struct read_args *);
 int	sys_write(struct thread *, struct write_args *);
 int	sys_open(struct thread *, struct open_args *);
 int	sys_close(struct thread *, struct close_args *);
+#ifndef __rtems__
 int	sys_wait4(struct thread *, struct wait4_args *);
+#endif /* __rtems__ */
 int	sys_link(struct thread *, struct link_args *);
 int	sys_unlink(struct thread *, struct unlink_args *);
 int	sys_chdir(struct thread *, struct chdir_args *);
 int	sys_fchdir(struct thread *, struct fchdir_args *);
 int	sys_chmod(struct thread *, struct chmod_args *);
 int	sys_chown(struct thread *, struct chown_args *);
+#ifndef __rtems__
 int	sys_break(struct thread *, struct break_args *);
 int	sys_getpid(struct thread *, struct getpid_args *);
+#endif /* __rtems__ */
 int	sys_mount(struct thread *, struct mount_args *);
 int	sys_unmount(struct thread *, struct unmount_args *);
+#ifndef __rtems__
 int	sys_setuid(struct thread *, struct setuid_args *);
 int	sys_getuid(struct thread *, struct getuid_args *);
 int	sys_geteuid(struct thread *, struct geteuid_args *);
 int	sys_ptrace(struct thread *, struct ptrace_args *);
+#endif /* __rtems__ */
 int	sys_recvmsg(struct thread *, struct recvmsg_args *);
 int	sys_sendmsg(struct thread *, struct sendmsg_args *);
 int	sys_recvfrom(struct thread *, struct recvfrom_args *);
@@ -1873,6 +1932,7 @@ int	sys_getsockname(struct thread *, struct getsockname_args *);
 int	sys_access(struct thread *, struct access_args *);
 int	sys_chflags(struct thread *, struct chflags_args *);
 int	sys_fchflags(struct thread *, struct fchflags_args *);
+#ifndef __rtems__
 int	sys_sync(struct thread *, struct sync_args *);
 int	sys_kill(struct thread *, struct kill_args *);
 int	sys_getppid(struct thread *, struct getppid_args *);
@@ -1885,11 +1945,15 @@ int	sys_getlogin(struct thread *, struct getlogin_args *);
 int	sys_setlogin(struct thread *, struct setlogin_args *);
 int	sys_acct(struct thread *, struct acct_args *);
 int	sys_sigaltstack(struct thread *, struct sigaltstack_args *);
+#endif /* __rtems__ */
 int	sys_ioctl(struct thread *, struct ioctl_args *);
+#ifndef __rtems__
 int	sys_reboot(struct thread *, struct reboot_args *);
 int	sys_revoke(struct thread *, struct revoke_args *);
+#endif /* __rtems__ */
 int	sys_symlink(struct thread *, struct symlink_args *);
 int	sys_readlink(struct thread *, struct readlink_args *);
+#ifndef __rtems__
 int	sys_execve(struct thread *, struct execve_args *);
 int	sys_umask(struct thread *, struct umask_args *);
 int	sys_chroot(struct thread *, struct chroot_args *);
@@ -1911,33 +1975,45 @@ int	sys_getitimer(struct thread *, struct getitimer_args *);
 int	sys_getdtablesize(struct thread *, struct getdtablesize_args *);
 int	sys_dup2(struct thread *, struct dup2_args *);
 int	sys_fcntl(struct thread *, struct fcntl_args *);
+#endif /* __rtems__ */
 int	sys_select(struct thread *, struct select_args *);
 int	sys_fsync(struct thread *, struct fsync_args *);
+#ifndef __rtems__
 int	sys_setpriority(struct thread *, struct setpriority_args *);
+#endif /* __rtems__ */
 int	sys_socket(struct thread *, struct socket_args *);
 int	sys_connect(struct thread *, struct connect_args *);
+#ifndef __rtems__
 int	sys_getpriority(struct thread *, struct getpriority_args *);
+#endif /* __rtems__ */
 int	sys_bind(struct thread *, struct bind_args *);
 int	sys_setsockopt(struct thread *, struct setsockopt_args *);
 int	sys_listen(struct thread *, struct listen_args *);
+#ifndef __rtems__
 int	sys_gettimeofday(struct thread *, struct gettimeofday_args *);
 int	sys_getrusage(struct thread *, struct getrusage_args *);
+#endif /* __rtems__ */
 int	sys_getsockopt(struct thread *, struct getsockopt_args *);
 int	sys_readv(struct thread *, struct readv_args *);
 int	sys_writev(struct thread *, struct writev_args *);
+#ifndef __rtems__
 int	sys_settimeofday(struct thread *, struct settimeofday_args *);
+#endif /* __rtems__ */
 int	sys_fchown(struct thread *, struct fchown_args *);
 int	sys_fchmod(struct thread *, struct fchmod_args *);
+#ifndef __rtems__
 int	sys_setreuid(struct thread *, struct setreuid_args *);
 int	sys_setregid(struct thread *, struct setregid_args *);
 int	sys_rename(struct thread *, struct rename_args *);
 int	sys_flock(struct thread *, struct flock_args *);
 int	sys_mkfifo(struct thread *, struct mkfifo_args *);
+#endif /* __rtems__ */
 int	sys_sendto(struct thread *, struct sendto_args *);
 int	sys_shutdown(struct thread *, struct shutdown_args *);
 int	sys_socketpair(struct thread *, struct socketpair_args *);
 int	sys_mkdir(struct thread *, struct mkdir_args *);
 int	sys_rmdir(struct thread *, struct rmdir_args *);
+#ifndef __rtems__
 int	sys_utimes(struct thread *, struct utimes_args *);
 int	sys_adjtime(struct thread *, struct adjtime_args *);
 int	sys_setsid(struct thread *, struct setsid_args *);
@@ -1951,7 +2027,9 @@ int	sys_rtprio(struct thread *, struct rtprio_args *);
 int	sys_semsys(struct thread *, struct semsys_args *);
 int	sys_msgsys(struct thread *, struct msgsys_args *);
 int	sys_shmsys(struct thread *, struct shmsys_args *);
+#endif /* __rtems__ */
 int	sys_setfib(struct thread *, struct setfib_args *);
+#ifndef __rtems__
 int	sys_ntp_adjtime(struct thread *, struct ntp_adjtime_args *);
 int	sys_setgid(struct thread *, struct setgid_args *);
 int	sys_setegid(struct thread *, struct setegid_args *);
@@ -1966,7 +2044,9 @@ int	sys_munlock(struct thread *, struct munlock_args *);
 int	sys_undelete(struct thread *, struct undelete_args *);
 int	sys_futimes(struct thread *, struct futimes_args *);
 int	sys_getpgid(struct thread *, struct getpgid_args *);
+#endif /* __rtems__ */
 int	sys_poll(struct thread *, struct poll_args *);
+#ifndef __rtems__
 int	sys_semget(struct thread *, struct semget_args *);
 int	sys_semop(struct thread *, struct semop_args *);
 int	sys_msgget(struct thread *, struct msgget_args *);
@@ -2055,7 +2135,9 @@ int	sys_extattr_delete_file(struct thread *, struct extattr_delete_file_args *);
 int	sys_aio_waitcomplete(struct thread *, struct aio_waitcomplete_args *);
 int	sys_getresuid(struct thread *, struct getresuid_args *);
 int	sys_getresgid(struct thread *, struct getresgid_args *);
+#endif /* __rtems__ */
 int	sys_kqueue(struct thread *, struct kqueue_args *);
+#ifndef __rtems__
 int	sys_extattr_set_fd(struct thread *, struct extattr_set_fd_args *);
 int	sys_extattr_get_fd(struct thread *, struct extattr_get_fd_args *);
 int	sys_extattr_delete_fd(struct thread *, struct extattr_delete_fd_args *);
@@ -2218,7 +2300,9 @@ int	sys_fstatfs(struct thread *, struct fstatfs_args *);
 int	sys_getfsstat(struct thread *, struct getfsstat_args *);
 int	sys_fhstatfs(struct thread *, struct fhstatfs_args *);
 int	sys_mknodat(struct thread *, struct mknodat_args *);
+#endif /* __rtems__ */
 int	sys_kevent(struct thread *, struct kevent_args *);
+#ifndef __rtems__
 int	sys_cpuset_getdomain(struct thread *, struct cpuset_getdomain_args *);
 int	sys_cpuset_setdomain(struct thread *, struct cpuset_setdomain_args *);
 int	sys_getrandom(struct thread *, struct getrandom_args *);
@@ -2226,7 +2310,9 @@ int	sys_getfhat(struct thread *, struct getfhat_args *);
 int	sys_fhlink(struct thread *, struct fhlink_args *);
 int	sys_fhlinkat(struct thread *, struct fhlinkat_args *);
 int	sys_fhreadlink(struct thread *, struct fhreadlink_args *);
+#endif /* __rtems__ */
 
+#ifndef __rtems__
 #ifdef COMPAT_43
 
 struct ocreat_args {
diff --git a/freebsd/sys/sys/user.h b/freebsd/sys/sys/user.h
index b2338f01..cc2f4704 100644
--- a/freebsd/sys/sys/user.h
+++ b/freebsd/sys/sys/user.h
@@ -340,7 +340,6 @@ struct kinfo_ofile {
 #endif
 
 struct kinfo_file {
-#ifndef __rtems__
 	int		kf_structsize;		/* Variable size of record. */
 	int		kf_type;		/* Descriptor type. */
 	int		kf_fd;			/* Array index. */
@@ -447,9 +446,6 @@ struct kinfo_file {
 	uint64_t	_kf_cap_spare;		/* Space for future cap_rights_t. */
 	/* Truncated before copyout in sysctl */
 	char		kf_path[PATH_MAX];	/* Path to file, if any. */
-#else /* __rtems__ */
-	int		kf_dummy;
-#endif /* __rtems__ */
 };
 
 /*
diff --git a/freebsd/sys/sys/vnode.h b/freebsd/sys/sys/vnode.h
index f3cdf8a5..d297c931 100644
--- a/freebsd/sys/sys/vnode.h
+++ b/freebsd/sys/sys/vnode.h
@@ -46,7 +46,6 @@
 #include <sys/acl.h>
 #include <sys/ktr.h>
 
-#ifndef __rtems__
 /*
  * The vnode is the focus of all file activity in UNIX.  There is a
  * unique vnode allocated for each active file, each current directory,
@@ -155,7 +154,9 @@ struct vnode {
 	struct vpollinfo *v_pollinfo;		/* i Poll events, p for *v_pi */
 	struct label *v_label;			/* MAC label for vnode */
 	struct lockf *v_lockf;		/* Byte-level advisory lock list */
+#ifndef __rtems__
 	struct rangelock v_rl;			/* Byte-range lock */
+#endif /* __rtems__ */
 
 	/*
 	 * clustering stuff
@@ -380,7 +381,9 @@ struct vattr {
 MALLOC_DECLARE(M_VNODE);
 #endif
 
+#ifndef __rtems__
 extern u_int ncsizefactor;
+#endif /* __rtems__ */
 
 /*
  * Convert between vnode types and inode formats (since POSIX.1
@@ -718,6 +721,7 @@ int	vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio);
 int	vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,
 	    struct uio *uio);
 
+#ifndef __rtems__
 #define	vn_rangelock_unlock(vp, cookie)					\
 	rangelock_unlock(&(vp)->v_rl, (cookie), VI_MTX(vp))
 #define	vn_rangelock_unlock_range(vp, cookie, start, end)		\
@@ -727,6 +731,12 @@ int	vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,
 	rangelock_rlock(&(vp)->v_rl, (start), (end), VI_MTX(vp))
 #define	vn_rangelock_wlock(vp, start, end)				\
 	rangelock_wlock(&(vp)->v_rl, (start), (end), VI_MTX(vp))
+#else /* __rtems__ */
+#define	vn_rangelock_unlock(vp, cookie)
+#define	vn_rangelock_unlock_range(vp, cookie, start, end)
+#define	vn_rangelock_rlock(vp, start, end) NULL
+#define	vn_rangelock_wlock(vp, start, end) NULL
+#endif /* __rtems__ */
 
 int	vfs_cache_lookup(struct vop_lookup_args *ap);
 void	vfs_timestamp(struct timespec *);
@@ -925,6 +935,5 @@ void vn_fsid(struct vnode *vp, struct vattr *va);
 int vn_dir_check_exec(struct vnode *vp, struct componentname *cnp);
 
 #endif /* _KERNEL */
-#endif /* __rtems__ */
 
 #endif /* !_SYS_VNODE_H_ */
diff --git a/freebsd/sys/vm/uma_core.c b/freebsd/sys/vm/uma_core.c
index 0efdb12f..a1ea3497 100644
--- a/freebsd/sys/vm/uma_core.c
+++ b/freebsd/sys/vm/uma_core.c
@@ -3898,12 +3898,15 @@ uma_zone_reserve_kva(uma_zone_t zone, int count)
 
 	return (1);
 }
+#endif /* __rtems__ */
 
 /* See uma.h */
 void
 uma_prealloc(uma_zone_t zone, int items)
 {
+#ifndef __rtems__
 	struct vm_domainset_iter di;
+#endif /* __rtems__ */
 	uma_domain_t dom;
 	uma_slab_t slab;
 	uma_keg_t keg;
@@ -3918,8 +3921,10 @@ uma_prealloc(uma_zone_t zone, int items)
 		slabs++;
 	while (slabs-- > 0) {
 		aflags = M_NOWAIT;
+#ifndef __rtems__
 		vm_domainset_iter_policy_ref_init(&di, &keg->uk_dr, &domain,
 		    &aflags);
+#endif /* __rtems__ */
 		for (;;) {
 			slab = keg_alloc_slab(keg, zone, domain, M_WAITOK,
 			    aflags);
@@ -3931,16 +3936,17 @@ uma_prealloc(uma_zone_t zone, int items)
 				break;
 			}
 			KEG_LOCK(keg);
+#ifndef __rtems__
 			if (vm_domainset_iter_policy(&di, &domain) != 0) {
 				KEG_UNLOCK(keg);
 				vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask);
 				KEG_LOCK(keg);
 			}
+#endif /* __rtems__ */
 		}
 	}
 	KEG_UNLOCK(keg);
 }
-#endif /* __rtems__ */
 
 /* See uma.h */
 static void
diff --git a/freebsd/sys/vm/vm_extern.h b/freebsd/sys/vm/vm_extern.h
index 0d17f8af..f9875c25 100644
--- a/freebsd/sys/vm/vm_extern.h
+++ b/freebsd/sys/vm/vm_extern.h
@@ -96,6 +96,18 @@ int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len,
     vm_prot_t prot, vm_page_t *ma, int max_count);
 int vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
     int fault_flags, int *signo, int *ucode);
+#else /* __rtems__ */
+static inline int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len,
+    vm_prot_t prot, vm_page_t *ma, int max_count) {
+  vm_offset_t end;
+  if (len == 0)
+    return (0);
+  end = round_page(addr + len);
+  addr = trunc_page(addr);
+ if (atop(end - addr) > max_count)
+   panic("vm_fault_quick_hold_pages: count > max_count");
+ return atop(end - addr);
+}
 #endif /* __rtems__ */
 int vm_forkproc(struct thread *, struct proc *, struct thread *,
     struct vmspace *, int);
diff --git a/freebsd/sys/vm/vm_meter.c b/freebsd/sys/vm/vm_meter.c
index dfd50081..b31cdd90 100644
--- a/freebsd/sys/vm/vm_meter.c
+++ b/freebsd/sys/vm/vm_meter.c
@@ -1,3 +1,5 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -41,7 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
-#include <sys/resource.h>
+#include <rtems/bsd/sys/resource.h>
 #include <sys/rwlock.h>
 #include <sys/sx.h>
 #include <sys/vmmeter.h>
@@ -106,6 +108,7 @@ vmcounter_startup(void)
 }
 SYSINIT(counter, SI_SUB_KMEM, SI_ORDER_FIRST, vmcounter_startup, NULL);
 
+#ifndef __rtems__
 SYSCTL_UINT(_vm, VM_V_FREE_MIN, v_free_min,
 	CTLFLAG_RW, &vm_cnt.v_free_min, 0, "Minimum low-free-pages threshold");
 SYSCTL_UINT(_vm, VM_V_FREE_TARGET, v_free_target,
@@ -559,3 +562,4 @@ vm_stats_init(void *arg __unused)
 }
 
 SYSINIT(vmstats_init, SI_SUB_VM_CONF, SI_ORDER_FIRST, vm_stats_init, NULL);
+#endif /* __rtems__ */
diff --git a/libbsd.py b/libbsd.py
index 2f56e7c6..c5f601ed 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -39,6 +39,11 @@ import builder
 # Default configuration.
 #
 _defaults = {
+    #
+    # Global defines, added to the build of all files
+    #
+    'defines': [],
+
     #
     # Compile flags
     #
@@ -162,6 +167,7 @@ class rtems(builder.Module):
         mm = self.manager
         self.addRTEMSKernelSourceFiles(
             [
+                'fs/rootfs/rootfs.c',
                 'local/bus_if.c',
                 'local/cryptodev_if.c',
                 'local/device_if.c',
@@ -181,6 +187,8 @@ class rtems(builder.Module):
                 'rtems/rtems-bsd-get-mac-address.c',
                 'rtems/rtems-bsd-get-task-priority.c',
                 'rtems/rtems-bsd-get-task-stack-size.c',
+                'rtems/rtems-bsd-libio.c',
+                'rtems/rtems-bsd-mountroot.c',
                 'rtems/rtems-bsd-syscall-api.c',
                 'rtems/rtems-kernel-assert.c',
                 'rtems/rtems-kernel-autoconf.c',
@@ -188,8 +196,11 @@ class rtems(builder.Module):
                 'rtems/rtems-kernel-bus-dma-mbuf.c',
                 'rtems/rtems-kernel-bus-root.c',
                 'rtems/rtems-kernel-cam.c',
+                'rtems/rtems-kernel-capability.c',
                 'rtems/rtems-kernel-chunk.c',
                 'rtems/rtems-kernel-delay.c',
+                'rtems/rtems-kernel-dev.c',
+                'rtems/rtems-kernel-dirent.c',
                 'rtems/rtems-kernel-epoch.c',
                 'rtems/rtems-kernel-get-file.c',
                 'rtems/rtems-kernel-init.c',
@@ -203,6 +214,7 @@ class rtems(builder.Module):
                 'rtems/rtems-kernel-muteximpl.c',
                 'rtems/rtems-kernel-nexus.c',
                 'rtems/rtems-kernel-page.c',
+                'rtems/rtems-kernel-pager.c',
                 'rtems/rtems-kernel-panic.c',
                 'rtems/rtems-kernel-pci_bus.c',
                 'rtems/rtems-kernel-pci_cfgreg.c',
@@ -215,7 +227,9 @@ class rtems(builder.Module):
                 'rtems/rtems-kernel-timesupport.c',
                 'rtems/rtems-kernel-termioskqueuepoll.c',
                 'rtems/rtems-kernel-thread.c',
+                'rtems/rtems-kernel-vfs.c',
                 'rtems/rtems-kernel-vprintf.c',
+                'rtems/rtems-kernel-vmem.c',
                 'rtems/rtems-kernel-wpa-supplicant.c',
                 'rtems/rtems-legacy-rtrequest.c',
                 'rtems/rtems-legacy-newproc.c',
@@ -242,6 +256,7 @@ class rtems(builder.Module):
                 'sys/dev/usb/controller/usb_otg_transceiver.c',
                 'sys/dev/usb/controller/usb_otg_transceiver_dump.c',
                 'sys/fs/devfs/devfs_devs.c',
+                'sys/kern/vnode_if.c',
                 'sys/net/if_ppp.c',
                 'sys/net/ppp_tty.c',
             ],
@@ -366,10 +381,13 @@ class base(builder.Module):
                 'sys/contrib/ck/include/gcc/x86/ck_f_pr.h',
                 'sys/contrib/ck/include/gcc/x86/ck_pr.h',
                 'sys/fs/devfs/devfs_int.h',
+                'sys/fs/pseudofs/pseudofs.h',
+                'sys/fs/pseudofs/pseudofs_internal.h',
                 'sys/security/audit/audit.h',
                 'sys/security/mac/mac_framework.h',
                 'sys/sys/acl.h',
                 'sys/sys/aio.h',
+                'sys/sys/bio.h',
                 'sys/sys/blist.h',
                 'sys/sys/bufobj.h',
                 'sys/sys/buf_ring.h',
@@ -427,12 +445,14 @@ class base(builder.Module):
                 'sys/sys/mount.h',
                 'sys/sys/_mutex.h',
                 'sys/sys/mutex.h',
+                'sys/sys/namei.h',
                 'sys/sys/nlist_aout.h',
                 'sys/sys/_null.h',
                 'sys/sys/nv.h',
                 'sys/sys/osd.h',
                 'sys/sys/pcpu.h',
                 'sys/sys/_pctrie.h',
+                'sys/sys/pctrie.h',
                 'sys/sys/pipe.h',
                 'sys/sys/priv.h',
                 'sys/sys/proc.h',
@@ -467,7 +487,9 @@ class base(builder.Module):
                 'sys/sys/stdint.h',
                 'sys/sys/_sx.h',
                 'sys/sys/sx.h',
+                'sys/sys/syscallsubr.h',
                 'sys/sys/sysctl.h',
+                'sys/sys/sysent.h',
                 'sys/sys/sysproto.h',
                 'sys/sys/systm.h',
                 'sys/sys/_task.h',
@@ -479,6 +501,7 @@ class base(builder.Module):
                 'sys/sys/unpcb.h',
                 'sys/sys/_unrhdr.h',
                 'sys/sys/uuid.h',
+                'sys/sys/vmem.h',
                 'sys/sys/vmmeter.h',
                 'sys/sys/vnode.h',
                 'sys/vm/uma_dbg.h',
@@ -491,14 +514,16 @@ class base(builder.Module):
         self.addKernelSpaceSourceFiles(
             [
                 'sys/contrib/ck/src/ck_epoch.c',
+                'sys/fs/deadfs/dead_vnops.c',
                 'sys/kern/init_main.c',
                 'sys/kern/kern_condvar.c',
                 'sys/kern/kern_conf.c',
+                'sys/kern/kern_descrip.c',
                 'sys/kern/kern_event.c',
                 'sys/kern/kern_hhook.c',
                 'sys/kern/kern_intr.c',
-                'sys/kern/kern_ktr.c',
                 'sys/kern/kern_khelp.c',
+                'sys/kern/kern_ktr.c',
                 'sys/kern/kern_linker.c',
                 'sys/kern/kern_mbuf.c',
                 'sys/kern/kern_mib.c',
@@ -525,6 +550,7 @@ class base(builder.Module):
                 'sys/kern/subr_kobj.c',
                 'sys/kern/subr_lock.c',
                 'sys/kern/subr_pcpu.c',
+                'sys/kern/subr_pctrie.c',
                 'sys/kern/subr_prf.c',
                 'sys/kern/subr_rman.c',
                 'sys/kern/subr_sbuf.c',
@@ -542,6 +568,21 @@ class base(builder.Module):
                 'sys/kern/uipc_sockbuf.c',
                 'sys/kern/uipc_socket.c',
                 'sys/kern/uipc_usrreq.c',
+                'sys/kern/vfs_acl.c',
+                'sys/kern/vfs_aio.c',
+                'sys/kern/vfs_bio.c',
+                'sys/kern/vfs_cache.c',
+                #'sys/kern/vfs_cluster.c',
+                'sys/kern/vfs_default.c',
+                'sys/kern/vfs_export.c',
+                #'sys/kern/vfs_extattr.c',
+                'sys/kern/vfs_hash.c',
+                'sys/kern/vfs_init.c',
+                'sys/kern/vfs_lookup.c',
+                'sys/kern/vfs_mount.c',
+                'sys/kern/vfs_subr.c',
+                'sys/kern/vfs_syscalls.c',
+                'sys/kern/vfs_vnops.c',
                 'sys/libkern/crc32.c',
                 'sys/libkern/bcd.c',
                 'sys/libkern/inet_ntoa.c',
@@ -549,8 +590,13 @@ class base(builder.Module):
                 'sys/libkern/murmur3_32.c',
                 'sys/libkern/random.c',
                 'sys/fs/devfs/devfs_vnops.c',
+                'sys/fs/pseudofs/pseudofs.c',
+                'sys/fs/pseudofs/pseudofs_fileno.c',
+                'sys/fs/pseudofs/pseudofs_vncache.c',
+                'sys/fs/pseudofs/pseudofs_vnops.c',
                 'sys/vm/uma_core.c',
                 'sys/vm/uma_dbg.c',
+                'sys/vm/vm_meter.c',
             ],
             mm.generator['source']()
         )
@@ -1465,6 +1511,7 @@ class dev_nic(builder.Module):
                 'sys/arm64/include/cpu.h',
                 'sys/arm/include/cpufunc.h',
                 'sys/i386/include/md_var.h',
+                'sys/i386/include/intr_machdep.h',
                 'sys/i386/include/cpufunc.h',
                 'sys/x86/include/intr_machdep.h',
                 'sys/x86/include/specialreg.h',
diff --git a/rtemsbsd/fs/rootfs/rootfs.c b/rtemsbsd/fs/rootfs/rootfs.c
new file mode 100644
index 00000000..d31b2c06
--- /dev/null
+++ b/rtemsbsd/fs/rootfs/rootfs.c
@@ -0,0 +1,94 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 2020 Chris Johns
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/vnode.h>
+
+#include <fs/pseudofs/pseudofs.h>
+
+static struct pfs_node *rootfs_root;
+
+static int
+rootfs_attr(PFS_ATTR_ARGS, int mode)
+{
+  vap->va_mode = 0;
+  return 0;
+}
+
+static int
+rootfs_attr_all_rwx(PFS_ATTR_ARGS)
+{
+  vap->va_mode = 0777;
+  return 0;
+}
+
+int
+rtems_bsd_rootfs_mkdir(const char *name)
+{
+  struct pfs_node *dir;
+  dir = pfs_create_dir(rootfs_root, name, rootfs_attr_all_rwx,
+                       NULL, NULL, PFS_RDWR | PFS_NOWAIT);
+  if (dir == NULL)
+    return ENOENT;
+  return 0;
+}
+
+int
+rtems_bsd_rootfs_rmdir(const char *name)
+{
+  struct pfs_node *dir;
+  dir = pfs_find_node(rootfs_root, name);
+  if (dir == NULL)
+    return ENOENT;
+  return pfs_destroy(dir);
+}
+
+static int
+rootfs_init(PFS_INIT_ARGS)
+{
+  rootfs_root = pi->pi_root;
+  return 0;
+}
+
+static int
+rootfs_uninit(PFS_INIT_ARGS)
+{
+  return 0;
+}
+
+PSEUDOFS(rootfs, 1, VFCF_SYNTHETIC);
diff --git a/rtemsbsd/fs/rootfs/rootvfs.c b/rtemsbsd/fs/rootfs/rootvfs.c
new file mode 100644
index 00000000..a5489f94
--- /dev/null
+++ b/rtemsbsd/fs/rootfs/rootvfs.c
@@ -0,0 +1,656 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 2020 Chris Johns
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/ctype.h>
+#include <sys/dirent.h>
+#include <sys/fcntl.h>
+#include <sys/limits.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mount.h>
+#include <sys/mutex.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/sbuf.h>
+#include <sys/sx.h>
+#include <sys/sysctl.h>
+#include <sys/vnode.h>
+#include <sys/systm.h>
+
+/*
+ * Debugging
+ */
+#ifdef ROOTFS_TRACE
+#define ROOTFS_TRACE(foo)                        \
+do {                                             \
+  printf("%s(): line %d: ", __func__, __LINE__); \
+  printf foo ;                                   \
+  printf("\n");                                  \
+} while (0)
+#define ROOTFS_RETURN(err)                       \
+do {                                             \
+  printf("%s(): line %d: returning %d\n",        \
+         __func__, __LINE__, err);               \
+  return (err);                                  \
+} while (0)
+#else
+#define ROOTFS_TRACE(foo) \
+  do { /* nothing */ } while (0)
+#define ROOTFS_RETURN(err) \
+  return (err)
+#endif
+
+static struct vop_vector rootfs_vnodeops;
+
+/*
+ * The nodes are the file system's data. The vnode data comes and
+ * goes depending on the state of the vnode cache.
+ */
+
+#define ROOTFS_NAMELEN (64)
+#define ROOTFS_ROOT    (1 << 0)
+
+struct rootfs_node {
+  char                rn_name[ROOTFS_NAMELEN];
+  int                 rn_flags;
+  struct rootfs_node *rn_parent;
+  struct rootfs_node *rn_children;
+  struct mtx          rn_mutex;
+  struct rootfs_node *rn_prev, *rn_next;
+};
+
+struct rootfs_vdata {
+  struct rootfs_node  *rvd_rn;
+  bool                 rvd_dead;
+  struct vnode        *rvd_vnode;
+  struct rootfs_vdata *rvd_prev, *rvd_next;
+};
+
+struct rootfs_info {
+  struct rootfs_node *ri_root;
+  struct mtx          ri_mutex;
+  struct unrhdr      *ri_unrhdr;
+};
+
+static MALLOC_DEFINE(M_ROOTFSVNCACHE, "rootfs_vncache", "rootfs vnode cache");
+
+static struct rootfs_info  *rootfs;
+static struct rootfs_vdata *rootfs_vncache;
+static struct mtx           rootfs_vncache_mutex;
+
+/*
+ * Vnode operations
+ */
+static vop_access_t       rootfs_access;
+static vop_cachedlookup_t rootfs_lookup;
+static vop_mkdir_t        rootfs_mkdir;
+static vop_rmdir_t        rootfs_rmdir;
+static vop_vptocnp_t      rootfs_vptocnp;
+
+static struct vop_vector rootfs_vnodeops = {
+  .vop_default =    &default_vnodeops,
+
+  .vop_access       = rootfs_access,
+  .vop_cachedlookup = rootfs_lookup,
+  .vop_close        = VOP_EOPNOTSUPP,
+  .vop_create       = VOP_EOPNOTSUPP,
+  .vop_getattr      = VOP_EOPNOTSUPP,
+  .vop_getextattr   = VOP_EOPNOTSUPP,
+  .vop_ioctl        = VOP_EOPNOTSUPP,
+  .vop_link         = VOP_EOPNOTSUPP,
+  .vop_lookup       = vfs_cache_lookup,
+  .vop_mkdir        = VOP_EOPNOTSUPP,
+  .vop_mknod        = VOP_EOPNOTSUPP,
+  .vop_open         = VOP_EOPNOTSUPP,
+  .vop_read         = VOP_EOPNOTSUPP,
+  .vop_readdir      = VOP_EOPNOTSUPP,
+  .vop_readlink     = VOP_EOPNOTSUPP,
+  .vop_remove       = VOP_EOPNOTSUPP,
+  .vop_rename       = VOP_EOPNOTSUPP,
+  .vop_rmdir        = rootfs_rmdir,
+  .vop_setattr      = VOP_EOPNOTSUPP,
+  .vop_symlink      = VOP_EOPNOTSUPP,
+  .vop_vptocnp      = rootfs_vptocnp,
+  .vop_write        = VOP_EOPNOTSUPP,
+};
+
+static vfs_init_t rootfs_init;
+static vfs_mount_t rootfs_mount;
+static vfs_cmount_t rootfs_cmount;
+static vfs_root_t rootfs_root;
+static vfs_statfs_t rootfs_statfs;
+static vfs_sync_t rootfs_sync;
+static vfs_uninit_t rootfs_uninit;
+static vfs_unmount_t rootfs_unmount;
+static vfs_sysctl_t rootfs_sysctl;
+static vfs_purge_t rootfs_purge;
+
+static struct vfsops rootfs_vfsops = {
+  .vfs_init    = rootfs_init,
+  .vfs_mount   = rootfs_mount,
+  .vfs_cmount  = rootfs_cmount,
+  .vfs_root    = rootfs_root,
+  .vfs_statfs  = rootfs_statfs,
+  .vfs_sync    = rootfs_sync,
+  .vfs_uninit  = rootfs_uninit,
+  .vfs_unmount = rootfs_unmount,
+  .vfs_sysctl  = rootfs_sysctl,
+  .vfs_purge   = rootfs_purge,
+};
+VFS_SET(rootfs_vfsops, rootfs, VFCF_STATIC);
+
+static void
+rootfs_assert_not_owned(struct rootfs_node *rn)
+{
+  mtx_assert(&rn->rn_mutex, MA_NOTOWNED);
+}
+
+static void
+rootfs_lock(struct rootfs_node *rn)
+{
+  mtx_lock(&rn->rn_mutex);
+}
+
+static void
+rootfs_unlock(struct rootfs_node *rn)
+{
+  mtx_unlock(&rn->rn_mutex);
+}
+
+static int
+rootfs_vncache_alloc(struct mount *mp,
+                     struct vnode **vpp,
+                     struct rootfs_node *rn)
+{
+  struct rootfs_vdata *rvd;
+  struct vnode *vp;
+  int error;
+
+  rvd = malloc(sizeof *rvd, M_ROOTFSVNCACHE, M_WAITOK);
+  rvd->rvd_next = rvd->rvd_prev = NULL;
+  error = getnewvnode("rootfs", mp, &rootfs_vnodeops, vpp);
+  if (error) {
+    free(rvd, M_ROOTFSVNCACHE);
+    return (error);
+  }
+  rvd->rvd_rn = rn;
+  (*vpp)->v_data = rvd;
+  (*vpp)->v_type = VDIR;
+  rvd->rvd_vnode = *vpp;
+  vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY);
+  VN_LOCK_AREC(*vpp);
+  error = insmntque(*vpp, mp);
+  if (error != 0) {
+    free(rvd, M_ROOTFSVNCACHE);
+    *vpp = NULLVP;
+    return (error);
+  }
+  while (true) {
+    struct rootfs_vdata *rvd2;
+    mtx_lock(&rootfs_vncache_mutex);
+    /*
+     * Other thread may race with us, creating the entry we are
+     * going to insert into the cache. Recheck after
+     * pfs_vncache_mutex is reacquired.
+     */
+    for (rvd2 = rootfs_vncache; rvd2; rvd2 = rvd2->rvd_next) {
+      if (rvd2->rvd_rn == rn && rvd2->rvd_vnode->v_mount == mp) {
+        vp = rvd2->rvd_vnode;
+        VI_LOCK(vp);
+        mtx_unlock(&rootfs_vncache_mutex);
+        if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, curthread) == 0) {
+          vgone(*vpp);
+          vput(*vpp);
+          *vpp = vp;
+          cache_purge(vp);
+          return (0);
+        }
+	continue;
+      }
+    }
+    break;
+  }
+  rvd->rvd_prev = NULL;
+  rvd->rvd_next = rootfs_vncache;
+  if (rvd->rvd_next)
+    rvd->rvd_next->rvd_prev = rvd;
+  rootfs_vncache = rvd;
+  mtx_unlock(&rootfs_vncache_mutex);
+  return (0);
+}
+
+int
+pfs_vncache_free(struct vnode *vp)
+{
+  struct rootfs_vdata *rvd;
+
+  mtx_lock(&rootfs_vncache_mutex);
+  rvd = (struct rootfs_vdata *)vp->v_data;
+  KASSERT(rvd != NULL, ("rootfs_vncache_free(): no vnode data\n"));
+  if (rvd->rvd_next)
+    rvd->rvd_next->rvd_prev = rvd->rvd_prev;
+  if (rvd->rvd_prev) {
+    rvd->rvd_prev->rvd_next = rvd->rvd_next;
+  } else if (rootfs_vncache == rvd) {
+    rootfs_vncache = rvd->rvd_next;
+  }
+  mtx_unlock(&rootfs_vncache_mutex);
+  free(rvd, M_ROOTFSVNCACHE);
+  vp->v_data = NULL;
+  return (0);
+}
+
+
+static void
+pfs_purge(struct rootfs_node *rn)
+{
+  struct rootfs_vdata *rvd;
+  struct vnode *vnp;
+  mtx_lock(&rootfs_vncache_mutex);
+  rvd = rootfs_vncache;
+  while (rvd != NULL) {
+    if (rvd->rvd_dead || (rn != NULL && rvd->rvd_rn == rn)) {
+      vnp = rvd->rvd_vnode;
+      vhold(vnp);
+      mtx_unlock(&rootfs_vncache_mutex);
+      VOP_LOCK(vnp, LK_EXCLUSIVE);
+      vgone(vnp);
+      VOP_UNLOCK(vnp, 0);
+      mtx_lock(&rootfs_vncache_mutex);
+      vdrop(vnp);
+      rvd = rootfs_vncache;
+    } else {
+      rvd = rvd->rvd_next;
+    }
+  }
+  mtx_unlock(&rootfs_vncache_mutex);
+}
+
+
+/*
+ * Verify permissions
+ */
+static int
+rootfs_access(struct vop_access_args *va)
+{
+  struct vnode *vn = va->a_vp;
+  struct rootfs_node *rn = vn->v_data;
+  struct vattr vattr;
+  int error;
+
+  ROOTFS_TRACE(("%s", rn->rn_name));
+  (void)rn;
+
+  error = VOP_GETATTR(vn, &vattr, va->a_cred);
+  if (error)
+    ROOTFS_RETURN (error);
+  error = vaccess(vn->v_type, vattr.va_mode, vattr.va_uid,
+                  vattr.va_gid, va->a_accmode, va->a_cred, NULL);
+  ROOTFS_RETURN (error);
+}
+
+/*
+ * Get file attributes
+ */
+static int
+rootfs_getattr(struct vop_getattr_args *va)
+{
+  struct vnode *vn = va->a_vp;
+  struct rootfs_node *rn = vn->v_data;
+  struct vattr *vap = va->a_vap;
+  int error = 0;
+
+  ROOTFS_TRACE(("%s", rn->rn_name));
+  rootfs_assert_not_owned(rn);
+
+  vap->va_type = vn->v_type;
+  vap->va_fileid = alloc_unr(rootfs->ri_unrhdr);
+  vap->va_flags = 0;
+  vap->va_blocksize = PAGE_SIZE;
+  vap->va_bytes = vap->va_size = 0;
+  vap->va_filerev = 0;
+  vap->va_fsid = vn->v_mount->mnt_stat.f_fsid.val[0];
+  vap->va_nlink = 1;
+  nanotime(&vap->va_ctime);
+  vap->va_atime = vap->va_mtime = vap->va_ctime;
+
+  vap->va_mode = 0555;
+  vap->va_uid = 0;
+  vap->va_gid = 0;
+
+  ROOTFS_RETURN (error);
+}
+
+/*
+ * Make directory
+ */
+static int
+rootfs_mkdir(struct vop_mkdir_args *va)
+{
+  struct vnode *dvn = va->a_dvp;
+  struct vnode **vpp = va->a_vpp;
+  struct vattr *vap = va->a_vap;
+  struct rootfs_node *rn;
+  int error = 0;
+
+  ROOTFS_TRACE(("%s", rn->rn_name));
+
+  error = EOPNOTSUPP;
+
+  ROOTFS_RETURN (error);
+}
+
+/*
+ * Remove directory
+ */
+static int
+rootfs_rmdir(struct vop_rmdir_args *va)
+{
+  struct vnode *vn = va->a_vp;
+  struct rootfs_node *rn = vn->v_data;
+  int error = 0;
+
+  ROOTFS_TRACE(("%s", rn->rn_name));
+  rootfs_assert_not_owned(rn);
+
+  error = EOPNOTSUPP;
+
+  ROOTFS_RETURN (error);
+}
+
+/*
+ * Convert a vnode to its component name
+ */
+static int
+rootfs_vptocnp(struct vop_vptocnp_args *ap)
+{
+  struct vnode *vp = ap->a_vp;
+  struct vnode **dvp = ap->a_vpp;
+  struct rootfs_node *rn = vp->v_data;
+  struct mount *mp;
+  char *buf = ap->a_buf;
+  int *buflen = ap->a_buflen;
+  char pidbuf[ROOTFS_NAMELEN];
+  int len, i, error, locked;
+
+  i = *buflen;
+  error = 0;
+
+  rootfs_lock(rn);
+
+  if (vp->v_type == VDIR && ((rn->rn_flags & ROOTFS_ROOT) != 0)) {
+    *dvp = vp;
+    vhold(*dvp);
+    rootfs_unlock(rn);
+    ROOTFS_RETURN (0);
+  } else {
+    len = strlen(rn->rn_name);
+    i -= len;
+    if (i < 0) {
+      error = ENOMEM;
+      goto failed;
+    }
+    bcopy(rn->rn_name, buf + i, len);
+  }
+
+  rootfs_unlock(rn);
+  rn = rn->rn_parent;
+  rootfs_lock(rn);
+
+  mp = vp->v_mount;
+  error = vfs_busy(mp, 0);
+  if (error)
+    return (error);
+
+  /*
+   * vp is held by caller.
+   */
+  locked = VOP_ISLOCKED(vp);
+  VOP_UNLOCK(vp, 0);
+
+  *buflen = i;
+  VOP_UNLOCK(*dvp, 0);
+  vn_lock(vp, locked | LK_RETRY);
+  vfs_unbusy(mp);
+
+  ROOTFS_RETURN (0);
+failed:
+  rootfs_unlock(rn);
+  ROOTFS_RETURN(error);
+}
+
+/*
+ * Look up a file or directory
+ */
+static int
+rootfs_lookup(struct vop_cachedlookup_args *va)
+{
+  struct vnode *vn = va->a_dvp;
+  struct vnode **vpp = va->a_vpp;
+  struct componentname *cnp = va->a_cnp;
+  struct rootfs_node *rvn = vn->v_data;
+  struct rootfs_node *rn, *pdn = NULL;
+  struct mount *mp;
+  char *rname;
+  int error, i, namelen, visible;
+
+  ROOTFS_TRACE(("%.*s", (int)cnp->cn_namelen, cnp->cn_nameptr));
+  rootfs_assert_not_owned(rvn);
+
+  if (vn->v_type != VDIR)
+    ROOTFS_RETURN (ENOTDIR);
+
+  if ((cnp->cn_flags & ISLASTCN) && cnp->cn_nameiop == RENAME)
+    ROOTFS_RETURN (EOPNOTSUPP);
+
+  /* shortcut: check if the name is too long */
+  if (cnp->cn_namelen >= ROOTFS_NAMELEN)
+    ROOTFS_RETURN (ENOENT);
+
+  /* self */
+  namelen = cnp->cn_namelen;
+  rname = cnp->cn_nameptr;
+  if (namelen == 1 && rname[0] == '.') {
+    *vpp = vn;
+    VREF(vn);
+    ROOTFS_RETURN (0);
+  }
+
+  mp = vn->v_mount;
+
+  /* parent */
+  if (cnp->cn_flags & ISDOTDOT) {
+    if (rvn->rn_flags & ROOTFS_ROOT)
+      ROOTFS_RETURN (EIO);
+    error = vfs_busy(mp, MBF_NOWAIT);
+    if (error != 0) {
+      vfs_ref(mp);
+      VOP_UNLOCK(vn, 0);
+      error = vfs_busy(mp, 0);
+      vn_lock(vn, LK_EXCLUSIVE | LK_RETRY);
+      vfs_rel(mp);
+      if (error != 0)
+        ROOTFS_RETURN(ENOENT);
+      if (vn->v_iflag & VI_DOOMED) {
+        vfs_unbusy(mp);
+        ROOTFS_RETURN(ENOENT);
+      }
+    }
+    VOP_UNLOCK(vn, 0);
+    rootfs_lock(rvn);
+    rn = rvn->rn_parent;
+    rootfs_unlock(rvn);
+    goto got_rnode;
+  }
+
+  rootfs_lock(rvn);
+
+  /* named node */
+  for (rn = rvn->rn_children; rn != NULL; rn = rn->rn_next) {
+    if (rn->rn_name[namelen] == '\0' &&
+        bcmp(rname, rn->rn_name, namelen) == 0) {
+      rootfs_unlock(rvn);
+      goto got_rnode;
+    }
+  }
+
+  rootfs_unlock(rvn);
+
+  ROOTFS_RETURN (ENOENT);
+got_rnode:
+  rootfs_assert_not_owned(rvn);
+  rootfs_assert_not_owned(rn);
+  error = rootfs_vncache_alloc(mp, vpp, rn);
+  if (error)
+    goto failed;
+  if (cnp->cn_flags & ISDOTDOT) {
+    vfs_unbusy(mp);
+    vn_lock(vn, LK_EXCLUSIVE | LK_RETRY);
+    if (vn->v_iflag & VI_DOOMED) {
+      vput(*vpp);
+      *vpp = NULL;
+      ROOTFS_RETURN(ENOENT);
+    }
+  }
+  if (cnp->cn_flags & MAKEENTRY && !(vn->v_iflag & VI_DOOMED))
+    cache_enter(vn, *vpp, cnp);
+  ROOTFS_RETURN (0);
+failed:
+  if (cnp->cn_flags & ISDOTDOT) {
+    vfs_unbusy(mp);
+    vn_lock(vn, LK_EXCLUSIVE | LK_RETRY);
+    *vpp = NULL;
+  }
+  ROOTFS_RETURN(error);
+}
+
+static int
+rootfs_init(struct vfsconf *vfsp)
+{
+  printf("rootfs: init\n");
+  return (0);
+}
+
+static int
+rootfs_mount(struct mount *mp)
+{
+  printf("rootfs: mount\n");
+  return (0);
+}
+
+static int
+rootfs_cmount(struct mntarg *ma, void *data, uint64_t flags)
+{
+  printf("rootfs: cmount\n");
+  return (0);
+}
+
+static int
+rootfs_root(struct mount *mp, int flags, struct vnode **vpp)
+{
+  *vpp = rootfs->ri_root->rn_vnode;
+  return (0);
+}
+
+static int
+rootfs_statfs(struct mount *mp, struct statfs *sbp)
+{
+  printf("rootfs: statfs\n");
+  return (0);
+}
+
+static int
+rootfs_sync(struct mount *mp, int waitfor)
+{
+  return (0);
+}
+
+static int
+rootfs_uninit(struct vfsconf *vfsp)
+{
+  printf("rootfs: uninit\n");
+  return (EOPNOTSUPP);
+}
+
+static int
+nfs_unmount(struct mount *mp, int mntflags)
+{
+  printf("rootfs: unmount\n");
+  return (EOPNOTSUPP);
+}
+
+static int
+rootfs_sysctl(struct mount *mp, fsctlop_t op, struct sysctl_req *req)
+{
+  return (0);
+}
+
+static void
+rootfs_purge(struct mount *mp)
+{
+}
+
+static int
+rootfs_modevent(module_t mod, int type, void *data)
+{
+  int error = 0;
+  static int loaded = 0;
+  switch (type) {
+  case MOD_LOAD:
+    if (loaded)
+      return (0);
+    mtx_init(&rootfs_vncache_mutex, "rootds_vncache_mutex", NULL, MTX_DEF);
+    loaded = 1;
+    break;
+  case MOD_UNLOAD:
+    error = EBUSY;
+    break;
+  default:
+    error = EOPNOTSUPP;
+    break;
+  }
+  return error;
+}
+static moduledata_t rootfs_mod = {
+	"rootfs",
+	rootfs_modevent,
+	NULL,
+};
+DECLARE_MODULE(rootfs, rootfs_mod, SI_SUB_VFS, SI_ORDER_FIRST);
+MODULE_VERSION(rootfs, 1);
diff --git a/rtemsbsd/include/machine/atomic.h b/rtemsbsd/include/machine/atomic.h
index a4b6b488..5d48a189 100644
--- a/rtemsbsd/include/machine/atomic.h
+++ b/rtemsbsd/include/machine/atomic.h
@@ -7,6 +7,7 @@
  */
 
 /*
+ * Copyright (c) 2020 Chris Johns  All rights reserved.
  * Copyright (c) 2009, 2015 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
@@ -97,902 +98,39 @@ rmb(void)
 #endif
 }
 
-static inline void
-atomic_add_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_add(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_add_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p += v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_add_acq_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_add(v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_add_explicit(q, v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p += v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_add_rel_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_add(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_add_explicit(q, v, memory_order_release);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p += v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_subtract_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_sub(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_sub_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p -= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_subtract_acq_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_sub(v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_sub_explicit(q, v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p -= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_subtract_rel_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_sub(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_sub_explicit(q, v, memory_order_release);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p -= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_set_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_or(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_or_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p |= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_set_acq_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_or(v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_or_explicit(q, v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p |= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_set_rel_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_or(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_or_explicit(q, v, memory_order_release);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p |= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_clear_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_and(~v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_and_explicit(q, ~v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p &= ~v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_clear_acq_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_and(~v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_and_explicit(q, ~v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p &= ~v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_clear_rel_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->fetch_and(~v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_fetch_and_explicit(q, ~v, memory_order_release);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p &= ~v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline int
-atomic_cmpset_int(volatile int *p, int cmp, int set)
-{
-	int rv;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	rv = q->compare_exchange_strong(cmp, set, std::memory_order_seq_cst,
-	    std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	rv = atomic_compare_exchange_strong_explicit(q, &cmp, set,
-	    memory_order_seq_cst, memory_order_relaxed);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	rv = *p == cmp;
-	if (rv) {
-		*p = set;
-	}
-	rtems_interrupt_enable(level);
-#endif
-
-	return (rv);
-}
-
-static inline int
-atomic_fcmpset_int(volatile int *p, int *cmp, int set)
-{
-	int rv;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	rv = q->compare_exchange_strong(*cmp, set, std::memory_order_seq_cst,
-	    std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	rv = atomic_compare_exchange_strong_explicit(q, cmp, set,
-	    memory_order_seq_cst, memory_order_relaxed);
-#else
-	rtems_interrupt_level level;
-	int actual;
-
-	rtems_interrupt_disable(level);
-	actual = *p;
-	rv = actual == *cmp;
-	*cmp = actual;
-	if (rv) {
-		*p = set;
-	}
-	rtems_interrupt_enable(level);
-#endif
-
-	return (rv);
-}
-
-static inline int
-atomic_cmpset_acq_int(volatile int *p, int cmp, int set)
-{
-	int rv;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	rv = q->compare_exchange_strong(cmp, set, std::memory_order_acquire,
-	    std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	rv = atomic_compare_exchange_strong_explicit(q, &cmp, set,
-	    memory_order_acquire, memory_order_relaxed);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	rv = *p == cmp;
-	if (rv) {
-		*p = set;
-	}
-	rtems_interrupt_enable(level);
-#endif
-
-	return (rv);
-}
-
-static inline int
-atomic_cmpset_rel_int(volatile int *p, int cmp, int set)
-{
-	int rv;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	rv = q->compare_exchange_strong(cmp, set, std::memory_order_release,
-	    std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	rv = atomic_compare_exchange_strong_explicit(q, &cmp, set,
-	    memory_order_release, memory_order_relaxed);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	rv = *p == cmp;
-	if (rv) {
-		*p = set;
-	}
-	rtems_interrupt_enable(level);
-#endif
-
-	return (rv);
-}
-
-static inline int
-atomic_fetchadd_int(volatile int *p, int v)
-{
-	int tmp;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	tmp = q->fetch_add(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	tmp = atomic_fetch_add_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	tmp = *p;
-	*p += v;
-	rtems_interrupt_enable(level);
-#endif
-
-	return (tmp);
-}
-
-static inline int
-atomic_readandclear_int(volatile int *p)
-{
-	int tmp;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	tmp = q->exchange(0, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	tmp = atomic_exchange_explicit(q, 0, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	tmp = *p;
-	*p = 0;
-	rtems_interrupt_enable(level);
-#endif
-
-	return (tmp);
-}
-
-static inline int
-atomic_load_int(volatile int *p)
-{
-	int tmp;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	tmp = q->load(std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	tmp = atomic_load_explicit(q, memory_order_relaxed);
-#else
-	tmp = *p;
-#endif
-
-	return (tmp);
-}
-
-static inline int
-atomic_load_acq_int(volatile int *p)
-{
-	int tmp;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	tmp = q->load(std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	tmp = atomic_load_explicit(q, memory_order_acquire);
-#else
-	RTEMS_COMPILER_MEMORY_BARRIER();
-	tmp = *p;
-#endif
-
-	return (tmp);
-}
-
-static inline void
-atomic_store_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->store(v, std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_store_explicit(q, v, memory_order_relaxed);
-#else
-	*p = v;
-#endif
-}
-
-static inline void
-atomic_store_rel_int(volatile int *p, int v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_int *q =
-	    reinterpret_cast<std::atomic_int *>(const_cast<int *>(p));
-
-	q->store(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_int *q = (atomic_int *)RTEMS_DEVOLATILE(int *, p);
-
-	atomic_store_explicit(q, v, memory_order_release);
-#else
-	*p = v;
-	RTEMS_COMPILER_MEMORY_BARRIER();
-#endif
-}
-
-static inline void
-atomic_add_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_add(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_add_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p += v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_add_acq_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_add(v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_add_explicit(q, v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p += v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_add_rel_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_add(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_add_explicit(q, v, memory_order_release);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p += v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_subtract_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_sub(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_sub_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p -= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_subtract_acq_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_sub(v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_sub_explicit(q, v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p -= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_subtract_rel_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_sub(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_sub_explicit(q, v, memory_order_release);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p -= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_set_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_or(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_or_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p |= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_set_acq_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_or(v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_or_explicit(q, v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p |= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_set_rel_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_or(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_or_explicit(q, v, memory_order_release);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p |= v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_clear_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_and(~v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_and_explicit(q, ~v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p &= ~v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_clear_acq_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_and(~v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_and_explicit(q, ~v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p &= ~v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline void
-atomic_clear_rel_32(volatile uint32_t *p, uint32_t v)
-{
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	q->fetch_and(~v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	atomic_fetch_and_explicit(q, ~v, memory_order_release);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p &= ~v;
-	rtems_interrupt_enable(level);
-#endif
-}
-
-static inline int
-atomic_cmpset_32(volatile uint32_t *p, uint32_t cmp, uint32_t set)
-{
-	int rv;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	rv = q->compare_exchange_strong(cmp, set, std::memory_order_seq_cst,
-	    std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	rv = atomic_compare_exchange_strong_explicit(q, &cmp, set,
-	    memory_order_seq_cst, memory_order_relaxed);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	rv = *p == cmp;
-	if (rv) {
-		*p = set;
-	}
-	rtems_interrupt_enable(level);
-#endif
-
-	return (rv);
-}
-
-static inline int
-atomic_cmpset_acq_32(volatile uint32_t *p, uint32_t cmp, uint32_t set)
-{
-	int rv;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	rv = q->compare_exchange_strong(cmp, set, std::memory_order_acquire,
-	    std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	rv = atomic_compare_exchange_strong_explicit(q, &cmp, set,
-	    memory_order_acquire, memory_order_relaxed);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	rv = *p == cmp;
-	if (rv) {
-		*p = set;
-	}
-	rtems_interrupt_enable(level);
-#endif
-
-	return (rv);
-}
-
-static inline int
-atomic_cmpset_rel_32(volatile uint32_t *p, uint32_t cmp, uint32_t set)
-{
-	int rv;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	rv = q->compare_exchange_strong(cmp, set, std::memory_order_release,
-	    std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	rv = atomic_compare_exchange_strong_explicit(q, &cmp, set,
-	    memory_order_release, memory_order_relaxed);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	rv = *p == cmp;
-	if (rv) {
-		*p = set;
-	}
-	rtems_interrupt_enable(level);
-#endif
-
-	return (rv);
-}
-
-static inline uint32_t
-atomic_fetchadd_32(volatile uint32_t *p, uint32_t v)
-{
-	uint32_t tmp;
+/*
+ * Load
+ */
 
 #if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	tmp = q->fetch_add(v, std::memory_order_seq_cst);
+#define _ATOMIC_LOAD(T, p, mo, barrier) \
+	std::atomic_##T *q = \
+	    reinterpret_cast<std::atomic_##T *>(const_cast<T *>(p)); \
+	tmp = q->load(std::##mo)
 #elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	tmp = atomic_fetch_add_explicit(q, v, memory_order_seq_cst);
+#define _ATOMIC_LOAD(T, p, mo, barrier) \
+	atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
+	tmp = atomic_load_explicit(q, v, mo)
 #else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	tmp = *p;
-	*p += v;
-	rtems_interrupt_enable(level);
+#define _ATOMIC_LOAD(T, p, mo, barrier) \
+	if (barrier) \
+		RTEMS_COMPILER_MEMORY_BARRIER(); \
+	tmp = *p
 #endif
 
+static inline int
+atomic_load_int(volatile int *p)
+{
+	int tmp;
+	_ATOMIC_LOAD(int, p, memory_order_relaxed, false);
 	return (tmp);
 }
 
-static inline uint32_t
-atomic_readandclear_32(volatile uint32_t *p)
+static inline int
+atomic_load_acq_int(volatile int *p)
 {
-	uint32_t tmp;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	tmp = q->exchange(0, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	tmp = atomic_exchange_explicit(q, 0, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	tmp = *p;
-	*p = 0;
-	rtems_interrupt_enable(level);
-#endif
-
+	int tmp;
+	_ATOMIC_LOAD(int, p, memory_order_acquire, true);
 	return (tmp);
 }
 
@@ -1000,20 +138,7 @@ static inline uint32_t
 atomic_load_32(volatile uint32_t *p)
 {
 	uint32_t tmp;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
-
-	tmp = q->load(std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
-
-	tmp = atomic_load_explicit(q, memory_order_relaxed);
-#else
-	tmp = *p;
-#endif
-
+	_ATOMIC_LOAD(uint32_t, p, memory_order_rlaxed, false);
 	return (tmp);
 }
 
@@ -1021,523 +146,729 @@ static inline uint32_t
 atomic_load_acq_32(volatile uint32_t *p)
 {
 	uint32_t tmp;
+	_ATOMIC_LOAD(uint32_t, p, memory_order_acquire, true);
+	return (tmp);
+}
 
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
+static inline long
+atomic_load_long(volatile long *p)
+{
+	long tmp;
+	_ATOMIC_LOAD(long, p, memory_order_relaxed, false);
+	return (tmp);
+}
 
-	tmp = q->load(std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
+static inline long
+atomic_load_acq_long(volatile long *p)
+{
+	long tmp;
+	_ATOMIC_LOAD(long, p, memory_order_acquire, true);
+	return (tmp);
+}
 
-	tmp = atomic_load_explicit(q, memory_order_acquire);
+/*
+ * Store
+ */
+
+#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
+#define _ATOMIC_STORE(T, p, v, mo, barrier) \
+	std::atomic_##T *q = \
+	    reinterpret_cast<std::atomic_##T *>(const_cast<T *>(p)); \
+	q->store(std::##mo)
+#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
+#define _ATOMIC_STORE(T, p, v, mo, barrier) \
+	atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
+	atomic_store_explicit(q, v, mo)
 #else
-	RTEMS_COMPILER_MEMORY_BARRIER();
-	tmp = *p;
+#define _ATOMIC_STORE(T, p, v, mo, barrier) \
+	*p = v; \
+	if (barrier) \
+		RTEMS_COMPILER_MEMORY_BARRIER()
 #endif
 
-	return (tmp);
+static inline void
+atomic_store_int(volatile int *p, int v)
+{
+	_ATOMIC_STORE(int, p, v, memory_order_relaxed, false);
 }
 
 static inline void
-atomic_store_rel_32(volatile uint32_t *p, uint32_t v)
+atomic_store_rel_int(volatile int *p, int v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least32_t *q =
-	    reinterpret_cast<std::atomic_uint_least32_t *>(const_cast<uint32_t *>(p));
+	_ATOMIC_STORE(int, p, v, memory_order_release, true);
+}
 
-	q->store(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least32_t *q = (atomic_uint_least32_t *)RTEMS_DEVOLATILE(uint32_t *, p);
+static inline void
+atomic_store_rel_32(volatile uint32_t *p, uint32_t v)
+{
+	_ATOMIC_STORE(uint32_t, p, v, memory_order_release, true);
+}
 
-	atomic_store_explicit(q, v, memory_order_release);
-#else
-	*p = v;
-	RTEMS_COMPILER_MEMORY_BARRIER();
-#endif
+static inline void
+atomic_store_rel_long(volatile long *p, long v)
+{
+	_ATOMIC_STORE(long, p, v, memory_order_release, true);
 }
 
-static inline uint64_t
-atomic_fetchadd_64(volatile uint64_t *p, uint64_t v)
+static inline void
+atomic_store_rel_ptr(volatile uintptr_t *p, uintptr_t v)
 {
-	uint64_t tmp;
+	/* XXX IPL32 ok with this? */
+	_ATOMIC_STORE(uintptr_t, p, v, memory_order_release, true);
+}
 
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_uint_least64_t *q =
-	    reinterpret_cast<std::atomic_uint_least64_t *>(const_cast<uint64_t *>(p));
+/*
+ * Add
+ */
 
-	tmp = q->fetch_add(v, std::memory_order_seq_cst);
+#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
+#define _ATOMIC_ADD(T, p, v, mo) \
+	std::atomic_##T *q = \
+	    reinterpret_cast<std::atomic_##T *>(const_cast<T *>(p)); \
+	q->fetch_add(v, std::##mo)
 #elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_uint_least64_t *q = (atomic_uint_least64_t *)RTEMS_DEVOLATILE(uint64_t *, p);
-
-	tmp = atomic_fetch_add_explicit(q, v, memory_order_seq_cst);
+#define _ATOMIC_ADD(T, p, v, mo) \
+	atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
+	atomic_fetch_add_explicit(q, v, mo)
 #else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	tmp = *p;
-	*p += v;
-	rtems_interrupt_enable(level);
+#define _ATOMIC_ADD(T, p, v, mo) \
+	rtems_interrupt_level level; \
+	rtems_interrupt_disable(level); \
+	*p += v; \
+	rtems_interrupt_enable(level)
 #endif
 
-	return (tmp);
+static inline void
+atomic_add_int(volatile int *p, int v)
+{
+	_ATOMIC_ADD(int, p, v, memory_order_seq_cst);
 }
 
 static inline void
-atomic_add_long(volatile long *p, long v)
+atomic_add_acq_int(volatile int *p, int v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
-
-	q->fetch_add(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+	_ATOMIC_ADD(int, p, v, memory_order_acquire);
+}
 
-	atomic_fetch_add_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
+static inline void
+atomic_add_rel_int(volatile int *p, int v)
+{
+	_ATOMIC_ADD(int, p, v, memory_order_release);
+}
 
-	rtems_interrupt_disable(level);
-	*p += v;
-	rtems_interrupt_enable(level);
-#endif
+static inline void
+atomic_add_32(volatile uint32_t *p, uint32_t v)
+{
+	_ATOMIC_ADD(uint32_t, p, v, memory_order_seq_cst);
 }
 
 static inline void
-atomic_add_acq_long(volatile long *p, long v)
+atomic_add_acq_32(volatile uint32_t *p, uint32_t v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+	_ATOMIC_ADD(uint32_t, p, v, memory_order_acquire);
+}
 
-	q->fetch_add(v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+static inline void
+atomic_add_rel_32(volatile uint32_t *p, uint32_t v)
+{
+	_ATOMIC_ADD(uint32_t, p, v, memory_order_release);
+}
 
-	atomic_fetch_add_explicit(q, v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
+static inline void
+atomic_add_long(volatile long *p, long v)
+{
+	_ATOMIC_ADD(long, p, v, memory_order_seq_cst);
+}
 
-	rtems_interrupt_disable(level);
-	*p += v;
-	rtems_interrupt_enable(level);
-#endif
+static inline void
+atomic_add_acq_long(volatile long *p, long v)
+{
+	_ATOMIC_ADD(long, p, v, memory_order_acquire);
 }
 
 static inline void
 atomic_add_rel_long(volatile long *p, long v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+	_ATOMIC_ADD(long, p, v, memory_order_release);
+}
 
-	q->fetch_add(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+/*
+ * Subtract
+ */
 
-	atomic_fetch_add_explicit(q, v, memory_order_release);
+#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
+#define _ATOMIC_SUB(T, p, v, mo) \
+	std::atomic_##T *q = \
+	    reinterpret_cast<std::atomic_##T *>(const_cast<T *>(p)); \
+	q->fetch_sub(v, std::##mo)
+#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
+#define _ATOMIC_SUB(T, p, v, mo) \
+	atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
+	atomic_fetch_sub_explicit(q, v, mo)
 #else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p += v;
-	rtems_interrupt_enable(level);
+#define _ATOMIC_SUB(T, p, v, mo) \
+	rtems_interrupt_level level; \
+	rtems_interrupt_disable(level); \
+	*p -= v; \
+	rtems_interrupt_enable(level)
 #endif
+
+static inline void
+atomic_subtract_int(volatile int *p, int v)
+{
+	_ATOMIC_SUB(int, p, v, memory_order_seq_cst);
 }
 
 static inline void
-atomic_subtract_long(volatile long *p, long v)
+atomic_subtract_acq_int(volatile int *p, int v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+	_ATOMIC_SUB(int, p, v, memory_order_acquire);
+}
 
-	q->fetch_sub(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+static inline void
+atomic_subtract_rel_int(volatile int *p, int v)
+{
+	_ATOMIC_SUB(int, p, v, memory_order_release);
+}
 
-	atomic_fetch_sub_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
+static inline void
+atomic_subtract_32(volatile uint32_t *p, uint32_t v)
+{
+	_ATOMIC_SUB(uint32_t, p, v, memory_order_seq_cst);
+}
 
-	rtems_interrupt_disable(level);
-	*p -= v;
-	rtems_interrupt_enable(level);
-#endif
+static inline void
+atomic_subtract_acq_32(volatile uint32_t *p, uint32_t v)
+{
+	_ATOMIC_SUB(uint32_t, p, v, memory_order_acquire);
+}
+
+static inline void
+atomic_subtract_rel_32(volatile uint32_t *p, uint32_t v)
+{
+	_ATOMIC_SUB(uint32_t, p, v, memory_order_release);
+}
+
+static inline void
+atomic_subtract_long(volatile long *p, long v)
+{
+	_ATOMIC_SUB(long, p, v, memory_order_seq_cst);
 }
 
 static inline void
 atomic_subtract_acq_long(volatile long *p, long v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+	_ATOMIC_SUB(long, p, v, memory_order_acquire);
+}
 
-	q->fetch_sub(v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+static inline void
+atomic_subtract_rel_long(volatile long *p, long v)
+{
+	_ATOMIC_SUB(long, p, v, memory_order_release);
+}
 
-	atomic_fetch_sub_explicit(q, v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
+/*
+ * Set
+ */
 
-	rtems_interrupt_disable(level);
-	*p -= v;
-	rtems_interrupt_enable(level);
+#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
+#define _ATOMIC_SET(T, p, v, mo) \
+	std::atomic_##T *q = \
+	    reinterpret_cast<std::atomic_##T *>(const_cast<T *>(p)); \
+	q->fetch_or(v, std::##mo)
+#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
+#define _ATOMIC_SET(T, p, v, mo) \
+	atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
+	atomic_fetch_or_explicit(q, v, mo)
+#else
+#define _ATOMIC_SET(T, p, v, mo) \
+	rtems_interrupt_level level; \
+	rtems_interrupt_disable(level); \
+	*p |= v; \
+	rtems_interrupt_enable(level)
 #endif
+
+static inline void
+atomic_set_int(volatile int *p, int v)
+{
+	_ATOMIC_SET(int, p, v, memory_order_seq_cst);
 }
 
 static inline void
-atomic_subtract_rel_long(volatile long *p, long v)
+atomic_set_acq_int(volatile int *p, int v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+	_ATOMIC_SET(int, p, v, memory_order_acquire);
+}
 
-	q->fetch_sub(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+static inline void
+atomic_set_rel_int(volatile int *p, int v)
+{
+	_ATOMIC_SET(int, p, v, memory_order_release);
+}
 
-	atomic_fetch_sub_explicit(q, v, memory_order_release);
-#else
-	rtems_interrupt_level level;
+static inline void
+atomic_set_32(volatile uint32_t *p, uint32_t v)
+{
+	_ATOMIC_SET(uint32_t, p, v, memory_order_seq_cst);
+}
 
-	rtems_interrupt_disable(level);
-	*p -= v;
-	rtems_interrupt_enable(level);
-#endif
+static inline void
+atomic_set_acq_32(volatile uint32_t *p, uint32_t v)
+{
+	_ATOMIC_SET(uint32_t, p, v, memory_order_acquire);
+}
+
+static inline void
+atomic_set_rel_32(volatile uint32_t *p, uint32_t v)
+{
+	_ATOMIC_SET(uint32_t, p, v, memory_order_release);
 }
 
 static inline void
 atomic_set_long(volatile long *p, long v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+	_ATOMIC_SET(long, p, v, memory_order_seq_cst);
+}
 
-	q->fetch_or(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+static inline void
+atomic_set_acq_long(volatile long *p, long v)
+{
+	_ATOMIC_SET(long, p, v, memory_order_acquire);
+}
 
-	atomic_fetch_or_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
+static inline void
+atomic_set_rel_long(volatile long *p, long v)
+{
+	_ATOMIC_SET(long, p, v, memory_order_release);
+}
 
-	rtems_interrupt_disable(level);
-	*p |= v;
-	rtems_interrupt_enable(level);
+/*
+ * Clear
+ */
+
+#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
+#define _ATOMIC_CLEAR(T, p, v, mo) \
+	std::atomic_##T *q = \
+	    reinterpret_cast<std::atomic_##T *>(const_cast<T *>(p)); \
+	q->fetch_and(~v, std::##mo)
+#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
+#define _ATOMIC_CLEAR(T, p, v, mo) \
+	atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
+	atomic_fetch_and_explicit(q, ~v, mo)
+#else
+#define _ATOMIC_CLEAR(T, p, v, mo) \
+	rtems_interrupt_level level; \
+	rtems_interrupt_disable(level); \
+	*p &= ~v; \
+	rtems_interrupt_enable(level)
 #endif
+
+static inline void
+atomic_clear_int(volatile int *p, int v)
+{
+	_ATOMIC_CLEAR(int, p, v, memory_order_seq_cst);
+}
+
+static inline void
+atomic_clear_acq_int(volatile int *p, int v)
+{
+	_ATOMIC_CLEAR(int, p, v, memory_order_acquire);
+}
+
+static inline void
+atomic_clear_rel_int(volatile int *p, int v)
+{
+	_ATOMIC_CLEAR(int, p, v, memory_order_release);
+}
+
+static inline void
+atomic_clear_32(volatile uint32_t *p, uint32_t v)
+{
+	_ATOMIC_CLEAR(uint32_t, p, v, memory_order_seq_cst);
 }
 
 static inline void
-atomic_set_acq_long(volatile long *p, long v)
+atomic_clear_acq_32(volatile uint32_t *p, uint32_t v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
-
-	q->fetch_or(v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
-
-	atomic_fetch_or_explicit(q, v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p |= v;
-	rtems_interrupt_enable(level);
-#endif
+	_ATOMIC_CLEAR(uint32_t, p, v, memory_order_acquire);
 }
 
 static inline void
-atomic_set_rel_long(volatile long *p, long v)
+atomic_clear_rel_32(volatile uint32_t *p, uint32_t v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
-
-	q->fetch_or(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
-
-	atomic_fetch_or_explicit(q, v, memory_order_release);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p |= v;
-	rtems_interrupt_enable(level);
-#endif
+	_ATOMIC_CLEAR(uint32_t, p, v, memory_order_release);
 }
 
 static inline void
 atomic_clear_long(volatile long *p, long v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
-
-	q->fetch_and(~v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
-
-	atomic_fetch_and_explicit(q, ~v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p &= ~v;
-	rtems_interrupt_enable(level);
-#endif
+	_ATOMIC_CLEAR(long, p, v, memory_order_release);
 }
 
 static inline void
 atomic_clear_acq_long(volatile long *p, long v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
-
-	q->fetch_and(~v, std::memory_order_acquire);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
-
-	atomic_fetch_and_explicit(q, ~v, memory_order_acquire);
-#else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p &= ~v;
-	rtems_interrupt_enable(level);
-#endif
+	_ATOMIC_CLEAR(long, p, v, memory_order_acquire);
 }
 
 static inline void
 atomic_clear_rel_long(volatile long *p, long v)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+	_ATOMIC_CLEAR(long, p, v, memory_order_release);
+}
 
-	q->fetch_and(~v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+/*
+ * Compare and set
+ */
 
-	atomic_fetch_and_explicit(q, ~v, memory_order_release);
+#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
+#define _ATOMIC_CMPSET(T, p, cmp, set, mo) \
+	std::atomic_##T *q = \
+	    reinterpret_cast<std::atomic_##T *>(const_cast<T *>(p)); \
+	rv = q->compare_exchange_strong(cmp, set, \
+            std::##mo, std::memory_order_relaxed)
+#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
+#define _ATOMIC_CMPSET(T, p, cmp, set, mo) \
+	atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
+	atomic_compare_exchange_strong_explicit(q, &cmp, set, \
+            mo, memory_order_relaxed)
 #else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	*p &= ~v;
+#define _ATOMIC_CMPSET(T, p, cmp, set, mo) \
+	rtems_interrupt_level level; \
+	rtems_interrupt_disable(level); \
+	rv = *p == cmp; \
+	if (rv) { \
+		*p = set; \
+	} \
 	rtems_interrupt_enable(level);
 #endif
+
+static inline int
+atomic_cmpset_int(volatile int *p, int cmp, int set)
+{
+	int rv;
+	_ATOMIC_CMPSET(int, p, cmp, set, memory_order_seq_cst);
+	return (rv);
 }
 
 static inline int
-atomic_cmpset_long(volatile long *p, long cmp, long set)
+atomic_cmpset_acq_int(volatile int *p, int cmp, int set)
 {
 	int rv;
+	_ATOMIC_CMPSET(int, p, cmp, set, memory_order_acquire);
+	return (rv);
+}
 
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+static inline int
+atomic_cmpset_rel_int(volatile int *p, int cmp, int set)
+{
+	int rv;
+	_ATOMIC_CMPSET(int, p, cmp, set, memory_order_release);
+	return (rv);
+}
 
-	rv = q->compare_exchange_strong(cmp, set, std::memory_order_seq_cst,
-	    std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+static inline int
+atomic_cmpset_32(volatile uint32_t *p, uint32_t cmp, uint32_t set)
+{
+	int rv;
+	_ATOMIC_CMPSET(uint_least32_t, p, cmp, set, memory_order_seq_cst);
+	return (rv);
+}
 
-	rv = atomic_compare_exchange_strong_explicit(q, &cmp, set,
-	    memory_order_seq_cst, memory_order_relaxed);
-#else
-	rtems_interrupt_level level;
+static inline int
+atomic_cmpset_acq_32(volatile uint32_t *p, uint32_t cmp, uint32_t set)
+{
+	int rv;
+	_ATOMIC_CMPSET(uint_least32_t, p, cmp, set, memory_order_acquire);
+	return (rv);
+}
 
-	rtems_interrupt_disable(level);
-	rv = *p == cmp;
-	if (rv) {
-		*p = set;
-	}
-	rtems_interrupt_enable(level);
-#endif
+static inline int
+atomic_cmpset_rel_32(volatile uint32_t *p, uint32_t cmp, uint32_t set)
+{
+	int rv;
+	_ATOMIC_CMPSET(uint_least32_t, p, cmp, set, memory_order_release);
+	return (rv);
+}
 
+static inline int
+atomic_cmpset_64(volatile uint64_t *p, uint64_t cmp, uint64_t set)
+{
+	int rv;
+	_ATOMIC_CMPSET(uint_least64_t, p, cmp, set, memory_order_seq_cst);
 	return (rv);
 }
 
 static inline int
-atomic_cmpset_acq_long(volatile long *p, long cmp, long set)
+atomic_cmpset_acq_64(volatile uint64_t *p, uint64_t cmp, uint64_t set)
 {
 	int rv;
+	_ATOMIC_CMPSET(uint_least64_t, p, cmp, set, memory_order_acquire);
+	return (rv);
+}
 
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+static inline int
+atomic_cmpset_rel_64(volatile uint64_t *p, uint64_t cmp, uint64_t set)
+{
+	int rv;
+	_ATOMIC_CMPSET(uint_least64_t, p, cmp, set, memory_order_release);
+	return (rv);
+}
 
-	rv = q->compare_exchange_strong(cmp, set, std::memory_order_acquire,
-	    std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+static inline int
+atomic_cmpset_long(volatile long *p, long cmp, long set)
+{
+	int rv;
+	_ATOMIC_CMPSET(long, p, cmp, set, memory_order_seq_cst);
+	return (rv);
+}
 
-	rv = atomic_compare_exchange_strong_explicit(q, &cmp, set,
-	    memory_order_acquire, memory_order_relaxed);
-#else
-	rtems_interrupt_level level;
+static inline int
+atomic_cmpset_acq_long(volatile long *p, long cmp, long set)
+{
+	int rv;
+	_ATOMIC_CMPSET(long, p, cmp, set, memory_order_acquire);
+	return (rv);
+}
 
-	rtems_interrupt_disable(level);
-	rv = *p == cmp;
-	if (rv) {
-		*p = set;
-	}
-	rtems_interrupt_enable(level);
-#endif
+static inline int
+atomic_cmpset_rel_long(volatile long *p, long cmp, long set)
+{
+	int rv;
+	_ATOMIC_CMPSET(long, p, cmp, set, memory_order_release);
+	return (rv);
+}
 
+static inline int
+atomic_cmpset_ptr(volatile uintptr_t *p, uintptr_t cmp, uintptr_t set)
+{
+	int rv;
+	_ATOMIC_CMPSET(uintptr_t, p, cmp, set, memory_order_seq_cst);
 	return (rv);
 }
 
 static inline int
-atomic_cmpset_rel_long(volatile long *p, long cmp, long set)
+atomic_cmpset_acq_ptr(volatile uintptr_t *p, uintptr_t cmp, uintptr_t set)
 {
 	int rv;
+	_ATOMIC_CMPSET(uintptr_t, p, cmp, set, memory_order_aquire);
+	return (rv);
+}
 
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+static inline int
+atomic_cmpset_rel_ptr(volatile uintptr_t *p, uintptr_t cmp, uintptr_t set)
+{
+	int rv;
+	_ATOMIC_CMPSET(uintptr_t, p, cmp, set, memory_order_release);
+	return (rv);
+}
 
-	rv = q->compare_exchange_strong(cmp, set, std::memory_order_release,
-	    std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+/*
+ * Fetch compare and set
+ */
 
-	rv = atomic_compare_exchange_strong_explicit(q, &cmp, set,
-	    memory_order_release, memory_order_relaxed);
+#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
+#define _ATOMIC_FCMPSET(T, p, cmp, set, mo) \
+	std::atomic_##T *q = \
+	    reinterpret_cast<std::atomic_##T *>(const_cast<T *>(p)); \
+	rv = q->compare_exchange_strong(*cmp, set, \
+            std::##mo, std::memory_order_relaxed)
+#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
+#define _ATOMIC_FCMPSET(T, cmp, set, mo) \
+	atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
+	atomic_compare_exchange_strong_explicit(q, cmp, set, \
+           mo, memory_order_relaxed)
 #else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	rv = *p == cmp;
-	if (rv) {
-		*p = set;
-	}
+#define _ATOMIC_FCMPSET(T, p, cmp, set, mo) \
+	rtems_interrupt_level level; \
+        T actual; \
+	rtems_interrupt_disable(level); \
+	actual = *p; \
+	rv = actual == *cmp; \
+	*cmp = actual; \
+	if (rv) { \
+		*p = set; \
+	} \
 	rtems_interrupt_enable(level);
 #endif
 
+static inline int
+atomic_fcmpset_int(volatile int *p, int *cmp, int set)
+{
+	int rv;
+	_ATOMIC_FCMPSET(int, p, cmp, set, memory_order_seq_cst);
 	return (rv);
 }
 
-static inline long
-atomic_fetchadd_long(volatile long *p, long v)
+static inline int
+atomic_fcmpset_acq_int(volatile int *p, int *cmp, int set)
 {
-	long tmp;
+	int rv;
+	_ATOMIC_FCMPSET(int, p, cmp, set, memory_order_acquire);
+	return (rv);
+}
 
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+static inline int
+atomic_fcmpset_rel_int(volatile int *p, int *cmp, int set)
+{
+	int rv;
+	_ATOMIC_FCMPSET(int, p, cmp, set, memory_order_release);
+	return (rv);
+}
 
-	tmp = q->fetch_add(v, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+static inline int
+atomic_fcmpset_64(volatile uint64_t *p, uint64_t *cmp, uint64_t set)
+{
+	int rv;
+	_ATOMIC_FCMPSET(uint_least64_t, p, cmp, set, memory_order_seq_cst);
+	return (rv);
+}
 
-	tmp = atomic_fetch_add_explicit(q, v, memory_order_seq_cst);
-#else
-	rtems_interrupt_level level;
+static inline int
+atomic_fcmpset_acq_64(volatile uint64_t *p, uint64_t *cmp, uint64_t set)
+{
+	int rv;
+	_ATOMIC_FCMPSET(uint_least64_t, p, cmp, set, memory_order_acquite);
+	return (rv);
+}
 
-	rtems_interrupt_disable(level);
-	tmp = *p;
-	*p += v;
-	rtems_interrupt_enable(level);
-#endif
+static inline int
+atomic_fcmpset_rel_64(volatile uint64_t *p, uint64_t *cmp, uint64_t set)
+{
+	int rv;
+	_ATOMIC_FCMPSET(uint_least64_t, p, cmp, set, memory_order_release);
+	return (rv);
+}
 
-	return (tmp);
+/*  XXX Is IPL32 ok with the .*_ptr versions? */
+static inline int
+atomic_fcmpset_ptr(volatile uintptr_t *p, uintptr_t *cmp, uintptr_t set)
+{
+	int rv;
+	_ATOMIC_FCMPSET(uintptr_t, p, cmp, set, memory_order_seq_cst);
+	return (rv);
 }
 
-static inline long
-atomic_readandclear_long(volatile long *p)
+static inline int
+atomic_fcmpset_acq_ptr(volatile uintptr_t *p, uintptr_t *cmp, uintptr_t set)
 {
-	long tmp;
+	int rv;
+	_ATOMIC_FCMPSET(uintptr_t, p, cmp, set, memory_order_acquire);
+	return (rv);
+}
 
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+static inline int
+atomic_fcmpset_rel_ptr(volatile uintptr_t *p, uintptr_t *cmp, uintptr_t set)
+{
+	int rv;
+	_ATOMIC_FCMPSET(uintptr_t, p, cmp, set, memory_order_release);
+	return (rv);
+}
 
-	tmp = q->exchange(0, std::memory_order_seq_cst);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+/*
+ * Fetch add
+ */
 
-	tmp = atomic_exchange_explicit(q, 0, memory_order_seq_cst);
+#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
+#define _ATOMIC_FETCHADD(T, p, v, mo) \
+	std::atomic_##T *q = \
+	    reinterpret_cast<std::atomic_##T *>(const_cast<T *>(p)); \
+	tmp = q->fetch_add(v, std::##mo)
+#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
+#define _ATOMIC_FETCHADD(T, p, v, mo) \
+	atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
+	tmp = atomic_fetch_add_explicit(q, v, mo)
 #else
-	rtems_interrupt_level level;
-
-	rtems_interrupt_disable(level);
-	tmp = *p;
-	*p = 0;
+#define _ATOMIC_FETCHADD(T, p, v, mo) \
+	rtems_interrupt_level level; \
+	rtems_interrupt_disable(level); \
+	tmp = *p; \
+	*p += v; \
 	rtems_interrupt_enable(level);
 #endif
 
+static inline int
+atomic_fetchadd_int(volatile int *p, int v)
+{
+	int tmp;
+	_ATOMIC_FETCHADD(int, p, v, memory_order_order_seq_cst);
 	return (tmp);
 }
 
-static inline long
-atomic_load_long(volatile long *p)
+static inline uint32_t
+atomic_fetchadd_32(volatile uint32_t *p, uint32_t v)
 {
-	long tmp;
-
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
-
-	tmp = q->load(std::memory_order_relaxed);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
-
-	tmp = atomic_load_explicit(q, memory_order_relaxed);
-#else
-	tmp = *p;
-#endif
+	uint32_t tmp;
+	_ATOMIC_FETCHADD(uint32_t, p, v, memory_order_order_seq_cst);
+	return (tmp);
+}
 
+static inline uint64_t
+atomic_fetchadd_64(volatile uint64_t *p, uint64_t v)
+{
+	uint64_t tmp;
+	_ATOMIC_FETCHADD(uint64_t, p, v, memory_order_order_seq_cst);
 	return (tmp);
 }
 
 static inline long
-atomic_load_acq_long(volatile long *p)
+atomic_fetchadd_long(volatile long *p, long v)
 {
 	long tmp;
+	_ATOMIC_FETCHADD(long, p, v, memory_order_order_seq_cst);
+	return (tmp);
+}
 
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
+/*
+ * Read and clear
+ */
 
-	tmp = q->load(std::memory_order_acquire);
+#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
+#define _ATOMIC_READANDCLEAR(T, p, mo) \
+	std::atomic_##T *q = \
+	    reinterpret_cast<std::atomic_##T *>(const_cast<T *>(p)); \
+	tmp = q->exchange(0, std::##mo)
 #elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
-
-	tmp = atomic_load_explicit(q, memory_order_acquire);
+#define _ATOMIC_READANDCLEAR(T, p, mo) \
+	atomic_##T *q = (atomic_##T *)RTEMS_DEVOLATILE(T *, p); \
+	tmp = atomic_exchange_explicit(q, 0, mo)
 #else
-	RTEMS_COMPILER_MEMORY_BARRIER();
-	tmp = *p;
+#define _ATOMIC_READANDCLEAR(T, p, mo) \
+	rtems_interrupt_level level; \
+	rtems_interrupt_disable(level); \
+	tmp = *p; \
+	*p = 0; \
+	rtems_interrupt_enable(level);
 #endif
 
+static inline int
+atomic_readandclear_int(volatile int *p)
+{
+	int tmp;
+	_ATOMIC_READANDCLEAR(int, p, memory_order_order_seq_cst);
 	return (tmp);
 }
 
-static inline void
-atomic_store_rel_long(volatile long *p, long v)
+static inline uint32_t
+atomic_readandclear_32(volatile uint32_t *p)
 {
-#if defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_ATOMIC)
-	std::atomic_long *q =
-	    reinterpret_cast<std::atomic_long *>(const_cast<long *>(p));
-
-	q->store(v, std::memory_order_release);
-#elif defined(_RTEMS_BSD_MACHINE_ATOMIC_USE_STDATOMIC)
-	atomic_long *q = (atomic_long *)RTEMS_DEVOLATILE(long *, p);
+	uint32_t tmp;
+	_ATOMIC_READANDCLEAR(uint_least32_t, p, memory_order_order_seq_cst);
+	return (tmp);
+}
 
-	atomic_store_explicit(q, v, memory_order_release);
-#else
-	*p = v;
-	RTEMS_COMPILER_MEMORY_BARRIER();
-#endif
+static inline long
+atomic_readandclear_long(volatile long *p)
+{
+	long tmp;
+	_ATOMIC_READANDCLEAR(long, p, memory_order_order_seq_cst);
+	return (tmp);
 }
 
+/*
+ * Thread fence
+ */
+
 static inline void
 atomic_thread_fence_acq(void)
 {
diff --git a/rtemsbsd/include/machine/rtems-bsd-config.h b/rtemsbsd/include/machine/rtems-bsd-config.h
index 491d9a72..a820e51d 100644
--- a/rtemsbsd/include/machine/rtems-bsd-config.h
+++ b/rtemsbsd/include/machine/rtems-bsd-config.h
@@ -85,6 +85,12 @@ extern "C" {
   #define RTEMS_BSD_CFGDECL_DOMAIN_PAGE_MBUFS_SIZE RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT
 #endif
 
+#if defined(RTEMS_BSD_CONFIG_DOMAIN_BIO_SIZE)
+  #define RTEMS_BSD_CFGDECL_DOMAIN_BIO_SIZE RTEMS_BSD_CONFIG_DOMAIN_BIO_SIZE
+#else
+  #define RTEMS_BSD_CFGDECL_DOMAIN_BIO_SIZE RTEMS_BSD_ALLOCATOR_DOMAIN_BIO_DEFAULT
+#endif
+
 /*
  * BSD Kernel modules.
  */
@@ -222,6 +228,12 @@ extern "C" {
   uintptr_t rtems_bsd_allocator_domain_page_mbuf_size = \
     RTEMS_BSD_CFGDECL_DOMAIN_PAGE_MBUFS_SIZE;
 
+  /*
+   * Configure the block IO buffer memory size.
+   */
+  uintptr_t rtems_bsd_allocator_domain_bio_size = \
+    RTEMS_BSD_CFGDECL_DOMAIN_BIO_SIZE;
+
   /*
    * If a BSP configuration is requested include the Nexus bus BSP
    * configuration.
diff --git a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
index 293c6115..9d3472d6 100644
--- a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
+++ b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
@@ -104,6 +104,7 @@
 #define	M_80211_SCAN _bsd_M_80211_SCAN
 #define	M_80211_VAP _bsd_M_80211_VAP
 #define	M_ACCF _bsd_M_ACCF
+#define	M_ACL _bsd_M_ACL
 #define	M_ALIAS _bsd_M_ALIAS
 #define	M_BPF _bsd_M_BPF
 #define	M_BPFJIT _bsd_M_BPFJIT
@@ -111,6 +112,8 @@
 #define	M_CRYPTO_DATA _bsd_M_CRYPTO_DATA
 #define	M_DEVBUF _bsd_M_DEVBUF
 #define	M_EVDEV _bsd_M_EVDEV
+#define	M_FADVISE _bsd_M_FADVISE
+#define	M_FILECAPS _bsd_M_FILECAPS
 #define	M_FIXEDREGULATOR _bsd_M_FIXEDREGULATOR
 #define	M_GIF _bsd_M_GIF
 #define	M_GRE _bsd_M_GRE
@@ -130,6 +133,7 @@
 #define	M_IPSEC_SPDCACHE _bsd_M_IPSEC_SPDCACHE
 #define	M_IPSEC_SR _bsd_M_IPSEC_SR
 #define	M_LLTABLE _bsd_M_LLTABLE
+#define	M_MOUNT _bsd_M_MOUNT
 #define	M_NVME _bsd_M_NVME
 #define	M_OFWPROP _bsd_M_OFWPROP
 #define	M_PCB _bsd_M_PCB
@@ -138,13 +142,18 @@
 #define	M_RTABLE _bsd_M_RTABLE
 #define	M_RTWN_PRIV _bsd_M_RTWN_PRIV
 #define	M_SONAME _bsd_M_SONAME
+#define	M_STATFS _bsd_M_STATFS
 #define	M_TAP _bsd_M_TAP
 #define	M_TCPFUNCTIONS _bsd_M_TCPFUNCTIONS
 #define	M_TCPLOG _bsd_M_TCPLOG
 #define	M_TEMP _bsd_M_TEMP
 #define	M_USB _bsd_M_USB
 #define	M_USBDEV _bsd_M_USBDEV
+#define	M_VNODE _bsd_M_VNODE
+#define	M_VNODE_MARKER _bsd_M_VNODE_MARKER
 #define	M_XDATA _bsd_M_XDATA
+#define	NDFREE _bsd_NDFREE
+#define	NDINIT_ALL _bsd_NDINIT_ALL
 #define	OF_call_method _bsd_OF_call_method
 #define	OF_canon _bsd_OF_canon
 #define	OF_child _bsd_OF_child
@@ -280,12 +289,22 @@
 #define	Skein_512_Output _bsd_Skein_512_Output
 #define	Skein_512_Process_Block _bsd_Skein_512_Process_Block
 #define	Skein_512_Update _bsd_Skein_512_Update
+#define	Skein_Get64_LSB_First _bsd_Skein_Get64_LSB_First
+#define	Skein_Put64_LSB_First _bsd_Skein_Put64_LSB_First
 #define	TB_DRAIN_WAITER _bsd_TB_DRAIN_WAITER
 #define	X_ip6_mforward _bsd_X_ip6_mforward
 #define	X_ip6_mrouter_done _bsd_X_ip6_mrouter_done
 #define	X_ip6_mrouter_get _bsd_X_ip6_mrouter_get
 #define	X_ip6_mrouter_set _bsd_X_ip6_mrouter_set
 #define	X_mrt6_ioctl _bsd_X_mrt6_ioctl
+#define	__lockmgr_args _bsd___lockmgr_args
+#define	__mnt_vnode_first_active _bsd___mnt_vnode_first_active
+#define	__mnt_vnode_first_all _bsd___mnt_vnode_first_all
+#define	__mnt_vnode_markerfree_active _bsd___mnt_vnode_markerfree_active
+#define	__mnt_vnode_markerfree_all _bsd___mnt_vnode_markerfree_all
+#define	__mnt_vnode_next_active _bsd___mnt_vnode_next_active
+#define	__mnt_vnode_next_all _bsd___mnt_vnode_next_all
+#define	__vfs_statfs _bsd___vfs_statfs
 #define	_callout_init_lock _bsd__callout_init_lock
 #define	_callout_stop_safe _bsd__callout_stop_safe
 #define	_ck_epoch_addref _bsd__ck_epoch_addref
@@ -295,6 +314,10 @@
 #define	_cv_wait _bsd__cv_wait
 #define	_cv_wait_sig _bsd__cv_wait_sig
 #define	_cv_wait_unlock _bsd__cv_wait_unlock
+#define	_eventhandler_list_vfs_mounted _bsd__eventhandler_list_vfs_mounted
+#define	_eventhandler_list_vfs_unmounted _bsd__eventhandler_list_vfs_unmounted
+#define	_fdrop _bsd__fdrop
+#define	_finstall _bsd__finstall
 #define	_kevent _bsd__kevent
 #define	_libmd_SHA224_Final _bsd__libmd_SHA224_Final
 #define	_libmd_SHA224_Init _bsd__libmd_SHA224_Init
@@ -314,8 +337,12 @@
 #define	_libmd_SKEIN512_Final _bsd__libmd_SKEIN512_Final
 #define	_libmd_SKEIN512_Init _bsd__libmd_SKEIN512_Init
 #define	_libmd_SKEIN512_Update _bsd__libmd_SKEIN512_Update
+#define	_lockmgr_assert _bsd__lockmgr_assert
+#define	_lockmgr_disown _bsd__lockmgr_disown
+#define	_mtx_assert _bsd__mtx_assert
 #define	_mtx_lock_flags _bsd__mtx_lock_flags
 #define	_mtx_unlock_flags _bsd__mtx_unlock_flags
+#define	_rw_assert _bsd__rw_assert
 #define	_rw_downgrade _bsd__rw_downgrade
 #define	_rw_rlock _bsd__rw_rlock
 #define	_rw_runlock _bsd__rw_runlock
@@ -345,9 +372,13 @@
 #define	_stop_set_scanner_set _bsd__stop_set_scanner_set
 #define	_stop_set_sysctl_set _bsd__stop_set_sysctl_set
 #define	_stop_set_sysinit_set _bsd__stop_set_sysinit_set
+#define	_sx_assert _bsd__sx_assert
 #define	_sx_slock_int _bsd__sx_slock_int
 #define	_sx_sunlock_int _bsd__sx_sunlock_int
 #define	_timeout_task_init _bsd__timeout_task_init
+#define	_vdrop _bsd__vdrop
+#define	_vhold _bsd__vhold
+#define	_vn_lock _bsd__vn_lock
 #define	accept_filt_add _bsd_accept_filt_add
 #define	accept_filt_del _bsd_accept_filt_del
 #define	accept_filt_generic_mod_event _bsd_accept_filt_generic_mod_event
@@ -355,6 +386,10 @@
 #define	accept_filt_getopt _bsd_accept_filt_getopt
 #define	accept_filt_setopt _bsd_accept_filt_setopt
 #define	accept_mtx _bsd_accept_mtx
+#define	acl_alloc _bsd_acl_alloc
+#define	acl_copy_acl_into_oldacl _bsd_acl_copy_acl_into_oldacl
+#define	acl_copy_oldacl_into_acl _bsd_acl_copy_oldacl_into_acl
+#define	acl_free _bsd_acl_free
 #define	addrsel_policy_init _bsd_addrsel_policy_init
 #define	ah_cleartos _bsd_ah_cleartos
 #define	ah_enable _bsd_ah_enable
@@ -362,11 +397,23 @@
 #define	ah_init0 _bsd_ah_init0
 #define	ah_zeroize _bsd_ah_zeroize
 #define	ahstat _bsd_ahstat
+#define	aio_aqueue _bsd_aio_aqueue
+#define	aio_cancel _bsd_aio_cancel
+#define	aio_cancel_cleared _bsd_aio_cancel_cleared
+#define	aio_clear_cancel_function _bsd_aio_clear_cancel_function
+#define	aio_complete _bsd_aio_complete
+#define	aio_init_aioinfo _bsd_aio_init_aioinfo
+#define	aio_schedule _bsd_aio_schedule
+#define	aio_set_cancel_function _bsd_aio_set_cancel_function
 #define	aio_swake _bsd_aio_swake
+#define	aio_switch_vmspace _bsd_aio_switch_vmspace
 #define	alloc_unr _bsd_alloc_unr
 #define	alloc_unr64 _bsd_alloc_unr64
 #define	alloc_unr_specific _bsd_alloc_unr_specific
 #define	alloc_unrl _bsd_alloc_unrl
+#define	allocbuf _bsd_allocbuf
+#define	allproc_lock _bsd_allproc_lock
+#define	altbufferflushes _bsd_altbufferflushes
 #define	altq_add _bsd_altq_add
 #define	altq_add_queue _bsd_altq_add_queue
 #define	altq_attach _bsd_altq_attach
@@ -415,7 +462,11 @@
 #define	auth_hash_sha2_256 _bsd_auth_hash_sha2_256
 #define	auth_hash_sha2_384 _bsd_auth_hash_sha2_384
 #define	auth_hash_sha2_512 _bsd_auth_hash_sha2_512
+#define	babarrierwrite _bsd_babarrierwrite
+#define	badfileops _bsd_badfileops
 #define	badport_bandlim _bsd_badport_bandlim
+#define	bawrite _bsd_bawrite
+#define	bbarrierwrite _bsd_bbarrierwrite
 #define	bcd2bin_data _bsd_bcd2bin_data
 #define	bce_COM_b06FwBss _bsd_bce_COM_b06FwBss
 #define	bce_COM_b06FwBssAddr _bsd_bce_COM_b06FwBssAddr
@@ -643,9 +694,24 @@
 #define	bce_xi90_rv2p_proc2 _bsd_bce_xi90_rv2p_proc2
 #define	bce_xi_rv2p_proc1 _bsd_bce_xi_rv2p_proc1
 #define	bce_xi_rv2p_proc2 _bsd_bce_xi_rv2p_proc2
+#define	bd_speedup _bsd_bd_speedup
+#define	bdata2bio _bsd_bdata2bio
+#define	bdhidirty _bsd_bdhidirty
+#define	bdirty _bsd_bdirty
+#define	bdlodirty _bsd_bdlodirty
+#define	bdomain _bsd_bdomain
+#define	bdone _bsd_bdone
+#define	bdwrite _bsd_bdwrite
+#define	bdwriteskip _bsd_bdwriteskip
 #define	be_uuid_dec _bsd_be_uuid_dec
 #define	be_uuid_enc _bsd_be_uuid_enc
+#define	bgetvp _bsd_bgetvp
 #define	bin2bcd_data _bsd_bin2bcd_data
+#define	bio_transient_maxcnt _bsd_bio_transient_maxcnt
+#define	biodone _bsd_biodone
+#define	biofinish _bsd_biofinish
+#define	bioops _bsd_bioops
+#define	biowait _bsd_biowait
 #define	blake2b_final_ref _bsd_blake2b_final_ref
 #define	blake2b_init_key_ref _bsd_blake2b_init_key_ref
 #define	blake2b_init_param_ref _bsd_blake2b_init_param_ref
@@ -666,6 +732,7 @@
 #define	blist_free _bsd_blist_free
 #define	blist_resize _bsd_blist_resize
 #define	blist_stats _bsd_blist_stats
+#define	bnoreuselist _bsd_bnoreuselist
 #define	bpf_buffer_append_bytes _bsd_bpf_buffer_append_bytes
 #define	bpf_buffer_append_mbuf _bsd_bpf_buffer_append_mbuf
 #define	bpf_buffer_free _bsd_bpf_buffer_free
@@ -682,6 +749,13 @@
 #define	bpfattach _bsd_bpfattach
 #define	bpfattach2 _bsd_bpfattach2
 #define	bpfdetach _bsd_bpfdetach
+#define	bqempty _bsd_bqempty
+#define	bqrelse _bsd_bqrelse
+#define	breadn_flags _bsd_breadn_flags
+#define	brelse _bsd_brelse
+#define	brelvp _bsd_brelvp
+#define	bremfree _bsd_bremfree
+#define	bremfreef _bsd_bremfreef
 #define	bridge_control_table _bsd_bridge_control_table
 #define	bridge_control_table_size _bsd_bridge_control_table_size
 #define	bridge_dn_p _bsd_bridge_dn_p
@@ -713,8 +787,29 @@
 #define	bt_tickthreshold _bsd_bt_tickthreshold
 #define	bt_timethreshold _bsd_bt_timethreshold
 #define	bucket_zones _bsd_bucket_zones
+#define	buf_dirty_count_severe _bsd_buf_dirty_count_severe
+#define	buf_ops_bio _bsd_buf_ops_bio
 #define	buf_ring_alloc _bsd_buf_ring_alloc
 #define	buf_ring_free _bsd_buf_ring_free
+#define	buf_wmesg _bsd_buf_wmesg
+#define	buf_zone _bsd_buf_zone
+#define	bufbdflush _bsd_bufbdflush
+#define	bufdaemonproc _bsd_bufdaemonproc
+#define	bufdone _bsd_bufdone
+#define	bufinit _bsd_bufinit
+#define	bufobj_init _bsd_bufobj_init
+#define	bufobj_invalbuf _bsd_bufobj_invalbuf
+#define	bufobj_wdrop _bsd_bufobj_wdrop
+#define	bufobj_wref _bsd_bufobj_wref
+#define	bufobj_wrefl _bsd_bufobj_wrefl
+#define	bufobj_wwait _bsd_bufobj_wwait
+#define	bufshutdown _bsd_bufshutdown
+#define	bufspacethresh _bsd_bufspacethresh
+#define	bufstrategy _bsd_bufstrategy
+#define	bufsync _bsd_bufsync
+#define	bufwait _bsd_bufwait
+#define	bufwrite _bsd_bufwrite
+#define	bundirty _bsd_bundirty
 #define	bus_activate_resource _bsd_bus_activate_resource
 #define	bus_adjust_resource _bsd_bus_adjust_resource
 #define	bus_alloc_resource _bsd_bus_alloc_resource
@@ -806,6 +901,14 @@
 #define	bus_teardown_intr _bsd_bus_teardown_intr
 #define	bus_unmap_resource _bsd_bus_unmap_resource
 #define	busdma_lock_mutex _bsd_busdma_lock_mutex
+#define	bwait _bsd_bwait
+#define	bwillwrite _bsd_bwillwrite
+#define	cache_changesize _bsd_cache_changesize
+#define	cache_enter_time _bsd_cache_enter_time
+#define	cache_lookup _bsd_cache_lookup
+#define	cache_purge _bsd_cache_purge
+#define	cache_purge_negative _bsd_cache_purge_negative
+#define	cache_purgevfs _bsd_cache_purgevfs
 #define	calculate_crc32c _bsd_calculate_crc32c
 #define	callout_handle_init _bsd_callout_handle_init
 #define	callout_init _bsd_callout_init
@@ -835,6 +938,32 @@
 #define	camellia_setup128 _bsd_camellia_setup128
 #define	camellia_setup192 _bsd_camellia_setup192
 #define	camellia_setup256 _bsd_camellia_setup256
+#define	cap_accept_rights _bsd_cap_accept_rights
+#define	cap_bind_rights _bsd_cap_bind_rights
+#define	cap_connect_rights _bsd_cap_connect_rights
+#define	cap_event_rights _bsd_cap_event_rights
+#define	cap_fcntl_rights _bsd_cap_fcntl_rights
+#define	cap_fstat_rights _bsd_cap_fstat_rights
+#define	cap_fsync_rights _bsd_cap_fsync_rights
+#define	cap_ftruncate_rights _bsd_cap_ftruncate_rights
+#define	cap_getpeername_rights _bsd_cap_getpeername_rights
+#define	cap_getsockname_rights _bsd_cap_getsockname_rights
+#define	cap_getsockopt_rights _bsd_cap_getsockopt_rights
+#define	cap_ioctl_rights _bsd_cap_ioctl_rights
+#define	cap_listen_rights _bsd_cap_listen_rights
+#define	cap_mkdirat_rights _bsd_cap_mkdirat_rights
+#define	cap_mknodat_rights _bsd_cap_mknodat_rights
+#define	cap_no_rights _bsd_cap_no_rights
+#define	cap_read_rights _bsd_cap_read_rights
+#define	cap_recv_rights _bsd_cap_recv_rights
+#define	cap_renameat_source_rights _bsd_cap_renameat_source_rights
+#define	cap_renameat_target_rights _bsd_cap_renameat_target_rights
+#define	cap_rights_is_valid _bsd_cap_rights_is_valid
+#define	cap_seek_rights _bsd_cap_seek_rights
+#define	cap_setsockopt_rights _bsd_cap_setsockopt_rights
+#define	cap_shutdown_rights _bsd_cap_shutdown_rights
+#define	cap_symlinkat_rights _bsd_cap_symlinkat_rights
+#define	cap_write_rights _bsd_cap_write_rights
 #define	carp6_input _bsd_carp6_input
 #define	carp_attach _bsd_carp_attach
 #define	carp_attach_p _bsd_carp_attach_p
@@ -879,6 +1008,13 @@
 #define	chacha_encrypt_bytes _bsd_chacha_encrypt_bytes
 #define	chacha_ivsetup _bsd_chacha_ivsetup
 #define	chacha_keysetup _bsd_chacha_keysetup
+#define	change_dir _bsd_change_dir
+#define	change_egid _bsd_change_egid
+#define	change_euid _bsd_change_euid
+#define	change_rgid _bsd_change_rgid
+#define	change_ruid _bsd_change_ruid
+#define	change_svgid _bsd_change_svgid
+#define	change_svuid _bsd_change_svuid
 #define	ck_epoch_barrier _bsd_ck_epoch_barrier
 #define	ck_epoch_barrier_wait _bsd_ck_epoch_barrier_wait
 #define	ck_epoch_init _bsd_ck_epoch_init
@@ -894,18 +1030,28 @@
 #define	clean_unrhdrl _bsd_clean_unrhdrl
 #define	clear_unrhdr _bsd_clear_unrhdr
 #define	clk_intr_event _bsd_clk_intr_event
+#define	closef _bsd_closef
 #define	comp_algo_deflate _bsd_comp_algo_deflate
 #define	comp_algorithm_lookup _bsd_comp_algorithm_lookup
 #define	config_intrhook_disestablish _bsd_config_intrhook_disestablish
 #define	config_intrhook_establish _bsd_config_intrhook_establish
 #define	config_intrhook_oneshot _bsd_config_intrhook_oneshot
 #define	copyiniov _bsd_copyiniov
+#define	count_dev _bsd_count_dev
 #define	counter_ratecheck _bsd_counter_ratecheck
 #define	counter_u64_alloc _bsd_counter_u64_alloc
 #define	counter_u64_fetch _bsd_counter_u64_fetch
 #define	counter_u64_free _bsd_counter_u64_free
 #define	counter_u64_zero _bsd_counter_u64_zero
 #define	crc32_tab _bsd_crc32_tab
+#define	crcopy _bsd_crcopy
+#define	crdup _bsd_crdup
+#define	crextend _bsd_crextend
+#define	crfree _bsd_crfree
+#define	crget _bsd_crget
+#define	crhold _bsd_crhold
+#define	crsetgroups _bsd_crsetgroups
+#define	cru2x _bsd_cru2x
 #define	crypto_apply _bsd_crypto_apply
 #define	crypto_contiguous_subsegment _bsd_crypto_contiguous_subsegment
 #define	crypto_copyback _bsd_crypto_copyback
@@ -960,8 +1106,13 @@
 #define	cv_destroy _bsd_cv_destroy
 #define	cv_init _bsd_cv_init
 #define	cv_signal _bsd_cv_signal
+#define	dead_poll _bsd_dead_poll
+#define	dead_read _bsd_dead_read
+#define	dead_vnodeops _bsd_dead_vnodeops
+#define	dead_write _bsd_dead_write
 #define	deembed_scopeid _bsd_deembed_scopeid
 #define	default_cc_ptr _bsd_default_cc_ptr
+#define	default_vnodeops _bsd_default_vnodeops
 #define	deflate_global _bsd_deflate_global
 #define	defrouter_del _bsd_defrouter_del
 #define	defrouter_lookup _bsd_defrouter_lookup
@@ -993,6 +1144,7 @@
 #define	des_set_key_checked _bsd_des_set_key_checked
 #define	des_set_key_unchecked _bsd_des_set_key_unchecked
 #define	des_set_odd_parity _bsd_des_set_odd_parity
+#define	desiredvnodes _bsd_desiredvnodes
 #define	dest6_input _bsd_dest6_input
 #define	destroy_dev _bsd_destroy_dev
 #define	destroy_dev_sched _bsd_destroy_dev_sched
@@ -1028,6 +1180,7 @@
 #define	devfs_destroy_cdevpriv _bsd_devfs_destroy_cdevpriv
 #define	devfs_fpdrop _bsd_devfs_fpdrop
 #define	devfs_get_cdevpriv _bsd_devfs_get_cdevpriv
+#define	devfs_iosize_max _bsd_devfs_iosize_max
 #define	devfs_set_cdevpriv _bsd_devfs_set_cdevpriv
 #define	device_add_child _bsd_device_add_child
 #define	device_add_child_ordered _bsd_device_add_child_ordered
@@ -1085,12 +1238,16 @@
 #define	device_verbose _bsd_device_verbose
 #define	devmtx _bsd_devmtx
 #define	devtoname _bsd_devtoname
+#define	dirent_terminate _bsd_dirent_terminate
+#define	dirtybufferflushes _bsd_dirtybufferflushes
+#define	dirtybufthresh _bsd_dirtybufthresh
 #define	div_protosw _bsd_div_protosw
 #define	div_usrreqs _bsd_div_usrreqs
 #define	domain_add _bsd_domain_add
 #define	domain_init _bsd_domain_init
 #define	domain_init_status _bsd_domain_init_status
 #define	domains _bsd_domains
+#define	dounmount _bsd_dounmount
 #define	drbr_dequeue_drv _bsd_drbr_dequeue_drv
 #define	drbr_enqueue_drv _bsd_drbr_enqueue_drv
 #define	drbr_inuse_drv _bsd_drbr_inuse_drv
@@ -1544,6 +1701,9 @@
 #define	eventhandler_find_list _bsd_eventhandler_find_list
 #define	eventhandler_prune_list _bsd_eventhandler_prune_list
 #define	eventhandler_register _bsd_eventhandler_register
+#define	extattr_check_cred _bsd_extattr_check_cred
+#define	falloc_caps _bsd_falloc_caps
+#define	falloc_noinstall _bsd_falloc_noinstall
 #define	fb_commonioctl _bsd_fb_commonioctl
 #define	fb_dump_adp_info _bsd_fb_dump_adp_info
 #define	fb_dump_mode_info _bsd_fb_dump_mode_info
@@ -1554,6 +1714,12 @@
 #define	fbd_list _bsd_fbd_list
 #define	fbd_register _bsd_fbd_register
 #define	fbd_unregister _bsd_fbd_unregister
+#define	fdalloc _bsd_fdalloc
+#define	fdallocn _bsd_fdallocn
+#define	fdcheckstd _bsd_fdcheckstd
+#define	fdclose _bsd_fdclose
+#define	fdinit _bsd_fdinit
+#define	fdshare _bsd_fdshare
 #define	fdt_addrsize_cells _bsd_fdt_addrsize_cells
 #define	fdt_data_get _bsd_fdt_data_get
 #define	fdt_data_to_res _bsd_fdt_data_to_res
@@ -1577,15 +1743,32 @@
 #define	fdt_pinctrl_configure_tree _bsd_fdt_pinctrl_configure_tree
 #define	fdt_pinctrl_register _bsd_fdt_pinctrl_register
 #define	fdt_regsize _bsd_fdt_regsize
+#define	fget _bsd_fget
+#define	fget_cap _bsd_fget_cap
+#define	fget_cap_locked _bsd_fget_cap_locked
+#define	fget_fcntl _bsd_fget_fcntl
+#define	fget_read _bsd_fget_read
+#define	fget_unlocked _bsd_fget_unlocked
+#define	fget_write _bsd_fget_write
+#define	fgetvp _bsd_fgetvp
+#define	fgetvp_read _bsd_fgetvp_read
+#define	fgetvp_rights _bsd_fgetvp_rights
 #define	fib4_free_nh_ext _bsd_fib4_free_nh_ext
 #define	fib4_lookup_nh_basic _bsd_fib4_lookup_nh_basic
 #define	fib4_lookup_nh_ext _bsd_fib4_lookup_nh_ext
 #define	fib6_free_nh_ext _bsd_fib6_free_nh_ext
 #define	fib6_lookup_nh_basic _bsd_fib6_lookup_nh_basic
 #define	fib6_lookup_nh_ext _bsd_fib6_lookup_nh_ext
+#define	filecaps_copy _bsd_filecaps_copy
+#define	filecaps_free _bsd_filecaps_free
+#define	filecaps_init _bsd_filecaps_init
+#define	filecaps_move _bsd_filecaps_move
+#define	filedesc_to_leader_alloc _bsd_filedesc_to_leader_alloc
 #define	find_and_ref_tcp_fb _bsd_find_and_ref_tcp_fb
 #define	find_and_ref_tcp_functions _bsd_find_and_ref_tcp_functions
 #define	find_handler _bsd_find_handler
+#define	finit _bsd_finit
+#define	finstall _bsd_finstall
 #define	firewire_broadcastaddr _bsd_firewire_broadcastaddr
 #define	firewire_busreset _bsd_firewire_busreset
 #define	firewire_ifattach _bsd_firewire_ifattach
@@ -1597,6 +1780,10 @@
 #define	firmware_register _bsd_firmware_register
 #define	firmware_unregister _bsd_firmware_unregister
 #define	first_handler _bsd_first_handler
+#define	foffset_lock _bsd_foffset_lock
+#define	foffset_lock_uio _bsd_foffset_lock_uio
+#define	foffset_unlock _bsd_foffset_unlock
+#define	foffset_unlock_uio _bsd_foffset_unlock_uio
 #define	frag6_drain _bsd_frag6_drain
 #define	frag6_init _bsd_frag6_init
 #define	frag6_input _bsd_frag6_input
@@ -1604,13 +1791,25 @@
 #define	frag6_set_bucketsize _bsd_frag6_set_bucketsize
 #define	frag6_slowtimo _bsd_frag6_slowtimo
 #define	free_unr _bsd_free_unr
+#define	fs_filtops _bsd_fs_filtops
+#define	gbincore _bsd_gbincore
 #define	genkbd_commonioctl _bsd_genkbd_commonioctl
 #define	genkbd_diag _bsd_genkbd_diag
 #define	genkbd_get_fkeystr _bsd_genkbd_get_fkeystr
 #define	genkbd_keyaction _bsd_genkbd_keyaction
 #define	get_keybuf _bsd_get_keybuf
 #define	get_random_bytes _bsd_get_random_bytes
+#define	getblk _bsd_getblk
+#define	getblkx _bsd_getblkx
 #define	getcredhostuuid _bsd_getcredhostuuid
+#define	geteblk _bsd_geteblk
+#define	getnewvnode _bsd_getnewvnode
+#define	getnewvnode_drop_reserve _bsd_getnewvnode_drop_reserve
+#define	getnewvnode_reserve _bsd_getnewvnode_reserve
+#define	getpbuf _bsd_getpbuf
+#define	getsock_cap _bsd_getsock_cap
+#define	getsockaddr _bsd_getsockaddr
+#define	getvnode _bsd_getvnode
 #define	gf128_genmultable _bsd_gf128_genmultable
 #define	gf128_genmultable4 _bsd_gf128_genmultable4
 #define	gf128_mul _bsd_gf128_mul
@@ -1648,6 +1847,7 @@
 #define	gre_sofree _bsd_gre_sofree
 #define	gre_update_hdr _bsd_gre_update_hdr
 #define	gre_update_udphdr _bsd_gre_update_udphdr
+#define	groupmember _bsd_groupmember
 #define	grouptask_block _bsd_grouptask_block
 #define	grouptask_unblock _bsd_grouptask_unblock
 #define	grouptaskqueue_enqueue _bsd_grouptaskqueue_enqueue
@@ -1657,6 +1857,7 @@
 #define	gtaskqueue_drain_all _bsd_gtaskqueue_drain_all
 #define	gtaskqueue_unblock _bsd_gtaskqueue_unblock
 #define	handlers _bsd_handlers
+#define	hardlink_check_uid _bsd_hardlink_check_uid
 #define	hashdestroy _bsd_hashdestroy
 #define	hashinit _bsd_hashinit
 #define	hashinit_flags _bsd_hashinit_flags
@@ -1675,6 +1876,7 @@
 #define	hhook_remove_hook_lookup _bsd_hhook_remove_hook_lookup
 #define	hhook_run_hooks _bsd_hhook_run_hooks
 #define	hhook_vhead_list _bsd_hhook_vhead_list
+#define	hibufspace _bsd_hibufspace
 #define	hid_end_parse _bsd_hid_end_parse
 #define	hid_get_data _bsd_hid_get_data
 #define	hid_get_data_unsigned _bsd_hid_get_data_unsigned
@@ -2357,6 +2559,7 @@
 #define	ifq_delete _bsd_ifq_delete
 #define	ifq_init _bsd_ifq_init
 #define	ifr_data_get_ptr _bsd_ifr_data_get_ptr
+#define	iftovt_tab _bsd_iftovt_tab
 #define	ifunit _bsd_ifunit
 #define	ifunit_ref _bsd_ifunit_ref
 #define	igb_sctx _bsd_igb_sctx
@@ -2605,6 +2808,7 @@
 #define	in_rtredirect _bsd_in_rtredirect
 #define	in_scrubprefix _bsd_in_scrubprefix
 #define	in_sockaddr _bsd_in_sockaddr
+#define	incore _bsd_incore
 #define	inet6_pfil_head _bsd_inet6_pfil_head
 #define	inet6_pfil_hook _bsd_inet6_pfil_hook
 #define	inet6ctlerrmap _bsd_inet6ctlerrmap
@@ -2620,6 +2824,7 @@
 #define	init_sin6 _bsd_init_sin6
 #define	init_sleepqueues _bsd_init_sleepqueues
 #define	init_unrhdr _bsd_init_unrhdr
+#define	init_va_filerev _bsd_init_va_filerev
 #define	inm_clear_recorded _bsd_inm_clear_recorded
 #define	inm_commit _bsd_inm_commit
 #define	inm_disconnect _bsd_inm_disconnect
@@ -2637,15 +2842,28 @@
 #define	inp_inpcbtotcpcb _bsd_inp_inpcbtotcpcb
 #define	inp_ip_tos_get _bsd_inp_ip_tos_get
 #define	inp_ip_tos_set _bsd_inp_ip_tos_set
+#define	inp_lock_assert _bsd_inp_lock_assert
 #define	inp_rlock _bsd_inp_rlock
 #define	inp_runlock _bsd_inp_runlock
 #define	inp_setmoptions _bsd_inp_setmoptions
 #define	inp_so_options _bsd_inp_so_options
 #define	inp_to_cpuid _bsd_inp_to_cpuid
+#define	inp_unlock_assert _bsd_inp_unlock_assert
 #define	inp_wlock _bsd_inp_wlock
 #define	inp_wunlock _bsd_inp_wunlock
+#define	insmntque _bsd_insmntque
+#define	insmntque1 _bsd_insmntque1
 #define	intr_event_add_handler _bsd_intr_event_add_handler
 #define	intr_event_create _bsd_intr_event_create
+#define	invfo_chmod _bsd_invfo_chmod
+#define	invfo_chown _bsd_invfo_chown
+#define	invfo_ioctl _bsd_invfo_ioctl
+#define	invfo_kqfilter _bsd_invfo_kqfilter
+#define	invfo_poll _bsd_invfo_poll
+#define	invfo_rdwr _bsd_invfo_rdwr
+#define	invfo_sendfile _bsd_invfo_sendfile
+#define	invfo_truncate _bsd_invfo_truncate
+#define	iosize_max _bsd_iosize_max
 #define	ip4_ah_net_deflev _bsd_ip4_ah_net_deflev
 #define	ip4_ah_trans_deflev _bsd_ip4_ah_trans_deflev
 #define	ip4_esp_net_deflev _bsd_ip4_esp_net_deflev
@@ -2906,7 +3124,62 @@
 #define	kdebug_secpolicyindex _bsd_kdebug_secpolicyindex
 #define	kdebug_secpolicyindex_dir _bsd_kdebug_secpolicyindex_dir
 #define	kdebug_sockaddr _bsd_kdebug_sockaddr
+#define	kern___getcwd _bsd_kern___getcwd
+#define	kern_accept _bsd_kern_accept
+#define	kern_accept4 _bsd_kern_accept4
+#define	kern_alternate_path _bsd_kern_alternate_path
+#define	kern_bindat _bsd_kern_bindat
+#define	kern_chdir _bsd_kern_chdir
+#define	kern_close _bsd_kern_close
+#define	kern_connectat _bsd_kern_connectat
+#define	kern_fchmodat _bsd_kern_fchmodat
+#define	kern_fchownat _bsd_kern_fchownat
+#define	kern_fcntl _bsd_kern_fcntl
+#define	kern_fstat _bsd_kern_fstat
+#define	kern_fstatfs _bsd_kern_fstatfs
+#define	kern_fsync _bsd_kern_fsync
+#define	kern_ftruncate _bsd_kern_ftruncate
+#define	kern_getdirentries _bsd_kern_getdirentries
+#define	kern_getfsstat _bsd_kern_getfsstat
+#define	kern_getpeername _bsd_kern_getpeername
+#define	kern_getsockname _bsd_kern_getsockname
+#define	kern_getsockopt _bsd_kern_getsockopt
+#define	kern_ioctl _bsd_kern_ioctl
+#define	kern_kevent _bsd_kern_kevent
+#define	kern_kevent_fp _bsd_kern_kevent_fp
+#define	kern_kqueue _bsd_kern_kqueue
+#define	kern_linkat _bsd_kern_linkat
+#define	kern_listen _bsd_kern_listen
+#define	kern_lseek _bsd_kern_lseek
+#define	kern_mkdirat _bsd_kern_mkdirat
+#define	kern_mknodat _bsd_kern_mknodat
+#define	kern_openat _bsd_kern_openat
+#define	kern_pipe _bsd_kern_pipe
+#define	kern_poll _bsd_kern_poll
+#define	kern_posix_fallocate _bsd_kern_posix_fallocate
+#define	kern_pselect _bsd_kern_pselect
+#define	kern_readlinkat _bsd_kern_readlinkat
+#define	kern_readv _bsd_kern_readv
+#define	kern_recvit _bsd_kern_recvit
+#define	kern_renameat _bsd_kern_renameat
+#define	kern_rmdirat _bsd_kern_rmdirat
+#define	kern_select _bsd_kern_select
+#define	kern_sendit _bsd_kern_sendit
+#define	kern_setsockopt _bsd_kern_setsockopt
+#define	kern_shutdown _bsd_kern_shutdown
+#define	kern_socket _bsd_kern_socket
+#define	kern_socketpair _bsd_kern_socketpair
+#define	kern_statat _bsd_kern_statat
+#define	kern_statfs _bsd_kern_statfs
+#define	kern_symlinkat _bsd_kern_symlinkat
+#define	kern_truncate _bsd_kern_truncate
+#define	kern_unlinkat _bsd_kern_unlinkat
+#define	kern_vfs_bio_buffer_alloc _bsd_kern_vfs_bio_buffer_alloc
+#define	kern_writev _bsd_kern_writev
+#define	kernel_arena _bsd_kernel_arena
+#define	kernel_mount _bsd_kernel_mount
 #define	kernel_sysctl _bsd_kernel_sysctl
+#define	kernel_vmount _bsd_kernel_vmount
 #define	key_addref _bsd_key_addref
 #define	key_allocsa _bsd_key_allocsa
 #define	key_allocsa_policy _bsd_key_allocsa_policy
@@ -2988,6 +3261,17 @@
 #define	kthread_add _bsd_kthread_add
 #define	kthread_exit _bsd_kthread_exit
 #define	kthread_start _bsd_kthread_start
+#define	ktr_buf _bsd_ktr_buf
+#define	ktr_buf_init _bsd_ktr_buf_init
+#define	ktr_compile _bsd_ktr_compile
+#define	ktr_cpumask _bsd_ktr_cpumask
+#define	ktr_entries _bsd_ktr_entries
+#define	ktr_idx _bsd_ktr_idx
+#define	ktr_mask _bsd_ktr_mask
+#define	ktr_tracepoint _bsd_ktr_tracepoint
+#define	ktr_verbose _bsd_ktr_verbose
+#define	ktr_version _bsd_ktr_version
+#define	kva_alloc _bsd_kva_alloc
 #define	kvprintf _bsd_kvprintf
 #define	lacp_attach _bsd_lacp_attach
 #define	lacp_detach _bsd_lacp_detach
@@ -3050,6 +3334,7 @@
 #define	lltable_try_set_entry_addr _bsd_lltable_try_set_entry_addr
 #define	lltable_unlink_entry _bsd_lltable_unlink_entry
 #define	lltable_update_ifaddr _bsd_lltable_update_ifaddr
+#define	lock_class_lockmgr _bsd_lock_class_lockmgr
 #define	lock_class_mtx_sleep _bsd_lock_class_mtx_sleep
 #define	lock_class_mtx_spin _bsd_lock_class_mtx_spin
 #define	lock_class_rw _bsd_lock_class_rw
@@ -3057,9 +3342,20 @@
 #define	lock_classes _bsd_lock_classes
 #define	lock_destroy _bsd_lock_destroy
 #define	lock_init _bsd_lock_init
+#define	lockallowrecurse _bsd_lockallowrecurse
+#define	lockallowshare _bsd_lockallowshare
+#define	lockdestroy _bsd_lockdestroy
+#define	lockdisablerecurse _bsd_lockdisablerecurse
+#define	lockdisableshare _bsd_lockdisableshare
+#define	lockinit _bsd_lockinit
+#define	lockmgr_lock_fast_path _bsd_lockmgr_lock_fast_path
+#define	lockmgr_printinfo _bsd_lockmgr_printinfo
+#define	lockmgr_unlock_fast_path _bsd_lockmgr_unlock_fast_path
+#define	lockstatus _bsd_lockstatus
 #define	log _bsd_log
 #define	loif _bsd_loif
 #define	loioctl _bsd_loioctl
+#define	lookup _bsd_lookup
 #define	looutput _bsd_looutput
 #define	lpc_pwr_read _bsd_lpc_pwr_read
 #define	lpc_pwr_write _bsd_lpc_pwr_write
@@ -3131,7 +3427,13 @@
 #define	malloc_init _bsd_malloc_init
 #define	malloc_uninit _bsd_malloc_uninit
 #define	mallocarray _bsd_mallocarray
+#define	maxbcache _bsd_maxbcache
+#define	maxbcachebuf _bsd_maxbcachebuf
+#define	maxfiles _bsd_maxfiles
+#define	maxfilesperproc _bsd_maxfilesperproc
 #define	maxpipekva _bsd_maxpipekva
+#define	maxproc _bsd_maxproc
+#define	maxvfsconf _bsd_maxvfsconf
 #define	mb_dupcl _bsd_mb_dupcl
 #define	mb_free_ext _bsd_mb_free_ext
 #define	mb_free_notready _bsd_mb_free_notready
@@ -3190,6 +3492,14 @@
 #define	module_register_init _bsd_module_register_init
 #define	module_release _bsd_module_release
 #define	modules_sx _bsd_modules_sx
+#define	mount_arg _bsd_mount_arg
+#define	mount_argb _bsd_mount_argb
+#define	mount_argf _bsd_mount_argf
+#define	mount_argsu _bsd_mount_argsu
+#define	mountcheckdirs _bsd_mountcheckdirs
+#define	mountlist _bsd_mountlist
+#define	mountlist_mtx _bsd_mountlist_mtx
+#define	mq_fdclose _bsd_mq_fdclose
 #define	mrt6_ioctl _bsd_mrt6_ioctl
 #define	mrt_ioctl _bsd_mrt_ioctl
 #define	mtrash_ctor _bsd_mtrash_ctor
@@ -3215,7 +3525,15 @@
 #define	musbotg_uninit _bsd_musbotg_uninit
 #define	musbotg_vbus_interrupt _bsd_musbotg_vbus_interrupt
 #define	mutex_init _bsd_mutex_init
+#define	mutexlist _bsd_mutexlist
+#define	mutexlist_lock _bsd_mutexlist_lock
+#define	namei _bsd_namei
+#define	namei_zone _bsd_namei_zone
 #define	natt_cksum_policy _bsd_natt_cksum_policy
+#define	nbuf _bsd_nbuf
+#define	nchstats _bsd_nchstats
+#define	ncl_pbuf_zone _bsd_ncl_pbuf_zone
+#define	ncsizefactor _bsd_ncsizefactor
 #define	nd6_add_ifa_lle _bsd_nd6_add_ifa_lle
 #define	nd6_alloc _bsd_nd6_alloc
 #define	nd6_cache_lladdr _bsd_nd6_cache_lladdr
@@ -3284,6 +3602,7 @@
 #define	new_unrhdr _bsd_new_unrhdr
 #define	newpacket _bsd_newpacket
 #define	newreno_cc_algo _bsd_newreno_cc_algo
+#define	nfs_pub _bsd_nfs_pub
 #define	ng_ether_attach_p _bsd_ng_ether_attach_p
 #define	ng_ether_detach_p _bsd_ng_ether_detach_p
 #define	ng_ether_input_orphan_p _bsd_ng_ether_input_orphan_p
@@ -3295,7 +3614,10 @@
 #define	ng_gif_input_orphan_p _bsd_ng_gif_input_orphan_p
 #define	ng_gif_input_p _bsd_ng_gif_input_p
 #define	ng_ipfw_input_p _bsd_ng_ipfw_input_p
+#define	ngroups_max _bsd_ngroups_max
+#define	nlminfo_release_p _bsd_nlminfo_release_p
 #define	nousrreqs _bsd_nousrreqs
+#define	nswbuf _bsd_nswbuf
 #define	null_class _bsd_null_class
 #define	null_filtops _bsd_null_filtops
 #define	nullop _bsd_nullop
@@ -3432,6 +3754,7 @@
 #define	ohci_init _bsd_ohci_init
 #define	ohci_interrupt _bsd_ohci_interrupt
 #define	ohci_iterate_hw_softc _bsd_ohci_iterate_hw_softc
+#define	openfiles _bsd_openfiles
 #define	osd_call _bsd_osd_call
 #define	osd_del _bsd_osd_del
 #define	osd_deregister _bsd_osd_deregister
@@ -3446,6 +3769,8 @@
 #define	panic _bsd_panic
 #define	parse_uuid _bsd_parse_uuid
 #define	pause_sbt _bsd_pause_sbt
+#define	pbuf_zone _bsd_pbuf_zone
+#define	pbuf_zsecond_create _bsd_pbuf_zsecond_create
 #define	pci_activate_resource _bsd_pci_activate_resource
 #define	pci_add_bar _bsd_pci_add_bar
 #define	pci_add_child _bsd_pci_add_child
@@ -3578,6 +3903,14 @@
 #define	pcpu_zone_64 _bsd_pcpu_zone_64
 #define	pcpu_zone_int _bsd_pcpu_zone_int
 #define	pcpu_zone_ptr _bsd_pcpu_zone_ptr
+#define	pctrie_insert _bsd_pctrie_insert
+#define	pctrie_lookup _bsd_pctrie_lookup
+#define	pctrie_lookup_ge _bsd_pctrie_lookup_ge
+#define	pctrie_lookup_le _bsd_pctrie_lookup_le
+#define	pctrie_node_size _bsd_pctrie_node_size
+#define	pctrie_reclaim_allnodes _bsd_pctrie_reclaim_allnodes
+#define	pctrie_remove _bsd_pctrie_remove
+#define	pctrie_zone_init _bsd_pctrie_zone_init
 #define	pf_addr_cmp _bsd_pf_addr_cmp
 #define	pf_addr_inc _bsd_pf_addr_inc
 #define	pf_addrcpy _bsd_pf_addrcpy
@@ -3813,6 +4146,28 @@
 #define	pfr_table_count _bsd_pfr_table_count
 #define	pfr_tst_addrs _bsd_pfr_tst_addrs
 #define	pfr_update_stats _bsd_pfr_update_stats
+#define	pfs_cmount _bsd_pfs_cmount
+#define	pfs_create_dir _bsd_pfs_create_dir
+#define	pfs_create_file _bsd_pfs_create_file
+#define	pfs_create_link _bsd_pfs_create_link
+#define	pfs_destroy _bsd_pfs_destroy
+#define	pfs_fileno_alloc _bsd_pfs_fileno_alloc
+#define	pfs_fileno_free _bsd_pfs_fileno_free
+#define	pfs_fileno_init _bsd_pfs_fileno_init
+#define	pfs_fileno_uninit _bsd_pfs_fileno_uninit
+#define	pfs_find_node _bsd_pfs_find_node
+#define	pfs_init _bsd_pfs_init
+#define	pfs_mount _bsd_pfs_mount
+#define	pfs_purge _bsd_pfs_purge
+#define	pfs_root _bsd_pfs_root
+#define	pfs_statfs _bsd_pfs_statfs
+#define	pfs_uninit _bsd_pfs_uninit
+#define	pfs_unmount _bsd_pfs_unmount
+#define	pfs_vncache_alloc _bsd_pfs_vncache_alloc
+#define	pfs_vncache_free _bsd_pfs_vncache_free
+#define	pfs_vncache_load _bsd_pfs_vncache_load
+#define	pfs_vncache_unload _bsd_pfs_vncache_unload
+#define	pfs_vnodeops _bsd_pfs_vnodeops
 #define	pfsync_clear_states_ptr _bsd_pfsync_clear_states_ptr
 #define	pfsync_cloner _bsd_pfsync_cloner
 #define	pfsync_defer_ptr _bsd_pfsync_defer_ptr
@@ -3829,14 +4184,20 @@
 #define	pick_mode_by_ref _bsd_pick_mode_by_ref
 #define	pipe_dtor _bsd_pipe_dtor
 #define	pipe_named_ctor _bsd_pipe_named_ctor
+#define	pipeops _bsd_pipeops
 #define	pipeselwakeup _bsd_pipeselwakeup
 #define	pmtu_expire _bsd_pmtu_expire
 #define	pmtu_probe _bsd_pmtu_probe
 #define	poll_no_poll _bsd_poll_no_poll
 #define	ppsratecheck _bsd_ppsratecheck
+#define	print_devclass_list _bsd_print_devclass_list
+#define	print_devclass_list_short _bsd_print_devclass_list_short
+#define	print_device_tree _bsd_print_device_tree
+#define	print_device_tree_short _bsd_print_device_tree_short
 #define	printf _bsd_printf
 #define	printf_uuid _bsd_printf_uuid
 #define	prison0 _bsd_prison0
+#define	proc0 _bsd_proc0
 #define	pru_accept_notsupp _bsd_pru_accept_notsupp
 #define	pru_aio_queue_notsupp _bsd_pru_aio_queue_notsupp
 #define	pru_attach_notsupp _bsd_pru_attach_notsupp
@@ -3859,6 +4220,8 @@
 #define	pru_sopoll_notsupp _bsd_pru_sopoll_notsupp
 #define	pru_soreceive_notsupp _bsd_pru_soreceive_notsupp
 #define	pru_sosend_notsupp _bsd_pru_sosend_notsupp
+#define	pwd_chdir _bsd_pwd_chdir
+#define	pwd_ensure_dirs _bsd_pwd_ensure_dirs
 #define	qgroup_config _bsd_qgroup_config
 #define	qgroup_if_config_tqg _bsd_qgroup_if_config_tqg
 #define	qgroup_if_io_tqg _bsd_qgroup_if_io_tqg
@@ -4088,6 +4451,7 @@
 #define	rc4_init _bsd_rc4_init
 #define	read_dsfield _bsd_read_dsfield
 #define	read_machclk _bsd_read_machclk
+#define	reassignbuf _bsd_reassignbuf
 #define	refcount_release_last _bsd_refcount_release_last
 #define	refcount_sleep _bsd_refcount_sleep
 #define	register_tcp_functions _bsd_register_tcp_functions
@@ -4130,6 +4494,8 @@
 #define	regulator_set_voltage _bsd_regulator_set_voltage
 #define	regulator_status _bsd_regulator_status
 #define	regulator_stop _bsd_regulator_stop
+#define	relookup _bsd_relookup
+#define	relpbuf _bsd_relpbuf
 #define	resource_disabled _bsd_resource_disabled
 #define	resource_find_match _bsd_resource_find_match
 #define	resource_int_value _bsd_resource_int_value
@@ -4348,6 +4714,8 @@
 #define	rtwn_usb_write_4 _bsd_rtwn_usb_write_4
 #define	rtwn_usb_write_region_1 _bsd_rtwn_usb_write_region_1
 #define	run_debug _bsd_run_debug
+#define	runningbufspace _bsd_runningbufspace
+#define	runningbufwakeup _bsd_runningbufwakeup
 #define	rw_destroy _bsd_rw_destroy
 #define	rw_init_flags _bsd_rw_init_flags
 #define	rw_sysinit _bsd_rw_sysinit
@@ -4833,10 +5201,13 @@
 #define	selwakeuppri _bsd_selwakeuppri
 #define	send_forward_tsn _bsd_send_forward_tsn
 #define	send_sendso_input_hook _bsd_send_sendso_input_hook
+#define	setfmode _bsd_setfmode
+#define	setfown _bsd_setfown
 #define	sha1_init _bsd_sha1_init
 #define	sha1_loop _bsd_sha1_loop
 #define	sha1_pad _bsd_sha1_pad
 #define	sha1_result _bsd_sha1_result
+#define	sigio_lock _bsd_sigio_lock
 #define	simplebus_add_device _bsd_simplebus_add_device
 #define	simplebus_driver _bsd_simplebus_driver
 #define	simplebus_fill_ranges _bsd_simplebus_fill_ranges
@@ -4929,6 +5300,7 @@
 #define	sonewconn _bsd_sonewconn
 #define	soo_close _bsd_soo_close
 #define	soo_ioctl _bsd_soo_ioctl
+#define	soo_kqfilter _bsd_soo_kqfilter
 #define	soo_poll _bsd_soo_poll
 #define	soo_read _bsd_soo_read
 #define	soo_write _bsd_soo_write
@@ -4954,6 +5326,7 @@
 #define	soupcall_clear _bsd_soupcall_clear
 #define	soupcall_set _bsd_soupcall_set
 #define	sowakeup _bsd_sowakeup
+#define	speedup_syncer _bsd_speedup_syncer
 #define	sppp_attach _bsd_sppp_attach
 #define	sppp_dequeue _bsd_sppp_dequeue
 #define	sppp_detach _bsd_sppp_detach
@@ -4967,6 +5340,7 @@
 #define	sppp_isempty _bsd_sppp_isempty
 #define	sppp_pick _bsd_sppp_pick
 #define	sprintf _bsd_sprintf
+#define	statfs_scale_blocks _bsd_statfs_scale_blocks
 #define	subkey_table_gen _bsd_subkey_table_gen
 #define	swi_add _bsd_swi_add
 #define	swi_sched _bsd_swi_sched
@@ -4974,7 +5348,9 @@
 #define	sx_downgrade_int _bsd_sx_downgrade_int
 #define	sx_init_flags _bsd_sx_init_flags
 #define	sx_sysinit _bsd_sx_sysinit
+#define	sx_try_downgrade_ _bsd_sx_try_downgrade_
 #define	sx_try_slock_int _bsd_sx_try_slock_int
+#define	sx_try_upgrade_ _bsd_sx_try_upgrade_
 #define	sx_try_upgrade_int _bsd_sx_try_upgrade_int
 #define	sx_xlocked _bsd_sx_xlocked
 #define	syncache_add _bsd_syncache_add
@@ -4984,6 +5360,104 @@
 #define	syncache_init _bsd_syncache_init
 #define	syncache_pcblist _bsd_syncache_pcblist
 #define	syncache_unreach _bsd_syncache_unreach
+#define	syncer_resume _bsd_syncer_resume
+#define	syncer_suspend _bsd_syncer_suspend
+#define	sys___acl_aclcheck_fd _bsd_sys___acl_aclcheck_fd
+#define	sys___acl_aclcheck_file _bsd_sys___acl_aclcheck_file
+#define	sys___acl_aclcheck_link _bsd_sys___acl_aclcheck_link
+#define	sys___acl_delete_fd _bsd_sys___acl_delete_fd
+#define	sys___acl_delete_file _bsd_sys___acl_delete_file
+#define	sys___acl_delete_link _bsd_sys___acl_delete_link
+#define	sys___acl_get_fd _bsd_sys___acl_get_fd
+#define	sys___acl_get_file _bsd_sys___acl_get_file
+#define	sys___acl_get_link _bsd_sys___acl_get_link
+#define	sys___acl_set_fd _bsd_sys___acl_set_fd
+#define	sys___acl_set_file _bsd_sys___acl_set_file
+#define	sys___acl_set_link _bsd_sys___acl_set_link
+#define	sys___getcwd _bsd_sys___getcwd
+#define	sys_accept _bsd_sys_accept
+#define	sys_accept4 _bsd_sys_accept4
+#define	sys_access _bsd_sys_access
+#define	sys_aio_cancel _bsd_sys_aio_cancel
+#define	sys_aio_error _bsd_sys_aio_error
+#define	sys_aio_fsync _bsd_sys_aio_fsync
+#define	sys_aio_mlock _bsd_sys_aio_mlock
+#define	sys_aio_read _bsd_sys_aio_read
+#define	sys_aio_return _bsd_sys_aio_return
+#define	sys_aio_suspend _bsd_sys_aio_suspend
+#define	sys_aio_waitcomplete _bsd_sys_aio_waitcomplete
+#define	sys_aio_write _bsd_sys_aio_write
+#define	sys_bind _bsd_sys_bind
+#define	sys_chdir _bsd_sys_chdir
+#define	sys_chflags _bsd_sys_chflags
+#define	sys_chmod _bsd_sys_chmod
+#define	sys_chown _bsd_sys_chown
+#define	sys_close _bsd_sys_close
+#define	sys_connect _bsd_sys_connect
+#define	sys_fchdir _bsd_sys_fchdir
+#define	sys_fchmod _bsd_sys_fchmod
+#define	sys_fchmodat _bsd_sys_fchmodat
+#define	sys_fchown _bsd_sys_fchown
+#define	sys_fchownat _bsd_sys_fchownat
+#define	sys_fdatasync _bsd_sys_fdatasync
+#define	sys_fstat _bsd_sys_fstat
+#define	sys_fstatat _bsd_sys_fstatat
+#define	sys_fstatfs _bsd_sys_fstatfs
+#define	sys_fsync _bsd_sys_fsync
+#define	sys_ftruncate _bsd_sys_ftruncate
+#define	sys_getdirentries _bsd_sys_getdirentries
+#define	sys_getdtablesize _bsd_sys_getdtablesize
+#define	sys_getfsstat _bsd_sys_getfsstat
+#define	sys_getpeername _bsd_sys_getpeername
+#define	sys_getsockname _bsd_sys_getsockname
+#define	sys_getsockopt _bsd_sys_getsockopt
+#define	sys_ioctl _bsd_sys_ioctl
+#define	sys_kevent _bsd_sys_kevent
+#define	sys_kqueue _bsd_sys_kqueue
+#define	sys_lchmod _bsd_sys_lchmod
+#define	sys_lchown _bsd_sys_lchown
+#define	sys_link _bsd_sys_link
+#define	sys_linkat _bsd_sys_linkat
+#define	sys_lio_listio _bsd_sys_lio_listio
+#define	sys_listen _bsd_sys_listen
+#define	sys_lseek _bsd_sys_lseek
+#define	sys_mkdir _bsd_sys_mkdir
+#define	sys_mkdirat _bsd_sys_mkdirat
+#define	sys_mknodat _bsd_sys_mknodat
+#define	sys_mount _bsd_sys_mount
+#define	sys_nmount _bsd_sys_nmount
+#define	sys_open _bsd_sys_open
+#define	sys_openat _bsd_sys_openat
+#define	sys_pipe2 _bsd_sys_pipe2
+#define	sys_poll _bsd_sys_poll
+#define	sys_pselect _bsd_sys_pselect
+#define	sys_read _bsd_sys_read
+#define	sys_readlink _bsd_sys_readlink
+#define	sys_readlinkat _bsd_sys_readlinkat
+#define	sys_readv _bsd_sys_readv
+#define	sys_recvfrom _bsd_sys_recvfrom
+#define	sys_recvmsg _bsd_sys_recvmsg
+#define	sys_rename _bsd_sys_rename
+#define	sys_renameat _bsd_sys_renameat
+#define	sys_rmdir _bsd_sys_rmdir
+#define	sys_select _bsd_sys_select
+#define	sys_sendmsg _bsd_sys_sendmsg
+#define	sys_sendto _bsd_sys_sendto
+#define	sys_setfib _bsd_sys_setfib
+#define	sys_setsockopt _bsd_sys_setsockopt
+#define	sys_shutdown _bsd_sys_shutdown
+#define	sys_socket _bsd_sys_socket
+#define	sys_socketpair _bsd_sys_socketpair
+#define	sys_statfs _bsd_sys_statfs
+#define	sys_symlink _bsd_sys_symlink
+#define	sys_symlinkat _bsd_sys_symlinkat
+#define	sys_sync _bsd_sys_sync
+#define	sys_truncate _bsd_sys_truncate
+#define	sys_unlink _bsd_sys_unlink
+#define	sys_unlinkat _bsd_sys_unlinkat
+#define	sys_unmount _bsd_sys_unmount
+#define	sys_write _bsd_sys_write
+#define	sys_writev _bsd_sys_writev
 #define	sysctl___debug _bsd_sysctl___debug
 #define	sysctl___dev _bsd_sysctl___dev
 #define	sysctl___hw _bsd_sysctl___hw
@@ -5045,6 +5519,8 @@
 #define	sysctl___net_wlan _bsd_sysctl___net_wlan
 #define	sysctl___security _bsd_sysctl___security
 #define	sysctl___sysctl _bsd_sysctl___sysctl
+#define	sysctl___vfs _bsd_sysctl___vfs
+#define	sysctl___vfs_pfs _bsd_sysctl___vfs_pfs
 #define	sysctl___vm _bsd_sysctl___vm
 #define	sysctl__children _bsd_sysctl__children
 #define	sysctl_add_oid _bsd_sysctl_add_oid
@@ -5302,6 +5778,7 @@
 #define	timeout _bsd_timeout
 #define	timevaladd _bsd_timevaladd
 #define	timevalsub _bsd_timevalsub
+#define	tprintf _bsd_tprintf
 #define	trash_ctor _bsd_trash_ctor
 #define	trash_dtor _bsd_trash_dtor
 #define	trash_fini _bsd_trash_fini
@@ -5446,7 +5923,12 @@
 #define	uhub_query_info _bsd_uhub_query_info
 #define	uhub_root_intr _bsd_uhub_root_intr
 #define	uhub_tt_buffer_reset_async_locked _bsd_uhub_tt_buffer_reset_async_locked
+#define	uifind _bsd_uifind
+#define	uifree _bsd_uifree
+#define	uihashinit _bsd_uihashinit
+#define	uihold _bsd_uihold
 #define	uiomove _bsd_uiomove
+#define	uiomove_frombuf _bsd_uiomove_frombuf
 #define	uiomove_nofault _bsd_uiomove_nofault
 #define	ukphy_status _bsd_ukphy_status
 #define	ulitecb _bsd_ulitecb
@@ -5454,6 +5936,7 @@
 #define	uma_align_cache _bsd_uma_align_cache
 #define	uma_avail _bsd_uma_avail
 #define	uma_limit _bsd_uma_limit
+#define	uma_prealloc _bsd_uma_prealloc
 #define	uma_print_stats _bsd_uma_print_stats
 #define	uma_print_zone _bsd_uma_print_zone
 #define	uma_reclaim _bsd_uma_reclaim
@@ -5490,6 +5973,9 @@
 #define	uma_zone_set_zinit _bsd_uma_zone_set_zinit
 #define	uma_zsecond_create _bsd_uma_zsecond_create
 #define	uma_zwait _bsd_uma_zwait
+#define	unmapped_base _bsd_unmapped_base
+#define	unmapped_buf _bsd_unmapped_buf
+#define	unmapped_buf_allowed _bsd_unmapped_buf_allowed
 #define	unp_copy_peercred _bsd_unp_copy_peercred
 #define	untimeout _bsd_untimeout
 #define	usb_alloc_device _bsd_usb_alloc_device
@@ -5772,8 +6258,98 @@
 #define	uuid_ether_add _bsd_uuid_ether_add
 #define	uuid_ether_del _bsd_uuid_ether_del
 #define	uuidcmp _bsd_uuidcmp
+#define	v_addpollinfo _bsd_v_addpollinfo
+#define	v_inval_buf_range _bsd_v_inval_buf_range
+#define	va_null _bsd_va_null
+#define	vaccess _bsd_vaccess
+#define	vattr_null _bsd_vattr_null
+#define	vcount _bsd_vcount
+#define	verbose_sysinit _bsd_verbose_sysinit
 #define	vesagtf_mode _bsd_vesagtf_mode
 #define	vesagtf_mode_params _bsd_vesagtf_mode_params
+#define	vflush _bsd_vflush
+#define	vfs_allocate_syncvnode _bsd_vfs_allocate_syncvnode
+#define	vfs_bio_awrite _bsd_vfs_bio_awrite
+#define	vfs_bio_brelse _bsd_vfs_bio_brelse
+#define	vfs_bio_bzero_buf _bsd_vfs_bio_bzero_buf
+#define	vfs_bio_clrbuf _bsd_vfs_bio_clrbuf
+#define	vfs_bio_getpages _bsd_vfs_bio_getpages
+#define	vfs_bio_set_flags _bsd_vfs_bio_set_flags
+#define	vfs_bio_set_valid _bsd_vfs_bio_set_valid
+#define	vfs_buildopts _bsd_vfs_buildopts
+#define	vfs_busy _bsd_vfs_busy
+#define	vfs_busy_pages _bsd_vfs_busy_pages
+#define	vfs_busyfs _bsd_vfs_busyfs
+#define	vfs_byname _bsd_vfs_byname
+#define	vfs_byname_kld _bsd_vfs_byname_kld
+#define	vfs_cache_lookup _bsd_vfs_cache_lookup
+#define	vfs_copyopt _bsd_vfs_copyopt
+#define	vfs_deallocate_syncvnode _bsd_vfs_deallocate_syncvnode
+#define	vfs_deleteopt _bsd_vfs_deleteopt
+#define	vfs_donmount _bsd_vfs_donmount
+#define	vfs_drain_busy_pages _bsd_vfs_drain_busy_pages
+#define	vfs_event_signal _bsd_vfs_event_signal
+#define	vfs_export _bsd_vfs_export
+#define	vfs_filteropt _bsd_vfs_filteropt
+#define	vfs_flagopt _bsd_vfs_flagopt
+#define	vfs_freeopts _bsd_vfs_freeopts
+#define	vfs_getnewfsid _bsd_vfs_getnewfsid
+#define	vfs_getopt _bsd_vfs_getopt
+#define	vfs_getopt_pos _bsd_vfs_getopt_pos
+#define	vfs_getopt_size _bsd_vfs_getopt_size
+#define	vfs_getopts _bsd_vfs_getopts
+#define	vfs_getvfs _bsd_vfs_getvfs
+#define	vfs_hash_changesize _bsd_vfs_hash_changesize
+#define	vfs_hash_get _bsd_vfs_hash_get
+#define	vfs_hash_index _bsd_vfs_hash_index
+#define	vfs_hash_insert _bsd_vfs_hash_insert
+#define	vfs_hash_ref _bsd_vfs_hash_ref
+#define	vfs_hash_rehash _bsd_vfs_hash_rehash
+#define	vfs_hash_remove _bsd_vfs_hash_remove
+#define	vfs_kqfilter _bsd_vfs_kqfilter
+#define	vfs_mark_atime _bsd_vfs_mark_atime
+#define	vfs_modevent _bsd_vfs_modevent
+#define	vfs_mount_alloc _bsd_vfs_mount_alloc
+#define	vfs_mount_destroy _bsd_vfs_mount_destroy
+#define	vfs_mount_error _bsd_vfs_mount_error
+#define	vfs_mountedfrom _bsd_vfs_mountedfrom
+#define	vfs_msync _bsd_vfs_msync
+#define	vfs_notify_upper _bsd_vfs_notify_upper
+#define	vfs_oexport_conv _bsd_vfs_oexport_conv
+#define	vfs_opterror _bsd_vfs_opterror
+#define	vfs_read_dirent _bsd_vfs_read_dirent
+#define	vfs_ref _bsd_vfs_ref
+#define	vfs_rel _bsd_vfs_rel
+#define	vfs_scanopt _bsd_vfs_scanopt
+#define	vfs_setopt _bsd_vfs_setopt
+#define	vfs_setopt_part _bsd_vfs_setopt_part
+#define	vfs_setopts _bsd_vfs_setopts
+#define	vfs_setpublicfs _bsd_vfs_setpublicfs
+#define	vfs_stdcheckexp _bsd_vfs_stdcheckexp
+#define	vfs_stdextattrctl _bsd_vfs_stdextattrctl
+#define	vfs_stdfhtovp _bsd_vfs_stdfhtovp
+#define	vfs_stdinit _bsd_vfs_stdinit
+#define	vfs_stdnosync _bsd_vfs_stdnosync
+#define	vfs_stdquotactl _bsd_vfs_stdquotactl
+#define	vfs_stdroot _bsd_vfs_stdroot
+#define	vfs_stdstatfs _bsd_vfs_stdstatfs
+#define	vfs_stdsync _bsd_vfs_stdsync
+#define	vfs_stdsysctl _bsd_vfs_stdsysctl
+#define	vfs_stduninit _bsd_vfs_stduninit
+#define	vfs_stdvget _bsd_vfs_stdvget
+#define	vfs_suser _bsd_vfs_suser
+#define	vfs_timestamp _bsd_vfs_timestamp
+#define	vfs_unbusy _bsd_vfs_unbusy
+#define	vfs_unbusy_pages _bsd_vfs_unbusy_pages
+#define	vfs_unixify_accmode _bsd_vfs_unixify_accmode
+#define	vfs_unmountall _bsd_vfs_unmountall
+#define	vfs_write_resume _bsd_vfs_write_resume
+#define	vfs_write_suspend _bsd_vfs_write_suspend
+#define	vfs_write_suspend_umnt _bsd_vfs_write_suspend_umnt
+#define	vfsconf _bsd_vfsconf
+#define	vfsconf_sx _bsd_vfsconf_sx
+#define	vget _bsd_vget
+#define	vgone _bsd_vgone
 #define	vht80_chan_ranges _bsd_vht80_chan_ranges
 #define	vid_allocate _bsd_vid_allocate
 #define	vid_configure _bsd_vid_configure
@@ -5787,6 +6363,8 @@
 #define	videomode_count _bsd_videomode_count
 #define	videomode_list _bsd_videomode_list
 #define	vidsw _bsd_vidsw
+#define	vinactive _bsd_vinactive
+#define	vinvalbuf _bsd_vinvalbuf
 #define	vlan_cookie_p _bsd_vlan_cookie_p
 #define	vlan_devat_p _bsd_vlan_devat_p
 #define	vlan_input_p _bsd_vlan_input_p
@@ -5798,11 +6376,125 @@
 #define	vlan_trunk_cap_p _bsd_vlan_trunk_cap_p
 #define	vlan_trunkdev_p _bsd_vlan_trunkdev_p
 #define	vlog _bsd_vlog
+#define	vm_cnt _bsd_vm_cnt
+#define	vm_pager_bufferinit _bsd_vm_pager_bufferinit
+#define	vmapbuf _bsd_vmapbuf
+#define	vmem_alloc _bsd_vmem_alloc
+#define	vmem_free _bsd_vmem_free
+#define	vmiodirenable _bsd_vmiodirenable
+#define	vn_bmap_seekhole _bsd_vn_bmap_seekhole
+#define	vn_chmod _bsd_vn_chmod
+#define	vn_chown _bsd_vn_chown
+#define	vn_close _bsd_vn_close
+#define	vn_commname _bsd_vn_commname
+#define	vn_dir_check_exec _bsd_vn_dir_check_exec
+#define	vn_dir_dd_ino _bsd_vn_dir_dd_ino
+#define	vn_extattr_get _bsd_vn_extattr_get
+#define	vn_extattr_rm _bsd_vn_extattr_rm
+#define	vn_extattr_set _bsd_vn_extattr_set
+#define	vn_fill_kinfo _bsd_vn_fill_kinfo
+#define	vn_fill_kinfo_vnode _bsd_vn_fill_kinfo_vnode
+#define	vn_finished_secondary_write _bsd_vn_finished_secondary_write
+#define	vn_finished_write _bsd_vn_finished_write
+#define	vn_fsid _bsd_vn_fsid
+#define	vn_fsync_buf _bsd_vn_fsync_buf
+#define	vn_fullpath _bsd_vn_fullpath
+#define	vn_fullpath_global _bsd_vn_fullpath_global
+#define	vn_io_fault_pgmove _bsd_vn_io_fault_pgmove
+#define	vn_io_fault_uiomove _bsd_vn_io_fault_uiomove
+#define	vn_isdisk _bsd_vn_isdisk
+#define	vn_open _bsd_vn_open
+#define	vn_open_cred _bsd_vn_open_cred
+#define	vn_open_vnode _bsd_vn_open_vnode
+#define	vn_pages_remove _bsd_vn_pages_remove
+#define	vn_path_to_global_path _bsd_vn_path_to_global_path
+#define	vn_pollrecord _bsd_vn_pollrecord
+#define	vn_printf _bsd_vn_printf
+#define	vn_rdwr _bsd_vn_rdwr
+#define	vn_rdwr_inchunks _bsd_vn_rdwr_inchunks
+#define	vn_rlimit_fsize _bsd_vn_rlimit_fsize
+#define	vn_seek _bsd_vn_seek
+#define	vn_start_secondary_write _bsd_vn_start_secondary_write
+#define	vn_start_write _bsd_vn_start_write
+#define	vn_stat _bsd_vn_stat
+#define	vn_utimes_perm _bsd_vn_utimes_perm
+#define	vn_vget_ino _bsd_vn_vget_ino
+#define	vn_vget_ino_gen _bsd_vn_vget_ino_gen
+#define	vn_vptocnp _bsd_vn_vptocnp
+#define	vn_writechk _bsd_vn_writechk
 #define	vnet_if_clone_init _bsd_vnet_if_clone_init
+#define	vnlru_free _bsd_vnlru_free
+#define	vnops _bsd_vnops
+#define	vntype_to_kinfo _bsd_vntype_to_kinfo
+#define	vop_close_post _bsd_vop_close_post
+#define	vop_create_post _bsd_vop_create_post
+#define	vop_deleteextattr_post _bsd_vop_deleteextattr_post
+#define	vop_ebadf _bsd_vop_ebadf
+#define	vop_einval _bsd_vop_einval
+#define	vop_enoent _bsd_vop_enoent
+#define	vop_enotty _bsd_vop_enotty
+#define	vop_eopnotsupp _bsd_vop_eopnotsupp
+#define	vop_link_post _bsd_vop_link_post
+#define	vop_mkdir_post _bsd_vop_mkdir_post
+#define	vop_mknod_post _bsd_vop_mknod_post
+#define	vop_nopoll _bsd_vop_nopoll
+#define	vop_null _bsd_vop_null
+#define	vop_open_post _bsd_vop_open_post
+#define	vop_panic _bsd_vop_panic
+#define	vop_read_post _bsd_vop_read_post
+#define	vop_readdir_post _bsd_vop_readdir_post
+#define	vop_reclaim_post _bsd_vop_reclaim_post
+#define	vop_remove_post _bsd_vop_remove_post
+#define	vop_rename_fail _bsd_vop_rename_fail
+#define	vop_rename_post _bsd_vop_rename_post
+#define	vop_rename_pre _bsd_vop_rename_pre
+#define	vop_rmdir_post _bsd_vop_rmdir_post
+#define	vop_setattr_post _bsd_vop_setattr_post
+#define	vop_setextattr_post _bsd_vop_setextattr_post
+#define	vop_stdaccess _bsd_vop_stdaccess
+#define	vop_stdaccessx _bsd_vop_stdaccessx
+#define	vop_stdadvise _bsd_vop_stdadvise
+#define	vop_stdadvlock _bsd_vop_stdadvlock
+#define	vop_stdadvlockasync _bsd_vop_stdadvlockasync
+#define	vop_stdadvlockpurge _bsd_vop_stdadvlockpurge
+#define	vop_stdallocate _bsd_vop_stdallocate
+#define	vop_stdbmap _bsd_vop_stdbmap
+#define	vop_stdfdatasync_buf _bsd_vop_stdfdatasync_buf
+#define	vop_stdfsync _bsd_vop_stdfsync
+#define	vop_stdgetpages _bsd_vop_stdgetpages
+#define	vop_stdgetwritemount _bsd_vop_stdgetwritemount
+#define	vop_stdislocked _bsd_vop_stdislocked
+#define	vop_stdkqfilter _bsd_vop_stdkqfilter
+#define	vop_stdlock _bsd_vop_stdlock
+#define	vop_stdpathconf _bsd_vop_stdpathconf
+#define	vop_stdpoll _bsd_vop_stdpoll
+#define	vop_stdputpages _bsd_vop_stdputpages
+#define	vop_stdset_text _bsd_vop_stdset_text
+#define	vop_stdunlock _bsd_vop_stdunlock
+#define	vop_stdunp_bind _bsd_vop_stdunp_bind
+#define	vop_stdunp_connect _bsd_vop_stdunp_connect
+#define	vop_stdunp_detach _bsd_vop_stdunp_detach
+#define	vop_stdvptocnp _bsd_vop_stdvptocnp
+#define	vop_stdvptofh _bsd_vop_stdvptofh
+#define	vop_symlink_post _bsd_vop_symlink_post
 #define	vprintf _bsd_vprintf
+#define	vput _bsd_vput
+#define	vrecycle _bsd_vrecycle
+#define	vrecyclel _bsd_vrecyclel
+#define	vref _bsd_vref
+#define	vrefact _bsd_vrefact
+#define	vrefcnt _bsd_vrefcnt
+#define	vrefl _bsd_vrefl
+#define	vrele _bsd_vrele
 #define	vsnprintf _bsd_vsnprintf
 #define	vsnrprintf _bsd_vsnrprintf
 #define	vsprintf _bsd_vsprintf
+#define	vtprintf _bsd_vtprintf
+#define	vtruncbuf _bsd_vtruncbuf
+#define	vttoif_tab _bsd_vttoif_tab
+#define	vunmapbuf _bsd_vunmapbuf
+#define	vunref _bsd_vunref
+#define	waitrunningbufspace _bsd_waitrunningbufspace
 #define	wakeup _bsd_wakeup
 #define	wakeup_any _bsd_wakeup_any
 #define	wakeup_one _bsd_wakeup_one
diff --git a/rtemsbsd/include/machine/rtems-bsd-kernel-space.h b/rtemsbsd/include/machine/rtems-bsd-kernel-space.h
index 09bcecf1..37bd701d 100644
--- a/rtemsbsd/include/machine/rtems-bsd-kernel-space.h
+++ b/rtemsbsd/include/machine/rtems-bsd-kernel-space.h
@@ -3,10 +3,12 @@
  *
  * @ingroup rtems_bsd_machine
  *
- * @brief TODO.
+ * @brief RTEMS FreeBSD Kernel related machine settings and defines
  */
 
 /*
+ * Copyright (c) 2020-2021 Chris Johns <chrisj@rtems.org>.  All rights reserved.
+ *
  * Copyright (c) 2009-2013 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
@@ -40,23 +42,82 @@
 #ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_KERNEL_SPACE_H_
 #define _RTEMS_BSD_MACHINE_RTEMS_BSD_KERNEL_SPACE_H_
 
-/* FIXME: Update Newlib */
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * FreeBSD warning control
+ */
+#pragma GCC diagnostic ignored "-Wunused-function"
+#pragma GCC diagnostic ignored "-Wunused-value"
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-const-variable"
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+
+/* FIXME: start: Update Newlib */
 #define MSIZE 256
 
-/* FIXME: Update Newlib */
 #define	__GLOBL1(sym)	__asm__(".globl " #sym)
 #define	__GLOBL(sym)	__GLOBL1(sym)
 
 #define O_CLOEXEC 0
-#define IO_NDELAY O_NONBLOCK
+
+/* FIXME: end: Update Newlib */
+
+#define FSEARCH O_SEARCH
+#define O_FSYNC FSYNC
+
+#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FNONBLOCK|O_DIRECT)
+#define FCNTLFLAGS (FAPPEND|FASYNC|FNONBLOCK|O_DIRECT)
+#define FHASLOCK 0
+
+#define PIPE_NODIRECT
+
+#define SEEK_DATA               3       /* set file offset to next data past offset */
+#define SEEK_HOLE               4       /* set file offset to next hole past offset */
+#define L_SET                   SEEK_SET
+#define L_INCR                  SEEK_CUR
+#define L_XTND                  SEEK_END
+#define O_FSYNC                 FSYNC
+#define O_SHLOCK                FSHLOCK
+#define O_EXLOCK                FEXLOCK
+#define POSIX_FADV_NORMAL       0       /* no special treatment */
+#define POSIX_FADV_RANDOM       1       /* expect random page references */
+#define POSIX_FADV_SEQUENTIAL   2       /* expect sequential page references */
+#define POSIX_FADV_WILLNEED     3       /* will need these pages */
+#define POSIX_FADV_DONTNEED     4       /* dont need these pages */
+#define POSIX_FADV_NOREUSE      5       /* access data only once */
+
+/* Used in NFS common code */
+#define __LINUX_ERRNO_EXTENSIONS__ 1
 
 #define __FreeBSD__ 1
 
 /* General define to activate BSD kernel parts */
 #define _KERNEL 1
 
+/*
+ * Various developer tracing options. See waf --help and --freebsd-options.
+ */
+#ifndef RTEMS_BSD_DESCRIP_TRACE
+  #define RTEMS_BSD_DESCRIP_TRACE (0)
+#endif
+#ifndef RTEMS_BSD_SYSCALL_TRACE
+  #define RTEMS_BSD_SYSCALL_TRACE (0)
+#endif
+#ifndef RTEMS_BSD_VFS_TRACE
+  #define RTEMS_BSD_VFS_TRACE (0)
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
 #include <machine/rtems-bsd-version.h>
 #include <machine/rtems-bsd-kernel-namespace.h>
+#include <sys/types.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -74,6 +135,8 @@ void rtems_bsd_assert_func(const char *file, int line, const char *func, const c
 
 /* General definitions */
 
+#define MACHINE "rtems"
+
 #define MACHINE_ARCH "rtems"
 
 #define M_RTEMS_HEAP 0
@@ -95,9 +158,92 @@ void rtems_bsd_assert_func(const char *file, int line, const char *func, const c
 #define	EJUSTRETURN	(-2)		/* don't modify regs, just return */
 #define	ENOIOCTL	(-3)		/* ioctl not handled by this layer */
 #define	EDIRIOCTL	(-4)		/* do direct ioctl in GEOM */
+#define ERELOOKUP       (-5)            /* retry the directory lookup */
+
+/* error codes used in the NFS code */
+#define EBADRPC         72
+#define EPROGMISMATCH   75
+#define EAUTH           80
+#define ENOTCAPABLE     93
 
 #define	EDOOFUS __ELASTERROR
 
+typedef unsigned char   u_char;
+typedef unsigned short  u_short;
+typedef unsigned int    u_int;
+typedef unsigned long   u_long;
+typedef unsigned short  ushort;         /* Sys V compatibility */
+typedef unsigned int    uint;           /* Sys V compatibility */
+
+typedef __UINT64_TYPE__ uoff_t;
+
+#define __LLONG_MAX __LONG_LONG_MAX__
+#define __OFF_MAX   __LLONG_MAX
+#define OFF_MAX     __OFF_MAX
+
+#define F_WAIT          0x010           /* Wait until lock is granted */
+#define F_FLOCK         0x020           /* Use flock(2) semantics for lock */
+#define F_POSIX         0x040           /* Use POSIX semantics for lock */
+#define F_REMOTE        0x080           /* Lock owner is remote NFS client */
+#define F_NOINTR        0x100           /* Ignore signals when waiting */
+
+#define _PC_ACL_EXTENDED        59
+#define _PC_ACL_PATH_MAX        60
+#define _PC_CAP_PRESENT         61
+#define _PC_INF_PRESENT         62
+#define _PC_MAC_PRESENT         63
+#define _PC_ACL_NFS4            64
+
+#define FFLAGS(oflags)  ((oflags) + 1)
+#define OFLAGS(fflags)  ((fflags) - 1)
+
+#define buffer_arena NULL
+extern struct vmem *rtems_bsd_transient_arena;
+#define transient_arena rtems_bsd_transient_arena
+
+struct uma_zone;
+extern struct uma_zone* ncl_pbuf_zone;
+struct uma_zone* pbuf_zsecond_create(char *name, int max);
+
+/*
+ * Device dev_t handling
+ */
+int rtems_bsd__major(dev_t _d);
+int rtems_bsd__minor(dev_t _d);
+dev_t rtems_bsd__makedev(int _M, int _m);
+#define major(d)        rtems_bsd__major(d)
+#define minor(d)        rtems_bsd__minor(d)
+#define makedev(M, m)   rtems_bsd__makedev((M), (m))
+
+/*
+ * VM, avoid bringing the headers across
+ */
+#define VM_OBJECT_WLOCK(object)
+#define VM_OBJECT_WUNLOCK(object)
+
+/*
+ * From freebsd-oirg/sys/sys/dirent.h
+ */
+#define _GENERIC_DIRLEN(namlen)                                 \
+        ((__offsetof(struct dirent, d_name) + (namlen) + 1 + 7) & ~7)
+#define _GENERIC_DIRSIZ(dp)     _GENERIC_DIRLEN((dp)->d_namlen)
+
+/*
+ * From signalvar.h
+ */
+#define SIGISMEMBER(set, signo) (0)
+
+/*
+ * Special knote status bit to indicate the kn_fp is an iop.
+ */
+#define KN_FP_IS_IOP       0x10000000
+
+/*
+ * Ensure that padding bytes are zeroed and that the name is NUL-terminated.
+ */
+struct dirent;
+void dirent_terminate(struct dirent *dp);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/rtemsbsd/include/machine/rtems-bsd-libio.h b/rtemsbsd/include/machine/rtems-bsd-libio.h
new file mode 100644
index 00000000..918164a7
--- /dev/null
+++ b/rtemsbsd/include/machine/rtems-bsd-libio.h
@@ -0,0 +1,330 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_machine
+ *
+ * @brief LibIO interface for FreeBSD filedesc.
+ */
+
+/*
+ * Copyright (c) 2020 Chrs Johns.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_LIBIO_H_
+#define _RTEMS_BSD_MACHINE_RTEMS_BSD_LIBIO_H_
+
+#include <stdint.h>
+#include <sys/event.h>
+#include <sys/fcntl.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/proc.h>
+
+#include <rtems/libio.h>
+#include <rtems/libio_.h>
+#include <rtems/seterr.h>
+
+#include <machine/rtems-bsd-vfs.h>
+
+struct rtems_bsd_vfs_loc;
+
+extern const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_nodeops;
+extern const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_imfsnodeops;
+extern const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_dirops;
+extern const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_fileops;
+
+static int inline
+rtems_bsd_error_to_status_and_errno(int error)
+{
+  if (error == 0) {
+    return 0;
+  } else {
+    rtems_set_errno_and_return_minus_one(error);
+  }
+}
+
+static inline uint32_t
+rtems_bsd_libio_fflag_to_flags(u_int fflag)
+{
+  uint32_t libio_flags = 0;
+
+  if ((fflag & FREAD) == FREAD) {
+    libio_flags |= LIBIO_FLAGS_READ;
+  }
+
+  if ((fflag & FWRITE) == FWRITE) {
+    libio_flags |= LIBIO_FLAGS_WRITE;
+  }
+
+  if ((fflag & FNONBLOCK) == FNONBLOCK) {
+    libio_flags |= LIBIO_FLAGS_NO_DELAY;
+  }
+
+  return (libio_flags);
+}
+
+static inline u_int
+rtems_bsd_libio_flags_to_fflag(uint32_t libio_flags)
+{
+  u_int fflag = 0;
+
+  if ((libio_flags & LIBIO_FLAGS_READ) == LIBIO_FLAGS_READ) {
+    fflag |= FREAD;
+  }
+
+  if ((libio_flags & LIBIO_FLAGS_WRITE) == LIBIO_FLAGS_WRITE) {
+    fflag |= FWRITE;
+  }
+
+  if ((libio_flags & LIBIO_FLAGS_NO_DELAY) == LIBIO_FLAGS_NO_DELAY) {
+    fflag |= FNONBLOCK;
+  }
+
+  return (fflag);
+}
+
+static inline bool
+rtems_bsd_is_libbsd_nvops(rtems_libio_t* iop) {
+  return (iop->pathinfo.handlers == &rtems_bsd_sysgen_dirops ||
+          iop->pathinfo.handlers == &rtems_bsd_sysgen_fileops);
+}
+
+static inline bool
+rtems_bsd_is_libbsd_descriptor(rtems_libio_t* iop) {
+  return (iop->pathinfo.handlers == &rtems_bsd_sysgen_nodeops ||
+          rtems_bsd_is_libbsd_nvops(iop));
+}
+
+static inline rtems_libio_t*
+rtems_bsd_libio_loc_to_iop(const rtems_filesystem_location_info_t* loc)
+{
+  return (rtems_libio_t*)
+    RTEMS_DECONST(rtems_filesystem_location_info_t*, loc)->node_access;
+}
+
+struct socket;
+
+static inline struct socket*
+rtems_bsd_libio_imfs_loc_to_so(const rtems_filesystem_location_info_t* loc)
+{
+  return (struct socket*)
+    RTEMS_DECONST(rtems_filesystem_location_info_t*, loc)->node_access_2;
+}
+
+static struct vnode*
+rtems_bsd_libio_loc_to_vnode(const rtems_filesystem_location_info_t* loc)
+{
+  return (struct vnode*)
+    RTEMS_DECONST(rtems_filesystem_location_info_t*, loc)->node_access;
+}
+
+static struct vnode*
+rtems_bsd_libio_loc_to_vnode_dir(const rtems_filesystem_location_info_t* loc)
+{
+  return (struct vnode*)
+    RTEMS_DECONST(rtems_filesystem_location_info_t*, loc)->node_access_2;
+}
+
+static inline void
+rtems_bsd_libio_iop_free(rtems_libio_t *iop)
+{
+  rtems_libio_free(iop);
+}
+
+static int
+rtems_bsd_libio_iop_to_descriptor(rtems_libio_t* iop)
+{
+  return (int) iop->data0;
+}
+
+static struct vnode*
+rtems_bsd_libio_iop_to_vnode(rtems_libio_t* iop)
+{
+  return rtems_bsd_libio_loc_to_vnode(&iop->pathinfo);
+}
+
+static int
+rtems_bsd_libio_fd_to_descriptor(int fd)
+{
+  return rtems_bsd_libio_iop_to_descriptor(rtems_libio_iop(fd));
+}
+
+static inline struct file *
+rtems_bsd_libio_iop_to_file_hold(rtems_libio_t *iop, struct thread *td)
+{
+  struct file *fp;
+  int error = fget_unlocked(td->td_proc->p_fd,
+                            rtems_bsd_libio_iop_to_descriptor(iop),
+                            NULL,
+                            &fp,
+                            NULL);
+  if (error != 0) {
+    fp = NULL;
+  }
+  return fp;
+}
+
+static inline int
+rtems_bsd_file_to_libio_fd(struct file *fp)
+{
+  return fp->f_io - rtems_libio_iops;
+}
+
+static inline void
+rtems_bsd_libio_iop_set_bsd_descriptor(rtems_libio_t *iop, int fd)
+{
+  iop->data0 = fd;
+  /* if not vnops the fstat passes a loc, need to get the iop to get the fp */
+  if (!rtems_bsd_is_libbsd_nvops(iop)) {
+    iop->pathinfo.node_access = iop;
+  }
+}
+
+static inline void
+rtems_bsd_libio_iop_set_bsd_file(rtems_libio_t *iop, struct file * fp)
+{
+  fp->f_io = iop;
+}
+
+/*
+ * The fd is a libio file descriptor.
+ *
+ * Return -1 if the descriptor is closed or not valid. The descriptor is not held.
+ *
+ * If open hold the descriptor. If the descriptor referneces a BSD
+ * descriptor return the BSD descriptor else return the libio descriptor.
+ *
+ * Optionally return the iop in *iopp if the descriptor if a libio descriptor
+ * else return NULL.
+ */
+static inline int
+rtems_bsd_libio_iop_hold(int fd, rtems_libio_t** iopp)
+{
+  rtems_libio_t *iop = NULL;
+  unsigned int flags = 0;
+  int ffd = -1;
+  if (fd < rtems_libio_number_iops) {
+    iop = rtems_libio_iop(fd);
+    flags = rtems_libio_iop_hold(iop);
+    if ((flags & LIBIO_FLAGS_OPEN) != 0) {
+      if (rtems_bsd_is_libbsd_descriptor(iop)) {
+        ffd = rtems_bsd_libio_iop_to_descriptor(iop);
+        if (iopp != NULL) {
+          *iopp = NULL;
+        }
+      } else {
+        ffd = fd;
+        if (iopp != NULL) {
+          *iopp = iop;
+        }
+      }
+    }
+    else {
+      rtems_libio_iop_drop(iop);
+    }
+    if (RTEMS_BSD_DESCRIP_TRACE)
+      flags = iop->flags;
+  } else {
+    *iopp = NULL;
+  }
+  if (RTEMS_BSD_DESCRIP_TRACE)
+    printf("bsd: iop: hold: fd=%d ffd=%d refs=%d iop=%p by %p\n",
+           fd, ffd, flags >> 12, iop, __builtin_return_address(0));
+  return ffd;
+}
+
+static inline int
+rtems_bsd_libio_iop_drop(int fd)
+{
+  if (RTEMS_BSD_DESCRIP_TRACE)
+    printf("bsd: iop: drop: fd=%d refs=%d by %p\n",
+           fd, rtems_libio_iop(fd)->flags >> 12, __builtin_return_address(0));
+  rtems_libio_iop_drop(rtems_libio_iop(fd));
+  return 0;
+}
+
+static inline int
+rtems_bsd_libio_fo_poll(int fd, struct file *fp, int events,
+                        struct ucred *active_cred, struct thread *td)
+{
+  int error;
+  if (fp == NULL) {
+    rtems_libio_t *iop = rtems_libio_iop(fd);
+    error = (*iop->pathinfo.handlers->poll_h)(iop, events);
+  } else {
+    error = (*fp->f_ops->fo_poll)(fp, events, active_cred, td);
+    fd = rtems_bsd_file_to_libio_fd(fp);
+  }
+  rtems_bsd_libio_iop_drop(fd);
+  return error;
+}
+
+
+static inline void
+rtems_bsd_libio_iop_to_knote(struct knote *kn, rtems_libio_t *iop)
+{
+  kn->kn_fp = (struct file*) iop;
+}
+
+static inline struct kqueue*
+rtems_bsd_libio_knote_to_kq(struct knote *kn)
+{
+  struct kqueue *kq = kn->kn_kq;
+  if ((kn->kn_status & KN_FP_IS_IOP) == 0) {
+    if (kq != kn->kn_fp->f_data)
+      panic("libio kq wrong\n");
+  }
+  return kq;
+}
+
+
+/*
+ * Returns an iop with null file system mount or NULL is ENFILE.
+ */
+rtems_libio_t* rtems_bsd_libio_iop_allocate(void);
+
+/*
+ * Returns the libio descriptor or -1 if ENFILE.
+ */
+int rtems_bsd_libio_iop_allocate_with_file(struct thread *td,
+                                           int fd,
+                                           const rtems_filesystem_file_handlers_r* ops);
+
+/*
+ * Set the BSD file descriptor in the iop. Returns 0 if successful or an error number,
+ */
+int rtems_bsd_libio_iop_set_bsd_fd(struct thread *td,
+                                   int fd,
+                                   rtems_libio_t *iop,
+                                   const rtems_filesystem_file_handlers_r* ops);
+
+/*
+ * Set the vnode in the libio location.
+ */
+void rtems_bsd_libio_loc_set_vnode(rtems_filesystem_location_info_t *loc,
+                                   struct vnode *vn);
+void rtems_bsd_libio_loc_set_vnode_dir(rtems_filesystem_location_info_t *loc,
+                                       struct vnode *dvn);
+
+#endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_LIBIO_H_ */
diff --git a/rtemsbsd/include/machine/rtems-bsd-page.h b/rtemsbsd/include/machine/rtems-bsd-page.h
index b732c1a9..bed33b4a 100644
--- a/rtemsbsd/include/machine/rtems-bsd-page.h
+++ b/rtemsbsd/include/machine/rtems-bsd-page.h
@@ -61,6 +61,8 @@ void *rtems_bsd_page_alloc(uintptr_t size_in_bytes, int wait);
 
 void rtems_bsd_page_free(void *addr);
 
+void vm_pager_bufferinit(void);
+
 static inline void **
 rtems_bsd_page_get_object_entry(void *addr)
 {
diff --git a/rtemsbsd/include/machine/rtems-bsd-vfs.h b/rtemsbsd/include/machine/rtems-bsd-vfs.h
new file mode 100644
index 00000000..44745b39
--- /dev/null
+++ b/rtemsbsd/include/machine/rtems-bsd-vfs.h
@@ -0,0 +1,89 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_machine
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (C) 2020 Chris Johns <chris@contemporary.software>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_VFS_H_
+#define _RTEMS_BSD_MACHINE_RTEMS_BSD_VFS_H_
+
+#include <rtems/libio.h>
+
+extern const rtems_filesystem_operations_table rtems_bsd_vfsops;
+
+int rtems_bsd_vfs_mount_init(rtems_filesystem_mount_table_entry_t *mt_entry);
+
+void rtems_bsd_vfs_mt_entry_lock(const rtems_filesystem_mount_table_entry_t *mt_entry);
+void rtems_bsd_vfs_mt_entry_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry);
+void rtems_bsd_vfs_eval_path(rtems_filesystem_eval_path_context_t *ctx);
+bool rtems_bsd_vfs_are_nodes_equal(const rtems_filesystem_location_info_t *a,
+				   const rtems_filesystem_location_info_t *b);
+int rtems_bsd_vfs_link(const rtems_filesystem_location_info_t *parentloc,
+		       const rtems_filesystem_location_info_t *targetloc,
+		       const char *name,
+		       size_t namelen);
+int rtems_bsd_vfs_fchmod(const rtems_filesystem_location_info_t *loc, mode_t mode);
+int rtems_bsd_vfs_chown(const rtems_filesystem_location_info_t *loc,
+			uid_t owner,
+			gid_t group);
+int rtems_bsd_vfs_clonenode(rtems_filesystem_location_info_t *loc);
+void rtems_bsd_vfs_freenode(const rtems_filesystem_location_info_t *loc);
+int rtems_bsd_vfs_mount(rtems_filesystem_mount_table_entry_t *mt_entry);
+int rtems_bsd_vfs_fsmount_me(rtems_filesystem_mount_table_entry_t *mt_entry,
+			     const void *data);
+int rtems_bsd_vfs_unmount(rtems_filesystem_mount_table_entry_t *mt_entry);
+void rtems_bsd_vfs_fsunmount_me(rtems_filesystem_mount_table_entry_t *mt_entry);
+int rtems_bsd_vfs_mknod(const rtems_filesystem_location_info_t *parentloc,
+			const char *name,
+			size_t namelen,
+			mode_t mode,
+			dev_t dev);
+int rtems_bsd_vfs_rmnod(const rtems_filesystem_location_info_t *parentloc,
+			const rtems_filesystem_location_info_t *loc);
+int rtems_bsd_vfs_utimens(const rtems_filesystem_location_info_t *loc,
+			  time_t actime,
+			  time_t modtime);
+int rtems_bsd_vfs_symlink(const rtems_filesystem_location_info_t *parentloc,
+			  const char *name,
+			  size_t namelen,
+			  const char *target);
+ssize_t rtems_bsd_vfs_readlink(const rtems_filesystem_location_info_t *loc,
+			       char *buf,
+			       size_t bufsize);
+int rtems_bsd_vfs_rename(const rtems_filesystem_location_info_t *oldparentloc,
+			 const rtems_filesystem_location_info_t *oldloc,
+			 const rtems_filesystem_location_info_t *newparentloc,
+			 const char *name,
+			 size_t namelen);
+int rtems_bsd_vfs_statvfs(const rtems_filesystem_location_info_t *loc,
+			  struct statvfs *buf);
+
+#endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_VFS_H_ */
diff --git a/rtemsbsd/include/rtems/bsd/bsd.h b/rtemsbsd/include/rtems/bsd/bsd.h
index cec14ac4..d5decbf2 100755
--- a/rtemsbsd/include/rtems/bsd/bsd.h
+++ b/rtemsbsd/include/rtems/bsd/bsd.h
@@ -58,6 +58,12 @@ extern "C" {
  */
 #define RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT (8 * 1024 * 1024)
 
+/*
+ * The default block IO buffer memory size. Do not change, use
+ * RTEMS_BSD_CONFIG_DOMAIN_BIO_SIZE to override for your application.
+ */
+#define RTEMS_BSD_ALLOCATOR_DOMAIN_BIO_DEFAULT (4 * 1024 * 1024)
+
 typedef enum {
 	RTEMS_BSD_RES_IRQ = 1,
 	RTEMS_BSD_RES_MEMORY = 3
@@ -165,6 +171,7 @@ size_t rtems_bsd_get_task_stack_size(const char *name);
 typedef enum {
 	RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE,
 	RTEMS_BSD_ALLOCATOR_DOMAIN_MBUF,
+	RTEMS_BSD_ALLOCATOR_DOMAIN_BIO,
 	RTEMS_BSD_ALLOCATOR_DOMAIN_MALLOC
 } rtems_bsd_allocator_domain;
 
@@ -175,6 +182,13 @@ typedef enum {
  */
 extern uintptr_t rtems_bsd_allocator_domain_page_mbuf_size;
 
+/**
+ * @brief The size for the block IO default buffer memory.
+ *
+ * Applications may set this value to change the value returned by the default.
+ */
+extern uintptr_t rtems_bsd_allocator_domain_bio_size;
+
 /**
  * @brief Returns the size for a specific allocator domain.
  *
diff --git a/rtemsbsd/include/rtems/bsd/local/opt_pseudofs.h b/rtemsbsd/include/rtems/bsd/local/opt_pseudofs.h
new file mode 100644
index 00000000..e69de29b
diff --git a/rtemsbsd/include/rtems/bsd/local/opt_swap.h b/rtemsbsd/include/rtems/bsd/local/opt_swap.h
new file mode 100644
index 00000000..e69de29b
diff --git a/rtemsbsd/include/rtems/bsd/local/opt_watchdog.h b/rtemsbsd/include/rtems/bsd/local/opt_watchdog.h
new file mode 100644
index 00000000..e69de29b
diff --git a/rtemsbsd/include/rtems/bsd/local/vnode_if.h b/rtemsbsd/include/rtems/bsd/local/vnode_if.h
new file mode 100644
index 00000000..62b3e340
--- /dev/null
+++ b/rtemsbsd/include/rtems/bsd/local/vnode_if.h
@@ -0,0 +1,1951 @@
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from $FreeBSD$
+ */
+
+extern struct vnodeop_desc vop_default_desc;
+#include "vnode_if_typedef.h"
+#include "vnode_if_newproto.h"
+struct vop_islocked_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_islocked_desc;
+
+int VOP_ISLOCKED_AP(struct vop_islocked_args *);
+int VOP_ISLOCKED_APV(struct vop_vector *vop, struct vop_islocked_args *);
+
+static __inline int VOP_ISLOCKED(
+	struct vnode *vp)
+{
+	struct vop_islocked_args a;
+
+	a.a_gen.a_desc = &vop_islocked_desc;
+	a.a_vp = vp;
+	return (VOP_ISLOCKED_APV(vp->v_op, &a));
+}
+
+struct vop_lookup_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_dvp;
+	struct vnode **a_vpp;
+	struct componentname *a_cnp;
+};
+
+extern struct vnodeop_desc vop_lookup_desc;
+
+int VOP_LOOKUP_AP(struct vop_lookup_args *);
+int VOP_LOOKUP_APV(struct vop_vector *vop, struct vop_lookup_args *);
+
+static __inline int VOP_LOOKUP(
+	struct vnode *dvp,
+	struct vnode **vpp,
+	struct componentname *cnp)
+{
+	struct vop_lookup_args a;
+
+	a.a_gen.a_desc = &vop_lookup_desc;
+	a.a_dvp = dvp;
+	a.a_vpp = vpp;
+	a.a_cnp = cnp;
+	return (VOP_LOOKUP_APV(dvp->v_op, &a));
+}
+
+struct vop_cachedlookup_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_dvp;
+	struct vnode **a_vpp;
+	struct componentname *a_cnp;
+};
+
+extern struct vnodeop_desc vop_cachedlookup_desc;
+
+int VOP_CACHEDLOOKUP_AP(struct vop_cachedlookup_args *);
+int VOP_CACHEDLOOKUP_APV(struct vop_vector *vop, struct vop_cachedlookup_args *);
+
+static __inline int VOP_CACHEDLOOKUP(
+	struct vnode *dvp,
+	struct vnode **vpp,
+	struct componentname *cnp)
+{
+	struct vop_cachedlookup_args a;
+
+	a.a_gen.a_desc = &vop_cachedlookup_desc;
+	a.a_dvp = dvp;
+	a.a_vpp = vpp;
+	a.a_cnp = cnp;
+	return (VOP_CACHEDLOOKUP_APV(dvp->v_op, &a));
+}
+
+struct vop_create_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_dvp;
+	struct vnode **a_vpp;
+	struct componentname *a_cnp;
+	struct vattr *a_vap;
+};
+
+extern struct vnodeop_desc vop_create_desc;
+
+int VOP_CREATE_AP(struct vop_create_args *);
+int VOP_CREATE_APV(struct vop_vector *vop, struct vop_create_args *);
+
+static __inline int VOP_CREATE(
+	struct vnode *dvp,
+	struct vnode **vpp,
+	struct componentname *cnp,
+	struct vattr *vap)
+{
+	struct vop_create_args a;
+
+	a.a_gen.a_desc = &vop_create_desc;
+	a.a_dvp = dvp;
+	a.a_vpp = vpp;
+	a.a_cnp = cnp;
+	a.a_vap = vap;
+	return (VOP_CREATE_APV(dvp->v_op, &a));
+}
+
+struct vop_whiteout_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_dvp;
+	struct componentname *a_cnp;
+	int a_flags;
+};
+
+extern struct vnodeop_desc vop_whiteout_desc;
+
+int VOP_WHITEOUT_AP(struct vop_whiteout_args *);
+int VOP_WHITEOUT_APV(struct vop_vector *vop, struct vop_whiteout_args *);
+
+static __inline int VOP_WHITEOUT(
+	struct vnode *dvp,
+	struct componentname *cnp,
+	int flags)
+{
+	struct vop_whiteout_args a;
+
+	a.a_gen.a_desc = &vop_whiteout_desc;
+	a.a_dvp = dvp;
+	a.a_cnp = cnp;
+	a.a_flags = flags;
+	return (VOP_WHITEOUT_APV(dvp->v_op, &a));
+}
+
+struct vop_mknod_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_dvp;
+	struct vnode **a_vpp;
+	struct componentname *a_cnp;
+	struct vattr *a_vap;
+};
+
+extern struct vnodeop_desc vop_mknod_desc;
+
+int VOP_MKNOD_AP(struct vop_mknod_args *);
+int VOP_MKNOD_APV(struct vop_vector *vop, struct vop_mknod_args *);
+
+static __inline int VOP_MKNOD(
+	struct vnode *dvp,
+	struct vnode **vpp,
+	struct componentname *cnp,
+	struct vattr *vap)
+{
+	struct vop_mknod_args a;
+
+	a.a_gen.a_desc = &vop_mknod_desc;
+	a.a_dvp = dvp;
+	a.a_vpp = vpp;
+	a.a_cnp = cnp;
+	a.a_vap = vap;
+	return (VOP_MKNOD_APV(dvp->v_op, &a));
+}
+
+struct vop_open_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_mode;
+	struct ucred *a_cred;
+	struct thread *a_td;
+	struct file *a_fp;
+};
+
+extern struct vnodeop_desc vop_open_desc;
+
+int VOP_OPEN_AP(struct vop_open_args *);
+int VOP_OPEN_APV(struct vop_vector *vop, struct vop_open_args *);
+
+static __inline int VOP_OPEN(
+	struct vnode *vp,
+	int mode,
+	struct ucred *cred,
+	struct thread *td,
+	struct file *fp)
+{
+	struct vop_open_args a;
+
+	a.a_gen.a_desc = &vop_open_desc;
+	a.a_vp = vp;
+	a.a_mode = mode;
+	a.a_cred = cred;
+	a.a_td = td;
+	a.a_fp = fp;
+	return (VOP_OPEN_APV(vp->v_op, &a));
+}
+
+struct vop_close_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_fflag;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_close_desc;
+
+int VOP_CLOSE_AP(struct vop_close_args *);
+int VOP_CLOSE_APV(struct vop_vector *vop, struct vop_close_args *);
+
+static __inline int VOP_CLOSE(
+	struct vnode *vp,
+	int fflag,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_close_args a;
+
+	a.a_gen.a_desc = &vop_close_desc;
+	a.a_vp = vp;
+	a.a_fflag = fflag;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_CLOSE_APV(vp->v_op, &a));
+}
+
+struct vop_access_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	accmode_t a_accmode;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_access_desc;
+
+int VOP_ACCESS_AP(struct vop_access_args *);
+int VOP_ACCESS_APV(struct vop_vector *vop, struct vop_access_args *);
+
+static __inline int VOP_ACCESS(
+	struct vnode *vp,
+	accmode_t accmode,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_access_args a;
+
+	a.a_gen.a_desc = &vop_access_desc;
+	a.a_vp = vp;
+	a.a_accmode = accmode;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_ACCESS_APV(vp->v_op, &a));
+}
+
+struct vop_accessx_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	accmode_t a_accmode;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_accessx_desc;
+
+int VOP_ACCESSX_AP(struct vop_accessx_args *);
+int VOP_ACCESSX_APV(struct vop_vector *vop, struct vop_accessx_args *);
+
+static __inline int VOP_ACCESSX(
+	struct vnode *vp,
+	accmode_t accmode,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_accessx_args a;
+
+	a.a_gen.a_desc = &vop_accessx_desc;
+	a.a_vp = vp;
+	a.a_accmode = accmode;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_ACCESSX_APV(vp->v_op, &a));
+}
+
+struct vop_getattr_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct vattr *a_vap;
+	struct ucred *a_cred;
+};
+
+extern struct vnodeop_desc vop_getattr_desc;
+
+int VOP_GETATTR_AP(struct vop_getattr_args *);
+int VOP_GETATTR_APV(struct vop_vector *vop, struct vop_getattr_args *);
+
+static __inline int VOP_GETATTR(
+	struct vnode *vp,
+	struct vattr *vap,
+	struct ucred *cred)
+{
+	struct vop_getattr_args a;
+
+	a.a_gen.a_desc = &vop_getattr_desc;
+	a.a_vp = vp;
+	a.a_vap = vap;
+	a.a_cred = cred;
+	return (VOP_GETATTR_APV(vp->v_op, &a));
+}
+
+struct vop_setattr_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct vattr *a_vap;
+	struct ucred *a_cred;
+};
+
+extern struct vnodeop_desc vop_setattr_desc;
+
+int VOP_SETATTR_AP(struct vop_setattr_args *);
+int VOP_SETATTR_APV(struct vop_vector *vop, struct vop_setattr_args *);
+
+static __inline int VOP_SETATTR(
+	struct vnode *vp,
+	struct vattr *vap,
+	struct ucred *cred)
+{
+	struct vop_setattr_args a;
+
+	a.a_gen.a_desc = &vop_setattr_desc;
+	a.a_vp = vp;
+	a.a_vap = vap;
+	a.a_cred = cred;
+	return (VOP_SETATTR_APV(vp->v_op, &a));
+}
+
+struct vop_markatime_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_markatime_desc;
+
+int VOP_MARKATIME_AP(struct vop_markatime_args *);
+int VOP_MARKATIME_APV(struct vop_vector *vop, struct vop_markatime_args *);
+
+static __inline int VOP_MARKATIME(
+	struct vnode *vp)
+{
+	struct vop_markatime_args a;
+
+	a.a_gen.a_desc = &vop_markatime_desc;
+	a.a_vp = vp;
+	return (VOP_MARKATIME_APV(vp->v_op, &a));
+}
+
+struct vop_read_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct uio *a_uio;
+	int a_ioflag;
+	struct ucred *a_cred;
+};
+
+extern struct vnodeop_desc vop_read_desc;
+
+int VOP_READ_AP(struct vop_read_args *);
+int VOP_READ_APV(struct vop_vector *vop, struct vop_read_args *);
+
+static __inline int VOP_READ(
+	struct vnode *vp,
+	struct uio *uio,
+	int ioflag,
+	struct ucred *cred)
+{
+	struct vop_read_args a;
+
+	a.a_gen.a_desc = &vop_read_desc;
+	a.a_vp = vp;
+	a.a_uio = uio;
+	a.a_ioflag = ioflag;
+	a.a_cred = cred;
+	return (VOP_READ_APV(vp->v_op, &a));
+}
+
+struct vop_write_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct uio *a_uio;
+	int a_ioflag;
+	struct ucred *a_cred;
+};
+
+extern struct vnodeop_desc vop_write_desc;
+
+int VOP_WRITE_AP(struct vop_write_args *);
+int VOP_WRITE_APV(struct vop_vector *vop, struct vop_write_args *);
+
+static __inline int VOP_WRITE(
+	struct vnode *vp,
+	struct uio *uio,
+	int ioflag,
+	struct ucred *cred)
+{
+	struct vop_write_args a;
+
+	a.a_gen.a_desc = &vop_write_desc;
+	a.a_vp = vp;
+	a.a_uio = uio;
+	a.a_ioflag = ioflag;
+	a.a_cred = cred;
+	return (VOP_WRITE_APV(vp->v_op, &a));
+}
+
+struct vop_ioctl_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	u_long a_command;
+	void *a_data;
+	int a_fflag;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_ioctl_desc;
+
+int VOP_IOCTL_AP(struct vop_ioctl_args *);
+int VOP_IOCTL_APV(struct vop_vector *vop, struct vop_ioctl_args *);
+
+static __inline int VOP_IOCTL(
+	struct vnode *vp,
+	u_long command,
+	void *data,
+	int fflag,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_ioctl_args a;
+
+	a.a_gen.a_desc = &vop_ioctl_desc;
+	a.a_vp = vp;
+	a.a_command = command;
+	a.a_data = data;
+	a.a_fflag = fflag;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_IOCTL_APV(vp->v_op, &a));
+}
+
+struct vop_poll_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_events;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_poll_desc;
+
+int VOP_POLL_AP(struct vop_poll_args *);
+int VOP_POLL_APV(struct vop_vector *vop, struct vop_poll_args *);
+
+static __inline int VOP_POLL(
+	struct vnode *vp,
+	int events,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_poll_args a;
+
+	a.a_gen.a_desc = &vop_poll_desc;
+	a.a_vp = vp;
+	a.a_events = events;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_POLL_APV(vp->v_op, &a));
+}
+
+struct vop_kqfilter_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct knote *a_kn;
+};
+
+extern struct vnodeop_desc vop_kqfilter_desc;
+
+int VOP_KQFILTER_AP(struct vop_kqfilter_args *);
+int VOP_KQFILTER_APV(struct vop_vector *vop, struct vop_kqfilter_args *);
+
+static __inline int VOP_KQFILTER(
+	struct vnode *vp,
+	struct knote *kn)
+{
+	struct vop_kqfilter_args a;
+
+	a.a_gen.a_desc = &vop_kqfilter_desc;
+	a.a_vp = vp;
+	a.a_kn = kn;
+	return (VOP_KQFILTER_APV(vp->v_op, &a));
+}
+
+struct vop_revoke_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_flags;
+};
+
+extern struct vnodeop_desc vop_revoke_desc;
+
+int VOP_REVOKE_AP(struct vop_revoke_args *);
+int VOP_REVOKE_APV(struct vop_vector *vop, struct vop_revoke_args *);
+
+static __inline int VOP_REVOKE(
+	struct vnode *vp,
+	int flags)
+{
+	struct vop_revoke_args a;
+
+	a.a_gen.a_desc = &vop_revoke_desc;
+	a.a_vp = vp;
+	a.a_flags = flags;
+	return (VOP_REVOKE_APV(vp->v_op, &a));
+}
+
+struct vop_fsync_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_waitfor;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_fsync_desc;
+
+int VOP_FSYNC_AP(struct vop_fsync_args *);
+int VOP_FSYNC_APV(struct vop_vector *vop, struct vop_fsync_args *);
+
+static __inline int VOP_FSYNC(
+	struct vnode *vp,
+	int waitfor,
+	struct thread *td)
+{
+	struct vop_fsync_args a;
+
+	a.a_gen.a_desc = &vop_fsync_desc;
+	a.a_vp = vp;
+	a.a_waitfor = waitfor;
+	a.a_td = td;
+	return (VOP_FSYNC_APV(vp->v_op, &a));
+}
+
+struct vop_remove_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_dvp;
+	struct vnode *a_vp;
+	struct componentname *a_cnp;
+};
+
+extern struct vnodeop_desc vop_remove_desc;
+
+int VOP_REMOVE_AP(struct vop_remove_args *);
+int VOP_REMOVE_APV(struct vop_vector *vop, struct vop_remove_args *);
+
+static __inline int VOP_REMOVE(
+	struct vnode *dvp,
+	struct vnode *vp,
+	struct componentname *cnp)
+{
+	struct vop_remove_args a;
+
+	a.a_gen.a_desc = &vop_remove_desc;
+	a.a_dvp = dvp;
+	a.a_vp = vp;
+	a.a_cnp = cnp;
+	return (VOP_REMOVE_APV(dvp->v_op, &a));
+}
+
+struct vop_link_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_tdvp;
+	struct vnode *a_vp;
+	struct componentname *a_cnp;
+};
+
+extern struct vnodeop_desc vop_link_desc;
+
+int VOP_LINK_AP(struct vop_link_args *);
+int VOP_LINK_APV(struct vop_vector *vop, struct vop_link_args *);
+
+static __inline int VOP_LINK(
+	struct vnode *tdvp,
+	struct vnode *vp,
+	struct componentname *cnp)
+{
+	struct vop_link_args a;
+
+	a.a_gen.a_desc = &vop_link_desc;
+	a.a_tdvp = tdvp;
+	a.a_vp = vp;
+	a.a_cnp = cnp;
+	return (VOP_LINK_APV(tdvp->v_op, &a));
+}
+
+struct vop_rename_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_fdvp;
+	struct vnode *a_fvp;
+	struct componentname *a_fcnp;
+	struct vnode *a_tdvp;
+	struct vnode *a_tvp;
+	struct componentname *a_tcnp;
+};
+
+extern struct vnodeop_desc vop_rename_desc;
+
+int VOP_RENAME_AP(struct vop_rename_args *);
+int VOP_RENAME_APV(struct vop_vector *vop, struct vop_rename_args *);
+
+static __inline int VOP_RENAME(
+	struct vnode *fdvp,
+	struct vnode *fvp,
+	struct componentname *fcnp,
+	struct vnode *tdvp,
+	struct vnode *tvp,
+	struct componentname *tcnp)
+{
+	struct vop_rename_args a;
+
+	a.a_gen.a_desc = &vop_rename_desc;
+	a.a_fdvp = fdvp;
+	a.a_fvp = fvp;
+	a.a_fcnp = fcnp;
+	a.a_tdvp = tdvp;
+	a.a_tvp = tvp;
+	a.a_tcnp = tcnp;
+	return (VOP_RENAME_APV(fdvp->v_op, &a));
+}
+
+struct vop_mkdir_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_dvp;
+	struct vnode **a_vpp;
+	struct componentname *a_cnp;
+	struct vattr *a_vap;
+};
+
+extern struct vnodeop_desc vop_mkdir_desc;
+
+int VOP_MKDIR_AP(struct vop_mkdir_args *);
+int VOP_MKDIR_APV(struct vop_vector *vop, struct vop_mkdir_args *);
+
+static __inline int VOP_MKDIR(
+	struct vnode *dvp,
+	struct vnode **vpp,
+	struct componentname *cnp,
+	struct vattr *vap)
+{
+	struct vop_mkdir_args a;
+
+	a.a_gen.a_desc = &vop_mkdir_desc;
+	a.a_dvp = dvp;
+	a.a_vpp = vpp;
+	a.a_cnp = cnp;
+	a.a_vap = vap;
+	return (VOP_MKDIR_APV(dvp->v_op, &a));
+}
+
+struct vop_rmdir_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_dvp;
+	struct vnode *a_vp;
+	struct componentname *a_cnp;
+};
+
+extern struct vnodeop_desc vop_rmdir_desc;
+
+int VOP_RMDIR_AP(struct vop_rmdir_args *);
+int VOP_RMDIR_APV(struct vop_vector *vop, struct vop_rmdir_args *);
+
+static __inline int VOP_RMDIR(
+	struct vnode *dvp,
+	struct vnode *vp,
+	struct componentname *cnp)
+{
+	struct vop_rmdir_args a;
+
+	a.a_gen.a_desc = &vop_rmdir_desc;
+	a.a_dvp = dvp;
+	a.a_vp = vp;
+	a.a_cnp = cnp;
+	return (VOP_RMDIR_APV(dvp->v_op, &a));
+}
+
+struct vop_symlink_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_dvp;
+	struct vnode **a_vpp;
+	struct componentname *a_cnp;
+	struct vattr *a_vap;
+	char *a_target;
+};
+
+extern struct vnodeop_desc vop_symlink_desc;
+
+int VOP_SYMLINK_AP(struct vop_symlink_args *);
+int VOP_SYMLINK_APV(struct vop_vector *vop, struct vop_symlink_args *);
+
+static __inline int VOP_SYMLINK(
+	struct vnode *dvp,
+	struct vnode **vpp,
+	struct componentname *cnp,
+	struct vattr *vap,
+	char *target)
+{
+	struct vop_symlink_args a;
+
+	a.a_gen.a_desc = &vop_symlink_desc;
+	a.a_dvp = dvp;
+	a.a_vpp = vpp;
+	a.a_cnp = cnp;
+	a.a_vap = vap;
+	a.a_target = target;
+	return (VOP_SYMLINK_APV(dvp->v_op, &a));
+}
+
+struct vop_readdir_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct uio *a_uio;
+	struct ucred *a_cred;
+	int *a_eofflag;
+	int *a_ncookies;
+	u_long **a_cookies;
+};
+
+extern struct vnodeop_desc vop_readdir_desc;
+
+int VOP_READDIR_AP(struct vop_readdir_args *);
+int VOP_READDIR_APV(struct vop_vector *vop, struct vop_readdir_args *);
+
+static __inline int VOP_READDIR(
+	struct vnode *vp,
+	struct uio *uio,
+	struct ucred *cred,
+	int *eofflag,
+	int *ncookies,
+	u_long **cookies)
+{
+	struct vop_readdir_args a;
+
+	a.a_gen.a_desc = &vop_readdir_desc;
+	a.a_vp = vp;
+	a.a_uio = uio;
+	a.a_cred = cred;
+	a.a_eofflag = eofflag;
+	a.a_ncookies = ncookies;
+	a.a_cookies = cookies;
+	return (VOP_READDIR_APV(vp->v_op, &a));
+}
+
+struct vop_readlink_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct uio *a_uio;
+	struct ucred *a_cred;
+};
+
+extern struct vnodeop_desc vop_readlink_desc;
+
+int VOP_READLINK_AP(struct vop_readlink_args *);
+int VOP_READLINK_APV(struct vop_vector *vop, struct vop_readlink_args *);
+
+static __inline int VOP_READLINK(
+	struct vnode *vp,
+	struct uio *uio,
+	struct ucred *cred)
+{
+	struct vop_readlink_args a;
+
+	a.a_gen.a_desc = &vop_readlink_desc;
+	a.a_vp = vp;
+	a.a_uio = uio;
+	a.a_cred = cred;
+	return (VOP_READLINK_APV(vp->v_op, &a));
+}
+
+struct vop_inactive_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_inactive_desc;
+
+int VOP_INACTIVE_AP(struct vop_inactive_args *);
+int VOP_INACTIVE_APV(struct vop_vector *vop, struct vop_inactive_args *);
+
+static __inline int VOP_INACTIVE(
+	struct vnode *vp,
+	struct thread *td)
+{
+	struct vop_inactive_args a;
+
+	a.a_gen.a_desc = &vop_inactive_desc;
+	a.a_vp = vp;
+	a.a_td = td;
+	return (VOP_INACTIVE_APV(vp->v_op, &a));
+}
+
+struct vop_reclaim_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_reclaim_desc;
+
+int VOP_RECLAIM_AP(struct vop_reclaim_args *);
+int VOP_RECLAIM_APV(struct vop_vector *vop, struct vop_reclaim_args *);
+
+static __inline int VOP_RECLAIM(
+	struct vnode *vp,
+	struct thread *td)
+{
+	struct vop_reclaim_args a;
+
+	a.a_gen.a_desc = &vop_reclaim_desc;
+	a.a_vp = vp;
+	a.a_td = td;
+	return (VOP_RECLAIM_APV(vp->v_op, &a));
+}
+
+struct vop_lock1_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_flags;
+	char *a_file;
+	int a_line;
+};
+
+extern struct vnodeop_desc vop_lock1_desc;
+
+int VOP_LOCK1_AP(struct vop_lock1_args *);
+int VOP_LOCK1_APV(struct vop_vector *vop, struct vop_lock1_args *);
+
+static __inline int VOP_LOCK1(
+	struct vnode *vp,
+	int flags,
+	char *file,
+	int line)
+{
+	struct vop_lock1_args a;
+
+	a.a_gen.a_desc = &vop_lock1_desc;
+	a.a_vp = vp;
+	a.a_flags = flags;
+	a.a_file = file;
+	a.a_line = line;
+	return (VOP_LOCK1_APV(vp->v_op, &a));
+}
+
+struct vop_unlock_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_flags;
+};
+
+extern struct vnodeop_desc vop_unlock_desc;
+
+int VOP_UNLOCK_AP(struct vop_unlock_args *);
+int VOP_UNLOCK_APV(struct vop_vector *vop, struct vop_unlock_args *);
+
+static __inline int VOP_UNLOCK(
+	struct vnode *vp,
+	int flags)
+{
+	struct vop_unlock_args a;
+
+	a.a_gen.a_desc = &vop_unlock_desc;
+	a.a_vp = vp;
+	a.a_flags = flags;
+	return (VOP_UNLOCK_APV(vp->v_op, &a));
+}
+
+struct vop_bmap_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	daddr_t a_bn;
+	struct bufobj **a_bop;
+	daddr_t *a_bnp;
+	int *a_runp;
+	int *a_runb;
+};
+
+extern struct vnodeop_desc vop_bmap_desc;
+
+int VOP_BMAP_AP(struct vop_bmap_args *);
+int VOP_BMAP_APV(struct vop_vector *vop, struct vop_bmap_args *);
+
+static __inline int VOP_BMAP(
+	struct vnode *vp,
+	daddr_t bn,
+	struct bufobj **bop,
+	daddr_t *bnp,
+	int *runp,
+	int *runb)
+{
+	struct vop_bmap_args a;
+
+	a.a_gen.a_desc = &vop_bmap_desc;
+	a.a_vp = vp;
+	a.a_bn = bn;
+	a.a_bop = bop;
+	a.a_bnp = bnp;
+	a.a_runp = runp;
+	a.a_runb = runb;
+	return (VOP_BMAP_APV(vp->v_op, &a));
+}
+
+struct vop_strategy_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct buf *a_bp;
+};
+
+extern struct vnodeop_desc vop_strategy_desc;
+
+int VOP_STRATEGY_AP(struct vop_strategy_args *);
+int VOP_STRATEGY_APV(struct vop_vector *vop, struct vop_strategy_args *);
+
+static __inline int VOP_STRATEGY(
+	struct vnode *vp,
+	struct buf *bp)
+{
+	struct vop_strategy_args a;
+
+	a.a_gen.a_desc = &vop_strategy_desc;
+	a.a_vp = vp;
+	a.a_bp = bp;
+	return (VOP_STRATEGY_APV(vp->v_op, &a));
+}
+
+struct vop_getwritemount_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct mount **a_mpp;
+};
+
+extern struct vnodeop_desc vop_getwritemount_desc;
+
+int VOP_GETWRITEMOUNT_AP(struct vop_getwritemount_args *);
+int VOP_GETWRITEMOUNT_APV(struct vop_vector *vop, struct vop_getwritemount_args *);
+
+static __inline int VOP_GETWRITEMOUNT(
+	struct vnode *vp,
+	struct mount **mpp)
+{
+	struct vop_getwritemount_args a;
+
+	a.a_gen.a_desc = &vop_getwritemount_desc;
+	a.a_vp = vp;
+	a.a_mpp = mpp;
+	return (VOP_GETWRITEMOUNT_APV(vp->v_op, &a));
+}
+
+struct vop_print_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_print_desc;
+
+int VOP_PRINT_AP(struct vop_print_args *);
+int VOP_PRINT_APV(struct vop_vector *vop, struct vop_print_args *);
+
+static __inline int VOP_PRINT(
+	struct vnode *vp)
+{
+	struct vop_print_args a;
+
+	a.a_gen.a_desc = &vop_print_desc;
+	a.a_vp = vp;
+	return (VOP_PRINT_APV(vp->v_op, &a));
+}
+
+struct vop_pathconf_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_name;
+	long *a_retval;
+};
+
+extern struct vnodeop_desc vop_pathconf_desc;
+
+int VOP_PATHCONF_AP(struct vop_pathconf_args *);
+int VOP_PATHCONF_APV(struct vop_vector *vop, struct vop_pathconf_args *);
+
+static __inline int VOP_PATHCONF(
+	struct vnode *vp,
+	int name,
+	long *retval)
+{
+	struct vop_pathconf_args a;
+
+	a.a_gen.a_desc = &vop_pathconf_desc;
+	a.a_vp = vp;
+	a.a_name = name;
+	a.a_retval = retval;
+	return (VOP_PATHCONF_APV(vp->v_op, &a));
+}
+
+struct vop_advlock_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	void *a_id;
+	int a_op;
+	struct flock *a_fl;
+	int a_flags;
+};
+
+extern struct vnodeop_desc vop_advlock_desc;
+
+int VOP_ADVLOCK_AP(struct vop_advlock_args *);
+int VOP_ADVLOCK_APV(struct vop_vector *vop, struct vop_advlock_args *);
+
+static __inline int VOP_ADVLOCK(
+	struct vnode *vp,
+	void *id,
+	int op,
+	struct flock *fl,
+	int flags)
+{
+	struct vop_advlock_args a;
+
+	a.a_gen.a_desc = &vop_advlock_desc;
+	a.a_vp = vp;
+	a.a_id = id;
+	a.a_op = op;
+	a.a_fl = fl;
+	a.a_flags = flags;
+	return (VOP_ADVLOCK_APV(vp->v_op, &a));
+}
+
+struct vop_advlockasync_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	void *a_id;
+	int a_op;
+	struct flock *a_fl;
+	int a_flags;
+	struct task *a_task;
+	void **a_cookiep;
+};
+
+extern struct vnodeop_desc vop_advlockasync_desc;
+
+int VOP_ADVLOCKASYNC_AP(struct vop_advlockasync_args *);
+int VOP_ADVLOCKASYNC_APV(struct vop_vector *vop, struct vop_advlockasync_args *);
+
+static __inline int VOP_ADVLOCKASYNC(
+	struct vnode *vp,
+	void *id,
+	int op,
+	struct flock *fl,
+	int flags,
+	struct task *task,
+	void **cookiep)
+{
+	struct vop_advlockasync_args a;
+
+	a.a_gen.a_desc = &vop_advlockasync_desc;
+	a.a_vp = vp;
+	a.a_id = id;
+	a.a_op = op;
+	a.a_fl = fl;
+	a.a_flags = flags;
+	a.a_task = task;
+	a.a_cookiep = cookiep;
+	return (VOP_ADVLOCKASYNC_APV(vp->v_op, &a));
+}
+
+struct vop_advlockpurge_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_advlockpurge_desc;
+
+int VOP_ADVLOCKPURGE_AP(struct vop_advlockpurge_args *);
+int VOP_ADVLOCKPURGE_APV(struct vop_vector *vop, struct vop_advlockpurge_args *);
+
+static __inline int VOP_ADVLOCKPURGE(
+	struct vnode *vp)
+{
+	struct vop_advlockpurge_args a;
+
+	a.a_gen.a_desc = &vop_advlockpurge_desc;
+	a.a_vp = vp;
+	return (VOP_ADVLOCKPURGE_APV(vp->v_op, &a));
+}
+
+struct vop_reallocblks_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct cluster_save *a_buflist;
+};
+
+extern struct vnodeop_desc vop_reallocblks_desc;
+
+int VOP_REALLOCBLKS_AP(struct vop_reallocblks_args *);
+int VOP_REALLOCBLKS_APV(struct vop_vector *vop, struct vop_reallocblks_args *);
+
+static __inline int VOP_REALLOCBLKS(
+	struct vnode *vp,
+	struct cluster_save *buflist)
+{
+	struct vop_reallocblks_args a;
+
+	a.a_gen.a_desc = &vop_reallocblks_desc;
+	a.a_vp = vp;
+	a.a_buflist = buflist;
+	return (VOP_REALLOCBLKS_APV(vp->v_op, &a));
+}
+
+struct vop_getpages_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	vm_page_t *a_m;
+	int a_count;
+	int *a_rbehind;
+	int *a_rahead;
+};
+
+extern struct vnodeop_desc vop_getpages_desc;
+
+int VOP_GETPAGES_AP(struct vop_getpages_args *);
+int VOP_GETPAGES_APV(struct vop_vector *vop, struct vop_getpages_args *);
+
+static __inline int VOP_GETPAGES(
+	struct vnode *vp,
+	vm_page_t *m,
+	int count,
+	int *rbehind,
+	int *rahead)
+{
+	struct vop_getpages_args a;
+
+	a.a_gen.a_desc = &vop_getpages_desc;
+	a.a_vp = vp;
+	a.a_m = m;
+	a.a_count = count;
+	a.a_rbehind = rbehind;
+	a.a_rahead = rahead;
+	return (VOP_GETPAGES_APV(vp->v_op, &a));
+}
+
+struct vop_getpages_async_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	vm_page_t *a_m;
+	int a_count;
+	int *a_rbehind;
+	int *a_rahead;
+	vop_getpages_iodone_t *a_iodone;
+	void *a_arg;
+};
+
+extern struct vnodeop_desc vop_getpages_async_desc;
+
+int VOP_GETPAGES_ASYNC_AP(struct vop_getpages_async_args *);
+int VOP_GETPAGES_ASYNC_APV(struct vop_vector *vop, struct vop_getpages_async_args *);
+
+static __inline int VOP_GETPAGES_ASYNC(
+	struct vnode *vp,
+	vm_page_t *m,
+	int count,
+	int *rbehind,
+	int *rahead,
+	vop_getpages_iodone_t *iodone,
+	void *arg)
+{
+	struct vop_getpages_async_args a;
+
+	a.a_gen.a_desc = &vop_getpages_async_desc;
+	a.a_vp = vp;
+	a.a_m = m;
+	a.a_count = count;
+	a.a_rbehind = rbehind;
+	a.a_rahead = rahead;
+	a.a_iodone = iodone;
+	a.a_arg = arg;
+	return (VOP_GETPAGES_ASYNC_APV(vp->v_op, &a));
+}
+
+struct vop_putpages_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	vm_page_t *a_m;
+	int a_count;
+	int a_sync;
+	int *a_rtvals;
+};
+
+extern struct vnodeop_desc vop_putpages_desc;
+
+int VOP_PUTPAGES_AP(struct vop_putpages_args *);
+int VOP_PUTPAGES_APV(struct vop_vector *vop, struct vop_putpages_args *);
+
+static __inline int VOP_PUTPAGES(
+	struct vnode *vp,
+	vm_page_t *m,
+	int count,
+	int sync,
+	int *rtvals)
+{
+	struct vop_putpages_args a;
+
+	a.a_gen.a_desc = &vop_putpages_desc;
+	a.a_vp = vp;
+	a.a_m = m;
+	a.a_count = count;
+	a.a_sync = sync;
+	a.a_rtvals = rtvals;
+	return (VOP_PUTPAGES_APV(vp->v_op, &a));
+}
+
+struct vop_getacl_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	acl_type_t a_type;
+	struct acl *a_aclp;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_getacl_desc;
+
+int VOP_GETACL_AP(struct vop_getacl_args *);
+int VOP_GETACL_APV(struct vop_vector *vop, struct vop_getacl_args *);
+
+static __inline int VOP_GETACL(
+	struct vnode *vp,
+	acl_type_t type,
+	struct acl *aclp,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_getacl_args a;
+
+	a.a_gen.a_desc = &vop_getacl_desc;
+	a.a_vp = vp;
+	a.a_type = type;
+	a.a_aclp = aclp;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_GETACL_APV(vp->v_op, &a));
+}
+
+struct vop_setacl_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	acl_type_t a_type;
+	struct acl *a_aclp;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_setacl_desc;
+
+int VOP_SETACL_AP(struct vop_setacl_args *);
+int VOP_SETACL_APV(struct vop_vector *vop, struct vop_setacl_args *);
+
+static __inline int VOP_SETACL(
+	struct vnode *vp,
+	acl_type_t type,
+	struct acl *aclp,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_setacl_args a;
+
+	a.a_gen.a_desc = &vop_setacl_desc;
+	a.a_vp = vp;
+	a.a_type = type;
+	a.a_aclp = aclp;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_SETACL_APV(vp->v_op, &a));
+}
+
+struct vop_aclcheck_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	acl_type_t a_type;
+	struct acl *a_aclp;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_aclcheck_desc;
+
+int VOP_ACLCHECK_AP(struct vop_aclcheck_args *);
+int VOP_ACLCHECK_APV(struct vop_vector *vop, struct vop_aclcheck_args *);
+
+static __inline int VOP_ACLCHECK(
+	struct vnode *vp,
+	acl_type_t type,
+	struct acl *aclp,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_aclcheck_args a;
+
+	a.a_gen.a_desc = &vop_aclcheck_desc;
+	a.a_vp = vp;
+	a.a_type = type;
+	a.a_aclp = aclp;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_ACLCHECK_APV(vp->v_op, &a));
+}
+
+struct vop_closeextattr_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_commit;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_closeextattr_desc;
+
+int VOP_CLOSEEXTATTR_AP(struct vop_closeextattr_args *);
+int VOP_CLOSEEXTATTR_APV(struct vop_vector *vop, struct vop_closeextattr_args *);
+
+static __inline int VOP_CLOSEEXTATTR(
+	struct vnode *vp,
+	int commit,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_closeextattr_args a;
+
+	a.a_gen.a_desc = &vop_closeextattr_desc;
+	a.a_vp = vp;
+	a.a_commit = commit;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_CLOSEEXTATTR_APV(vp->v_op, &a));
+}
+
+struct vop_getextattr_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_attrnamespace;
+	const char *a_name;
+	struct uio *a_uio;
+	size_t *a_size;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_getextattr_desc;
+
+int VOP_GETEXTATTR_AP(struct vop_getextattr_args *);
+int VOP_GETEXTATTR_APV(struct vop_vector *vop, struct vop_getextattr_args *);
+
+static __inline int VOP_GETEXTATTR(
+	struct vnode *vp,
+	int attrnamespace,
+	const char *name,
+	struct uio *uio,
+	size_t *size,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_getextattr_args a;
+
+	a.a_gen.a_desc = &vop_getextattr_desc;
+	a.a_vp = vp;
+	a.a_attrnamespace = attrnamespace;
+	a.a_name = name;
+	a.a_uio = uio;
+	a.a_size = size;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_GETEXTATTR_APV(vp->v_op, &a));
+}
+
+struct vop_listextattr_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_attrnamespace;
+	struct uio *a_uio;
+	size_t *a_size;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_listextattr_desc;
+
+int VOP_LISTEXTATTR_AP(struct vop_listextattr_args *);
+int VOP_LISTEXTATTR_APV(struct vop_vector *vop, struct vop_listextattr_args *);
+
+static __inline int VOP_LISTEXTATTR(
+	struct vnode *vp,
+	int attrnamespace,
+	struct uio *uio,
+	size_t *size,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_listextattr_args a;
+
+	a.a_gen.a_desc = &vop_listextattr_desc;
+	a.a_vp = vp;
+	a.a_attrnamespace = attrnamespace;
+	a.a_uio = uio;
+	a.a_size = size;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_LISTEXTATTR_APV(vp->v_op, &a));
+}
+
+struct vop_openextattr_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_openextattr_desc;
+
+int VOP_OPENEXTATTR_AP(struct vop_openextattr_args *);
+int VOP_OPENEXTATTR_APV(struct vop_vector *vop, struct vop_openextattr_args *);
+
+static __inline int VOP_OPENEXTATTR(
+	struct vnode *vp,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_openextattr_args a;
+
+	a.a_gen.a_desc = &vop_openextattr_desc;
+	a.a_vp = vp;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_OPENEXTATTR_APV(vp->v_op, &a));
+}
+
+struct vop_deleteextattr_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_attrnamespace;
+	const char *a_name;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_deleteextattr_desc;
+
+int VOP_DELETEEXTATTR_AP(struct vop_deleteextattr_args *);
+int VOP_DELETEEXTATTR_APV(struct vop_vector *vop, struct vop_deleteextattr_args *);
+
+static __inline int VOP_DELETEEXTATTR(
+	struct vnode *vp,
+	int attrnamespace,
+	const char *name,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_deleteextattr_args a;
+
+	a.a_gen.a_desc = &vop_deleteextattr_desc;
+	a.a_vp = vp;
+	a.a_attrnamespace = attrnamespace;
+	a.a_name = name;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_DELETEEXTATTR_APV(vp->v_op, &a));
+}
+
+struct vop_setextattr_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_attrnamespace;
+	const char *a_name;
+	struct uio *a_uio;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_setextattr_desc;
+
+int VOP_SETEXTATTR_AP(struct vop_setextattr_args *);
+int VOP_SETEXTATTR_APV(struct vop_vector *vop, struct vop_setextattr_args *);
+
+static __inline int VOP_SETEXTATTR(
+	struct vnode *vp,
+	int attrnamespace,
+	const char *name,
+	struct uio *uio,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_setextattr_args a;
+
+	a.a_gen.a_desc = &vop_setextattr_desc;
+	a.a_vp = vp;
+	a.a_attrnamespace = attrnamespace;
+	a.a_name = name;
+	a.a_uio = uio;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_SETEXTATTR_APV(vp->v_op, &a));
+}
+
+struct vop_setlabel_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct label *a_label;
+	struct ucred *a_cred;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_setlabel_desc;
+
+int VOP_SETLABEL_AP(struct vop_setlabel_args *);
+int VOP_SETLABEL_APV(struct vop_vector *vop, struct vop_setlabel_args *);
+
+static __inline int VOP_SETLABEL(
+	struct vnode *vp,
+	struct label *label,
+	struct ucred *cred,
+	struct thread *td)
+{
+	struct vop_setlabel_args a;
+
+	a.a_gen.a_desc = &vop_setlabel_desc;
+	a.a_vp = vp;
+	a.a_label = label;
+	a.a_cred = cred;
+	a.a_td = td;
+	return (VOP_SETLABEL_APV(vp->v_op, &a));
+}
+
+struct vop_vptofh_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct fid *a_fhp;
+};
+
+extern struct vnodeop_desc vop_vptofh_desc;
+
+int VOP_VPTOFH_AP(struct vop_vptofh_args *);
+int VOP_VPTOFH_APV(struct vop_vector *vop, struct vop_vptofh_args *);
+
+static __inline int VOP_VPTOFH(
+	struct vnode *vp,
+	struct fid *fhp)
+{
+	struct vop_vptofh_args a;
+
+	a.a_gen.a_desc = &vop_vptofh_desc;
+	a.a_vp = vp;
+	a.a_fhp = fhp;
+	return (VOP_VPTOFH_APV(vp->v_op, &a));
+}
+
+struct vop_vptocnp_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct vnode **a_vpp;
+	struct ucred *a_cred;
+	char *a_buf;
+	int *a_buflen;
+};
+
+extern struct vnodeop_desc vop_vptocnp_desc;
+
+int VOP_VPTOCNP_AP(struct vop_vptocnp_args *);
+int VOP_VPTOCNP_APV(struct vop_vector *vop, struct vop_vptocnp_args *);
+
+static __inline int VOP_VPTOCNP(
+	struct vnode *vp,
+	struct vnode **vpp,
+	struct ucred *cred,
+	char *buf,
+	int *buflen)
+{
+	struct vop_vptocnp_args a;
+
+	a.a_gen.a_desc = &vop_vptocnp_desc;
+	a.a_vp = vp;
+	a.a_vpp = vpp;
+	a.a_cred = cred;
+	a.a_buf = buf;
+	a.a_buflen = buflen;
+	return (VOP_VPTOCNP_APV(vp->v_op, &a));
+}
+
+struct vop_allocate_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	off_t *a_offset;
+	off_t *a_len;
+};
+
+extern struct vnodeop_desc vop_allocate_desc;
+
+int VOP_ALLOCATE_AP(struct vop_allocate_args *);
+int VOP_ALLOCATE_APV(struct vop_vector *vop, struct vop_allocate_args *);
+
+static __inline int VOP_ALLOCATE(
+	struct vnode *vp,
+	off_t *offset,
+	off_t *len)
+{
+	struct vop_allocate_args a;
+
+	a.a_gen.a_desc = &vop_allocate_desc;
+	a.a_vp = vp;
+	a.a_offset = offset;
+	a.a_len = len;
+	return (VOP_ALLOCATE_APV(vp->v_op, &a));
+}
+
+struct vop_advise_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	off_t a_start;
+	off_t a_end;
+	int a_advice;
+};
+
+extern struct vnodeop_desc vop_advise_desc;
+
+int VOP_ADVISE_AP(struct vop_advise_args *);
+int VOP_ADVISE_APV(struct vop_vector *vop, struct vop_advise_args *);
+
+static __inline int VOP_ADVISE(
+	struct vnode *vp,
+	off_t start,
+	off_t end,
+	int advice)
+{
+	struct vop_advise_args a;
+
+	a.a_gen.a_desc = &vop_advise_desc;
+	a.a_vp = vp;
+	a.a_start = start;
+	a.a_end = end;
+	a.a_advice = advice;
+	return (VOP_ADVISE_APV(vp->v_op, &a));
+}
+
+struct vop_unp_bind_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct unpcb *a_unpcb;
+};
+
+extern struct vnodeop_desc vop_unp_bind_desc;
+
+int VOP_UNP_BIND_AP(struct vop_unp_bind_args *);
+int VOP_UNP_BIND_APV(struct vop_vector *vop, struct vop_unp_bind_args *);
+
+static __inline int VOP_UNP_BIND(
+	struct vnode *vp,
+	struct unpcb *unpcb)
+{
+	struct vop_unp_bind_args a;
+
+	a.a_gen.a_desc = &vop_unp_bind_desc;
+	a.a_vp = vp;
+	a.a_unpcb = unpcb;
+	return (VOP_UNP_BIND_APV(vp->v_op, &a));
+}
+
+struct vop_unp_connect_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct unpcb **a_unpcb;
+};
+
+extern struct vnodeop_desc vop_unp_connect_desc;
+
+int VOP_UNP_CONNECT_AP(struct vop_unp_connect_args *);
+int VOP_UNP_CONNECT_APV(struct vop_vector *vop, struct vop_unp_connect_args *);
+
+static __inline int VOP_UNP_CONNECT(
+	struct vnode *vp,
+	struct unpcb **unpcb)
+{
+	struct vop_unp_connect_args a;
+
+	a.a_gen.a_desc = &vop_unp_connect_desc;
+	a.a_vp = vp;
+	a.a_unpcb = unpcb;
+	return (VOP_UNP_CONNECT_APV(vp->v_op, &a));
+}
+
+struct vop_unp_detach_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_unp_detach_desc;
+
+int VOP_UNP_DETACH_AP(struct vop_unp_detach_args *);
+int VOP_UNP_DETACH_APV(struct vop_vector *vop, struct vop_unp_detach_args *);
+
+static __inline int VOP_UNP_DETACH(
+	struct vnode *vp)
+{
+	struct vop_unp_detach_args a;
+
+	a.a_gen.a_desc = &vop_unp_detach_desc;
+	a.a_vp = vp;
+	return (VOP_UNP_DETACH_APV(vp->v_op, &a));
+}
+
+struct vop_is_text_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_is_text_desc;
+
+int VOP_IS_TEXT_AP(struct vop_is_text_args *);
+int VOP_IS_TEXT_APV(struct vop_vector *vop, struct vop_is_text_args *);
+
+static __inline int VOP_IS_TEXT(
+	struct vnode *vp)
+{
+	struct vop_is_text_args a;
+
+	a.a_gen.a_desc = &vop_is_text_desc;
+	a.a_vp = vp;
+	return (VOP_IS_TEXT_APV(vp->v_op, &a));
+}
+
+struct vop_set_text_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_set_text_desc;
+
+int VOP_SET_TEXT_AP(struct vop_set_text_args *);
+int VOP_SET_TEXT_APV(struct vop_vector *vop, struct vop_set_text_args *);
+
+static __inline int VOP_SET_TEXT(
+	struct vnode *vp)
+{
+	struct vop_set_text_args a;
+
+	a.a_gen.a_desc = &vop_set_text_desc;
+	a.a_vp = vp;
+	return (VOP_SET_TEXT_APV(vp->v_op, &a));
+}
+
+struct vop_unset_text_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_unset_text_desc;
+
+int VOP_UNSET_TEXT_AP(struct vop_unset_text_args *);
+int VOP_UNSET_TEXT_APV(struct vop_vector *vop, struct vop_unset_text_args *);
+
+static __inline int VOP_UNSET_TEXT(
+	struct vnode *vp)
+{
+	struct vop_unset_text_args a;
+
+	a.a_gen.a_desc = &vop_unset_text_desc;
+	a.a_vp = vp;
+	return (VOP_UNSET_TEXT_APV(vp->v_op, &a));
+}
+
+struct vop_get_writecount_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int *a_writecount;
+};
+
+extern struct vnodeop_desc vop_get_writecount_desc;
+
+int VOP_GET_WRITECOUNT_AP(struct vop_get_writecount_args *);
+int VOP_GET_WRITECOUNT_APV(struct vop_vector *vop, struct vop_get_writecount_args *);
+
+static __inline int VOP_GET_WRITECOUNT(
+	struct vnode *vp,
+	int *writecount)
+{
+	struct vop_get_writecount_args a;
+
+	a.a_gen.a_desc = &vop_get_writecount_desc;
+	a.a_vp = vp;
+	a.a_writecount = writecount;
+	return (VOP_GET_WRITECOUNT_APV(vp->v_op, &a));
+}
+
+struct vop_add_writecount_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	int a_inc;
+};
+
+extern struct vnodeop_desc vop_add_writecount_desc;
+
+int VOP_ADD_WRITECOUNT_AP(struct vop_add_writecount_args *);
+int VOP_ADD_WRITECOUNT_APV(struct vop_vector *vop, struct vop_add_writecount_args *);
+
+static __inline int VOP_ADD_WRITECOUNT(
+	struct vnode *vp,
+	int inc)
+{
+	struct vop_add_writecount_args a;
+
+	a.a_gen.a_desc = &vop_add_writecount_desc;
+	a.a_vp = vp;
+	a.a_inc = inc;
+	return (VOP_ADD_WRITECOUNT_APV(vp->v_op, &a));
+}
+
+struct vop_fdatasync_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+	struct thread *a_td;
+};
+
+extern struct vnodeop_desc vop_fdatasync_desc;
+
+int VOP_FDATASYNC_AP(struct vop_fdatasync_args *);
+int VOP_FDATASYNC_APV(struct vop_vector *vop, struct vop_fdatasync_args *);
+
+static __inline int VOP_FDATASYNC(
+	struct vnode *vp,
+	struct thread *td)
+{
+	struct vop_fdatasync_args a;
+
+	a.a_gen.a_desc = &vop_fdatasync_desc;
+	a.a_vp = vp;
+	a.a_td = td;
+	return (VOP_FDATASYNC_APV(vp->v_op, &a));
+}
+
+struct vop_spare1_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_spare1_desc;
+
+int VOP_SPARE1_AP(struct vop_spare1_args *);
+int VOP_SPARE1_APV(struct vop_vector *vop, struct vop_spare1_args *);
+
+static __inline int VOP_SPARE1(
+	struct vnode *vp)
+{
+	struct vop_spare1_args a;
+
+	a.a_gen.a_desc = &vop_spare1_desc;
+	a.a_vp = vp;
+	return (VOP_SPARE1_APV(vp->v_op, &a));
+}
+
+struct vop_spare2_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_spare2_desc;
+
+int VOP_SPARE2_AP(struct vop_spare2_args *);
+int VOP_SPARE2_APV(struct vop_vector *vop, struct vop_spare2_args *);
+
+static __inline int VOP_SPARE2(
+	struct vnode *vp)
+{
+	struct vop_spare2_args a;
+
+	a.a_gen.a_desc = &vop_spare2_desc;
+	a.a_vp = vp;
+	return (VOP_SPARE2_APV(vp->v_op, &a));
+}
+
+struct vop_spare3_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_spare3_desc;
+
+int VOP_SPARE3_AP(struct vop_spare3_args *);
+int VOP_SPARE3_APV(struct vop_vector *vop, struct vop_spare3_args *);
+
+static __inline int VOP_SPARE3(
+	struct vnode *vp)
+{
+	struct vop_spare3_args a;
+
+	a.a_gen.a_desc = &vop_spare3_desc;
+	a.a_vp = vp;
+	return (VOP_SPARE3_APV(vp->v_op, &a));
+}
+
+struct vop_spare4_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_spare4_desc;
+
+int VOP_SPARE4_AP(struct vop_spare4_args *);
+int VOP_SPARE4_APV(struct vop_vector *vop, struct vop_spare4_args *);
+
+static __inline int VOP_SPARE4(
+	struct vnode *vp)
+{
+	struct vop_spare4_args a;
+
+	a.a_gen.a_desc = &vop_spare4_desc;
+	a.a_vp = vp;
+	return (VOP_SPARE4_APV(vp->v_op, &a));
+}
+
+struct vop_spare5_args {
+	struct vop_generic_args a_gen;
+	struct vnode *a_vp;
+};
+
+extern struct vnodeop_desc vop_spare5_desc;
+
+int VOP_SPARE5_AP(struct vop_spare5_args *);
+int VOP_SPARE5_APV(struct vop_vector *vop, struct vop_spare5_args *);
+
+static __inline int VOP_SPARE5(
+	struct vnode *vp)
+{
+	struct vop_spare5_args a;
+
+	a.a_gen.a_desc = &vop_spare5_desc;
+	a.a_vp = vp;
+	return (VOP_SPARE5_APV(vp->v_op, &a));
+}
+
diff --git a/rtemsbsd/include/rtems/bsd/local/vnode_if_newproto.h b/rtemsbsd/include/rtems/bsd/local/vnode_if_newproto.h
new file mode 100644
index 00000000..b2e2deba
--- /dev/null
+++ b/rtemsbsd/include/rtems/bsd/local/vnode_if_newproto.h
@@ -0,0 +1,84 @@
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from $FreeBSD$
+ */
+
+
+struct vop_vector {
+	struct vop_vector	*vop_default;
+	vop_bypass_t	*vop_bypass;
+	vop_islocked_t	*vop_islocked;
+	vop_lookup_t	*vop_lookup;
+	vop_cachedlookup_t	*vop_cachedlookup;
+	vop_create_t	*vop_create;
+	vop_whiteout_t	*vop_whiteout;
+	vop_mknod_t	*vop_mknod;
+	vop_open_t	*vop_open;
+	vop_close_t	*vop_close;
+	vop_access_t	*vop_access;
+	vop_accessx_t	*vop_accessx;
+	vop_getattr_t	*vop_getattr;
+	vop_setattr_t	*vop_setattr;
+	vop_markatime_t	*vop_markatime;
+	vop_read_t	*vop_read;
+	vop_write_t	*vop_write;
+	vop_ioctl_t	*vop_ioctl;
+	vop_poll_t	*vop_poll;
+	vop_kqfilter_t	*vop_kqfilter;
+	vop_revoke_t	*vop_revoke;
+	vop_fsync_t	*vop_fsync;
+	vop_remove_t	*vop_remove;
+	vop_link_t	*vop_link;
+	vop_rename_t	*vop_rename;
+	vop_mkdir_t	*vop_mkdir;
+	vop_rmdir_t	*vop_rmdir;
+	vop_symlink_t	*vop_symlink;
+	vop_readdir_t	*vop_readdir;
+	vop_readlink_t	*vop_readlink;
+	vop_inactive_t	*vop_inactive;
+	vop_reclaim_t	*vop_reclaim;
+	vop_lock1_t	*vop_lock1;
+	vop_unlock_t	*vop_unlock;
+	vop_bmap_t	*vop_bmap;
+	vop_strategy_t	*vop_strategy;
+	vop_getwritemount_t	*vop_getwritemount;
+	vop_print_t	*vop_print;
+	vop_pathconf_t	*vop_pathconf;
+	vop_advlock_t	*vop_advlock;
+	vop_advlockasync_t	*vop_advlockasync;
+	vop_advlockpurge_t	*vop_advlockpurge;
+	vop_reallocblks_t	*vop_reallocblks;
+	vop_getpages_t	*vop_getpages;
+	vop_getpages_async_t	*vop_getpages_async;
+	vop_putpages_t	*vop_putpages;
+	vop_getacl_t	*vop_getacl;
+	vop_setacl_t	*vop_setacl;
+	vop_aclcheck_t	*vop_aclcheck;
+	vop_closeextattr_t	*vop_closeextattr;
+	vop_getextattr_t	*vop_getextattr;
+	vop_listextattr_t	*vop_listextattr;
+	vop_openextattr_t	*vop_openextattr;
+	vop_deleteextattr_t	*vop_deleteextattr;
+	vop_setextattr_t	*vop_setextattr;
+	vop_setlabel_t	*vop_setlabel;
+	vop_vptofh_t	*vop_vptofh;
+	vop_vptocnp_t	*vop_vptocnp;
+	vop_allocate_t	*vop_allocate;
+	vop_advise_t	*vop_advise;
+	vop_unp_bind_t	*vop_unp_bind;
+	vop_unp_connect_t	*vop_unp_connect;
+	vop_unp_detach_t	*vop_unp_detach;
+	vop_is_text_t	*vop_is_text;
+	vop_set_text_t	*vop_set_text;
+	vop_unset_text_t	*vop_unset_text;
+	vop_get_writecount_t	*vop_get_writecount;
+	vop_add_writecount_t	*vop_add_writecount;
+	vop_fdatasync_t	*vop_fdatasync;
+	vop_spare1_t	*vop_spare1;
+	vop_spare2_t	*vop_spare2;
+	vop_spare3_t	*vop_spare3;
+	vop_spare4_t	*vop_spare4;
+	vop_spare5_t	*vop_spare5;
+};
diff --git a/rtemsbsd/include/rtems/bsd/local/vnode_if_typedef.h b/rtemsbsd/include/rtems/bsd/local/vnode_if_typedef.h
new file mode 100644
index 00000000..22204a1f
--- /dev/null
+++ b/rtemsbsd/include/rtems/bsd/local/vnode_if_typedef.h
@@ -0,0 +1,224 @@
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from $FreeBSD$
+ */
+
+
+struct vop_islocked_args;
+typedef int vop_islocked_t(struct vop_islocked_args *);
+
+struct vop_lookup_args;
+typedef int vop_lookup_t(struct vop_lookup_args *);
+
+struct vop_cachedlookup_args;
+typedef int vop_cachedlookup_t(struct vop_cachedlookup_args *);
+
+struct vop_create_args;
+typedef int vop_create_t(struct vop_create_args *);
+
+struct vop_whiteout_args;
+typedef int vop_whiteout_t(struct vop_whiteout_args *);
+
+struct vop_mknod_args;
+typedef int vop_mknod_t(struct vop_mknod_args *);
+
+struct vop_open_args;
+typedef int vop_open_t(struct vop_open_args *);
+
+struct vop_close_args;
+typedef int vop_close_t(struct vop_close_args *);
+
+struct vop_access_args;
+typedef int vop_access_t(struct vop_access_args *);
+
+struct vop_accessx_args;
+typedef int vop_accessx_t(struct vop_accessx_args *);
+
+struct vop_getattr_args;
+typedef int vop_getattr_t(struct vop_getattr_args *);
+
+struct vop_setattr_args;
+typedef int vop_setattr_t(struct vop_setattr_args *);
+
+struct vop_markatime_args;
+typedef int vop_markatime_t(struct vop_markatime_args *);
+
+struct vop_read_args;
+typedef int vop_read_t(struct vop_read_args *);
+
+struct vop_write_args;
+typedef int vop_write_t(struct vop_write_args *);
+
+struct vop_ioctl_args;
+typedef int vop_ioctl_t(struct vop_ioctl_args *);
+
+struct vop_poll_args;
+typedef int vop_poll_t(struct vop_poll_args *);
+
+struct vop_kqfilter_args;
+typedef int vop_kqfilter_t(struct vop_kqfilter_args *);
+
+struct vop_revoke_args;
+typedef int vop_revoke_t(struct vop_revoke_args *);
+
+struct vop_fsync_args;
+typedef int vop_fsync_t(struct vop_fsync_args *);
+
+struct vop_remove_args;
+typedef int vop_remove_t(struct vop_remove_args *);
+
+struct vop_link_args;
+typedef int vop_link_t(struct vop_link_args *);
+
+struct vop_rename_args;
+typedef int vop_rename_t(struct vop_rename_args *);
+
+struct vop_mkdir_args;
+typedef int vop_mkdir_t(struct vop_mkdir_args *);
+
+struct vop_rmdir_args;
+typedef int vop_rmdir_t(struct vop_rmdir_args *);
+
+struct vop_symlink_args;
+typedef int vop_symlink_t(struct vop_symlink_args *);
+
+struct vop_readdir_args;
+typedef int vop_readdir_t(struct vop_readdir_args *);
+
+struct vop_readlink_args;
+typedef int vop_readlink_t(struct vop_readlink_args *);
+
+struct vop_inactive_args;
+typedef int vop_inactive_t(struct vop_inactive_args *);
+
+struct vop_reclaim_args;
+typedef int vop_reclaim_t(struct vop_reclaim_args *);
+
+struct vop_lock1_args;
+typedef int vop_lock1_t(struct vop_lock1_args *);
+
+struct vop_unlock_args;
+typedef int vop_unlock_t(struct vop_unlock_args *);
+
+struct vop_bmap_args;
+typedef int vop_bmap_t(struct vop_bmap_args *);
+
+struct vop_strategy_args;
+typedef int vop_strategy_t(struct vop_strategy_args *);
+
+struct vop_getwritemount_args;
+typedef int vop_getwritemount_t(struct vop_getwritemount_args *);
+
+struct vop_print_args;
+typedef int vop_print_t(struct vop_print_args *);
+
+struct vop_pathconf_args;
+typedef int vop_pathconf_t(struct vop_pathconf_args *);
+
+struct vop_advlock_args;
+typedef int vop_advlock_t(struct vop_advlock_args *);
+
+struct vop_advlockasync_args;
+typedef int vop_advlockasync_t(struct vop_advlockasync_args *);
+
+struct vop_advlockpurge_args;
+typedef int vop_advlockpurge_t(struct vop_advlockpurge_args *);
+
+struct vop_reallocblks_args;
+typedef int vop_reallocblks_t(struct vop_reallocblks_args *);
+
+struct vop_getpages_args;
+typedef int vop_getpages_t(struct vop_getpages_args *);
+
+struct vop_getpages_async_args;
+typedef int vop_getpages_async_t(struct vop_getpages_async_args *);
+
+struct vop_putpages_args;
+typedef int vop_putpages_t(struct vop_putpages_args *);
+
+struct vop_getacl_args;
+typedef int vop_getacl_t(struct vop_getacl_args *);
+
+struct vop_setacl_args;
+typedef int vop_setacl_t(struct vop_setacl_args *);
+
+struct vop_aclcheck_args;
+typedef int vop_aclcheck_t(struct vop_aclcheck_args *);
+
+struct vop_closeextattr_args;
+typedef int vop_closeextattr_t(struct vop_closeextattr_args *);
+
+struct vop_getextattr_args;
+typedef int vop_getextattr_t(struct vop_getextattr_args *);
+
+struct vop_listextattr_args;
+typedef int vop_listextattr_t(struct vop_listextattr_args *);
+
+struct vop_openextattr_args;
+typedef int vop_openextattr_t(struct vop_openextattr_args *);
+
+struct vop_deleteextattr_args;
+typedef int vop_deleteextattr_t(struct vop_deleteextattr_args *);
+
+struct vop_setextattr_args;
+typedef int vop_setextattr_t(struct vop_setextattr_args *);
+
+struct vop_setlabel_args;
+typedef int vop_setlabel_t(struct vop_setlabel_args *);
+
+struct vop_vptofh_args;
+typedef int vop_vptofh_t(struct vop_vptofh_args *);
+
+struct vop_vptocnp_args;
+typedef int vop_vptocnp_t(struct vop_vptocnp_args *);
+
+struct vop_allocate_args;
+typedef int vop_allocate_t(struct vop_allocate_args *);
+
+struct vop_advise_args;
+typedef int vop_advise_t(struct vop_advise_args *);
+
+struct vop_unp_bind_args;
+typedef int vop_unp_bind_t(struct vop_unp_bind_args *);
+
+struct vop_unp_connect_args;
+typedef int vop_unp_connect_t(struct vop_unp_connect_args *);
+
+struct vop_unp_detach_args;
+typedef int vop_unp_detach_t(struct vop_unp_detach_args *);
+
+struct vop_is_text_args;
+typedef int vop_is_text_t(struct vop_is_text_args *);
+
+struct vop_set_text_args;
+typedef int vop_set_text_t(struct vop_set_text_args *);
+
+struct vop_unset_text_args;
+typedef int vop_unset_text_t(struct vop_unset_text_args *);
+
+struct vop_get_writecount_args;
+typedef int vop_get_writecount_t(struct vop_get_writecount_args *);
+
+struct vop_add_writecount_args;
+typedef int vop_add_writecount_t(struct vop_add_writecount_args *);
+
+struct vop_fdatasync_args;
+typedef int vop_fdatasync_t(struct vop_fdatasync_args *);
+
+struct vop_spare1_args;
+typedef int vop_spare1_t(struct vop_spare1_args *);
+
+struct vop_spare2_args;
+typedef int vop_spare2_t(struct vop_spare2_args *);
+
+struct vop_spare3_args;
+typedef int vop_spare3_t(struct vop_spare3_args *);
+
+struct vop_spare4_args;
+typedef int vop_spare4_t(struct vop_spare4_args *);
+
+struct vop_spare5_args;
+typedef int vop_spare5_t(struct vop_spare5_args *);
+
diff --git a/rtemsbsd/include/rtems/bsd/rootfs.h b/rtemsbsd/include/rtems/bsd/rootfs.h
new file mode 100644
index 00000000..b2768c31
--- /dev/null
+++ b/rtemsbsd/include/rtems/bsd/rootfs.h
@@ -0,0 +1,51 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 20206 Chris Johns.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RTEMS_BSD_ROOTFS_H_
+#define _RTEMS_BSD_ROOTFS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * Short cut to creating a directory in the root file system.
+ */
+int rtems_bsd_rootfs_mkdir(const char *name);
+int rtems_bsd_rootfs_rmdir(const char *name);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTEMS_BSD_ROOTFS_H_ */
diff --git a/rtemsbsd/include/sys/bio.h b/rtemsbsd/include/sys/bio.h
deleted file mode 100644
index 936ffd88..00000000
--- a/rtemsbsd/include/sys/bio.h
+++ /dev/null
@@ -1 +0,0 @@
-/* EMPTY */
diff --git a/rtemsbsd/include/sys/namei.h b/rtemsbsd/include/sys/namei.h
deleted file mode 100644
index 936ffd88..00000000
--- a/rtemsbsd/include/sys/namei.h
+++ /dev/null
@@ -1 +0,0 @@
-/* EMPTY */
diff --git a/rtemsbsd/include/sys/sysent.h b/rtemsbsd/include/sys/sysent.h
deleted file mode 100644
index 936ffd88..00000000
--- a/rtemsbsd/include/sys/sysent.h
+++ /dev/null
@@ -1 +0,0 @@
-/* EMPTY */
diff --git a/rtemsbsd/include/vm/vm_object.h b/rtemsbsd/include/vm/vm_object.h
index 936ffd88..9707a0c6 100644
--- a/rtemsbsd/include/vm/vm_object.h
+++ b/rtemsbsd/include/vm/vm_object.h
@@ -1 +1,16 @@
-/* EMPTY */
+#ifndef RTEMS_VM_OBJCT_H
+#define RTEMS_VM_OBJCT_H
+
+/*
+ * Helpers to perform conversion between vm_object page indexes and offsets.
+ * IDX_TO_OFF() converts an index into an offset.
+ * OFF_TO_IDX() converts an offset into an index.
+ * OBJ_MAX_SIZE specifies the maximum page index corresponding to the
+ *   maximum unsigned offset.
+ */
+#define IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT)
+#define OFF_TO_IDX(off) ((vm_pindex_t)(((vm_ooffset_t)(off)) >> PAGE_SHIFT))
+#define UOFF_TO_IDX(off) OFF_TO_IDX(off)
+#define OBJ_MAX_SIZE    (OFF_TO_IDX(UINT64_MAX) + 1)
+
+#endif
diff --git a/rtemsbsd/include/vm/vm_pager.h b/rtemsbsd/include/vm/vm_pager.h
index e69de29b..d9bc1524 100644
--- a/rtemsbsd/include/vm/vm_pager.h
+++ b/rtemsbsd/include/vm/vm_pager.h
@@ -0,0 +1,20 @@
+#ifndef RTEMS_VM_PAGER_H
+#define RTEMS_VM_PAGER_H
+
+/*
+ * get/put return values
+ * OK    operation was successful
+ * BAD   specified data was out of the accepted range
+ * FAIL  specified data was in range, but doesn't exist
+ * PEND  operations was initiated but not completed
+ * ERROR error while accessing data that is in range and exists
+ * AGAIN temporary resource shortage prevented operation from happening
+ */
+#define VM_PAGER_OK     0
+#define VM_PAGER_BAD    1
+#define VM_PAGER_FAIL   2
+#define VM_PAGER_PEND   3
+#define VM_PAGER_ERROR  4
+#define VM_PAGER_AGAIN  5
+
+#endif
diff --git a/rtemsbsd/rtems/rtems-bsd-allocator-domain-size.c b/rtemsbsd/rtems/rtems-bsd-allocator-domain-size.c
index 089ba747..771bca73 100644
--- a/rtemsbsd/rtems/rtems-bsd-allocator-domain-size.c
+++ b/rtemsbsd/rtems/rtems-bsd-allocator-domain-size.c
@@ -41,3 +41,4 @@
 #include <rtems/bsd/bsd.h>
 
 uintptr_t rtems_bsd_allocator_domain_page_mbuf_size = RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT;
+uintptr_t rtems_bsd_allocator_domain_bio_size = RTEMS_BSD_ALLOCATOR_DOMAIN_BIO_DEFAULT;
diff --git a/rtemsbsd/rtems/rtems-bsd-get-allocator-domain-size.c b/rtemsbsd/rtems/rtems-bsd-get-allocator-domain-size.c
index d94a719b..590c3386 100644
--- a/rtemsbsd/rtems/rtems-bsd-get-allocator-domain-size.c
+++ b/rtemsbsd/rtems/rtems-bsd-get-allocator-domain-size.c
@@ -49,6 +49,9 @@ rtems_bsd_get_allocator_domain_size(rtems_bsd_allocator_domain domain)
 		case RTEMS_BSD_ALLOCATOR_DOMAIN_MBUF:
 			size = rtems_bsd_allocator_domain_page_mbuf_size;
 			break;
+		case RTEMS_BSD_ALLOCATOR_DOMAIN_BIO:
+			size = rtems_bsd_allocator_domain_bio_size;
+			break;
 		default:
 			size = 0;
 			break;
diff --git a/rtemsbsd/rtems/rtems-bsd-libio.c b/rtemsbsd/rtems/rtems-bsd-libio.c
new file mode 100644
index 00000000..5736a001
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-bsd-libio.c
@@ -0,0 +1,193 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright 2020 Chris Johns. All Rights Reserved.
+ *
+ *  Contemporary Software
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE FREEBSD PROJECT BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/param.h>
+#include <sys/filedesc.h>
+#include <sys/proc.h>
+#include <sys/vnode.h>
+
+#include <rtems/libio.h>
+
+#include <machine/rtems-bsd-libio.h>
+
+rtems_libio_t *
+rtems_bsd_libio_iop_allocate(void)
+{
+	rtems_libio_t *iop = rtems_libio_allocate();
+	if (iop != NULL) {
+		iop->pathinfo.mt_entry = &rtems_filesystem_null_mt_entry;
+		rtems_filesystem_location_add_to_mt_entry(&iop->pathinfo);
+	}
+	return iop;
+}
+
+int
+rtems_bsd_libio_iop_allocate_with_file(
+    struct thread *td, int fd, const rtems_filesystem_file_handlers_r *ops)
+{
+	rtems_libio_t *iop = rtems_bsd_libio_iop_allocate();
+	int iofd = -1;
+	if (iop != NULL) {
+		int error = rtems_bsd_libio_iop_set_bsd_fd(td, fd, iop, ops);
+		/*
+		 * The fp is held and needs to be dropped and that drops the
+		 * iop.
+		 */
+		if (error == 0) {
+			rtems_libio_iop_hold(iop);
+			iofd = rtems_libio_iop_to_descriptor(iop);
+		} else {
+			rtems_libio_free(iop);
+		}
+	}
+	return iofd;
+}
+
+int
+rtems_bsd_libio_iop_set_bsd_fd(struct thread *td, int fd, rtems_libio_t *iop,
+    const rtems_filesystem_file_handlers_r *ops)
+{
+	struct filedesc *fdp = td->td_proc->p_fd;
+	int error;
+	FILEDESC_XLOCK(fdp);
+	if (fd < fdp->fd_nfiles) {
+		struct file *fp = fget_locked(fdp, fd);
+		if (fp != NULL) {
+			rtems_bsd_libio_iop_set_bsd_file(iop, fp);
+			rtems_libio_iop_flags_set(iop,
+			    LIBIO_FLAGS_OPEN |
+				rtems_bsd_libio_fflag_to_flags(fp->f_flag));
+			if (ops != NULL)
+				iop->pathinfo.handlers = ops;
+			rtems_bsd_libio_iop_set_bsd_descriptor(iop, fd);
+			error = 0;
+		} else {
+			error = EBADF;
+		}
+	} else {
+		error = EBADF;
+	}
+	FILEDESC_XUNLOCK(fdp);
+	return error;
+}
+
+void
+rtems_bsd_libio_loc_set_vnode(
+    rtems_filesystem_location_info_t *loc, struct vnode *vp)
+{
+	struct vnode *old = loc->node_access;
+	int hc = 0;
+	int rc = 0;
+	if (vp != NULL) {
+		hc = vp->v_holdcnt;
+		rc = vrefcnt(vp);
+	}
+	int old_hc = 0;
+	int old_rc = 0;
+	if (old != NULL) {
+		old_hc = old->v_holdcnt;
+		old_rc = vrefcnt(old);
+	}
+	if (vp != old) {
+		if (old != NULL)
+			vrele(old);
+		if (vp != NULL)
+			VREF(vp);
+		loc->node_access = vp;
+	}
+	int new_hc = 0;
+	int new_rc = 0;
+	if (vp != NULL) {
+		new_hc = vp->v_holdcnt;
+		new_rc = vrefcnt(vp);
+	}
+	int old_new_hc = 0;
+	int old_new_rc = 0;
+	if (old != NULL) {
+		old_new_hc = old->v_holdcnt;
+		old_new_rc = vrefcnt(old);
+	}
+	if (RTEMS_BSD_DESCRIP_TRACE || true)
+		printf(
+		    "bsd: lio: set-vode loc=%p vn=%p (%d/%d)->(%d/%d) old=%p (%d/%d)->(%d/%d)\n",
+		    loc, vp, hc, rc, new_hc, new_rc, old, old_hc, old_rc,
+		    old_new_hc, old_new_rc);
+}
+
+void
+rtems_bsd_libio_loc_set_vnode_dir(
+    rtems_filesystem_location_info_t *loc, struct vnode *dvp)
+{
+	struct vnode *old = loc->node_access_2;
+	int hc = 0;
+	int rc = 0;
+	if (dvp != NULL) {
+		hc = dvp->v_holdcnt;
+		rc = vrefcnt(dvp);
+	}
+	int old_hc = 0;
+	int old_rc = 0;
+	if (old != NULL) {
+		old_hc = old->v_holdcnt;
+		old_rc = vrefcnt(old);
+	}
+	if (dvp != old) {
+		if (old != NULL)
+			vrele(old);
+		if (dvp != NULL)
+			VREF(dvp);
+		loc->node_access_2 = dvp;
+	}
+	int new_hc = 0;
+	int new_rc = 0;
+	if (dvp != NULL) {
+		new_hc = dvp->v_holdcnt;
+		new_rc = vrefcnt(dvp);
+	}
+	int old_new_hc = 0;
+	int old_new_rc = 0;
+	if (old != NULL) {
+		old_new_hc = old->v_holdcnt;
+		old_new_rc = vrefcnt(old);
+	}
+	if (RTEMS_BSD_DESCRIP_TRACE || true)
+		printf(
+		    "bsd: lio: set-vode-dir loc=%p vn=%p (%d/%d)->(%d/%d) old=%p (%d/%d)->(%d/%d)\n",
+		    loc, dvp, hc, rc, new_hc, new_rc, old, old_hc, old_rc,
+		    old_new_hc, old_new_rc);
+}
diff --git a/rtemsbsd/rtems/rtems-bsd-mountroot.c b/rtemsbsd/rtems/rtems-bsd-mountroot.c
new file mode 100644
index 00000000..132a08ff
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-bsd-mountroot.c
@@ -0,0 +1,124 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup FileSystems
+ *
+ * @brief Mount a root file system.
+ */
+
+/*
+ * Copyright (C) 2020 Chris Johns <chris@contemporary.software>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/resourcevar.h>
+#include <sys/vnode.h>
+
+#include <vm/vm_extern.h>
+
+struct vnode *rootvnode;
+
+MALLOC_DECLARE(M_MOUNT);
+
+static void
+set_rootvnode(struct mount *mp)
+{
+	struct proc *p;
+	int error;
+
+	error = VFS_ROOT(mp, LK_EXCLUSIVE, &rootvnode);
+	if (error != 0)
+		panic("Cannot find root vnode");
+
+	VOP_UNLOCK(rootvnode, 0);
+
+	p = curthread->td_proc;
+	FILEDESC_XLOCK(p->p_fd);
+
+	if (p->p_fd->fd_cdir != NULL)
+		vrele(p->p_fd->fd_cdir);
+	p->p_fd->fd_cdir = rootvnode;
+	VREF(rootvnode);
+
+	if (p->p_fd->fd_rdir != NULL)
+		vrele(p->p_fd->fd_rdir);
+	p->p_fd->fd_rdir = rootvnode;
+	VREF(rootvnode);
+
+	FILEDESC_XUNLOCK(p->p_fd);
+}
+
+static void
+bsd_mountroot(const char *fstype)
+{
+	struct vfsoptlist *opts;
+	struct vfsconf *vfsp;
+	struct mount *mp;
+	struct ucred *cred;
+	int error;
+
+	cred = crget();
+	cred->cr_uidinfo = uifind(0);
+	cred->cr_ruidinfo = uifind(0);
+
+	vfsp = vfs_byname(fstype);
+	if (vfsp != NULL) {
+		mp = vfs_mount_alloc(NULLVP, vfsp, "/", cred);
+
+		crfree(cred);
+
+		error = VFS_MOUNT(mp);
+		if (error != 0)
+			panic("Cannot mount root file system: %d", error);
+
+		error = VFS_STATFS(mp, &mp->mnt_stat);
+		if (error != 0)
+			panic("Cannot stat root file system: %d", error);
+
+		opts = malloc(sizeof(struct vfsoptlist), M_MOUNT, M_WAITOK);
+		TAILQ_INIT(opts);
+		mp->mnt_opt = opts;
+
+		mtx_lock(&mountlist_mtx);
+		TAILQ_INSERT_HEAD(&mountlist, mp, mnt_list);
+		mtx_unlock(&mountlist_mtx);
+
+		set_rootvnode(mp);
+	}
+}
+
+static void
+bsd_rootfs_init(const void *dummy)
+{
+	bsd_mountroot("rootfs");
+}
+SYSINIT(bsdroot, SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, bsd_rootfs_init, NULL);
diff --git a/rtemsbsd/rtems/rtems-bsd-syscall-api.c b/rtemsbsd/rtems/rtems-bsd-syscall-api.c
index 63274a0e..defa1eb6 100644
--- a/rtemsbsd/rtems/rtems-bsd-syscall-api.c
+++ b/rtemsbsd/rtems/rtems-bsd-syscall-api.c
@@ -1,26 +1,32 @@
-/*
- * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
  *
- *  embedded brains GmbH
- *  Dornierstr. 4
- *  82178 Puchheim
- *  Germany
- *  <rtems@embedded-brains.de>
+ * @brief TODO.
+ *
+ * File origin from FreeBSD 'lib/libc/gen/sysctlnametomib.c'.
+ */
+
+/*
+ * Copyright 2001 The FreeBSD Project. All Rights Reserved.
+ * Copyright 2020 Chris Johns
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
+ *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE FREEBSD PROJECT BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
@@ -29,4 +35,1480 @@
  * SUCH DAMAGE.
  */
 
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/dirent.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/proc.h>
+#include <sys/syscallsubr.h>
+#include <sys/sysproto.h>
+#include <sys/vnode.h>
+
+#include <machine/rtems-bsd-libio.h>
 #include <machine/rtems-bsd-syscall-api.h>
+#include <machine/rtems-bsd-vfs.h>
+
+#include <errno.h>
+#include <rtems/imfs.h>
+#include <rtems/libio.h>
+#include <rtems/seterr.h>
+
+static int rtems_bsd_sysgen_open_error(
+    rtems_libio_t *iop, const char *path, int oflag, mode_t mode);
+static int rtems_bsd_sysgen_open(
+    rtems_libio_t *iop, const char *path, int oflag, mode_t mode);
+static int rtems_bsd_sysgen_close(rtems_libio_t *iop);
+static ssize_t rtems_bsd_sysgen_read(
+    rtems_libio_t *iop, void *buffer, size_t count);
+static ssize_t rtems_bsd_sysgen_readv(
+    rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total);
+static ssize_t rtems_bsd_sysgen_write(
+    rtems_libio_t *iop, const void *buffer, size_t count);
+static ssize_t rtems_bsd_sysgen_writev(
+    rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total);
+static int rtems_bsd_sysgen_ioctl(
+    rtems_libio_t *iop, ioctl_command_t request, void *buffer);
+static off_t rtems_bsd_sysgen_lseek(
+    rtems_libio_t *iop, off_t offset, int whence);
+static int rtems_bsd_sysgen_vnstat(
+    const rtems_filesystem_location_info_t *loc, struct stat *buf);
+static int rtems_bsd_sysgen_fstat(
+    const rtems_filesystem_location_info_t *loc, struct stat *buf);
+static int rtems_bsd_sysgen_imfsfstat(
+    const rtems_filesystem_location_info_t *loc, struct stat *buf);
+static int rtems_bsd_sysgen_ftruncate(rtems_libio_t *iop, off_t length);
+static int rtems_bsd_sysgen_fsync(rtems_libio_t *iop);
+static int rtems_bsd_sysgen_fdatasync(rtems_libio_t *iop);
+static int rtems_bsd_sysgen_fcntl(rtems_libio_t *iop, int cmd);
+static int rtems_bsd_sysgen_poll(rtems_libio_t *iop, int events);
+static int rtems_bsd_sysgen_kqfilter(rtems_libio_t *iop, struct knote *kn);
+
+const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_dirops = {
+	.open_h = rtems_bsd_sysgen_open,
+	.close_h = rtems_bsd_sysgen_close,
+	.read_h = rtems_bsd_sysgen_read,
+	.write_h = rtems_filesystem_default_write,
+	.ioctl_h = rtems_filesystem_default_ioctl,
+	.lseek_h = rtems_filesystem_default_lseek_directory,
+	.fstat_h = rtems_bsd_sysgen_vnstat,
+	.ftruncate_h = rtems_filesystem_default_ftruncate_directory,
+	.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
+	.fdatasync_h = rtems_bsd_sysgen_fdatasync,
+	.fcntl_h = rtems_filesystem_default_fcntl,
+	.kqfilter_h = rtems_filesystem_default_kqfilter,
+	.mmap_h = rtems_filesystem_default_mmap,
+	.poll_h = rtems_filesystem_default_poll,
+	.readv_h = rtems_filesystem_default_readv,
+	.writev_h = rtems_filesystem_default_writev
+};
+
+const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_fileops = {
+	.open_h = rtems_bsd_sysgen_open,
+	.close_h = rtems_bsd_sysgen_close,
+	.read_h = rtems_bsd_sysgen_read,
+	.write_h = rtems_bsd_sysgen_write,
+	.ioctl_h = rtems_bsd_sysgen_ioctl,
+	.lseek_h = rtems_bsd_sysgen_lseek,
+	.fstat_h = rtems_bsd_sysgen_vnstat,
+	.ftruncate_h = rtems_bsd_sysgen_ftruncate,
+	.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
+	.fdatasync_h = rtems_bsd_sysgen_fdatasync,
+	.fcntl_h = rtems_bsd_sysgen_fcntl,
+	.kqfilter_h = rtems_bsd_sysgen_kqfilter,
+	.mmap_h = rtems_filesystem_default_mmap,
+	.poll_h = rtems_bsd_sysgen_poll,
+	.readv_h = rtems_bsd_sysgen_readv,
+	.writev_h = rtems_bsd_sysgen_writev
+};
+
+const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_nodeops = {
+	.open_h = rtems_bsd_sysgen_open_error,
+	.close_h = rtems_bsd_sysgen_close,
+	.read_h = rtems_bsd_sysgen_read,
+	.write_h = rtems_bsd_sysgen_write,
+	.ioctl_h = rtems_bsd_sysgen_ioctl,
+	.lseek_h = rtems_filesystem_default_lseek,
+	.fstat_h = rtems_bsd_sysgen_fstat,
+	.ftruncate_h = rtems_filesystem_default_ftruncate,
+	.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
+	.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
+	.fcntl_h = rtems_bsd_sysgen_fcntl,
+	.poll_h = rtems_bsd_sysgen_poll,
+	.kqfilter_h = rtems_bsd_sysgen_kqfilter,
+	.readv_h = rtems_bsd_sysgen_readv,
+	.writev_h = rtems_bsd_sysgen_writev,
+	.mmap_h = rtems_filesystem_default_mmap
+};
+
+const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_imfsnodeops = {
+	.open_h = rtems_bsd_sysgen_open_error,
+	.close_h = rtems_bsd_sysgen_close,
+	.read_h = rtems_bsd_sysgen_read,
+	.write_h = rtems_bsd_sysgen_write,
+	.ioctl_h = rtems_bsd_sysgen_ioctl,
+	.lseek_h = rtems_filesystem_default_lseek,
+	.fstat_h = rtems_bsd_sysgen_imfsfstat,
+	.ftruncate_h = rtems_filesystem_default_ftruncate,
+	.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
+	.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
+	.fcntl_h = rtems_bsd_sysgen_fcntl,
+	.poll_h = rtems_bsd_sysgen_poll,
+	.kqfilter_h = rtems_bsd_sysgen_kqfilter,
+	.readv_h = rtems_bsd_sysgen_readv,
+	.writev_h = rtems_bsd_sysgen_writev,
+	.mmap_h = rtems_filesystem_default_mmap
+};
+
+int
+accept(int socket, struct sockaddr *__restrict address,
+    socklen_t *__restrict address_len)
+{
+	struct thread *td;
+	int error;
+	struct accept_args ua;
+	rtems_libio_t *iop;
+	int afd;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: accept: %d\n", socket);
+	}
+	td = rtems_bsd_get_curthread_or_null();
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	int ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.s = ffd;
+	ua.name = address;
+	ua.anamelen = address_len;
+	error = sys_accept(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	if (error != 0) {
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	iop = rtems_bsd_libio_iop_allocate();
+	afd = td->td_retval[0];
+	if (iop == NULL) {
+		kern_close(td, afd);
+		return rtems_bsd_error_to_status_and_errno(ENFILE);
+	}
+	error = rtems_bsd_libio_iop_set_bsd_fd(
+		    td, afd, iop, &rtems_bsd_sysgen_nodeops);
+	if (error != 0) {
+		rtems_bsd_libio_iop_free(iop);
+		kern_close(td, afd);
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf(
+		    "bsd: sys: accept: %d (%d) => %d -> %d\n",
+		    socket, ffd,
+		    rtems_libio_iop_to_descriptor(iop),
+		    rtems_bsd_libio_iop_to_descriptor(iop));
+	}
+	return rtems_libio_iop_to_descriptor(iop);
+}
+
+int
+bind(int socket, const struct sockaddr *address, socklen_t address_len)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct bind_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: bind: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd == -1) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.s = ffd;
+	ua.name = address;
+	ua.namelen = address_len;
+	error = sys_bind(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+connect(int socket, const struct sockaddr *address, socklen_t address_len)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct connect_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: connect: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.s = ffd;
+	ua.name = address;
+	ua.namelen = address_len;
+	error = sys_connect(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+getpeername(int socket, struct sockaddr *__restrict address,
+    socklen_t *__restrict address_len)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct getpeername_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: getpeername: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.fdes = ffd;
+	ua.asa = address;
+	ua.alen = address_len;
+	error = sys_getpeername(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+getsockname(int socket, struct sockaddr *__restrict address,
+    socklen_t *__restrict address_len)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct getsockname_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: getsockname: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.fdes = ffd;
+	ua.asa = address;
+	ua.alen = address_len;
+	error = sys_getsockname(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+getsockopt(int socket, int level, int option_name,
+    void *__restrict option_value, socklen_t *__restrict option_len)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct getsockopt_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: getsockopt: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.s = ffd;
+	ua.level = level;
+	ua.name = option_name;
+	ua.val = (caddr_t)option_value;
+	ua.avalsize = option_len;
+	error = sys_getsockopt(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+kqueue(void)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct kqueue_args ua = {};
+	rtems_libio_t *iop;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: kqueue:\n");
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	iop = rtems_bsd_libio_iop_allocate();
+	if (iop == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENFILE);
+	}
+	error = sys_kqueue(td, &ua);
+	if (error != 0) {
+		goto out;
+	}
+	error = rtems_bsd_libio_iop_set_bsd_fd(td,
+		    td->td_retval[0], iop,
+			    &rtems_bsd_sysgen_nodeops);
+	if (error == 0) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf(
+			    "bsd: sys: kqueue: %d -> %d\n",
+			    rtems_libio_iop_to_descriptor(iop),
+			    rtems_bsd_libio_iop_to_descriptor(iop));
+		}
+		return rtems_libio_iop_to_descriptor(iop);
+	}
+	kern_close(td, rtems_libio_iop_to_descriptor(iop));
+out:
+	rtems_bsd_libio_iop_free(iop);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+__weak_reference(kevent, _kevent);
+
+int
+kevent(int kq, const struct kevent *changelist, int nchanges,
+    struct kevent *eventlist, int nevents, const struct timespec *timeout)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct kevent_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: kevent: %d\n", kq);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(kq, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.fd = ffd;
+	ua.changelist = changelist;
+	ua.nchanges = nchanges;
+	ua.eventlist = eventlist;
+	ua.nevents = nevents;
+	ua.timeout = timeout;
+	error = sys_kevent(td, &ua);
+	rtems_bsd_libio_iop_drop(kq);
+	if (error != 0) {
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	return td->td_retval[0];
+}
+
+int
+listen(int socket, int backlog)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct listen_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: listen: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.s = ffd;
+	ua.backlog = backlog;
+	error = sys_listen(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+pipe(int fildes[2])
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	rtems_libio_t *iop[2];
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: pipe: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	iop[0] = rtems_bsd_libio_iop_allocate();
+	if (iop[0] == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENFILE);
+	}
+	iop[1] = rtems_bsd_libio_iop_allocate();
+	if (iop[1] == NULL) {
+		rtems_bsd_libio_iop_free(iop[0]);
+		return rtems_bsd_error_to_status_and_errno(ENFILE);
+	}
+	error = kern_pipe(td, fildes, 0, NULL, NULL);
+	if (error != 0) {
+		goto out;
+	}
+	error = rtems_bsd_libio_iop_set_bsd_fd(
+		    td, fildes[0], iop[0],
+		    &rtems_bsd_sysgen_nodeops);
+	if (error != 0) {
+		goto out;
+	}
+	error = rtems_bsd_libio_iop_set_bsd_fd(
+			td, fildes[1], iop[1],
+			&rtems_bsd_sysgen_nodeops);
+	if (error == 0) {
+		fildes[0] = rtems_libio_iop_to_descriptor(iop[0]);
+		fildes[1] = rtems_libio_iop_to_descriptor(iop[1]);
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf(
+			    "bsd: sys: pipe: %d -> %d, %d -> %d\n",
+			    fildes[0],
+			    rtems_bsd_libio_iop_to_descriptor(iop[0]),
+			    fildes[1],
+			    rtems_bsd_libio_iop_to_descriptor(iop[1]));
+		}
+		return 0;
+	}
+out:
+	kern_close(td, rtems_bsd_libio_iop_to_descriptor(iop[0]));
+	kern_close(td, rtems_bsd_libio_iop_to_descriptor(iop[1]));
+	rtems_bsd_libio_iop_free(iop[0]);
+	rtems_bsd_libio_iop_free(iop[1]);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+poll(struct pollfd fds[], nfds_t nfds, int timeout)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct poll_args ua;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: poll: %d\n", nfds);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	/*
+	 * Pass libio descriptors through as libio and bsd descriptors
+	 * can be in the list at the same time.
+	 */
+	ua.fds = &fds[0];
+	ua.nfds = nfds;
+	ua.timeout = timeout;
+	error = sys_poll(td, &ua);
+	if (error != 0) {
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	return td->td_retval[0];
+}
+
+int
+pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds,
+    const struct timespec *timeout, const sigset_t *set)
+{
+	struct thread *td;
+	struct timeval tv;
+	struct timeval *tvp;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: pselect: %d\n", nfds);
+	}
+	if (set != NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOSYS);
+	}
+	td = rtems_bsd_get_curthread_or_null();
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	if (timeout != NULL) {
+		TIMESPEC_TO_TIMEVAL(&tv, timeout);
+		tvp = &tv;
+	} else {
+		tvp = NULL;
+	}
+	/*
+	 * Pass libio descriptors through as libio and bsd descriptors
+	 * can be in the list at the same time.
+	 */
+	error = kern_select(
+		td, nfds, readfds, writefds, errorfds, tvp, NFDBITS);
+	if (error != 0) {
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	return td->td_retval[0];
+}
+
+ssize_t
+recvfrom(int socket, void *__restrict buffer, size_t length, int flags,
+    struct sockaddr *__restrict address, socklen_t *__restrict address_len)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct recvfrom_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: recvfrom: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.s = ffd;
+	ua.buf = buffer;
+	ua.len = length;
+	ua.flags = flags;
+	ua.from = address;
+	ua.fromlenaddr = address_len;
+	error = sys_recvfrom(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	if (error != 0) {
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	return td->td_retval[0];
+}
+
+ssize_t
+recvmsg(int socket, struct msghdr *message, int flags)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct recvmsg_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: recvmsg: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.s = ffd;
+	ua.msg = message;
+	ua.flags = flags;
+	error = sys_recvmsg(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	if (error != 0) {
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	return td->td_retval[0];
+}
+
+int
+select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds,
+    struct timeval *timeout)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: select: %d\n", nfds);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	/*
+	 * Pass libio descriptors through as libio and bsd descriptors
+	 * can be in the list at the same time.
+	 */
+	error = kern_select(
+		td, nfds, readfds, writefds, errorfds, timeout, NFDBITS);
+	if (error != 0) {
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	return td->td_retval[0];
+}
+
+ssize_t
+sendto(int socket, const void *message, size_t length, int flags,
+    const struct sockaddr *dest_addr, socklen_t dest_len)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct sendto_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: sendto: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.s = ffd;
+	ua.buf = (caddr_t)message;
+	ua.len = length;
+	ua.flags = flags;
+	ua.to = dest_addr;
+	ua.tolen = dest_len;
+	error = sys_sendto(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	if (error != 0) {
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	return td->td_retval[0];
+}
+
+ssize_t
+sendmsg(int socket, const struct msghdr *message, int flags)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct sendmsg_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: sendmsg: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.s = ffd;
+	ua.msg = message;
+	ua.flags = flags;
+	error = sys_sendmsg(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+setfib(int fibnum)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	int error;
+	if (td != NULL) {
+		struct setfib_args ua = { .fibnum = fibnum };
+		error = sys_setfib(td, &ua);
+	} else {
+		error = ENOMEM;
+	}
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+setsockopt(int socket, int level, int option_name, const void *option_value,
+    socklen_t option_len)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct setsockopt_args ua;
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: setsockopt: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	ua.s = ffd;
+	ua.level = level;
+	ua.name = option_name;
+	ua.val = __DECONST(void *, option_value);
+	ua.valsize = option_len;
+	error = sys_setsockopt(td, &ua);
+	rtems_bsd_libio_iop_drop(socket);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+shutdown(int socket, int how)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	int ffd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: shutdown: %d\n", socket);
+	}
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	ffd = rtems_bsd_libio_iop_hold(socket, NULL);
+	if (ffd < 0) {
+		return rtems_bsd_error_to_status_and_errno(EBADF);
+	}
+	if (rtems_bsd_is_libbsd_descriptor(rtems_libio_iop(socket))) {
+		struct shutdown_args ua = { .s = ffd,
+			.how = how };
+		error = sys_shutdown(td, &ua);
+	} else {
+		error = ENOTSOCK;
+	}
+	rtems_bsd_libio_iop_drop(socket);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+socket(int domain, int type, int protocol)
+{
+	struct thread *td;
+	rtems_libio_t *iop;
+	struct socket_args ua;
+	int error;
+	td = rtems_bsd_get_curthread_or_null();
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	iop = rtems_bsd_libio_iop_allocate();
+	if (iop == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENFILE);
+	}
+	ua.domain = domain;
+	ua.type = type;
+	ua.protocol = protocol;
+	error = sys_socket(td, &ua);
+	if (error != 0) {
+		rtems_bsd_libio_iop_free(iop);
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	error = rtems_bsd_libio_iop_set_bsd_fd(td,
+		    td->td_retval[0], iop,
+		    &rtems_bsd_sysgen_nodeops);
+	if (error != 0) {
+		kern_close(td, td->td_retval[0]);
+		rtems_bsd_libio_iop_free(iop);
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf(
+		    "bsd: sys: socket: %d -> %d\n",
+		    rtems_libio_iop_to_descriptor(iop),
+		    rtems_bsd_libio_iop_to_descriptor(iop));
+	}
+	return rtems_libio_iop_to_descriptor(iop);
+}
+
+int
+socketpair(int domain, int type, int protocol, int *socket_vector)
+{
+	struct thread *td;
+	rtems_libio_t *iop[2];
+	struct socketpair_args ua;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: socketpair:\n");
+	}
+	td = rtems_bsd_get_curthread_or_null();
+	if (td == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	iop[0] = rtems_bsd_libio_iop_allocate();
+	if (iop[0] == NULL) {
+		return rtems_bsd_error_to_status_and_errno(ENFILE);
+	}
+	iop[1] = rtems_bsd_libio_iop_allocate();
+	if (iop[1] == NULL) {
+		rtems_bsd_libio_iop_free(iop[0]);
+		return rtems_bsd_error_to_status_and_errno(ENFILE);
+	}
+	ua.domain = domain;
+	ua.type = type;
+	ua.protocol = protocol;
+	ua.rsv = socket_vector;
+	error = sys_socketpair(td, &ua);
+	if (error != 0) {
+		goto out;
+	}
+	error = rtems_bsd_libio_iop_set_bsd_fd(
+		    td, socket_vector[0], iop[0],
+		    &rtems_bsd_sysgen_nodeops);
+	if (error != 0) {
+		goto out;
+	}
+	error = rtems_bsd_libio_iop_set_bsd_fd(
+			td, socket_vector[1],
+			iop[1],
+			&rtems_bsd_sysgen_nodeops);
+	if (error == 0) {
+		socket_vector[0] = rtems_libio_iop_to_descriptor(iop[0]);
+		socket_vector[1] = rtems_libio_iop_to_descriptor(iop[1]);
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf(
+			    "bsd: sys: socketpair: %d -> %d, %d -> %d\n",
+			    socket_vector[0],
+			    rtems_bsd_libio_iop_to_descriptor(iop[0]),
+			    socket_vector[1],
+			    rtems_bsd_libio_iop_to_descriptor(iop[1]));
+		}
+		return 0;
+	}
+out:
+	kern_close(td, rtems_bsd_libio_iop_to_descriptor(iop[0]));
+	kern_close(td, rtems_bsd_libio_iop_to_descriptor(iop[1]));
+	rtems_bsd_libio_iop_free(iop[0]);
+	rtems_bsd_libio_iop_free(iop[1]);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp,
+    const void *newp, size_t newlen)
+{
+	int error = EINVAL;
+	if (namelen <= CTL_MAXNAME) {
+		int namedup[CTL_MAXNAME];
+		memcpy(namedup, name, namelen * sizeof(*name));
+		error = kernel_sysctl(NULL, namedup, namelen, oldp, oldlenp,
+		    RTEMS_DECONST(void *, newp), newlen, oldlenp, 0);
+	}
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+/*
+ * File origin from FreeBSD 'lib/libc/gen/sysctlbyname.c'.
+ *
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ */
+int
+sysctlbyname(const char *name, void *oldp, size_t *oldlenp, const void *newp,
+    size_t newlen)
+{
+	int real_oid[CTL_MAXNAME + 2];
+	int error;
+	size_t oidlen;
+	oidlen = sizeof(real_oid) / sizeof(int);
+	error = sysctlnametomib(name, real_oid, &oidlen);
+	if (error < 0)
+		return (error);
+	error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+/*
+ * File origin from FreeBSD 'lib/libc/gen/sysctlnametomib.c'.
+ *
+ * This function uses a presently undocumented interface to the kernel
+ * to walk the tree and get the type so it can print the value.
+ * This interface is under work and consideration, and should probably
+ * be killed with a big axe by the first person who can find the time.
+ * (be aware though, that the proper interface isn't as obvious as it
+ * may seem, there are various conflicting requirements.
+ */
+int
+sysctlnametomib(const char *name, int *mibp, size_t *sizep)
+{
+	int oid[2];
+	int error;
+	oid[0] = 0;
+	oid[1] = 3;
+	*sizep *= sizeof(int);
+	error = sysctl(oid, 2, mibp, sizep, name, strlen(name));
+	*sizep /= sizeof(int);
+	return (error);
+}
+
+static int
+rtems_bsd_sysgen_open_error(
+    rtems_libio_t *iop, const char *path, int oflag, mode_t mode)
+{
+	return rtems_bsd_error_to_status_and_errno(ENXIO);
+}
+
+int
+rtems_bsd_sysgen_open(
+    rtems_libio_t *iop, const char *path, int oflag, mode_t mode)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct filedesc *fdp;
+	struct file *fp;
+	const char *opath;
+	const bool creat = (oflag & O_CREAT) == O_CREAT;
+	struct vnode *cdir;
+	struct vnode *rdir;
+	int pathlen;
+	int fd;
+	int error;
+
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: open: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+
+	fdp = td->td_proc->p_fd;
+	pathlen = strlen(path);
+	;
+
+	/*
+	 * There is no easy or clean means to open a vnode and follow the
+	 * POSIX open semantics. You can open a vnode but the extra
+	 * functionality such as create and truncate are not part of the
+	 * basic vnode open. All the calls that provide that functionality
+	 * take a path as the argument. As a result find the last token in
+	 * the path and use the parent directory vnode to position ourselves
+	 * in the parent directory. The pathloc vnode points to the '.' or
+	 * '..'  directory.
+	 */
+	if (rtems_filesystem_is_current_directory(path, pathlen) ||
+	    rtems_filesystem_is_parent_directory(path, pathlen)) {
+		if (((oflag + 1) & _FWRITE) == _FWRITE) {
+			if (RTEMS_BSD_SYSCALL_TRACE) {
+				printf("bsd: sys: open: write to .  or ..\n");
+			}
+			return rtems_bsd_error_to_status_and_errno(EPERM);
+		}
+		opath = ".";
+		cdir = rtems_bsd_libio_loc_to_vnode_dir(&iop->pathinfo);
+	} else {
+		rtems_filesystem_location_info_t *rootloc =
+		    &iop->pathinfo.mt_entry->mt_fs_root->location;
+		opath = path + pathlen;
+		while (opath != path &&
+		    !rtems_filesystem_is_delimiter(opath[-1])) {
+			opath--;
+		}
+		cdir = rtems_bsd_libio_loc_to_vnode_dir(&iop->pathinfo);
+		if (fdp->fd_cdir == NULL ||
+		    rtems_bsd_libio_loc_to_vnode(&iop->pathinfo) ==
+			rtems_bsd_libio_loc_to_vnode(rootloc)) {
+			cdir = rootvnode;
+		}
+	}
+
+	FILEDESC_XLOCK(fdp);
+	rdir = fdp->fd_cdir;
+	fdp->fd_cdir = cdir;
+	cdir = rdir;
+	rdir = fdp->fd_rdir;
+	fdp->fd_rdir = fdp->fd_cdir;
+	FILEDESC_XUNLOCK(fdp);
+
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: open: path=%s opath=%s vn=%p cwd=%p"
+		       " flags=%08x mode=%08x\n",
+		    path, opath,
+		    creat ? NULL : rtems_bsd_libio_loc_to_vnode(&iop->pathinfo),
+		    fdp->fd_cdir, oflag, mode);
+	}
+
+	VREF(fdp->fd_cdir);
+
+	error = kern_openat(td, AT_FDCWD, RTEMS_DECONST(char *, opath),
+	    UIO_USERSPACE, oflag, mode);
+
+	vrele(fdp->fd_cdir);
+
+	if (error != 0) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: open: error = (%d) %s\n", error,
+			    strerror(error));
+		}
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+
+	fd = td->td_retval[0];
+
+	FILEDESC_XLOCK(fdp);
+	fdp->fd_cdir = cdir;
+	fdp->fd_rdir = rdir;
+	if (fd < fdp->fd_nfiles) {
+		struct vnode *vn;
+		fp = fget_locked(fdp, fd);
+		if (fp != NULL) {
+			vn = fp->f_vnode;
+		} else {
+			vn = NULL;
+		}
+		rtems_bsd_libio_loc_set_vnode(&iop->pathinfo, vn);
+	}
+	FILEDESC_XUNLOCK(fdp);
+
+	rtems_bsd_libio_iop_set_bsd_fd(td, fd, iop, &rtems_bsd_sysgen_fileops);
+
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: open: fd = %d vn=%p\n", fd,
+		    rtems_bsd_libio_loc_to_vnode(&iop->pathinfo));
+	}
+
+	return 0;
+}
+
+int
+rtems_bsd_sysgen_close(rtems_libio_t *iop)
+{
+	struct thread *td = curthread;
+	int error;
+	int ffd = rtems_bsd_libio_iop_to_descriptor(iop);
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: close: %d -> %d\n",
+		    rtems_libio_iop_to_descriptor(iop), ffd);
+	}
+	if (td != NULL) {
+		if (ffd >= 0) {
+			rtems_libio_iop_hold(iop);
+			error = kern_close(td, ffd);
+		} else {
+			error = EBADF;
+		}
+	} else {
+		error = ENOMEM;
+	}
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: close: %d: %d: %s\n",
+		    rtems_libio_iop_to_descriptor(iop), error, strerror(error));
+	}
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+ssize_t
+rtems_bsd_sysgen_read(rtems_libio_t *iop, void *buffer, size_t count)
+{
+	struct thread *td = curthread;
+	struct vnode *vp = rtems_bsd_libio_iop_to_vnode(iop);
+	int fd = rtems_bsd_libio_iop_to_descriptor(iop);
+	int error;
+	ssize_t size = 0;
+
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: read: %d -> %d: vn=%p len=%d\n",
+		    rtems_libio_iop_to_descriptor(iop), fd, vp, count);
+	}
+
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: read: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+
+	if (count > IOSIZE_MAX)
+		return rtems_bsd_error_to_status_and_errno(EINVAL);
+
+	if (vp != NULL && vp->v_type == VDIR) {
+		off_t offset;
+		error = kern_getdirentries(
+		    td, fd, buffer, count, &iop->offset, NULL, UIO_USERSPACE);
+		size = td->td_retval[0];
+	} else {
+		struct iovec aiov = { .iov_base = buffer, .iov_len = count };
+		struct uio auio = { .uio_iov = &aiov,
+			.uio_iovcnt = 1,
+			.uio_offset = iop->offset,
+			.uio_resid = count,
+			.uio_segflg = UIO_USERSPACE,
+			.uio_rw = UIO_READ,
+			.uio_td = td };
+		error = kern_readv(
+		    td, rtems_bsd_libio_iop_to_descriptor(iop), &auio);
+		if (error == 0)
+			size = td->td_retval[0];
+	}
+
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: read: %d: %d: %s size=%i\n",
+		    rtems_libio_iop_to_descriptor(iop), error, strerror(error),
+		    size);
+	}
+
+	if (error != 0)
+		return rtems_bsd_error_to_status_and_errno(error);
+
+	return size;
+}
+
+ssize_t
+rtems_bsd_sysgen_readv(
+    rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total)
+{
+	struct thread *td = curthread;
+	struct uio auio;
+	int error;
+
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: readv: %d len=%d\n",
+		    rtems_libio_iop_to_descriptor(iop), total);
+	}
+
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: readv: readv: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+
+	if (total > IOSIZE_MAX)
+		return rtems_bsd_error_to_status_and_errno(EINVAL);
+
+	auio.uio_iov = RTEMS_DECONST(struct iovec *, iov);
+	auio.uio_iovcnt = iovcnt;
+	auio.uio_resid = total;
+	auio.uio_segflg = UIO_USERSPACE;
+
+	error = kern_readv(td, rtems_bsd_libio_iop_to_descriptor(iop), &auio);
+
+	if (error != 0)
+		return rtems_bsd_error_to_status_and_errno(error);
+
+	return td->td_retval[0];
+}
+
+ssize_t
+rtems_bsd_sysgen_write(rtems_libio_t *iop, const void *buffer, size_t count)
+{
+	struct thread *td = curthread;
+	struct uio auio;
+	struct iovec aiov;
+	int error;
+
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: write: %d len=%d\n",
+		    rtems_libio_iop_to_descriptor(iop), count);
+	}
+
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: write: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+
+	if (count > IOSIZE_MAX)
+		return (EINVAL);
+
+	aiov.iov_base = RTEMS_DECONST(void *, buffer);
+	aiov.iov_len = count;
+	auio.uio_iov = &aiov;
+	auio.uio_iovcnt = 1;
+	auio.uio_resid = count;
+	auio.uio_segflg = UIO_USERSPACE;
+
+	error = kern_writev(td, rtems_bsd_libio_iop_to_descriptor(iop), &auio);
+
+	if (error != 0)
+		return rtems_bsd_error_to_status_and_errno(error);
+
+	return td->td_retval[0];
+}
+
+ssize_t
+rtems_bsd_sysgen_writev(
+    rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total)
+{
+	struct thread *td = curthread;
+	struct uio auio;
+	int error;
+
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: writev: %d iocnt=%d len=%d\n",
+		    rtems_libio_iop_to_descriptor(iop), iovcnt, total);
+	}
+
+	if (total > IOSIZE_MAX)
+		return EINVAL;
+
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: writev: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+
+	auio.uio_iov = RTEMS_DECONST(struct iovec *, iov);
+	auio.uio_iovcnt = iovcnt;
+	auio.uio_resid = total;
+	auio.uio_segflg = UIO_USERSPACE;
+
+	error = kern_writev(td, rtems_bsd_libio_iop_to_descriptor(iop), &auio);
+
+	if (error != 0)
+		return rtems_bsd_error_to_status_and_errno(error);
+
+	return td->td_retval[0];
+}
+
+int
+rtems_bsd_sysgen_ioctl(
+    rtems_libio_t *iop, ioctl_command_t request, void *buffer)
+{
+	struct thread *td = curthread;
+	u_long com = request & 0xffffffff;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: ioctl: %d req=%08x\n",
+		    rtems_libio_iop_to_descriptor(iop), com);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: ioctl: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	error = kern_ioctl(
+	    td, rtems_bsd_libio_iop_to_descriptor(iop), com, buffer);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+off_t
+rtems_bsd_sysgen_lseek(rtems_libio_t *iop, off_t offset, int whence)
+{
+	struct thread *td = curthread;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: lseek: %d offset=%zu whence=%d\n",
+		    rtems_libio_iop_to_descriptor(iop), offset, whence);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: lseek: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	error = kern_lseek(
+	    td, rtems_bsd_libio_iop_to_descriptor(iop), offset, whence);
+	if (error != 0) {
+		return rtems_bsd_error_to_status_and_errno(error);
+	}
+	return td->td_uretoff.tdu_off;
+}
+
+int
+rtems_bsd_sysgen_vnstat(
+    const rtems_filesystem_location_info_t *loc, struct stat *buf)
+{
+	struct thread *td = curthread;
+	struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: vnstat: %p\n", vp);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: vnstat: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	if (vp == NULL)
+		error = EFAULT;
+	else {
+		VOP_LOCK(vp, LK_SHARED);
+		error = vn_stat(vp, buf, td->td_ucred, NOCRED, td);
+		VOP_UNLOCK(vp, 0);
+	}
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: vnstat: exit %p\n", vp);
+	}
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_sysgen_fstat(
+    const rtems_filesystem_location_info_t *loc, struct stat *buf)
+{
+	struct thread *td = curthread;
+	rtems_libio_t *iop = rtems_bsd_libio_loc_to_iop(loc);
+	struct filedesc *fdp;
+	struct file *fp = NULL;
+	int fd;
+	int error;
+	if (iop == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: ffile: no iop\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENXIO);
+	}
+	fd = rtems_bsd_libio_iop_to_descriptor(iop);
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: fstat: %d\n", fd);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: fstat: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	fdp = td->td_proc->p_fd;
+	FILEDESC_XLOCK(fdp);
+	if (fd < fdp->fd_nfiles) {
+		fp = fget_locked(fdp, fd);
+	}
+	FILEDESC_XUNLOCK(fdp);
+	if (fp != NULL) {
+		error = fo_stat(fp, buf, NULL, td);
+	} else {
+		error = EBADF;
+	}
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_sysgen_imfsfstat(
+    const rtems_filesystem_location_info_t *loc, struct stat *buf)
+{
+	struct thread *td = curthread;
+	struct socket *so = rtems_bsd_libio_imfs_loc_to_so(loc);
+	struct filedesc *fdp;
+	struct file *fp = NULL;
+	struct socket *fd_so = NULL;
+	int fd;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: imfsfstat: socket=%p\n", so);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: fstat: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	fdp = td->td_proc->p_fd;
+	FILEDESC_XLOCK(fdp);
+	for (fd = 0; fd < fdp->fd_nfiles; fd++) {
+		fp = fget_locked(fdp, fd);
+		fd_so = fp->f_data;
+		if (so == fd_so) {
+			break;
+		}
+		fp = NULL;
+	}
+	FILEDESC_XUNLOCK(fdp);
+	if (fp != NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: imfsfstat: %d\n", fd);
+		}
+		error = fo_stat(fp, buf, NULL, td);
+	} else {
+		error = EBADF;
+	}
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_sysgen_ftruncate(rtems_libio_t *iop, off_t length)
+{
+	struct thread *td = curthread;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: ftruncate: len=%d\n", length);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: ftruncate: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	error = kern_ftruncate(
+	    td, rtems_bsd_libio_iop_to_descriptor(iop), length);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_sysgen_fsync(rtems_libio_t *iop)
+{
+	struct thread *td = curthread;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: fsync\n");
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: fsync: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	error = kern_fsync(td, rtems_bsd_libio_iop_to_descriptor(iop), true);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_sysgen_fdatasync(rtems_libio_t *iop)
+{
+	struct thread *td = curthread;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: fdatasync\n");
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: fdatasync: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	error = kern_fsync(td, rtems_bsd_libio_iop_to_descriptor(iop), false);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_sysgen_fcntl(rtems_libio_t *iop, int cmd)
+{
+	struct thread *td = curthread;
+	intptr_t arg;
+	int error;
+	if (RTEMS_BSD_SYSCALL_TRACE) {
+		printf("bsd: sys: fcntl: %d cmd=%d\n",
+		    rtems_libio_iop_to_descriptor(iop), cmd);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_SYSCALL_TRACE) {
+			printf("bsd: sys: fcntl: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	switch (cmd) {
+	case F_SETFD:
+		arg = rtems_libio_to_fcntl_flags(rtems_libio_iop_flags(iop)) &
+		    FD_CLOEXEC;
+		break;
+	case F_SETFL:
+		arg = rtems_libio_to_fcntl_flags(rtems_libio_iop_flags(iop)) &
+		    FCNTLFLAGS;
+		break;
+	default:
+		arg = -1;
+		error = 0;
+		break;
+	}
+	if (arg >= 0) {
+		error = kern_fcntl(
+		    td, rtems_bsd_libio_iop_to_descriptor(iop), cmd, arg);
+		/* no return path with the RTEMS API for get calls */
+	}
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_sysgen_poll(rtems_libio_t *iop, int events)
+{
+	printf("rtems_bsd_sysgen_poll called!\n");
+	return rtems_bsd_error_to_status_and_errno(EOPNOTSUPP);
+}
+
+int
+rtems_bsd_sysgen_kqfilter(rtems_libio_t *iop, struct knote *kn)
+{
+	printf("rtems_bsd_sysgen_kqfilter called!\n");
+	return rtems_bsd_error_to_status_and_errno(EOPNOTSUPP);
+}
diff --git a/rtemsbsd/rtems/rtems-kernel-capability.c b/rtemsbsd/rtems/rtems-kernel-capability.c
new file mode 100644
index 00000000..3d3787da
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-kernel-capability.c
@@ -0,0 +1,71 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 2020 Chris Johns
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/types.h>
+#include <sys/caprights.h>
+
+cap_rights_t cap_no_rights;
+
+#define RTEMS_BSD_CAP_ALIAS(var, tar) \
+	extern int __attribute__((alias("_bsd_" #var))) _bsd_##tar;
+
+#ifdef INVARIANT_SUPPORT
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_rights_is_valid);
+#endif
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_accept_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_bind_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_connect_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_event_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_fcntl_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_fstat_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_fsync_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_ftruncate_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_getpeername_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_getsockname_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_getsockopt_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_ioctl_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_listen_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_mkdirat_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_mknodat_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_read_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_recv_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_renameat_source_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_renameat_target_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_seek_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_setsockopt_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_shutdown_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_symlinkat_rights);
+RTEMS_BSD_CAP_ALIAS(cap_no_rights, cap_write_rights);
diff --git a/rtemsbsd/rtems/rtems-kernel-dev.c b/rtemsbsd/rtems/rtems-kernel-dev.c
new file mode 100644
index 00000000..56180188
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-kernel-dev.c
@@ -0,0 +1,64 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief Handle the major, minor and makedev support
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1991, 1993, 1994
+ *      The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/types.h>
+
+int
+rtems_bsd__major(dev_t _d)
+{
+	return (((_d >> 32) & 0xffffff00) | ((_d >> 8) & 0xff));
+}
+
+int
+rtems_bsd__minor(dev_t _d)
+{
+	return (((_d >> 24) & 0xff00) | (_d & 0xffff00ff));
+}
+
+dev_t
+rtems_bsd__makedev(int _M, int _m)
+{
+	return (((dev_t)(_M & 0xffffff00) << 32) | ((_M & 0xff) << 8) |
+	    ((dev_t)(_m & 0xff00) << 24) | (_m & 0xffff00ff));
+}
diff --git a/rtemsbsd/rtems/rtems-kernel-dirent.c b/rtemsbsd/rtems/rtems-kernel-dirent.c
new file mode 100644
index 00000000..4c18b2bc
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-kernel-dirent.c
@@ -0,0 +1,52 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 2009, 2015 embedded brains GmbH
+ * All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/dirent.h>
+
+#include <string.h>
+
+void
+dirent_terminate(struct dirent *dp)
+{
+	memset(dp->d_name + dp->d_namlen, 0,
+	    dp->d_reclen - (__offsetof(struct dirent, d_name) + dp->d_namlen));
+}
diff --git a/rtemsbsd/rtems/rtems-kernel-init.c b/rtemsbsd/rtems/rtems-kernel-init.c
index eb958ede..90a9c809 100644
--- a/rtemsbsd/rtems/rtems-kernel-init.c
+++ b/rtemsbsd/rtems/rtems-kernel-init.c
@@ -38,30 +38,37 @@
  */
 
 #include <machine/rtems-bsd-kernel-space.h>
-#include <machine/rtems-bsd-thread.h>
 
-#include <sys/param.h>
 #include <sys/types.h>
+#include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/buf.h>
+#include <sys/filedesc.h>
+#include <sys/jail.h>
+#include <sys/kbio.h>
 #include <sys/kernel.h>
 #include <sys/ktr.h>
-#include <sys/sysctl.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
-#include <sys/stat.h>
-#include <sys/kbio.h>
 #include <sys/resourcevar.h>
-#include <sys/jail.h>
-#include <uuid/uuid.h>
+#include <sys/stat.h>
+#include <sys/sx.h>
+#include <sys/sysctl.h>
+#include <sys/sysent.h>
 
-#include <limits.h>
+#include <machine/rtems-bsd-page.h>
+#include <machine/rtems-bsd-thread.h>
 
 #include <dev/kbd/kbdreg.h>
 
 #include <net80211/ieee80211_freebsd.h>
 
+#include <limits.h>
 #include <rtems/bsd/bsd.h>
+#include <rtems/libio_.h>
+#include <rtems/malloc.h>
+#include <uuid/uuid.h>
 
 SYSINIT_REFERENCE(configure1);
 SYSINIT_REFERENCE(module);
@@ -98,25 +105,47 @@ sbintime_t sbt_timethreshold;
 sbintime_t sbt_tickthreshold;
 struct bintime tc_tick_bt;
 sbintime_t tc_tick_sbt;
-int maxproc;
 int tc_precexp;
-
-static SYSCTL_NODE(_kern, OID_AUTO, smp, CTLFLAG_RD|CTLFLAG_CAPRD, NULL,
-    "Kernel SMP");
+int maxproc;
+int maxfiles;
+int maxfilesperproc;
+int ngroups_max;
+int unmapped_buf_allowed;
+caddr_t unmapped_base;
+long maxbcache;
+int bio_transient_maxcnt;
+struct sx allproc_lock;
+struct vmem *rtems_bsd_transient_arena;
+int nbuf;   /* The number of buffer headers */
+int nswbuf; /* Number of swap I/O buffer headers. */
+void (*nlminfo_release_p)(struct proc *p);
+struct sysentvec rtems_sysvec;
+
+static SYSCTL_NODE(
+    _kern, OID_AUTO, smp, CTLFLAG_RD | CTLFLAG_CAPRD, NULL, "Kernel SMP");
 
 static int maxid_maxcpus;
 
-SYSCTL_INT(_kern_smp, OID_AUTO, maxid, CTLFLAG_RD|CTLFLAG_CAPRD,
+SYSCTL_INT(_kern_smp, OID_AUTO, maxid, CTLFLAG_RD | CTLFLAG_CAPRD,
     &maxid_maxcpus, 0, "Max CPU ID.");
 
-SYSCTL_INT(_kern_smp, OID_AUTO, maxcpus, CTLFLAG_RD|CTLFLAG_CAPRD,
+SYSCTL_INT(_kern_smp, OID_AUTO, maxcpus, CTLFLAG_RD | CTLFLAG_CAPRD,
     &maxid_maxcpus, 0, "Max number of CPUs that the system was compiled for.");
 
+static void
+cpu_startup(void *dummy)
+{
+	kern_vfs_bio_buffer_alloc(unmapped_base, maxbcache);
+	bufinit();
+	vm_pager_bufferinit();
+}
+SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
+
 /*
  * Create a single process. RTEMS is a single address, single process OS.
  */
 static void
-proc0_init(void* dummy)
+proc0_init(void *dummy)
 {
 	struct proc *p = &proc0;
 	struct ucred *newcred;
@@ -127,7 +156,7 @@ proc0_init(void* dummy)
 	newcred = crget();
 	newcred->cr_uid = 0;
 	newcred->cr_ruid = 0;
-	newcred->cr_ngroups = 1;	/* group 0 */
+	newcred->cr_ngroups = 1; /* group 0 */
 	newcred->cr_groups[0] = 0;
 	newcred->cr_rgid = 0;
 	tmpuinfo.ui_uid = 1;
@@ -137,8 +166,15 @@ proc0_init(void* dummy)
 	newcred->cr_ruidinfo = uifind(0);
 	p->p_ucred = newcred;
 	p->p_pid = getpid();
-	p->p_fd = NULL;
+	p->p_fd = fdinit(NULL, false);
 	p->p_fdtol = NULL;
+	rtems_sysvec.sv_flags = SV_ABI_FREEBSD;
+#ifdef __LP64__
+	rtems_sysvec.sv_flags |= SV_LP64;
+#else
+	rtems_sysvec.sv_flags |= SV_ILP32;
+#endif
+	p->p_sysent = &rtems_sysvec;
 	uuid_generate(uuid);
 	uuid_unparse(uuid, prison0.pr_hostuuid);
 }
@@ -170,17 +206,27 @@ rtems_bsd_initialize(void)
 	bt_tickthreshold = bt_timethreshold;
 	sbt_timethreshold = bttosbt(bt_timethreshold);
 	sbt_tickthreshold = bttosbt(bt_tickthreshold);
-	maxid_maxcpus = (int) rtems_scheduler_get_processor_maximum();
+	maxid_maxcpus = (int)rtems_scheduler_get_processor_maximum();
+	bio_transient_maxcnt = 1024;
+	sx_init(&allproc_lock, "allproc");
 
+	maxfiles = rtems_libio_number_iops;
+	maxfilesperproc = maxfiles;
 	maxproc = 16;
+	ngroups_max = 4;
+
+	maxbcache = rtems_bsd_get_allocator_domain_size(
+	    RTEMS_BSD_ALLOCATOR_DOMAIN_BIO);
+	unmapped_base = (caddr_t)rtems_heap_allocate_aligned_with_boundary(
+	    maxbcache, CACHE_LINE_SIZE, 0);
+	if (unmapped_base == NULL) {
+		return RTEMS_UNSATISFIED;
+	}
 
 	mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO);
 
-	sc =  rtems_timer_initiate_server(
-		rtems_bsd_get_task_priority(name),
-		rtems_bsd_get_task_stack_size(name),
-		RTEMS_DEFAULT_ATTRIBUTES
-	);
+	sc = rtems_timer_initiate_server(rtems_bsd_get_task_priority(name),
+	    rtems_bsd_get_task_stack_size(name), RTEMS_DEFAULT_ATTRIBUTES);
 	if (sc != RTEMS_SUCCESSFUL) {
 		return RTEMS_UNSATISFIED;
 	}
@@ -191,7 +237,8 @@ rtems_bsd_initialize(void)
 #ifdef KTR
 	ktr_verbose = 10;
 	ktr_mask = KTR_ALL;
-	ktr_mask = KTR_GEN | KTR_LOCK | KTR_VFS | KTR_VOP | KTR_BUF | KTR_MALLOC | KTR_SYSC | KTR_RUNQ;
+	ktr_mask = KTR_GEN | KTR_LOCK | KTR_VFS | KTR_VOP | KTR_BUF |
+	    KTR_MALLOC | KTR_SYSC | KTR_RUNQ;
 #endif
 
 	return RTEMS_SUCCESSFUL;
diff --git a/rtemsbsd/rtems/rtems-kernel-pager.c b/rtemsbsd/rtems/rtems-kernel-pager.c
new file mode 100644
index 00000000..5a48c2e8
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-kernel-pager.c
@@ -0,0 +1,171 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 2020 Chris Johns <chris@contemporary.software>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/param.h>
+#include <sys/buf.h>
+#include <sys/kernel.h>
+#include <sys/vmem.h>
+
+#include <vm/vm.h>
+#include <vm/uma.h>
+#include <vm/vm_extern.h>
+
+#define B_MAXPHYS 0x00200000 /* nitems(b_pages[]) = atop(MAXPHYS). */
+#define PBUF_PAGES (atop(maxphys) + 1)
+#define MAXPHYS (128 * 1024)
+#define NSWBUF_MIN 16
+
+static u_long maxphys; /* max raw I/O transfer size */
+static int nswbuf_max;
+
+vmem_t *kernel_arena;
+uma_zone_t pbuf_zone;
+uma_zone_t ncl_pbuf_zone;
+
+vm_offset_t
+kva_alloc(vm_size_t size)
+{
+	vm_offset_t addr;
+
+	size = round_page(size);
+	if (vmem_alloc(kernel_arena, size, M_BESTFIT | M_NOWAIT, &addr))
+		return (0);
+
+	return (addr);
+}
+
+static int
+pbuf_ctor(void *mem, int size, void *arg, int flags)
+{
+	struct buf *bp = mem;
+
+	bp->b_vp = NULL;
+	bp->b_bufobj = NULL;
+
+	/* copied from initpbuf() */
+	bp->b_rcred = NOCRED;
+	bp->b_wcred = NOCRED;
+	bp->b_qindex = 0; /* On no queue (QUEUE_NONE) */
+	bp->b_data = bp->b_kvabase;
+	bp->b_xflags = 0;
+	bp->b_flags = B_MAXPHYS;
+	bp->b_ioflags = 0;
+	bp->b_iodone = NULL;
+	bp->b_error = 0;
+	BUF_LOCK(bp, LK_EXCLUSIVE, NULL);
+
+	return (0);
+}
+
+static void
+pbuf_dtor(void *mem, int size, void *arg)
+{
+	struct buf *bp = mem;
+
+	if (bp->b_rcred != NOCRED) {
+		crfree(bp->b_rcred);
+		bp->b_rcred = NOCRED;
+	}
+	if (bp->b_wcred != NOCRED) {
+		crfree(bp->b_wcred);
+		bp->b_wcred = NOCRED;
+	}
+
+	BUF_UNLOCK(bp);
+}
+
+static int
+pbuf_init(void *mem, int size, int flags)
+{
+	struct buf *bp = mem;
+
+	bp->b_kvabase = (void *)kva_alloc(ptoa(PBUF_PAGES));
+	if (bp->b_kvabase == NULL)
+		return (ENOMEM);
+	bp->b_kvasize = ptoa(PBUF_PAGES);
+	BUF_LOCKINIT(bp);
+	LIST_INIT(&bp->b_dep);
+	bp->b_rcred = bp->b_wcred = NOCRED;
+	bp->b_xflags = 0;
+
+	return (0);
+}
+
+void
+vm_pager_bufferinit(void)
+{
+	/* Main zone for paging bufs. */
+	pbuf_zone = uma_zcreate("pbuf",
+	    sizeof(struct buf) + PBUF_PAGES * sizeof(vm_page_t), pbuf_ctor,
+	    pbuf_dtor, pbuf_init, NULL, UMA_ALIGN_CACHE, UMA_ZONE_NOFREE);
+	/* Few systems may still use this zone directly, so it needs a limit. */
+	nswbuf_max += uma_zone_set_max(pbuf_zone, NSWBUF_MIN);
+}
+
+uma_zone_t
+pbuf_zsecond_create(char *name, int max)
+{
+	uma_zone_t zone;
+
+	zone = uma_zsecond_create(
+	    name, pbuf_ctor, pbuf_dtor, NULL, NULL, pbuf_zone);
+	/*
+	 * uma_prealloc() rounds up to items per slab. If we would prealloc
+	 * immediately on every pbuf_zsecond_create(), we may accumulate too
+	 * much of difference between hard limit and prealloced items, which
+	 * means wasted memory.
+	 */
+	if (nswbuf_max > 0)
+		nswbuf_max += uma_zone_set_max(zone, max);
+	else
+		uma_prealloc(pbuf_zone, uma_zone_set_max(zone, max));
+
+	return (zone);
+}
+
+struct buf *
+getpbuf(int *pfreecnt)
+{
+	(void)pfreecnt;
+	return uma_zalloc(ncl_pbuf_zone, M_WAITOK);
+}
+
+void
+relpbuf(struct buf *bp, int *pfreecnt)
+{
+	(void)pfreecnt;
+	uma_zfree(ncl_pbuf_zone, bp);
+}
diff --git a/rtemsbsd/rtems/rtems-kernel-param.c b/rtemsbsd/rtems/rtems-kernel-param.c
new file mode 100644
index 00000000..f8fb2dd7
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-kernel-param.c
@@ -0,0 +1,40 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 2020 Chris Johns <chris@contemporary.software>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/types.h>
+#include <sys/systm.h>
+
+int ngroups_max; /* max # of supplemental groups */
diff --git a/rtemsbsd/rtems/rtems-kernel-vfs.c b/rtemsbsd/rtems/rtems-kernel-vfs.c
new file mode 100644
index 00000000..da7a1533
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-kernel-vfs.c
@@ -0,0 +1,941 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief VFS to RTEMS LibIO interface.
+ */
+
+/*
+ * Copyright (c) 2020 Chris Johns.  All rights reserved.
+ *
+ *  Contemporary Software
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/param.h>
+#include <sys/buf.h>
+#include <sys/capsicum.h>
+#include <sys/errno.h>
+#include <sys/fcntl.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mount.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/syscallsubr.h>
+#include <sys/sysproto.h>
+#include <sys/time.h>
+#include <sys/vnode.h>
+
+#include <rtems/libio.h>
+#include <rtems/seterr.h>
+
+const rtems_filesystem_operations_table rtems_bsd_vfsops = {
+	.lock_h = rtems_bsd_vfs_mt_entry_lock,
+	.unlock_h = rtems_bsd_vfs_mt_entry_unlock,
+	.eval_path_h = rtems_bsd_vfs_eval_path,
+	.link_h = rtems_bsd_vfs_link,
+	.are_nodes_equal_h = rtems_bsd_vfs_are_nodes_equal,
+	.mknod_h = rtems_bsd_vfs_mknod,
+	.rmnod_h = rtems_bsd_vfs_rmnod,
+	.fchmod_h = rtems_bsd_vfs_fchmod,
+	.chown_h = rtems_bsd_vfs_chown,
+	.clonenod_h = rtems_bsd_vfs_clonenode,
+	.freenod_h = rtems_bsd_vfs_freenode,
+	.mount_h = rtems_bsd_vfs_mount,
+	.unmount_h = rtems_bsd_vfs_unmount,
+	.fsunmount_me_h = rtems_bsd_vfs_fsunmount_me,
+	.utimens_h = rtems_bsd_vfs_utimens,
+	.symlink_h = rtems_bsd_vfs_symlink,
+	.readlink_h = rtems_bsd_vfs_readlink,
+	.rename_h = rtems_bsd_vfs_rename,
+	.statvfs_h = rtems_bsd_vfs_statvfs
+};
+
+int
+rtems_bsd_vfs_mount_init(rtems_filesystem_mount_table_entry_t *mt_entry)
+{
+	mt_entry->fs_info = NULL;
+	mt_entry->no_regular_file_mknod = true;
+	mt_entry->ops = &rtems_bsd_vfsops;
+	mt_entry->mt_fs_root->location.node_access = 0;
+	mt_entry->mt_fs_root->location.handlers = &rtems_bsd_sysgen_dirops;
+	return 0;
+}
+
+static void
+rtems_bsd_vfs_loc_vnode_hold(
+    rtems_filesystem_location_info_t *loc, struct vnode *vp)
+{
+	if (vp != NULL) {
+		VREF(vp);
+		if (RTEMS_BSD_VFS_TRACE)
+			printf("bsd: vfs: loc: hold loc=%p vn=%p\n", loc, vp);
+	}
+}
+
+static void
+rtems_bsd_vfs_loc_vnode_drop(
+    rtems_filesystem_location_info_t *loc, struct vnode *vp)
+{
+	if (vp != NULL) {
+		vrele(vp);
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: loc: drop loc=%p vn=%p\n", loc, vp);
+		}
+	}
+}
+
+static void
+rtems_bsd_vfs_loc_hold(rtems_filesystem_location_info_t *loc)
+{
+	if (loc != NULL) {
+		if (RTEMS_BSD_VFS_TRACE)
+			printf("bsd: vfs: loc: hold loc=%p vn=%p vdp=%p\n", loc,
+			    rtems_bsd_libio_loc_to_vnode(loc),
+			    rtems_bsd_libio_loc_to_vnode_dir(loc));
+		rtems_bsd_vfs_loc_vnode_hold(
+		    loc, rtems_bsd_libio_loc_to_vnode(loc));
+		rtems_bsd_vfs_loc_vnode_hold(
+		    loc, rtems_bsd_libio_loc_to_vnode_dir(loc));
+	}
+}
+
+static void
+rtems_bsd_vfs_loc_drop(rtems_filesystem_location_info_t *loc)
+{
+	if (loc != NULL) {
+		if (RTEMS_BSD_VFS_TRACE)
+			printf("bsd: vfs: loc: drop loc=%p vn=%p vdp=%p\n", loc,
+			    rtems_bsd_libio_loc_to_vnode(loc),
+			    rtems_bsd_libio_loc_to_vnode_dir(loc));
+		rtems_bsd_libio_loc_set_vnode(loc, NULL);
+		rtems_bsd_libio_loc_set_vnode_dir(loc, NULL);
+	}
+}
+
+void
+rtems_bsd_vfs_mt_entry_lock(
+    const rtems_filesystem_mount_table_entry_t *mt_entry)
+{
+	struct vnode *vp = rtems_bsd_libio_loc_to_vnode(
+	    &mt_entry->mt_fs_root->location);
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: lock: vn=%p\n", vp);
+	}
+	VREF(vp);
+}
+
+void
+rtems_bsd_vfs_mt_entry_unlock(
+    const rtems_filesystem_mount_table_entry_t *mt_entry)
+{
+	struct vnode *vp = rtems_bsd_libio_loc_to_vnode(
+	    &mt_entry->mt_fs_root->location);
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: unlock: vn=%p\n", vp);
+	}
+	vrele(vp);
+}
+
+static void
+rtems_bsd_vfs_componentname(struct componentname *cnd, u_long nameiop,
+    char *name, u_int namelen, struct ucred *cred)
+{
+	memset(cnd, 0, sizeof(*cnd));
+	cnd->cn_nameiop = nameiop;
+	cnd->cn_nameptr = name;
+	cnd->cn_namelen = namelen;
+	cnd->cn_cred = cred;
+}
+
+static int
+rtems_bsd_vfs_vnode_componentname(struct componentname *cnd, struct vnode *vp,
+    u_long nameiop, char *name, u_int namelen, struct ucred *cred)
+{
+	struct vnode *tvp;
+	const u_int namemax = namelen - 1;
+	char *namep;
+	int error;
+	name[namemax] = '\0';
+	namelen = namemax;
+	tvp = vp;
+	error = vn_vptocnp(&tvp, NULL, name, &namelen);
+	if (error == 0) {
+		name = &name[namelen];
+		namelen = namemax - namelen;
+	} else {
+		name = NULL;
+		namelen = 0;
+	}
+	rtems_bsd_vfs_componentname(cnd, nameiop, name, namelen, cred);
+	return error;
+}
+
+static bool
+rtems_bsd_vfs_vnode_is_directory(
+    rtems_filesystem_eval_path_context_t *ctx, void *arg)
+{
+	struct vnode *vp = *((struct vnode **)arg);
+	return vp->v_type == VDIR;
+}
+
+static rtems_filesystem_eval_path_generic_status
+rtems_bsd_vfs_eval_token(rtems_filesystem_eval_path_context_t *ctx, void *arg,
+    const char *token, size_t tokenlen)
+{
+	rtems_filesystem_location_info_t *currentloc;
+	struct thread *td = curthread;
+	struct filedesc *fdp = td->td_proc->p_fd;
+	struct nameidata nd;
+	struct vnode **vpp = arg;
+	struct vnode *vp;
+	struct vnode *dvp;
+	struct vnode *cdir;
+	struct vnode *rdir;
+	char ntoken[NAME_MAX + 1];
+	u_long op = LOOKUP;
+	u_long flags = 0;
+	int eval_flags;
+	bool no_more_path;
+	int error;
+
+	currentloc = rtems_filesystem_eval_path_get_currentloc(ctx);
+	no_more_path = !rtems_filesystem_eval_path_has_path(ctx);
+
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: eval_token: t=%s:%d vp=%p\n", token, tokenlen,
+		    *vpp);
+	}
+
+	if (tokenlen > NAME_MAX) {
+		rtems_filesystem_eval_path_error(ctx, E2BIG);
+		return RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE;
+	}
+
+	if (rtems_filesystem_is_current_directory(token, tokenlen)) {
+		rtems_filesystem_eval_path_clear_token(ctx);
+		return RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE;
+	}
+
+	/*
+	 * Have we reached the root vnode. Note the namei call will
+	 * successfully lookup `..` when we are at the mount point
+	 * because VFS mounts are held under the root pseudofs file
+	 * system.
+	 */
+	if (rtems_filesystem_is_parent_directory(token, tokenlen)) {
+		rtems_filesystem_location_info_t *rootloc =
+		    &currentloc->mt_entry->mt_fs_root->location;
+		if (*vpp == rtems_bsd_libio_loc_to_vnode(rootloc)) {
+			return RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE;
+		}
+	}
+
+	eval_flags = rtems_filesystem_eval_path_get_flags(ctx);
+	flags |= (eval_flags & RTEMS_FS_FOLLOW_LINK) != 0 ? FOLLOW : NOFOLLOW;
+
+	if (no_more_path && ((eval_flags & RTEMS_FS_MAKE) != 0)) {
+		op = CREATE;
+		flags |= LOCKPARENT;
+	}
+
+	flags |= WANTPARENT;
+
+	FILEDESC_XLOCK(fdp);
+	rdir = fdp->fd_rdir;
+	cdir = fdp->fd_cdir;
+	fdp->fd_rdir = rootvnode;
+	fdp->fd_cdir = *vpp;
+	vref(*vpp);
+	FILEDESC_XUNLOCK(fdp);
+
+	bcopy(token, ntoken, tokenlen);
+	ntoken[tokenlen] = '\0';
+
+	NDINIT_ATVP(&nd, op, flags, UIO_USERSPACE, ntoken, *vpp, td);
+	error = namei(&nd);
+
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf(
+		    "bsd: vfs: eval_token: namei=%d:%s cwd=%p vp=%p dvp=%p mp=%p\n",
+		    error, strerror(error), *vpp, nd.ni_vp, nd.ni_dvp,
+		    nd.ni_vp ? nd.ni_vp->v_mountedhere : NULL);
+	}
+
+	if (error != 0) {
+		NDFREE(&nd, NDF_ONLY_PNBUF);
+		rtems_filesystem_eval_path_error(ctx, error);
+		return RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE;
+	}
+
+	FILEDESC_XLOCK(fdp);
+	fdp->fd_rdir = rdir;
+	fdp->fd_cdir = cdir;
+	FILEDESC_XUNLOCK(fdp);
+
+	*vpp = nd.ni_vp;
+
+	/*
+	 * If there is no more path and this is the last token and the lookup
+	 * with CREATE failed to find a vnode it does not exist and needs to be
+	 * created. Leave the currentloc where it is.
+	 */
+	if (nd.ni_vp != NULL) {
+		rtems_bsd_libio_loc_set_vnode(currentloc, nd.ni_vp);
+		rtems_bsd_libio_loc_set_vnode_dir(currentloc, nd.ni_dvp);
+		rtems_filesystem_eval_path_clear_token(ctx);
+	}
+
+	NDFREE(&nd, 0);
+
+	return no_more_path ? RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE :
+			      RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE;
+}
+
+static const rtems_filesystem_eval_path_generic_config
+    rtems_bsd_vfs_eval_config = {
+	    .is_directory = rtems_bsd_vfs_vnode_is_directory,
+	    .eval_token = rtems_bsd_vfs_eval_token
+    };
+
+void
+rtems_bsd_vfs_eval_path(rtems_filesystem_eval_path_context_t *ctx)
+{
+	rtems_filesystem_location_info_t *currentloc;
+	struct vnode *vp;
+
+	errno = 0;
+
+	currentloc = rtems_filesystem_eval_path_get_currentloc(ctx);
+	vp = rtems_bsd_libio_loc_to_vnode(currentloc);
+
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: eval_path: t=%s:%d (%s) cloc=%p\n",
+		    ctx->token, ctx->tokenlen, ctx->path, vp);
+	}
+
+	rtems_bsd_libio_loc_set_vnode(currentloc, vp);
+	rtems_bsd_libio_loc_set_vnode_dir(currentloc, vp);
+
+	rtems_filesystem_eval_path_generic(
+	    ctx, &vp, &rtems_bsd_vfs_eval_config);
+
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: eval_path: e=%d:%s vp=%p cloc=%p lookup=%p\n",
+		    errno, strerror(errno), vp,
+		    rtems_bsd_libio_loc_to_vnode(currentloc),
+		    rtems_bsd_libio_loc_to_vnode_dir(currentloc));
+	}
+}
+
+bool
+rtems_bsd_vfs_are_nodes_equal(const rtems_filesystem_location_info_t *a,
+    const rtems_filesystem_location_info_t *b)
+{
+	struct vnode *avp = rtems_bsd_libio_loc_to_vnode(a);
+	struct vnode *bvp = rtems_bsd_libio_loc_to_vnode(b);
+	struct vnode *advp = rtems_bsd_libio_loc_to_vnode_dir(a);
+	struct vnode *bdvp = rtems_bsd_libio_loc_to_vnode_dir(b);
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf(
+		    "bsd: vfs: nodes_equal: vn:%s (%p == %p) dvn:%s (%p == %p)\n",
+		    avp == bvp ? "equal" : "not-equal", avp, bvp,
+		    advp == bdvp ? "equal" : "not-equal", advp, bdvp);
+	}
+	if (advp != NULL && bdvp != NULL) {
+		return avp == bvp && advp == bdvp;
+	} else {
+		return avp == bvp;
+	}
+}
+
+int
+rtems_bsd_vfs_clonenode(rtems_filesystem_location_info_t *loc)
+{
+	rtems_bsd_vfs_loc_hold(loc);
+	if (RTEMS_BSD_VFS_TRACE) {
+		struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
+		struct vnode *dvp = rtems_bsd_libio_loc_to_vnode_dir(loc);
+		printf("bsd: vfs: clonenode: %p vn=%p dvp=%p\n", loc, vp, dvp);
+	}
+	return 0;
+}
+
+void
+rtems_bsd_vfs_freenode(const rtems_filesystem_location_info_t *loc)
+{
+	if (RTEMS_BSD_VFS_TRACE) {
+		struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
+		struct vnode *dp = rtems_bsd_libio_loc_to_vnode_dir(loc);
+		printf("bsd: vfs:  freenode: %p vn=%p dp=%p\n", loc, vp, dp);
+	}
+	rtems_bsd_vfs_loc_drop(
+	    RTEMS_DECONST(rtems_filesystem_location_info_t *, loc));
+}
+
+int
+rtems_bsd_vfs_link(const rtems_filesystem_location_info_t *targetdirloc,
+    const rtems_filesystem_location_info_t *sourceloc, const char *name,
+    size_t namelen)
+{
+	struct thread *td = curthread;
+	struct mount *mp;
+	struct vnode *tdvp = rtems_bsd_libio_loc_to_vnode(targetdirloc);
+	struct vnode *svp = rtems_bsd_libio_loc_to_vnode(sourceloc);
+	struct componentname cn;
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf(
+		    "bsd: vfs: link tdvn=%p svn=%p name=%s\n", tdvp, svp, name);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: link: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	if (svp->v_mount != tdvp->v_mount) {
+		if (RTEMS_BSD_VFS_TRACE)
+			printf("bsd: vfs: link: crossmounts\n");
+		error = EXDEV;
+		goto out;
+	}
+	vref(tdvp);
+	vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY);
+	error = vn_start_write(tdvp, &mp, V_NOWAIT);
+	if (error != 0) {
+		vput(tdvp);
+		error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH);
+		if (error == 0)
+			error = EAGAIN;
+		goto out;
+	}
+	rtems_bsd_vfs_componentname(
+	    &cn, LOOKUP, RTEMS_DECONST(char *, name), namelen, td->td_ucred);
+	error = VOP_LINK(tdvp, svp, &cn);
+	VOP_UNLOCK(tdvp, 0);
+out:
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_vfs_fchmod(const rtems_filesystem_location_info_t *loc, mode_t mode)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: fchmod: vn=%p mode=%x\n", vp, mode);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: fchmod: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	error = setfmode(td, NULL, vp, mode);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_vfs_chown(
+    const rtems_filesystem_location_info_t *loc, uid_t owner, gid_t group)
+{
+	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: chown: vn=%p owner=%d group=%d\n", vp, owner,
+		    group);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: chown: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	error = setfown(td, NULL, vp, owner, group);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_vfs_mount(rtems_filesystem_mount_table_entry_t *mt_entry)
+{
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: mount\n");
+	}
+	error = EOPNOTSUPP;
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_vfs_fsmount_me(
+    rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
+{
+	struct thread *td = curthread;
+	struct mount_args *args = (struct mount_args *)data;
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: fsmount_me\n");
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: fsmount_me: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	error = sys_mount(td, args);
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: fsmount_me: error=%d %s\n", error,
+		    strerror(error));
+	}
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_vfs_unmount(rtems_filesystem_mount_table_entry_t *mt_entry)
+{
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: unmount\n");
+	}
+	error = EOPNOTSUPP;
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+void
+rtems_bsd_vfs_fsunmount_me(rtems_filesystem_mount_table_entry_t *mt_entry)
+{
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: fsunmount_me: %p\n",
+		    rtems_bsd_libio_loc_to_vnode(
+			&mt_entry->mt_fs_root->location));
+	}
+	rtems_bsd_vfs_loc_drop(&mt_entry->mt_fs_root->location);
+}
+
+int
+rtems_bsd_vfs_mknod(const rtems_filesystem_location_info_t *parentloc,
+    const char *name, size_t namelen, mode_t mode, dev_t dev)
+{
+	struct thread *td = curthread;
+	struct filedesc *fdp = td->td_proc->p_fd;
+	struct vnode *vn = rtems_bsd_libio_loc_to_vnode(parentloc);
+	char *path = RTEMS_DECONST(char *, name);
+	int error;
+
+	if (td == NULL) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: mknod: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+
+	if (RTEMS_BSD_VFS_TRACE) {
+		const char *type;
+		if ((mode & S_IFMT) == S_IFREG)
+			type = "REG";
+		else if ((mode & S_IFMT) == S_IFDIR)
+			type = "DIR";
+		else
+			type = "DEV";
+		printf(
+		    "bsd: vfs: mknod: mode=%s name=%s (%d) mode=%08x dev=%08llx parent=%p\n",
+		    type, name, namelen, mode, dev, vn);
+	}
+
+	fdp->fd_cdir = vn;
+
+	switch (mode & S_IFMT) {
+	case S_IFREG:
+		error = 0;
+		break;
+	case S_IFDIR:
+		VREF(vn);
+		error = kern_mkdirat(td, AT_FDCWD, path, UIO_USERSPACE, mode);
+		vrele(vn);
+		break;
+	default:
+		VREF(vn);
+		error = kern_mknodat(
+		    td, AT_FDCWD, path, UIO_USERSPACE, mode, dev);
+		vrele(vn);
+		break;
+	}
+
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf(
+		    "bsd: vfs: mknod: error=%s (%d)\n", strerror(error), error);
+	}
+
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_vfs_rmnod(const rtems_filesystem_location_info_t *parentloc,
+    const rtems_filesystem_location_info_t *loc)
+{
+	struct thread *td = curthread;
+	struct mount *mp;
+	struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
+	struct vnode *dvp = rtems_bsd_libio_loc_to_vnode(parentloc);
+	struct vnode *tvp;
+	struct componentname cn;
+	char name[255];
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: rmnod vn=%p at=%p\n", vp, dvp);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: rmnod: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	error = rtems_bsd_vfs_vnode_componentname(
+	    &cn, vp, DELETE, name, sizeof(name), td->td_ucred);
+	if (error != 0) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf(
+			    "bsd: vfs: rmnod: componentname lookup: (%d) %s\n",
+			    error, strerror(error));
+		}
+		goto out;
+	}
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: rmnod name=%s\n", cn.cn_nameptr);
+	}
+	vref(vp);
+restart:
+	bwillwrite();
+	if (vp->v_vflag & VV_ROOT) {
+		error = EBUSY;
+		goto out;
+	}
+	if (vn_start_write(dvp, &mp, V_NOWAIT) != 0) {
+		if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) !=
+		    0) {
+			return rtems_bsd_error_to_status_and_errno(error);
+		}
+		goto restart;
+	}
+	vfs_notify_upper(vp, VFS_NOTIFY_UPPER_UNLINK);
+	error = VOP_RMDIR(dvp, vp, &cn);
+	vn_finished_write(mp);
+out:
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_vfs_utimens(
+    const rtems_filesystem_location_info_t *loc, time_t actime, time_t modtime)
+{
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: utimens\n");
+	}
+	error = EOPNOTSUPP;
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_vfs_symlink(const rtems_filesystem_location_info_t *targetdirloc,
+    const char *name, size_t namelen, const char *target)
+{
+	struct thread *td = curthread;
+	struct filedesc *fdp;
+	struct mount *mp;
+	struct vnode *tdvp = rtems_bsd_libio_loc_to_vnode(targetdirloc);
+	struct vattr vattr;
+	struct nameidata nd;
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: symlink tdvn=%p name=%s target=%s\n", tdvp,
+		    name, target);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: symlink: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	fdp = td->td_proc->p_fd;
+	fdp->fd_cdir = tdvp;
+restart:
+	bwillwrite();
+	NDINIT_ATRIGHTS(&nd, CREATE,
+	    LOCKPARENT | SAVENAME | AUDITVNODE1 | NOCACHE, UIO_SYSSPACE, name,
+	    AT_FDCWD, &cap_symlinkat_rights, td);
+	error = namei(&nd);
+	if (error != 0) {
+		goto out;
+	}
+	if (nd.ni_vp != NULL) {
+		NDFREE(&nd, NDF_ONLY_PNBUF);
+		if (nd.ni_vp == nd.ni_dvp)
+			vrele(nd.ni_dvp);
+		else
+			vput(nd.ni_dvp);
+		vrele(nd.ni_vp);
+		error = EEXIST;
+		goto out;
+	}
+	error = vn_start_write(nd.ni_dvp, &mp, V_NOWAIT);
+	if (error != 0) {
+		NDFREE(&nd, NDF_ONLY_PNBUF);
+		vput(nd.ni_dvp);
+		error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH);
+		if (error != 0) {
+			goto out;
+		}
+		goto restart;
+	}
+	VATTR_NULL(&vattr);
+	vattr.va_mode = ACCESSPERMS & ~td->td_proc->p_fd->fd_cmask;
+	error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr,
+	    RTEMS_DECONST(char *, target));
+	if (error != 0) {
+		goto out;
+	}
+	NDFREE(&nd, NDF_ONLY_PNBUF);
+	vput(nd.ni_dvp);
+	vn_finished_write(mp);
+out:
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+ssize_t
+rtems_bsd_vfs_readlink(
+    const rtems_filesystem_location_info_t *loc, char *buf, size_t bufsize)
+{
+	struct thread *td = curthread;
+	struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
+	struct iovec aiov;
+	struct uio auio;
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: readlink vn=%p\n", vp);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: readlink: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+	if (vp->v_type != VLNK && (vp->v_vflag & VV_READLINK) == 0) {
+		error = EINVAL;
+		goto out;
+	}
+	aiov.iov_base = buf;
+	aiov.iov_len = bufsize;
+	auio.uio_iov = &aiov;
+	auio.uio_iovcnt = 1;
+	auio.uio_offset = 0;
+	auio.uio_rw = UIO_READ;
+	auio.uio_segflg = UIO_SYSSPACE;
+	auio.uio_td = td;
+	auio.uio_resid = bufsize;
+	error = VOP_READLINK(vp, &auio, td->td_ucred);
+	td->td_retval[0] = bufsize - auio.uio_resid;
+out:
+	VOP_UNLOCK(vp, 0);
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_vfs_rename(const rtems_filesystem_location_info_t *oldparentloc,
+    const rtems_filesystem_location_info_t *oldloc,
+    const rtems_filesystem_location_info_t *newparentloc, const char *name,
+    size_t namelen)
+{
+	struct thread *td = curthread;
+	struct mount *mp;
+	struct vnode *olddvp = rtems_bsd_libio_loc_to_vnode(oldparentloc);
+	struct vnode *oldvp = rtems_bsd_libio_loc_to_vnode(oldloc);
+	struct vnode *newdvp = rtems_bsd_libio_loc_to_vnode(newparentloc);
+	struct vnode *fvp;
+	struct vnode *tdvp;
+	struct vnode *tvp;
+	struct nameidata fromnd;
+	struct nameidata tond;
+	struct componentname cn;
+	char fromname[255];
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: rename from=%p/%p to=%p/%s\n", olddvp, oldvp,
+		    newdvp, name);
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: rename: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	error = rtems_bsd_vfs_vnode_componentname(
+	    &cn, oldvp, DELETE, fromname, sizeof(fromname), td->td_ucred);
+	if (error != 0) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf(
+			    "bsd: vfs: rename: componentname lookup: %p: (%d) %s\n",
+			    oldvp, error, strerror(error));
+		}
+		goto out2;
+	}
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: rename fromname=%s\n", cn.cn_nameptr);
+	}
+again:
+	bwillwrite();
+	NDINIT_ATVP(&fromnd, DELETE, WANTPARENT | SAVESTART | AUDITVNODE1,
+	    UIO_SYSSPACE, cn.cn_nameptr, olddvp, td);
+	error = namei(&fromnd);
+	if (error != 0) {
+		goto out2;
+	}
+	fvp = fromnd.ni_vp;
+	NDINIT_ATVP(&tond, RENAME,
+	    LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | AUDITVNODE2,
+	    UIO_SYSSPACE, name, newdvp, td);
+	if (fromnd.ni_vp->v_type == VDIR)
+		tond.ni_cnd.cn_flags |= WILLBEDIR;
+	error = namei(&tond);
+	if (error != 0) {
+		/* Translate error code for rename("dir1", "dir2/."). */
+		if (error == EISDIR && fvp->v_type == VDIR)
+			error = EINVAL;
+		NDFREE(&fromnd, NDF_ONLY_PNBUF);
+		vrele(fromnd.ni_dvp);
+		vrele(fvp);
+		goto out1;
+	}
+	tdvp = tond.ni_dvp;
+	tvp = tond.ni_vp;
+	error = vn_start_write(fvp, &mp, V_NOWAIT);
+	if (error != 0) {
+		NDFREE(&fromnd, NDF_ONLY_PNBUF);
+		NDFREE(&tond, NDF_ONLY_PNBUF);
+		if (tvp != NULL)
+			vput(tvp);
+		if (tdvp == tvp)
+			vrele(tdvp);
+		else
+			vput(tdvp);
+		vrele(fromnd.ni_dvp);
+		vrele(fvp);
+		vrele(tond.ni_startdir);
+		if (fromnd.ni_startdir != NULL)
+			vrele(fromnd.ni_startdir);
+		error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH);
+		if (error != 0)
+			return (error);
+		goto again;
+	}
+	if (tvp != NULL) {
+		if (fvp->v_type == VDIR && tvp->v_type != VDIR) {
+			error = ENOTDIR;
+			goto out;
+		} else if (fvp->v_type != VDIR && tvp->v_type == VDIR) {
+			error = EISDIR;
+			goto out;
+		}
+	}
+	if (fvp == tdvp) {
+		error = EINVAL;
+		goto out;
+	}
+out:
+	if (error == 0) {
+		error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
+		    tond.ni_dvp, tond.ni_vp, &tond.ni_cnd);
+		NDFREE(&fromnd, NDF_ONLY_PNBUF);
+		NDFREE(&tond, NDF_ONLY_PNBUF);
+	} else {
+		NDFREE(&fromnd, NDF_ONLY_PNBUF);
+		NDFREE(&tond, NDF_ONLY_PNBUF);
+		if (tvp != NULL)
+			vput(tvp);
+		if (tdvp == tvp)
+			vrele(tdvp);
+		else
+			vput(tdvp);
+		vrele(fromnd.ni_dvp);
+		vrele(fvp);
+	}
+	vrele(tond.ni_startdir);
+	vn_finished_write(mp);
+out1:
+	if (fromnd.ni_startdir)
+		vrele(fromnd.ni_startdir);
+	if (error == -1)
+		error = 0;
+out2:
+	return rtems_bsd_error_to_status_and_errno(error);
+}
+
+int
+rtems_bsd_vfs_statvfs(
+    const rtems_filesystem_location_info_t *loc, struct statvfs *buf)
+{
+	struct thread *td = curthread;
+	struct vnode *vp = rtems_bsd_libio_loc_to_vnode(loc);
+	struct statfs *sp;
+	struct mount *mp;
+	int error;
+	if (RTEMS_BSD_VFS_TRACE) {
+		printf("bsd: vfs: statvfs\n");
+	}
+	if (td == NULL) {
+		if (RTEMS_BSD_VFS_TRACE) {
+			printf("bsd: vfs: statvfs: no curthread\n");
+		}
+		return rtems_bsd_error_to_status_and_errno(ENOMEM);
+	}
+	mp = vp->v_mount;
+	sp = &mp->mnt_stat;
+	sp->f_version = STATFS_VERSION;
+	sp->f_namemax = NAME_MAX;
+	sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
+	error = VFS_STATFS(mp, sp);
+	if (error == 0) {
+		buf->f_bsize = sp->f_bsize;
+		buf->f_frsize = sp->f_bsize;
+		buf->f_blocks = sp->f_blocks;
+		buf->f_bfree = sp->f_bfree;
+		buf->f_bavail = sp->f_bavail;
+		buf->f_files = sp->f_files;
+		buf->f_ffree = sp->f_ffree;
+		buf->f_fsid = sp->f_fsid.val[0];
+		buf->f_flag = sp->f_flags;
+		buf->f_namemax = sp->f_namemax;
+	}
+	return rtems_bsd_error_to_status_and_errno(error);
+}
diff --git a/rtemsbsd/rtems/rtems-kernel-vmem.c b/rtemsbsd/rtems/rtems-kernel-vmem.c
new file mode 100644
index 00000000..f64fbd17
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-kernel-vmem.c
@@ -0,0 +1,55 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 2020 Chris Johns <chris@contemporary.software>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/vmem.h>
+
+static MALLOC_DEFINE(M_VMEM, "vmem", "VMEM buffers");
+
+int
+vmem_alloc(vmem_t *vm, vmem_size_t size, int flags, vmem_addr_t *addrp)
+{
+	*addrp = malloc(size, M_VMEM, M_WAITOK);
+	return 0;
+}
+
+void
+vmem_free(vmem_t *vm, vmem_addr_t addr, vmem_size_t size)
+{
+	free((void *)addr, M_VMEM);
+}
diff --git a/rtemsbsd/sys/fs/devfs/devfs_devs.c b/rtemsbsd/sys/fs/devfs/devfs_devs.c
index 7c697b0a..39a38d62 100644
--- a/rtemsbsd/sys/fs/devfs/devfs_devs.c
+++ b/rtemsbsd/sys/fs/devfs/devfs_devs.c
@@ -35,6 +35,7 @@
 #include <sys/conf.h>
 #include <sys/kernel.h>
 #include <sys/file.h>
+#include <sys/filedesc.h>
 #include <sys/malloc.h>
 #include <sys/proc.h>
 #include <sys/poll.h>
@@ -42,6 +43,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#include <machine/rtems-bsd-libio.h>
+
 #include <fs/devfs/devfs_int.h>
 
 #include <machine/pcpu.h>
@@ -72,17 +75,25 @@ static int
 devfs_imfs_open(rtems_libio_t *iop, const char *path, int oflag, mode_t mode)
 {
 	struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
 	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct file *fp = NULL;
+	struct cdevsw *dsw = NULL;
 	struct file *fpop;
-	struct cdevsw *dsw;
 	int error, ref;
+	int fd = -1;
 
 	if (td != NULL) {
 		if (cdev == NULL) {
 			error = ENXIO;
 			goto err;
 		}
+		error = falloc(td, &fp, &fd, oflag);
+		if (error != 0)
+			goto err;
+		finit(fp, FREAD | FWRITE, DTYPE_DEV, NULL, NULL);
+		rtems_libio_iop_hold(iop);
+		rtems_bsd_libio_iop_set_bsd_descriptor(iop, fd);
+		rtems_bsd_libio_iop_set_bsd_file(iop, fp);
 		if (cdev->si_flags & SI_ALIAS) {
 			cdev = cdev->si_parent;
 		}
@@ -91,11 +102,6 @@ devfs_imfs_open(rtems_libio_t *iop, const char *path, int oflag, mode_t mode)
 			error = ENXIO;
 			goto err;
 		}
-		if (fp == NULL) {
-			dev_relthread(cdev, ref);
-			error = ENXIO;
-			goto err;
-		}
 		fpop = td->td_fpop;
 		curthread->td_fpop = fp;
 		fp->f_cdevpriv = NULL;
@@ -104,12 +110,19 @@ devfs_imfs_open(rtems_libio_t *iop, const char *path, int oflag, mode_t mode)
 		if (error != 0)
 			devfs_clear_cdevpriv();
 		curthread->td_fpop = fpop;
-		dev_relthread(cdev, ref);
 	} else {
 		error = ENOMEM;
 	}
 
 err:
+	if (dsw != NULL)
+		dev_relthread(cdev, ref);
+	if (td != NULL && fp != NULL) {
+		if (error != 0)
+			fdclose(td, fp, fd);
+		else
+			fdrop(fp, td);
+	}
 	return rtems_bsd_error_to_status_and_errno(error);
 }
 
@@ -117,11 +130,11 @@ static int
 devfs_imfs_close(rtems_libio_t *iop)
 {
 	struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
 	struct thread *td = rtems_bsd_get_curthread_or_null();
 	int flags = rtems_libio_to_fcntl_flags(iop->flags);
+	struct file *fp = NULL;
+	struct cdevsw *dsw = NULL;
 	struct file *fpop;
-	struct cdevsw *dsw;
 	int error, ref;
 
 	if (td != NULL) {
@@ -132,6 +145,11 @@ devfs_imfs_close(rtems_libio_t *iop)
 		if (cdev->si_flags & SI_ALIAS) {
 			cdev = cdev->si_parent;
 		}
+		fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
+		if (fp == NULL) {
+			error = EBADF;
+			goto err;
+		}
 		dsw = dev_refthread(cdev, &ref);
 		if (dsw == NULL) {
 			error = ENXIO;
@@ -141,7 +159,6 @@ devfs_imfs_close(rtems_libio_t *iop)
 		curthread->td_fpop = fp;
 		error = dsw->d_close(cdev, flags, 0, td);
 		curthread->td_fpop = fpop;
-		dev_relthread(cdev, ref);
 		if (fp->f_cdevpriv != NULL)
 			devfs_fpdrop(fp);
 	} else {
@@ -149,6 +166,10 @@ devfs_imfs_close(rtems_libio_t *iop)
 	}
 
 err:
+	if (dsw != NULL)
+		dev_relthread(cdev, ref);
+	if (td != NULL && fp != NULL)
+		fdrop(fp, td);
 	return rtems_bsd_error_to_status_and_errno(error);
 }
 
@@ -157,7 +178,6 @@ devfs_imfs_readv(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
     ssize_t total)
 {
 	struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
 	struct thread *td = rtems_bsd_get_curthread_or_null();
 	struct uio uio = {
 		.uio_iov = __DECONST(struct iovec *, iov),
@@ -168,8 +188,9 @@ devfs_imfs_readv(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
 		.uio_rw = UIO_READ,
 		.uio_td = td
 	};
+	struct file *fp = NULL;
+	struct cdevsw *dsw = NULL;
 	struct file *fpop;
-	struct cdevsw *dsw;
 	int error, ref;
 
 	if (td != NULL) {
@@ -180,6 +201,11 @@ devfs_imfs_readv(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
 		if (cdev->si_flags & SI_ALIAS) {
 			cdev = cdev->si_parent;
 		}
+		fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
+		if (fp == NULL) {
+			error = EBADF;
+			goto err;
+		}
 		dsw = dev_refthread(cdev, &ref);
 		if (dsw == NULL) {
 			error = ENXIO;
@@ -190,12 +216,15 @@ devfs_imfs_readv(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
 		error = dsw->d_read(cdev, &uio,
 		    rtems_libio_to_fcntl_flags(iop->flags));
 		td->td_fpop = fpop;
-		dev_relthread(cdev, ref);
 	} else {
 		error = ENOMEM;
 	}
 
 err:
+	if (dsw != NULL)
+		dev_relthread(cdev, ref);
+	if (td != NULL && fp != NULL)
+		fdrop(fp, td);
 	if (error == 0) {
 		return (total - uio.uio_resid);
 	} else {
@@ -219,7 +248,6 @@ devfs_imfs_writev(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
     ssize_t total)
 {
 	struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
 	struct thread *td = rtems_bsd_get_curthread_or_null();
 	struct uio uio = {
 		.uio_iov = __DECONST(struct iovec *, iov),
@@ -230,8 +258,9 @@ devfs_imfs_writev(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
 		.uio_rw = UIO_WRITE,
 		.uio_td = td
 	};
+	struct file *fp = NULL;
+	struct cdevsw *dsw = NULL;
 	struct file *fpop;
-	struct cdevsw *dsw;
 	int error, ref;
 
 	if (td != NULL) {
@@ -242,6 +271,11 @@ devfs_imfs_writev(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
 		if (cdev->si_flags & SI_ALIAS) {
 			cdev = cdev->si_parent;
 		}
+		fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
+		if (fp == NULL) {
+			error = EBADF;
+			goto err;
+		}
 		dsw = dev_refthread(cdev, &ref);
 		if (dsw == NULL) {
 			error = ENXIO;
@@ -252,12 +286,15 @@ devfs_imfs_writev(rtems_libio_t *iop, const struct iovec *iov, int iovcnt,
 		error = dsw->d_write(cdev, &uio,
 		    rtems_libio_to_fcntl_flags(iop->flags));
 		td->td_fpop = fpop;
-		dev_relthread(cdev, ref);
 	} else {
 		error = ENOMEM;
 	}
 
 err:
+	if (dsw != NULL)
+		dev_relthread(cdev, ref);
+	if (td != NULL && fp != NULL)
+		fdrop(fp, td);
 	if (error == 0) {
 		return (total - uio.uio_resid);
 	} else {
@@ -280,10 +317,10 @@ static int
 devfs_imfs_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer)
 {
 	struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
 	struct thread *td = rtems_bsd_get_curthread_or_null();
+	struct file *fp = NULL;
+	struct cdevsw *dsw = NULL;
 	struct file *fpop;
-	struct cdevsw *dsw;
 	int error, ref;
 	int flags = rtems_libio_to_fcntl_flags(iop->flags);
 
@@ -295,6 +332,11 @@ devfs_imfs_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer)
 		if (cdev->si_flags & SI_ALIAS) {
 			cdev = cdev->si_parent;
 		}
+		fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
+		if (fp == NULL) {
+			error = EBADF;
+			goto err;
+		}
 		dsw = dev_refthread(cdev, &ref);
 		if (dsw == NULL) {
 			error = ENXIO;
@@ -305,12 +347,15 @@ devfs_imfs_ioctl(rtems_libio_t *iop, ioctl_command_t request, void *buffer)
 		error = dsw->d_ioctl(cdev, request, buffer, flags,
 		    td);
 		td->td_fpop = fpop;
-		dev_relthread(cdev, ref);
 	} else {
 		error = ENOMEM;
 	}
 
 err:
+	if (dsw != NULL)
+		dev_relthread(cdev, ref);
+	if (td != NULL && fp != NULL)
+		fdrop(fp, td);
 	return rtems_bsd_error_to_status_and_errno(error);
 }
 
@@ -333,28 +378,43 @@ static int
 devfs_imfs_poll(rtems_libio_t *iop, int events)
 {
 	struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
 	struct thread *td = rtems_bsd_get_curthread_or_wait_forever();
+	struct file *fp = NULL;
+	struct cdevsw *dsw = NULL;
 	struct file *fpop;
-	struct cdevsw *dsw;
 	int error, ref;
 
-	if (cdev == NULL) {
-		return POLLERR;
-	}
-	if (cdev->si_flags & SI_ALIAS) {
-		cdev = cdev->si_parent;
-	}
-	dsw = dev_refthread(cdev, &ref);
-	if (dsw == NULL) {
-		return POLLERR;
+	if (td != 0) {
+		if (cdev == NULL) {
+			error = POLLERR;
+			goto err;
+		}
+		if (cdev->si_flags & SI_ALIAS) {
+			cdev = cdev->si_parent;
+		}
+		fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
+		if (fp == NULL) {
+			error = EBADF;
+			goto err;
+		}
+		dsw = dev_refthread(cdev, &ref);
+		if (dsw == NULL) {
+			error = POLLERR;
+			goto err;
+		}
+		fpop = td->td_fpop;
+		curthread->td_fpop = fp;
+		error = dsw->d_poll(cdev, events, td);
+		td->td_fpop = fpop;
+	} else {
+		error = ENOMEM;
 	}
-	fpop = td->td_fpop;
-	curthread->td_fpop = fp;
-	error = dsw->d_poll(cdev, events, td);
-	td->td_fpop = fpop;
-	dev_relthread(cdev, ref);
 
+err:
+	if (dsw != NULL)
+		dev_relthread(cdev, ref);
+	if (td != NULL && fp != NULL)
+		fdrop(fp, td);
 	return error;
 }
 
@@ -362,28 +422,41 @@ static int
 devfs_imfs_kqfilter(rtems_libio_t *iop, struct knote *kn)
 {
 	struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
-	struct file *fp = rtems_bsd_iop_to_fp(iop);
 	struct thread *td = rtems_bsd_get_curthread_or_wait_forever();
+	struct file *fp = NULL;
+	struct cdevsw *dsw = NULL;
 	struct file *fpop;
-	struct cdevsw *dsw;
 	int error, ref;
 
-	if (cdev == NULL) {
-		return EINVAL;
-	}
-	if (cdev->si_flags & SI_ALIAS) {
-		cdev = cdev->si_parent;
-	}
-	dsw = dev_refthread(cdev, &ref);
-	if (dsw == NULL) {
-		return EINVAL;
+	if (td != 0) {
+		if (cdev == NULL) {
+			error = EINVAL;
+		}
+		fp = rtems_bsd_libio_iop_to_file_hold(iop, td);
+		if (fp == NULL) {
+			error = EBADF;
+			goto err;
+		}
+		if (cdev->si_flags & SI_ALIAS) {
+			cdev = cdev->si_parent;
+		}
+		dsw = dev_refthread(cdev, &ref);
+		if (dsw == NULL) {
+			error = EINVAL;
+		}
+		fpop = td->td_fpop;
+		curthread->td_fpop = fp;
+		error = dsw->d_kqfilter(cdev, kn);
+		td->td_fpop = fpop;
+	} else {
+		error = ENOMEM;
 	}
-	fpop = td->td_fpop;
-	curthread->td_fpop = fp;
-	error = dsw->d_kqfilter(cdev, kn);
-	td->td_fpop = fpop;
-	dev_relthread(cdev, ref);
 
+err:
+	if (dsw != NULL)
+		dev_relthread(cdev, ref);
+	if (td != NULL && fp != NULL)
+		fdrop(fp, td);
 	return error;
 }
 
diff --git a/rtemsbsd/sys/kern/vnode_if.c b/rtemsbsd/sys/kern/vnode_if.c
new file mode 100644
index 00000000..0f51c54a
--- /dev/null
+++ b/rtemsbsd/sys/kern/vnode_if.c
@@ -0,0 +1,4763 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <sys/event.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/sdt.h>
+#include <sys/signalvar.h>
+#include <sys/systm.h>
+#include <sys/vnode.h>
+
+SDT_PROVIDER_DECLARE(vfs);
+
+struct vnodeop_desc vop_default_desc = {
+	"default",
+	0,
+	(vop_bypass_t *)vop_panic,
+	NULL,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_islocked_vp_offsets[] =  {
+	VOPARG_OFFSETOF(struct vop_islocked_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_islocked, entry, "struct vnode *", "struct vop_islocked_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_islocked, return, "struct vnode *", "struct vop_islocked_args *", "int");
+
+
+int
+VOP_ISLOCKED_AP(struct vop_islocked_args *a)
+{
+
+	return(VOP_ISLOCKED_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_ISLOCKED_APV(struct vop_vector *vop, struct vop_islocked_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_islocked_desc, a->a_vp,
+	    ("Wrong a_desc in vop_islocked(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_islocked == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_islocked(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_islocked, entry, a->a_vp, a);
+
+	KTR_START1(KTR_VOP, "VOP", "VOP_ISLOCKED", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_islocked != NULL)
+		rc = vop->vop_islocked(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_islocked, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_ISLOCKED", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_islocked_desc = {
+	"vop_islocked",
+	0,
+	(vop_bypass_t *)VOP_ISLOCKED_AP,
+	vop_islocked_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_lookup_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_lookup_args,a_dvp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_lookup, entry, "struct vnode *", "struct vop_lookup_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_lookup, return, "struct vnode *", "struct vop_lookup_args *", "int");
+
+
+int
+VOP_LOOKUP_AP(struct vop_lookup_args *a)
+{
+
+	return(VOP_LOOKUP_APV(a->a_dvp->v_op, a));
+}
+
+int
+VOP_LOOKUP_APV(struct vop_vector *vop, struct vop_lookup_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_lookup_desc, a->a_dvp,
+	    ("Wrong a_desc in vop_lookup(%p, %p)", a->a_dvp, a));
+	while(vop != NULL && \
+	    vop->vop_lookup == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_dvp, ("No vop_lookup(%p, %p)", a->a_dvp, a));
+	SDT_PROBE2(vfs, vop, vop_lookup, entry, a->a_dvp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_LOOKUP");
+	ASSERT_VOP_LOCKED(a->a_dvp, "VOP_LOOKUP");
+	KTR_START3(KTR_VOP, "VOP", "VOP_LOOKUP", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp);
+	VFS_PROLOGUE(a->a_dvp->v_mount);
+	if (vop->vop_lookup != NULL)
+		rc = vop->vop_lookup(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_dvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_lookup, return, a->a_dvp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_LOOKUP");
+		ASSERT_VOP_LOCKED(a->a_dvp, "VOP_LOOKUP");
+		ASSERT_VI_UNLOCKED(*a->a_vpp, "VOP_LOOKUP");
+		ASSERT_VOP_LOCKED(*a->a_vpp, "VOP_LOOKUP");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_LOOKUP");
+		ASSERT_VOP_LOCKED(a->a_dvp, "VOP_LOOKUP");
+	}
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_LOOKUP", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_lookup_desc = {
+	"vop_lookup",
+	0,
+	(vop_bypass_t *)VOP_LOOKUP_AP,
+	vop_lookup_vp_offsets,
+	VOPARG_OFFSETOF(struct vop_lookup_args,a_vpp),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_lookup_args,a_cnp),
+};
+
+static int vop_cachedlookup_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_cachedlookup_args,a_dvp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_cachedlookup, entry, "struct vnode *", "struct vop_cachedlookup_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_cachedlookup, return, "struct vnode *", "struct vop_cachedlookup_args *", "int");
+
+
+int
+VOP_CACHEDLOOKUP_AP(struct vop_cachedlookup_args *a)
+{
+
+	return(VOP_CACHEDLOOKUP_APV(a->a_dvp->v_op, a));
+}
+
+int
+VOP_CACHEDLOOKUP_APV(struct vop_vector *vop, struct vop_cachedlookup_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_cachedlookup_desc, a->a_dvp,
+	    ("Wrong a_desc in vop_cachedlookup(%p, %p)", a->a_dvp, a));
+	while(vop != NULL && \
+	    vop->vop_cachedlookup == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_dvp, ("No vop_cachedlookup(%p, %p)", a->a_dvp, a));
+	SDT_PROBE2(vfs, vop, vop_cachedlookup, entry, a->a_dvp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_CACHEDLOOKUP");
+	ASSERT_VOP_LOCKED(a->a_dvp, "VOP_CACHEDLOOKUP");
+	KTR_START3(KTR_VOP, "VOP", "VOP_CACHEDLOOKUP", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp);
+	VFS_PROLOGUE(a->a_dvp->v_mount);
+	if (vop->vop_cachedlookup != NULL)
+		rc = vop->vop_cachedlookup(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_dvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_cachedlookup, return, a->a_dvp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_CACHEDLOOKUP");
+		ASSERT_VOP_LOCKED(a->a_dvp, "VOP_CACHEDLOOKUP");
+		ASSERT_VI_UNLOCKED(*a->a_vpp, "VOP_CACHEDLOOKUP");
+		ASSERT_VOP_LOCKED(*a->a_vpp, "VOP_CACHEDLOOKUP");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_CACHEDLOOKUP");
+		ASSERT_VOP_LOCKED(a->a_dvp, "VOP_CACHEDLOOKUP");
+	}
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_CACHEDLOOKUP", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_cachedlookup_desc = {
+	"vop_cachedlookup",
+	0,
+	(vop_bypass_t *)VOP_CACHEDLOOKUP_AP,
+	vop_cachedlookup_vp_offsets,
+	VOPARG_OFFSETOF(struct vop_cachedlookup_args,a_vpp),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_cachedlookup_args,a_cnp),
+};
+
+static int vop_create_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_create_args,a_dvp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_create, entry, "struct vnode *", "struct vop_create_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_create, return, "struct vnode *", "struct vop_create_args *", "int");
+
+
+int
+VOP_CREATE_AP(struct vop_create_args *a)
+{
+
+	return(VOP_CREATE_APV(a->a_dvp->v_op, a));
+}
+
+int
+VOP_CREATE_APV(struct vop_vector *vop, struct vop_create_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_create_desc, a->a_dvp,
+	    ("Wrong a_desc in vop_create(%p, %p)", a->a_dvp, a));
+	while(vop != NULL && \
+	    vop->vop_create == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_dvp, ("No vop_create(%p, %p)", a->a_dvp, a));
+	SDT_PROBE2(vfs, vop, vop_create, entry, a->a_dvp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_CREATE");
+	ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_CREATE");
+	KTR_START4(KTR_VOP, "VOP", "VOP_CREATE", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp, "vap:0x%jX", a->a_vap);
+	VFS_PROLOGUE(a->a_dvp->v_mount);
+	if (vop->vop_create != NULL)
+		rc = vop->vop_create(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_dvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_create, return, a->a_dvp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_CREATE");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_CREATE");
+		ASSERT_VI_UNLOCKED(*a->a_vpp, "VOP_CREATE");
+		ASSERT_VOP_LOCKED(*a->a_vpp, "VOP_CREATE");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_CREATE");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_CREATE");
+	}
+	vop_create_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_CREATE", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp, "vap:0x%jX", a->a_vap);
+	return (rc);
+}
+
+struct vnodeop_desc vop_create_desc = {
+	"vop_create",
+	0,
+	(vop_bypass_t *)VOP_CREATE_AP,
+	vop_create_vp_offsets,
+	VOPARG_OFFSETOF(struct vop_create_args,a_vpp),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_create_args,a_cnp),
+};
+
+static int vop_whiteout_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_whiteout_args,a_dvp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_whiteout, entry, "struct vnode *", "struct vop_whiteout_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_whiteout, return, "struct vnode *", "struct vop_whiteout_args *", "int");
+
+
+int
+VOP_WHITEOUT_AP(struct vop_whiteout_args *a)
+{
+
+	return(VOP_WHITEOUT_APV(a->a_dvp->v_op, a));
+}
+
+int
+VOP_WHITEOUT_APV(struct vop_vector *vop, struct vop_whiteout_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_whiteout_desc, a->a_dvp,
+	    ("Wrong a_desc in vop_whiteout(%p, %p)", a->a_dvp, a));
+	while(vop != NULL && \
+	    vop->vop_whiteout == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_dvp, ("No vop_whiteout(%p, %p)", a->a_dvp, a));
+	SDT_PROBE2(vfs, vop, vop_whiteout, entry, a->a_dvp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_WHITEOUT");
+	ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_WHITEOUT");
+	KTR_START3(KTR_VOP, "VOP", "VOP_WHITEOUT", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "cnp:0x%jX", a->a_cnp, "flags:0x%jX", a->a_flags);
+	VFS_PROLOGUE(a->a_dvp->v_mount);
+	if (vop->vop_whiteout != NULL)
+		rc = vop->vop_whiteout(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_dvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_whiteout, return, a->a_dvp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_WHITEOUT");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_WHITEOUT");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_WHITEOUT");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_WHITEOUT");
+	}
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_WHITEOUT", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "cnp:0x%jX", a->a_cnp, "flags:0x%jX", a->a_flags);
+	return (rc);
+}
+
+struct vnodeop_desc vop_whiteout_desc = {
+	"vop_whiteout",
+	0,
+	(vop_bypass_t *)VOP_WHITEOUT_AP,
+	vop_whiteout_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_whiteout_args,a_cnp),
+};
+
+static int vop_mknod_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_mknod_args,a_dvp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_mknod, entry, "struct vnode *", "struct vop_mknod_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_mknod, return, "struct vnode *", "struct vop_mknod_args *", "int");
+
+
+int
+VOP_MKNOD_AP(struct vop_mknod_args *a)
+{
+
+	return(VOP_MKNOD_APV(a->a_dvp->v_op, a));
+}
+
+int
+VOP_MKNOD_APV(struct vop_vector *vop, struct vop_mknod_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_mknod_desc, a->a_dvp,
+	    ("Wrong a_desc in vop_mknod(%p, %p)", a->a_dvp, a));
+	while(vop != NULL && \
+	    vop->vop_mknod == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_dvp, ("No vop_mknod(%p, %p)", a->a_dvp, a));
+	SDT_PROBE2(vfs, vop, vop_mknod, entry, a->a_dvp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_MKNOD");
+	ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_MKNOD");
+	KTR_START4(KTR_VOP, "VOP", "VOP_MKNOD", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp, "vap:0x%jX", a->a_vap);
+	VFS_PROLOGUE(a->a_dvp->v_mount);
+	if (vop->vop_mknod != NULL)
+		rc = vop->vop_mknod(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_dvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_mknod, return, a->a_dvp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_MKNOD");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_MKNOD");
+		ASSERT_VI_UNLOCKED(*a->a_vpp, "VOP_MKNOD");
+		ASSERT_VOP_LOCKED(*a->a_vpp, "VOP_MKNOD");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_MKNOD");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_MKNOD");
+	}
+	vop_mknod_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_MKNOD", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp, "vap:0x%jX", a->a_vap);
+	return (rc);
+}
+
+struct vnodeop_desc vop_mknod_desc = {
+	"vop_mknod",
+	0,
+	(vop_bypass_t *)VOP_MKNOD_AP,
+	vop_mknod_vp_offsets,
+	VOPARG_OFFSETOF(struct vop_mknod_args,a_vpp),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_mknod_args,a_cnp),
+};
+
+static int vop_open_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_open_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_open, entry, "struct vnode *", "struct vop_open_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_open, return, "struct vnode *", "struct vop_open_args *", "int");
+
+
+int
+VOP_OPEN_AP(struct vop_open_args *a)
+{
+
+	return(VOP_OPEN_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_OPEN_APV(struct vop_vector *vop, struct vop_open_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_open_desc, a->a_vp,
+	    ("Wrong a_desc in vop_open(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_open == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_open(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_open, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_OPEN");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_OPEN");
+	KTR_START4(KTR_VOP, "VOP", "VOP_OPEN", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "mode:0x%jX", a->a_mode, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_open != NULL)
+		rc = vop->vop_open(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_open, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_OPEN");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_OPEN");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_OPEN");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_OPEN");
+	}
+	vop_open_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_OPEN", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "mode:0x%jX", a->a_mode, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_open_desc = {
+	"vop_open",
+	0,
+	(vop_bypass_t *)VOP_OPEN_AP,
+	vop_open_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_open_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_open_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_close_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_close_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_close, entry, "struct vnode *", "struct vop_close_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_close, return, "struct vnode *", "struct vop_close_args *", "int");
+
+
+int
+VOP_CLOSE_AP(struct vop_close_args *a)
+{
+
+	return(VOP_CLOSE_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_CLOSE_APV(struct vop_vector *vop, struct vop_close_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_close_desc, a->a_vp,
+	    ("Wrong a_desc in vop_close(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_close == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_close(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_close, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_CLOSE");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_CLOSE");
+	KTR_START4(KTR_VOP, "VOP", "VOP_CLOSE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "fflag:0x%jX", a->a_fflag, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_close != NULL)
+		rc = vop->vop_close(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_close, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_CLOSE");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_CLOSE");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_CLOSE");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_CLOSE");
+	}
+	vop_close_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_CLOSE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "fflag:0x%jX", a->a_fflag, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_close_desc = {
+	"vop_close",
+	0,
+	(vop_bypass_t *)VOP_CLOSE_AP,
+	vop_close_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_close_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_close_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_access_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_access_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_access, entry, "struct vnode *", "struct vop_access_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_access, return, "struct vnode *", "struct vop_access_args *", "int");
+
+
+int
+VOP_ACCESS_AP(struct vop_access_args *a)
+{
+
+	return(VOP_ACCESS_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_ACCESS_APV(struct vop_vector *vop, struct vop_access_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_access_desc, a->a_vp,
+	    ("Wrong a_desc in vop_access(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_access == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_access(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_access, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ACCESS");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_ACCESS");
+	KTR_START4(KTR_VOP, "VOP", "VOP_ACCESS", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "accmode:0x%jX", a->a_accmode, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_access != NULL)
+		rc = vop->vop_access(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_access, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ACCESS");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_ACCESS");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ACCESS");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_ACCESS");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_ACCESS", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "accmode:0x%jX", a->a_accmode, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_access_desc = {
+	"vop_access",
+	0,
+	(vop_bypass_t *)VOP_ACCESS_AP,
+	vop_access_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_access_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_access_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_accessx_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_accessx_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_accessx, entry, "struct vnode *", "struct vop_accessx_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_accessx, return, "struct vnode *", "struct vop_accessx_args *", "int");
+
+
+int
+VOP_ACCESSX_AP(struct vop_accessx_args *a)
+{
+
+	return(VOP_ACCESSX_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_ACCESSX_APV(struct vop_vector *vop, struct vop_accessx_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_accessx_desc, a->a_vp,
+	    ("Wrong a_desc in vop_accessx(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_accessx == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_accessx(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_accessx, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ACCESSX");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_ACCESSX");
+	KTR_START4(KTR_VOP, "VOP", "VOP_ACCESSX", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "accmode:0x%jX", a->a_accmode, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_accessx != NULL)
+		rc = vop->vop_accessx(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_accessx, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ACCESSX");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_ACCESSX");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ACCESSX");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_ACCESSX");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_ACCESSX", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "accmode:0x%jX", a->a_accmode, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_accessx_desc = {
+	"vop_accessx",
+	0,
+	(vop_bypass_t *)VOP_ACCESSX_AP,
+	vop_accessx_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_accessx_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_accessx_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_getattr_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_getattr_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_getattr, entry, "struct vnode *", "struct vop_getattr_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_getattr, return, "struct vnode *", "struct vop_getattr_args *", "int");
+
+
+int
+VOP_GETATTR_AP(struct vop_getattr_args *a)
+{
+
+	return(VOP_GETATTR_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_GETATTR_APV(struct vop_vector *vop, struct vop_getattr_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_getattr_desc, a->a_vp,
+	    ("Wrong a_desc in vop_getattr(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_getattr == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_getattr(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_getattr, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETATTR");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETATTR");
+	KTR_START3(KTR_VOP, "VOP", "VOP_GETATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "vap:0x%jX", a->a_vap, "cred:0x%jX", a->a_cred);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_getattr != NULL)
+		rc = vop->vop_getattr(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_getattr, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETATTR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETATTR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETATTR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETATTR");
+	}
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_GETATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "vap:0x%jX", a->a_vap, "cred:0x%jX", a->a_cred);
+	return (rc);
+}
+
+struct vnodeop_desc vop_getattr_desc = {
+	"vop_getattr",
+	0,
+	(vop_bypass_t *)VOP_GETATTR_AP,
+	vop_getattr_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_getattr_args,a_cred),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_setattr_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_setattr_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_setattr, entry, "struct vnode *", "struct vop_setattr_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_setattr, return, "struct vnode *", "struct vop_setattr_args *", "int");
+
+
+int
+VOP_SETATTR_AP(struct vop_setattr_args *a)
+{
+
+	return(VOP_SETATTR_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_SETATTR_APV(struct vop_vector *vop, struct vop_setattr_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_setattr_desc, a->a_vp,
+	    ("Wrong a_desc in vop_setattr(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_setattr == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_setattr(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_setattr, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETATTR");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETATTR");
+	KTR_START3(KTR_VOP, "VOP", "VOP_SETATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "vap:0x%jX", a->a_vap, "cred:0x%jX", a->a_cred);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_setattr != NULL)
+		rc = vop->vop_setattr(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_setattr, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETATTR");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETATTR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETATTR");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETATTR");
+	}
+	vop_setattr_post(a, rc);
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_SETATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "vap:0x%jX", a->a_vap, "cred:0x%jX", a->a_cred);
+	return (rc);
+}
+
+struct vnodeop_desc vop_setattr_desc = {
+	"vop_setattr",
+	0,
+	(vop_bypass_t *)VOP_SETATTR_AP,
+	vop_setattr_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_setattr_args,a_cred),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_markatime_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_markatime_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_markatime, entry, "struct vnode *", "struct vop_markatime_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_markatime, return, "struct vnode *", "struct vop_markatime_args *", "int");
+
+
+int
+VOP_MARKATIME_AP(struct vop_markatime_args *a)
+{
+
+	return(VOP_MARKATIME_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_MARKATIME_APV(struct vop_vector *vop, struct vop_markatime_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_markatime_desc, a->a_vp,
+	    ("Wrong a_desc in vop_markatime(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_markatime == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_markatime(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_markatime, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_MARKATIME");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_MARKATIME");
+	KTR_START1(KTR_VOP, "VOP", "VOP_MARKATIME", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_markatime != NULL)
+		rc = vop->vop_markatime(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_markatime, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_MARKATIME");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_MARKATIME");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_MARKATIME");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_MARKATIME");
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_MARKATIME", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_markatime_desc = {
+	"vop_markatime",
+	0,
+	(vop_bypass_t *)VOP_MARKATIME_AP,
+	vop_markatime_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_read_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_read_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_read, entry, "struct vnode *", "struct vop_read_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_read, return, "struct vnode *", "struct vop_read_args *", "int");
+
+
+int
+VOP_READ_AP(struct vop_read_args *a)
+{
+
+	return(VOP_READ_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_READ_APV(struct vop_vector *vop, struct vop_read_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_read_desc, a->a_vp,
+	    ("Wrong a_desc in vop_read(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_read == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_read(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_read, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_READ");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_READ");
+	KTR_START4(KTR_VOP, "VOP", "VOP_READ", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "uio:0x%jX", a->a_uio, "ioflag:0x%jX", a->a_ioflag, "cred:0x%jX", a->a_cred);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_read != NULL)
+		rc = vop->vop_read(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_read, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_READ");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_READ");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_READ");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_READ");
+	}
+	vop_read_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_READ", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "uio:0x%jX", a->a_uio, "ioflag:0x%jX", a->a_ioflag, "cred:0x%jX", a->a_cred);
+	return (rc);
+}
+
+struct vnodeop_desc vop_read_desc = {
+	"vop_read",
+	0,
+	(vop_bypass_t *)VOP_READ_AP,
+	vop_read_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_read_args,a_cred),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_write_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_write_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_write, entry, "struct vnode *", "struct vop_write_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_write, return, "struct vnode *", "struct vop_write_args *", "int");
+
+
+int
+VOP_WRITE_AP(struct vop_write_args *a)
+{
+
+	return(VOP_WRITE_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_WRITE_APV(struct vop_vector *vop, struct vop_write_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_write_desc, a->a_vp,
+	    ("Wrong a_desc in vop_write(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_write == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_write(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_write, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_WRITE");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_WRITE");
+	KTR_START4(KTR_VOP, "VOP", "VOP_WRITE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "uio:0x%jX", a->a_uio, "ioflag:0x%jX", a->a_ioflag, "cred:0x%jX", a->a_cred);
+	VOP_WRITE_PRE(a);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_write != NULL)
+		rc = vop->vop_write(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_write, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_WRITE");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_WRITE");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_WRITE");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_WRITE");
+	}
+	VOP_WRITE_POST(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_WRITE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "uio:0x%jX", a->a_uio, "ioflag:0x%jX", a->a_ioflag, "cred:0x%jX", a->a_cred);
+	return (rc);
+}
+
+struct vnodeop_desc vop_write_desc = {
+	"vop_write",
+	0,
+	(vop_bypass_t *)VOP_WRITE_AP,
+	vop_write_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_write_args,a_cred),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_ioctl_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_ioctl_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_ioctl, entry, "struct vnode *", "struct vop_ioctl_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_ioctl, return, "struct vnode *", "struct vop_ioctl_args *", "int");
+
+
+int
+VOP_IOCTL_AP(struct vop_ioctl_args *a)
+{
+
+	return(VOP_IOCTL_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_IOCTL_APV(struct vop_vector *vop, struct vop_ioctl_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_ioctl_desc, a->a_vp,
+	    ("Wrong a_desc in vop_ioctl(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_ioctl == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_ioctl(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_ioctl, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_IOCTL");
+	ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_IOCTL");
+	KTR_START4(KTR_VOP, "VOP", "VOP_IOCTL", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "command:0x%jX", a->a_command, "data:0x%jX", a->a_data, "fflag:0x%jX", a->a_fflag);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_ioctl != NULL)
+		rc = vop->vop_ioctl(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_ioctl, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_IOCTL");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_IOCTL");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_IOCTL");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_IOCTL");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_IOCTL", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "command:0x%jX", a->a_command, "data:0x%jX", a->a_data, "fflag:0x%jX", a->a_fflag);
+	return (rc);
+}
+
+struct vnodeop_desc vop_ioctl_desc = {
+	"vop_ioctl",
+	0,
+	(vop_bypass_t *)VOP_IOCTL_AP,
+	vop_ioctl_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_ioctl_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_ioctl_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_poll_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_poll_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_poll, entry, "struct vnode *", "struct vop_poll_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_poll, return, "struct vnode *", "struct vop_poll_args *", "int");
+
+
+int
+VOP_POLL_AP(struct vop_poll_args *a)
+{
+
+	return(VOP_POLL_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_POLL_APV(struct vop_vector *vop, struct vop_poll_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_poll_desc, a->a_vp,
+	    ("Wrong a_desc in vop_poll(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_poll == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_poll(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_poll, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_POLL");
+	ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_POLL");
+	KTR_START4(KTR_VOP, "VOP", "VOP_POLL", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "events:0x%jX", a->a_events, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_poll != NULL)
+		rc = vop->vop_poll(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_poll, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_POLL");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_POLL");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_POLL");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_POLL");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_POLL", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "events:0x%jX", a->a_events, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_poll_desc = {
+	"vop_poll",
+	0,
+	(vop_bypass_t *)VOP_POLL_AP,
+	vop_poll_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_poll_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_poll_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_kqfilter_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_kqfilter_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_kqfilter, entry, "struct vnode *", "struct vop_kqfilter_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_kqfilter, return, "struct vnode *", "struct vop_kqfilter_args *", "int");
+
+
+int
+VOP_KQFILTER_AP(struct vop_kqfilter_args *a)
+{
+
+	return(VOP_KQFILTER_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_KQFILTER_APV(struct vop_vector *vop, struct vop_kqfilter_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_kqfilter_desc, a->a_vp,
+	    ("Wrong a_desc in vop_kqfilter(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_kqfilter == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_kqfilter(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_kqfilter, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_KQFILTER");
+	ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_KQFILTER");
+	KTR_START2(KTR_VOP, "VOP", "VOP_KQFILTER", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "kn:0x%jX", a->a_kn);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_kqfilter != NULL)
+		rc = vop->vop_kqfilter(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_kqfilter, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_KQFILTER");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_KQFILTER");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_KQFILTER");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_KQFILTER");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_KQFILTER", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "kn:0x%jX", a->a_kn);
+	return (rc);
+}
+
+struct vnodeop_desc vop_kqfilter_desc = {
+	"vop_kqfilter",
+	0,
+	(vop_bypass_t *)VOP_KQFILTER_AP,
+	vop_kqfilter_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_revoke_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_revoke_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_revoke, entry, "struct vnode *", "struct vop_revoke_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_revoke, return, "struct vnode *", "struct vop_revoke_args *", "int");
+
+
+int
+VOP_REVOKE_AP(struct vop_revoke_args *a)
+{
+
+	return(VOP_REVOKE_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_REVOKE_APV(struct vop_vector *vop, struct vop_revoke_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_revoke_desc, a->a_vp,
+	    ("Wrong a_desc in vop_revoke(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_revoke == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_revoke(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_revoke, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_REVOKE");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_REVOKE");
+	KTR_START2(KTR_VOP, "VOP", "VOP_REVOKE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "flags:0x%jX", a->a_flags);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_revoke != NULL)
+		rc = vop->vop_revoke(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_revoke, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_REVOKE");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_REVOKE");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_REVOKE");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_REVOKE");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_REVOKE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "flags:0x%jX", a->a_flags);
+	return (rc);
+}
+
+struct vnodeop_desc vop_revoke_desc = {
+	"vop_revoke",
+	0,
+	(vop_bypass_t *)VOP_REVOKE_AP,
+	vop_revoke_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_fsync_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_fsync_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_fsync, entry, "struct vnode *", "struct vop_fsync_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_fsync, return, "struct vnode *", "struct vop_fsync_args *", "int");
+
+
+int
+VOP_FSYNC_AP(struct vop_fsync_args *a)
+{
+
+	return(VOP_FSYNC_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_FSYNC_APV(struct vop_vector *vop, struct vop_fsync_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_fsync_desc, a->a_vp,
+	    ("Wrong a_desc in vop_fsync(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_fsync == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_fsync(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_fsync, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_FSYNC");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_FSYNC");
+	KTR_START3(KTR_VOP, "VOP", "VOP_FSYNC", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "waitfor:0x%jX", a->a_waitfor, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_fsync != NULL)
+		rc = vop->vop_fsync(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_fsync, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_FSYNC");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_FSYNC");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_FSYNC");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_FSYNC");
+	}
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_FSYNC", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "waitfor:0x%jX", a->a_waitfor, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_fsync_desc = {
+	"vop_fsync",
+	0,
+	(vop_bypass_t *)VOP_FSYNC_AP,
+	vop_fsync_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_fsync_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_remove_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_remove_args,a_dvp),
+	VOPARG_OFFSETOF(struct vop_remove_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_remove, entry, "struct vnode *", "struct vop_remove_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_remove, return, "struct vnode *", "struct vop_remove_args *", "int");
+
+
+int
+VOP_REMOVE_AP(struct vop_remove_args *a)
+{
+
+	return(VOP_REMOVE_APV(a->a_dvp->v_op, a));
+}
+
+int
+VOP_REMOVE_APV(struct vop_vector *vop, struct vop_remove_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_remove_desc, a->a_dvp,
+	    ("Wrong a_desc in vop_remove(%p, %p)", a->a_dvp, a));
+	while(vop != NULL && \
+	    vop->vop_remove == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_dvp, ("No vop_remove(%p, %p)", a->a_dvp, a));
+	SDT_PROBE2(vfs, vop, vop_remove, entry, a->a_dvp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_REMOVE");
+	ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_REMOVE");
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_REMOVE");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_REMOVE");
+	KTR_START3(KTR_VOP, "VOP", "VOP_REMOVE", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vp:0x%jX", a->a_vp, "cnp:0x%jX", a->a_cnp);
+	VFS_PROLOGUE(a->a_dvp->v_mount);
+	if (vop->vop_remove != NULL)
+		rc = vop->vop_remove(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_dvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_remove, return, a->a_dvp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_REMOVE");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_REMOVE");
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_REMOVE");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_REMOVE");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_REMOVE");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_REMOVE");
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_REMOVE");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_REMOVE");
+	}
+	vop_remove_post(a, rc);
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_REMOVE", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vp:0x%jX", a->a_vp, "cnp:0x%jX", a->a_cnp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_remove_desc = {
+	"vop_remove",
+	0,
+	(vop_bypass_t *)VOP_REMOVE_AP,
+	vop_remove_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_remove_args,a_cnp),
+};
+
+static int vop_link_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_link_args,a_tdvp),
+	VOPARG_OFFSETOF(struct vop_link_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_link, entry, "struct vnode *", "struct vop_link_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_link, return, "struct vnode *", "struct vop_link_args *", "int");
+
+
+int
+VOP_LINK_AP(struct vop_link_args *a)
+{
+
+	return(VOP_LINK_APV(a->a_tdvp->v_op, a));
+}
+
+int
+VOP_LINK_APV(struct vop_vector *vop, struct vop_link_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_link_desc, a->a_tdvp,
+	    ("Wrong a_desc in vop_link(%p, %p)", a->a_tdvp, a));
+	while(vop != NULL && \
+	    vop->vop_link == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_tdvp, ("No vop_link(%p, %p)", a->a_tdvp, a));
+	SDT_PROBE2(vfs, vop, vop_link, entry, a->a_tdvp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_tdvp, "VOP_LINK");
+	ASSERT_VOP_ELOCKED(a->a_tdvp, "VOP_LINK");
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_LINK");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_LINK");
+	KTR_START3(KTR_VOP, "VOP", "VOP_LINK", (uintptr_t)a,
+	    "tdvp:0x%jX", (uintptr_t)a->a_tdvp, "vp:0x%jX", a->a_vp, "cnp:0x%jX", a->a_cnp);
+	VFS_PROLOGUE(a->a_tdvp->v_mount);
+	if (vop->vop_link != NULL)
+		rc = vop->vop_link(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_tdvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_link, return, a->a_tdvp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_tdvp, "VOP_LINK");
+		ASSERT_VOP_ELOCKED(a->a_tdvp, "VOP_LINK");
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_LINK");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_LINK");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_tdvp, "VOP_LINK");
+		ASSERT_VOP_ELOCKED(a->a_tdvp, "VOP_LINK");
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_LINK");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_LINK");
+	}
+	vop_link_post(a, rc);
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_LINK", (uintptr_t)a,
+	    "tdvp:0x%jX", (uintptr_t)a->a_tdvp, "vp:0x%jX", a->a_vp, "cnp:0x%jX", a->a_cnp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_link_desc = {
+	"vop_link",
+	0,
+	(vop_bypass_t *)VOP_LINK_AP,
+	vop_link_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_link_args,a_cnp),
+};
+
+static int vop_rename_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_rename_args,a_fdvp),
+	VOPARG_OFFSETOF(struct vop_rename_args,a_fvp),
+	VOPARG_OFFSETOF(struct vop_rename_args,a_tdvp),
+	VOPARG_OFFSETOF(struct vop_rename_args,a_tvp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_rename, entry, "struct vnode *", "struct vop_rename_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_rename, return, "struct vnode *", "struct vop_rename_args *", "int");
+
+
+int
+VOP_RENAME_AP(struct vop_rename_args *a)
+{
+
+	return(VOP_RENAME_APV(a->a_fdvp->v_op, a));
+}
+
+int
+VOP_RENAME_APV(struct vop_vector *vop, struct vop_rename_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_rename_desc, a->a_fdvp,
+	    ("Wrong a_desc in vop_rename(%p, %p)", a->a_fdvp, a));
+	while(vop != NULL && \
+	    vop->vop_rename == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_fdvp, ("No vop_rename(%p, %p)", a->a_fdvp, a));
+	SDT_PROBE2(vfs, vop, vop_rename, entry, a->a_fdvp, a);
+
+	KTR_START4(KTR_VOP, "VOP", "VOP_RENAME", (uintptr_t)a,
+	    "fdvp:0x%jX", (uintptr_t)a->a_fdvp, "fvp:0x%jX", a->a_fvp, "fcnp:0x%jX", a->a_fcnp, "tdvp:0x%jX", a->a_tdvp);
+	vop_rename_pre(a);
+	VFS_PROLOGUE(a->a_fdvp->v_mount);
+	if (vop->vop_rename != NULL)
+		rc = vop->vop_rename(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_fdvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_rename, return, a->a_fdvp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	vop_rename_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_RENAME", (uintptr_t)a,
+	    "fdvp:0x%jX", (uintptr_t)a->a_fdvp, "fvp:0x%jX", a->a_fvp, "fcnp:0x%jX", a->a_fcnp, "tdvp:0x%jX", a->a_tdvp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_rename_desc = {
+	"vop_rename",
+	VDESC_VP0_WILLRELE|VDESC_VP1_WILLRELE|VDESC_VP2_WILLRELE|VDESC_VP3_WILLRELE,
+	(vop_bypass_t *)VOP_RENAME_AP,
+	vop_rename_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_rename_args,a_fcnp),
+};
+
+static int vop_mkdir_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_mkdir_args,a_dvp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_mkdir, entry, "struct vnode *", "struct vop_mkdir_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_mkdir, return, "struct vnode *", "struct vop_mkdir_args *", "int");
+
+
+int
+VOP_MKDIR_AP(struct vop_mkdir_args *a)
+{
+
+	return(VOP_MKDIR_APV(a->a_dvp->v_op, a));
+}
+
+int
+VOP_MKDIR_APV(struct vop_vector *vop, struct vop_mkdir_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_mkdir_desc, a->a_dvp,
+	    ("Wrong a_desc in vop_mkdir(%p, %p)", a->a_dvp, a));
+	while(vop != NULL && \
+	    vop->vop_mkdir == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_dvp, ("No vop_mkdir(%p, %p)", a->a_dvp, a));
+	SDT_PROBE2(vfs, vop, vop_mkdir, entry, a->a_dvp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_MKDIR");
+	ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_MKDIR");
+	KTR_START4(KTR_VOP, "VOP", "VOP_MKDIR", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp, "vap:0x%jX", a->a_vap);
+	VFS_PROLOGUE(a->a_dvp->v_mount);
+	if (vop->vop_mkdir != NULL)
+		rc = vop->vop_mkdir(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_dvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_mkdir, return, a->a_dvp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_MKDIR");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_MKDIR");
+		ASSERT_VI_UNLOCKED(*a->a_vpp, "VOP_MKDIR");
+		ASSERT_VOP_ELOCKED(*a->a_vpp, "VOP_MKDIR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_MKDIR");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_MKDIR");
+	}
+	vop_mkdir_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_MKDIR", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp, "vap:0x%jX", a->a_vap);
+	return (rc);
+}
+
+struct vnodeop_desc vop_mkdir_desc = {
+	"vop_mkdir",
+	0,
+	(vop_bypass_t *)VOP_MKDIR_AP,
+	vop_mkdir_vp_offsets,
+	VOPARG_OFFSETOF(struct vop_mkdir_args,a_vpp),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_mkdir_args,a_cnp),
+};
+
+static int vop_rmdir_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_rmdir_args,a_dvp),
+	VOPARG_OFFSETOF(struct vop_rmdir_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_rmdir, entry, "struct vnode *", "struct vop_rmdir_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_rmdir, return, "struct vnode *", "struct vop_rmdir_args *", "int");
+
+
+int
+VOP_RMDIR_AP(struct vop_rmdir_args *a)
+{
+
+	return(VOP_RMDIR_APV(a->a_dvp->v_op, a));
+}
+
+int
+VOP_RMDIR_APV(struct vop_vector *vop, struct vop_rmdir_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_rmdir_desc, a->a_dvp,
+	    ("Wrong a_desc in vop_rmdir(%p, %p)", a->a_dvp, a));
+	while(vop != NULL && \
+	    vop->vop_rmdir == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_dvp, ("No vop_rmdir(%p, %p)", a->a_dvp, a));
+	SDT_PROBE2(vfs, vop, vop_rmdir, entry, a->a_dvp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_RMDIR");
+	ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_RMDIR");
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_RMDIR");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_RMDIR");
+	KTR_START3(KTR_VOP, "VOP", "VOP_RMDIR", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vp:0x%jX", a->a_vp, "cnp:0x%jX", a->a_cnp);
+	VFS_PROLOGUE(a->a_dvp->v_mount);
+	if (vop->vop_rmdir != NULL)
+		rc = vop->vop_rmdir(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_dvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_rmdir, return, a->a_dvp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_RMDIR");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_RMDIR");
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_RMDIR");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_RMDIR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_RMDIR");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_RMDIR");
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_RMDIR");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_RMDIR");
+	}
+	vop_rmdir_post(a, rc);
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_RMDIR", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vp:0x%jX", a->a_vp, "cnp:0x%jX", a->a_cnp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_rmdir_desc = {
+	"vop_rmdir",
+	0,
+	(vop_bypass_t *)VOP_RMDIR_AP,
+	vop_rmdir_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_rmdir_args,a_cnp),
+};
+
+static int vop_symlink_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_symlink_args,a_dvp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_symlink, entry, "struct vnode *", "struct vop_symlink_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_symlink, return, "struct vnode *", "struct vop_symlink_args *", "int");
+
+
+int
+VOP_SYMLINK_AP(struct vop_symlink_args *a)
+{
+
+	return(VOP_SYMLINK_APV(a->a_dvp->v_op, a));
+}
+
+int
+VOP_SYMLINK_APV(struct vop_vector *vop, struct vop_symlink_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_symlink_desc, a->a_dvp,
+	    ("Wrong a_desc in vop_symlink(%p, %p)", a->a_dvp, a));
+	while(vop != NULL && \
+	    vop->vop_symlink == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_dvp, ("No vop_symlink(%p, %p)", a->a_dvp, a));
+	SDT_PROBE2(vfs, vop, vop_symlink, entry, a->a_dvp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_SYMLINK");
+	ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_SYMLINK");
+	KTR_START4(KTR_VOP, "VOP", "VOP_SYMLINK", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp, "vap:0x%jX", a->a_vap);
+	VFS_PROLOGUE(a->a_dvp->v_mount);
+	if (vop->vop_symlink != NULL)
+		rc = vop->vop_symlink(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_dvp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_symlink, return, a->a_dvp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_SYMLINK");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_SYMLINK");
+		ASSERT_VI_UNLOCKED(*a->a_vpp, "VOP_SYMLINK");
+		ASSERT_VOP_ELOCKED(*a->a_vpp, "VOP_SYMLINK");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_dvp, "VOP_SYMLINK");
+		ASSERT_VOP_ELOCKED(a->a_dvp, "VOP_SYMLINK");
+	}
+	vop_symlink_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_SYMLINK", (uintptr_t)a,
+	    "dvp:0x%jX", (uintptr_t)a->a_dvp, "vpp:0x%jX", a->a_vpp, "cnp:0x%jX", a->a_cnp, "vap:0x%jX", a->a_vap);
+	return (rc);
+}
+
+struct vnodeop_desc vop_symlink_desc = {
+	"vop_symlink",
+	0,
+	(vop_bypass_t *)VOP_SYMLINK_AP,
+	vop_symlink_vp_offsets,
+	VOPARG_OFFSETOF(struct vop_symlink_args,a_vpp),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_symlink_args,a_cnp),
+};
+
+static int vop_readdir_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_readdir_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_readdir, entry, "struct vnode *", "struct vop_readdir_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_readdir, return, "struct vnode *", "struct vop_readdir_args *", "int");
+
+
+int
+VOP_READDIR_AP(struct vop_readdir_args *a)
+{
+
+	return(VOP_READDIR_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_READDIR_APV(struct vop_vector *vop, struct vop_readdir_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_readdir_desc, a->a_vp,
+	    ("Wrong a_desc in vop_readdir(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_readdir == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_readdir(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_readdir, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_READDIR");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_READDIR");
+	KTR_START4(KTR_VOP, "VOP", "VOP_READDIR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "uio:0x%jX", a->a_uio, "cred:0x%jX", a->a_cred, "eofflag:0x%jX", a->a_eofflag);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_readdir != NULL)
+		rc = vop->vop_readdir(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_readdir, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_READDIR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_READDIR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_READDIR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_READDIR");
+	}
+	vop_readdir_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_READDIR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "uio:0x%jX", a->a_uio, "cred:0x%jX", a->a_cred, "eofflag:0x%jX", a->a_eofflag);
+	return (rc);
+}
+
+struct vnodeop_desc vop_readdir_desc = {
+	"vop_readdir",
+	0,
+	(vop_bypass_t *)VOP_READDIR_AP,
+	vop_readdir_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_readdir_args,a_cred),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_readlink_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_readlink_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_readlink, entry, "struct vnode *", "struct vop_readlink_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_readlink, return, "struct vnode *", "struct vop_readlink_args *", "int");
+
+
+int
+VOP_READLINK_AP(struct vop_readlink_args *a)
+{
+
+	return(VOP_READLINK_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_READLINK_APV(struct vop_vector *vop, struct vop_readlink_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_readlink_desc, a->a_vp,
+	    ("Wrong a_desc in vop_readlink(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_readlink == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_readlink(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_readlink, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_READLINK");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_READLINK");
+	KTR_START3(KTR_VOP, "VOP", "VOP_READLINK", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "uio:0x%jX", a->a_uio, "cred:0x%jX", a->a_cred);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_readlink != NULL)
+		rc = vop->vop_readlink(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_readlink, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_READLINK");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_READLINK");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_READLINK");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_READLINK");
+	}
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_READLINK", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "uio:0x%jX", a->a_uio, "cred:0x%jX", a->a_cred);
+	return (rc);
+}
+
+struct vnodeop_desc vop_readlink_desc = {
+	"vop_readlink",
+	0,
+	(vop_bypass_t *)VOP_READLINK_AP,
+	vop_readlink_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_readlink_args,a_cred),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_inactive_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_inactive_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_inactive, entry, "struct vnode *", "struct vop_inactive_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_inactive, return, "struct vnode *", "struct vop_inactive_args *", "int");
+
+
+int
+VOP_INACTIVE_AP(struct vop_inactive_args *a)
+{
+
+	return(VOP_INACTIVE_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_INACTIVE_APV(struct vop_vector *vop, struct vop_inactive_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_inactive_desc, a->a_vp,
+	    ("Wrong a_desc in vop_inactive(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_inactive == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_inactive(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_inactive, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_INACTIVE");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_INACTIVE");
+	KTR_START2(KTR_VOP, "VOP", "VOP_INACTIVE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_inactive != NULL)
+		rc = vop->vop_inactive(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_inactive, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_INACTIVE");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_INACTIVE");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_INACTIVE");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_INACTIVE");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_INACTIVE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_inactive_desc = {
+	"vop_inactive",
+	0,
+	(vop_bypass_t *)VOP_INACTIVE_AP,
+	vop_inactive_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_inactive_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_reclaim_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_reclaim_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_reclaim, entry, "struct vnode *", "struct vop_reclaim_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_reclaim, return, "struct vnode *", "struct vop_reclaim_args *", "int");
+
+
+int
+VOP_RECLAIM_AP(struct vop_reclaim_args *a)
+{
+
+	return(VOP_RECLAIM_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_RECLAIM_APV(struct vop_vector *vop, struct vop_reclaim_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_reclaim_desc, a->a_vp,
+	    ("Wrong a_desc in vop_reclaim(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_reclaim == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_reclaim(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_reclaim, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_RECLAIM");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_RECLAIM");
+	KTR_START2(KTR_VOP, "VOP", "VOP_RECLAIM", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_reclaim != NULL)
+		rc = vop->vop_reclaim(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_reclaim, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_RECLAIM");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_RECLAIM");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_RECLAIM");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_RECLAIM");
+	}
+	vop_reclaim_post(a, rc);
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_RECLAIM", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_reclaim_desc = {
+	"vop_reclaim",
+	0,
+	(vop_bypass_t *)VOP_RECLAIM_AP,
+	vop_reclaim_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_reclaim_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_lock1_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_lock1_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_lock1, entry, "struct vnode *", "struct vop_lock1_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_lock1, return, "struct vnode *", "struct vop_lock1_args *", "int");
+
+
+int
+VOP_LOCK1_AP(struct vop_lock1_args *a)
+{
+
+	return(VOP_LOCK1_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_LOCK1_APV(struct vop_vector *vop, struct vop_lock1_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_lock1_desc, a->a_vp,
+	    ("Wrong a_desc in vop_lock1(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_lock1 == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_lock1(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_lock1, entry, a->a_vp, a);
+
+	KTR_START4(KTR_VOP, "VOP", "VOP_LOCK1", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "flags:0x%jX", a->a_flags, "file:0x%jX", a->a_file, "line:0x%jX", a->a_line);
+	vop_lock_pre(a);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_lock1 != NULL)
+		rc = vop->vop_lock1(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_lock1, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	vop_lock_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_LOCK1", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "flags:0x%jX", a->a_flags, "file:0x%jX", a->a_file, "line:0x%jX", a->a_line);
+	return (rc);
+}
+
+struct vnodeop_desc vop_lock1_desc = {
+	"vop_lock1",
+	0,
+	(vop_bypass_t *)VOP_LOCK1_AP,
+	vop_lock1_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_unlock_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_unlock_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_unlock, entry, "struct vnode *", "struct vop_unlock_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_unlock, return, "struct vnode *", "struct vop_unlock_args *", "int");
+
+
+int
+VOP_UNLOCK_AP(struct vop_unlock_args *a)
+{
+
+	return(VOP_UNLOCK_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_UNLOCK_APV(struct vop_vector *vop, struct vop_unlock_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_unlock_desc, a->a_vp,
+	    ("Wrong a_desc in vop_unlock(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_unlock == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_unlock(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_unlock, entry, a->a_vp, a);
+
+	KTR_START2(KTR_VOP, "VOP", "VOP_UNLOCK", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "flags:0x%jX", a->a_flags);
+	vop_unlock_pre(a);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_unlock != NULL)
+		rc = vop->vop_unlock(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_unlock, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	vop_unlock_post(a, rc);
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_UNLOCK", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "flags:0x%jX", a->a_flags);
+	return (rc);
+}
+
+struct vnodeop_desc vop_unlock_desc = {
+	"vop_unlock",
+	0,
+	(vop_bypass_t *)VOP_UNLOCK_AP,
+	vop_unlock_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_bmap_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_bmap_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_bmap, entry, "struct vnode *", "struct vop_bmap_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_bmap, return, "struct vnode *", "struct vop_bmap_args *", "int");
+
+
+int
+VOP_BMAP_AP(struct vop_bmap_args *a)
+{
+
+	return(VOP_BMAP_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_BMAP_APV(struct vop_vector *vop, struct vop_bmap_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_bmap_desc, a->a_vp,
+	    ("Wrong a_desc in vop_bmap(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_bmap == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_bmap(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_bmap, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_BMAP");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_BMAP");
+	KTR_START4(KTR_VOP, "VOP", "VOP_BMAP", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "bn:0x%jX", a->a_bn, "bop:0x%jX", a->a_bop, "bnp:0x%jX", a->a_bnp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_bmap != NULL)
+		rc = vop->vop_bmap(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_bmap, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_BMAP");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_BMAP");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_BMAP");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_BMAP");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_BMAP", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "bn:0x%jX", a->a_bn, "bop:0x%jX", a->a_bop, "bnp:0x%jX", a->a_bnp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_bmap_desc = {
+	"vop_bmap",
+	0,
+	(vop_bypass_t *)VOP_BMAP_AP,
+	vop_bmap_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_strategy_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_strategy_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_strategy, entry, "struct vnode *", "struct vop_strategy_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_strategy, return, "struct vnode *", "struct vop_strategy_args *", "int");
+
+
+int
+VOP_STRATEGY_AP(struct vop_strategy_args *a)
+{
+
+	return(VOP_STRATEGY_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_STRATEGY_APV(struct vop_vector *vop, struct vop_strategy_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_strategy_desc, a->a_vp,
+	    ("Wrong a_desc in vop_strategy(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_strategy == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_strategy(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_strategy, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_STRATEGY");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_STRATEGY");
+	KTR_START2(KTR_VOP, "VOP", "VOP_STRATEGY", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "bp:0x%jX", a->a_bp);
+	vop_strategy_pre(a);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_strategy != NULL)
+		rc = vop->vop_strategy(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_strategy, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_STRATEGY");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_STRATEGY");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_STRATEGY");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_STRATEGY");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_STRATEGY", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "bp:0x%jX", a->a_bp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_strategy_desc = {
+	"vop_strategy",
+	0,
+	(vop_bypass_t *)VOP_STRATEGY_AP,
+	vop_strategy_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_getwritemount_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_getwritemount_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_getwritemount, entry, "struct vnode *", "struct vop_getwritemount_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_getwritemount, return, "struct vnode *", "struct vop_getwritemount_args *", "int");
+
+
+int
+VOP_GETWRITEMOUNT_AP(struct vop_getwritemount_args *a)
+{
+
+	return(VOP_GETWRITEMOUNT_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_GETWRITEMOUNT_APV(struct vop_vector *vop, struct vop_getwritemount_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_getwritemount_desc, a->a_vp,
+	    ("Wrong a_desc in vop_getwritemount(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_getwritemount == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_getwritemount(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_getwritemount, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETWRITEMOUNT");
+	KTR_START2(KTR_VOP, "VOP", "VOP_GETWRITEMOUNT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "mpp:0x%jX", a->a_mpp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_getwritemount != NULL)
+		rc = vop->vop_getwritemount(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_getwritemount, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETWRITEMOUNT");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETWRITEMOUNT");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_GETWRITEMOUNT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "mpp:0x%jX", a->a_mpp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_getwritemount_desc = {
+	"vop_getwritemount",
+	0,
+	(vop_bypass_t *)VOP_GETWRITEMOUNT_AP,
+	vop_getwritemount_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_print_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_print_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_print, entry, "struct vnode *", "struct vop_print_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_print, return, "struct vnode *", "struct vop_print_args *", "int");
+
+
+int
+VOP_PRINT_AP(struct vop_print_args *a)
+{
+
+	return(VOP_PRINT_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_PRINT_APV(struct vop_vector *vop, struct vop_print_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_print_desc, a->a_vp,
+	    ("Wrong a_desc in vop_print(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_print == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_print(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_print, entry, a->a_vp, a);
+
+	KTR_START1(KTR_VOP, "VOP", "VOP_PRINT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_print != NULL)
+		rc = vop->vop_print(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_print, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_PRINT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_print_desc = {
+	"vop_print",
+	0,
+	(vop_bypass_t *)VOP_PRINT_AP,
+	vop_print_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_pathconf_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_pathconf_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_pathconf, entry, "struct vnode *", "struct vop_pathconf_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_pathconf, return, "struct vnode *", "struct vop_pathconf_args *", "int");
+
+
+int
+VOP_PATHCONF_AP(struct vop_pathconf_args *a)
+{
+
+	return(VOP_PATHCONF_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_PATHCONF_APV(struct vop_vector *vop, struct vop_pathconf_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_pathconf_desc, a->a_vp,
+	    ("Wrong a_desc in vop_pathconf(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_pathconf == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_pathconf(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_pathconf, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_PATHCONF");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_PATHCONF");
+	KTR_START3(KTR_VOP, "VOP", "VOP_PATHCONF", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "name:0x%jX", a->a_name, "retval:0x%jX", a->a_retval);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_pathconf != NULL)
+		rc = vop->vop_pathconf(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_pathconf, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_PATHCONF");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_PATHCONF");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_PATHCONF");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_PATHCONF");
+	}
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_PATHCONF", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "name:0x%jX", a->a_name, "retval:0x%jX", a->a_retval);
+	return (rc);
+}
+
+struct vnodeop_desc vop_pathconf_desc = {
+	"vop_pathconf",
+	0,
+	(vop_bypass_t *)VOP_PATHCONF_AP,
+	vop_pathconf_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_advlock_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_advlock_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_advlock, entry, "struct vnode *", "struct vop_advlock_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_advlock, return, "struct vnode *", "struct vop_advlock_args *", "int");
+
+
+int
+VOP_ADVLOCK_AP(struct vop_advlock_args *a)
+{
+
+	return(VOP_ADVLOCK_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_ADVLOCK_APV(struct vop_vector *vop, struct vop_advlock_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_advlock_desc, a->a_vp,
+	    ("Wrong a_desc in vop_advlock(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_advlock == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_advlock(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_advlock, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVLOCK");
+	ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_ADVLOCK");
+	KTR_START4(KTR_VOP, "VOP", "VOP_ADVLOCK", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "id:0x%jX", a->a_id, "op:0x%jX", a->a_op, "fl:0x%jX", a->a_fl);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_advlock != NULL)
+		rc = vop->vop_advlock(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_advlock, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVLOCK");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_ADVLOCK");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVLOCK");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_ADVLOCK");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_ADVLOCK", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "id:0x%jX", a->a_id, "op:0x%jX", a->a_op, "fl:0x%jX", a->a_fl);
+	return (rc);
+}
+
+struct vnodeop_desc vop_advlock_desc = {
+	"vop_advlock",
+	0,
+	(vop_bypass_t *)VOP_ADVLOCK_AP,
+	vop_advlock_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_advlockasync_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_advlockasync_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_advlockasync, entry, "struct vnode *", "struct vop_advlockasync_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_advlockasync, return, "struct vnode *", "struct vop_advlockasync_args *", "int");
+
+
+int
+VOP_ADVLOCKASYNC_AP(struct vop_advlockasync_args *a)
+{
+
+	return(VOP_ADVLOCKASYNC_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_ADVLOCKASYNC_APV(struct vop_vector *vop, struct vop_advlockasync_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_advlockasync_desc, a->a_vp,
+	    ("Wrong a_desc in vop_advlockasync(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_advlockasync == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_advlockasync(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_advlockasync, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVLOCKASYNC");
+	ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_ADVLOCKASYNC");
+	KTR_START4(KTR_VOP, "VOP", "VOP_ADVLOCKASYNC", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "id:0x%jX", a->a_id, "op:0x%jX", a->a_op, "fl:0x%jX", a->a_fl);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_advlockasync != NULL)
+		rc = vop->vop_advlockasync(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_advlockasync, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVLOCKASYNC");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_ADVLOCKASYNC");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVLOCKASYNC");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_ADVLOCKASYNC");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_ADVLOCKASYNC", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "id:0x%jX", a->a_id, "op:0x%jX", a->a_op, "fl:0x%jX", a->a_fl);
+	return (rc);
+}
+
+struct vnodeop_desc vop_advlockasync_desc = {
+	"vop_advlockasync",
+	0,
+	(vop_bypass_t *)VOP_ADVLOCKASYNC_AP,
+	vop_advlockasync_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_advlockpurge_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_advlockpurge_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_advlockpurge, entry, "struct vnode *", "struct vop_advlockpurge_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_advlockpurge, return, "struct vnode *", "struct vop_advlockpurge_args *", "int");
+
+
+int
+VOP_ADVLOCKPURGE_AP(struct vop_advlockpurge_args *a)
+{
+
+	return(VOP_ADVLOCKPURGE_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_ADVLOCKPURGE_APV(struct vop_vector *vop, struct vop_advlockpurge_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_advlockpurge_desc, a->a_vp,
+	    ("Wrong a_desc in vop_advlockpurge(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_advlockpurge == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_advlockpurge(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_advlockpurge, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVLOCKPURGE");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_ADVLOCKPURGE");
+	KTR_START1(KTR_VOP, "VOP", "VOP_ADVLOCKPURGE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_advlockpurge != NULL)
+		rc = vop->vop_advlockpurge(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_advlockpurge, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVLOCKPURGE");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_ADVLOCKPURGE");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVLOCKPURGE");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_ADVLOCKPURGE");
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_ADVLOCKPURGE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_advlockpurge_desc = {
+	"vop_advlockpurge",
+	0,
+	(vop_bypass_t *)VOP_ADVLOCKPURGE_AP,
+	vop_advlockpurge_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_reallocblks_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_reallocblks_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_reallocblks, entry, "struct vnode *", "struct vop_reallocblks_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_reallocblks, return, "struct vnode *", "struct vop_reallocblks_args *", "int");
+
+
+int
+VOP_REALLOCBLKS_AP(struct vop_reallocblks_args *a)
+{
+
+	return(VOP_REALLOCBLKS_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_REALLOCBLKS_APV(struct vop_vector *vop, struct vop_reallocblks_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_reallocblks_desc, a->a_vp,
+	    ("Wrong a_desc in vop_reallocblks(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_reallocblks == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_reallocblks(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_reallocblks, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_REALLOCBLKS");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_REALLOCBLKS");
+	KTR_START2(KTR_VOP, "VOP", "VOP_REALLOCBLKS", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "buflist:0x%jX", a->a_buflist);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_reallocblks != NULL)
+		rc = vop->vop_reallocblks(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_reallocblks, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_REALLOCBLKS");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_REALLOCBLKS");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_REALLOCBLKS");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_REALLOCBLKS");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_REALLOCBLKS", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "buflist:0x%jX", a->a_buflist);
+	return (rc);
+}
+
+struct vnodeop_desc vop_reallocblks_desc = {
+	"vop_reallocblks",
+	0,
+	(vop_bypass_t *)VOP_REALLOCBLKS_AP,
+	vop_reallocblks_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_getpages_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_getpages_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_getpages, entry, "struct vnode *", "struct vop_getpages_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_getpages, return, "struct vnode *", "struct vop_getpages_args *", "int");
+
+
+int
+VOP_GETPAGES_AP(struct vop_getpages_args *a)
+{
+
+	return(VOP_GETPAGES_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_GETPAGES_APV(struct vop_vector *vop, struct vop_getpages_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_getpages_desc, a->a_vp,
+	    ("Wrong a_desc in vop_getpages(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_getpages == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_getpages(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_getpages, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETPAGES");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETPAGES");
+	KTR_START4(KTR_VOP, "VOP", "VOP_GETPAGES", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "m:0x%jX", a->a_m, "count:0x%jX", a->a_count, "rbehind:0x%jX", a->a_rbehind);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_getpages != NULL)
+		rc = vop->vop_getpages(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_getpages, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETPAGES");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETPAGES");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETPAGES");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETPAGES");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_GETPAGES", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "m:0x%jX", a->a_m, "count:0x%jX", a->a_count, "rbehind:0x%jX", a->a_rbehind);
+	return (rc);
+}
+
+struct vnodeop_desc vop_getpages_desc = {
+	"vop_getpages",
+	0,
+	(vop_bypass_t *)VOP_GETPAGES_AP,
+	vop_getpages_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_getpages_async_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_getpages_async_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_getpages_async, entry, "struct vnode *", "struct vop_getpages_async_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_getpages_async, return, "struct vnode *", "struct vop_getpages_async_args *", "int");
+
+
+int
+VOP_GETPAGES_ASYNC_AP(struct vop_getpages_async_args *a)
+{
+
+	return(VOP_GETPAGES_ASYNC_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_GETPAGES_ASYNC_APV(struct vop_vector *vop, struct vop_getpages_async_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_getpages_async_desc, a->a_vp,
+	    ("Wrong a_desc in vop_getpages_async(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_getpages_async == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_getpages_async(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_getpages_async, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETPAGES_ASYNC");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETPAGES_ASYNC");
+	KTR_START4(KTR_VOP, "VOP", "VOP_GETPAGES_ASYNC", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "m:0x%jX", a->a_m, "count:0x%jX", a->a_count, "rbehind:0x%jX", a->a_rbehind);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_getpages_async != NULL)
+		rc = vop->vop_getpages_async(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_getpages_async, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETPAGES_ASYNC");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETPAGES_ASYNC");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETPAGES_ASYNC");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETPAGES_ASYNC");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_GETPAGES_ASYNC", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "m:0x%jX", a->a_m, "count:0x%jX", a->a_count, "rbehind:0x%jX", a->a_rbehind);
+	return (rc);
+}
+
+struct vnodeop_desc vop_getpages_async_desc = {
+	"vop_getpages_async",
+	0,
+	(vop_bypass_t *)VOP_GETPAGES_ASYNC_AP,
+	vop_getpages_async_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_putpages_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_putpages_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_putpages, entry, "struct vnode *", "struct vop_putpages_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_putpages, return, "struct vnode *", "struct vop_putpages_args *", "int");
+
+
+int
+VOP_PUTPAGES_AP(struct vop_putpages_args *a)
+{
+
+	return(VOP_PUTPAGES_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_PUTPAGES_APV(struct vop_vector *vop, struct vop_putpages_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_putpages_desc, a->a_vp,
+	    ("Wrong a_desc in vop_putpages(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_putpages == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_putpages(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_putpages, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_PUTPAGES");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_PUTPAGES");
+	KTR_START4(KTR_VOP, "VOP", "VOP_PUTPAGES", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "m:0x%jX", a->a_m, "count:0x%jX", a->a_count, "sync:0x%jX", a->a_sync);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_putpages != NULL)
+		rc = vop->vop_putpages(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_putpages, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_PUTPAGES");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_PUTPAGES");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_PUTPAGES");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_PUTPAGES");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_PUTPAGES", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "m:0x%jX", a->a_m, "count:0x%jX", a->a_count, "sync:0x%jX", a->a_sync);
+	return (rc);
+}
+
+struct vnodeop_desc vop_putpages_desc = {
+	"vop_putpages",
+	0,
+	(vop_bypass_t *)VOP_PUTPAGES_AP,
+	vop_putpages_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_getacl_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_getacl_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_getacl, entry, "struct vnode *", "struct vop_getacl_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_getacl, return, "struct vnode *", "struct vop_getacl_args *", "int");
+
+
+int
+VOP_GETACL_AP(struct vop_getacl_args *a)
+{
+
+	return(VOP_GETACL_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_GETACL_APV(struct vop_vector *vop, struct vop_getacl_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_getacl_desc, a->a_vp,
+	    ("Wrong a_desc in vop_getacl(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_getacl == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_getacl(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_getacl, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETACL");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETACL");
+	KTR_START4(KTR_VOP, "VOP", "VOP_GETACL", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "type:0x%jX", a->a_type, "aclp:0x%jX", a->a_aclp, "cred:0x%jX", a->a_cred);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_getacl != NULL)
+		rc = vop->vop_getacl(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_getacl, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETACL");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETACL");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETACL");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETACL");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_GETACL", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "type:0x%jX", a->a_type, "aclp:0x%jX", a->a_aclp, "cred:0x%jX", a->a_cred);
+	return (rc);
+}
+
+struct vnodeop_desc vop_getacl_desc = {
+	"vop_getacl",
+	0,
+	(vop_bypass_t *)VOP_GETACL_AP,
+	vop_getacl_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_getacl_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_getacl_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_setacl_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_setacl_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_setacl, entry, "struct vnode *", "struct vop_setacl_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_setacl, return, "struct vnode *", "struct vop_setacl_args *", "int");
+
+
+int
+VOP_SETACL_AP(struct vop_setacl_args *a)
+{
+
+	return(VOP_SETACL_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_SETACL_APV(struct vop_vector *vop, struct vop_setacl_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_setacl_desc, a->a_vp,
+	    ("Wrong a_desc in vop_setacl(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_setacl == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_setacl(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_setacl, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETACL");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETACL");
+	KTR_START4(KTR_VOP, "VOP", "VOP_SETACL", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "type:0x%jX", a->a_type, "aclp:0x%jX", a->a_aclp, "cred:0x%jX", a->a_cred);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_setacl != NULL)
+		rc = vop->vop_setacl(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_setacl, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETACL");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETACL");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETACL");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETACL");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_SETACL", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "type:0x%jX", a->a_type, "aclp:0x%jX", a->a_aclp, "cred:0x%jX", a->a_cred);
+	return (rc);
+}
+
+struct vnodeop_desc vop_setacl_desc = {
+	"vop_setacl",
+	0,
+	(vop_bypass_t *)VOP_SETACL_AP,
+	vop_setacl_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_setacl_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_setacl_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_aclcheck_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_aclcheck_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_aclcheck, entry, "struct vnode *", "struct vop_aclcheck_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_aclcheck, return, "struct vnode *", "struct vop_aclcheck_args *", "int");
+
+
+int
+VOP_ACLCHECK_AP(struct vop_aclcheck_args *a)
+{
+
+	return(VOP_ACLCHECK_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_ACLCHECK_APV(struct vop_vector *vop, struct vop_aclcheck_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_aclcheck_desc, a->a_vp,
+	    ("Wrong a_desc in vop_aclcheck(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_aclcheck == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_aclcheck(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_aclcheck, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ACLCHECK");
+	KTR_START4(KTR_VOP, "VOP", "VOP_ACLCHECK", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "type:0x%jX", a->a_type, "aclp:0x%jX", a->a_aclp, "cred:0x%jX", a->a_cred);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_aclcheck != NULL)
+		rc = vop->vop_aclcheck(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_aclcheck, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ACLCHECK");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ACLCHECK");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_ACLCHECK", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "type:0x%jX", a->a_type, "aclp:0x%jX", a->a_aclp, "cred:0x%jX", a->a_cred);
+	return (rc);
+}
+
+struct vnodeop_desc vop_aclcheck_desc = {
+	"vop_aclcheck",
+	0,
+	(vop_bypass_t *)VOP_ACLCHECK_AP,
+	vop_aclcheck_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_aclcheck_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_aclcheck_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_closeextattr_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_closeextattr_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_closeextattr, entry, "struct vnode *", "struct vop_closeextattr_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_closeextattr, return, "struct vnode *", "struct vop_closeextattr_args *", "int");
+
+
+int
+VOP_CLOSEEXTATTR_AP(struct vop_closeextattr_args *a)
+{
+
+	return(VOP_CLOSEEXTATTR_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_CLOSEEXTATTR_APV(struct vop_vector *vop, struct vop_closeextattr_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_closeextattr_desc, a->a_vp,
+	    ("Wrong a_desc in vop_closeextattr(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_closeextattr == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_closeextattr(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_closeextattr, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_CLOSEEXTATTR");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_CLOSEEXTATTR");
+	KTR_START4(KTR_VOP, "VOP", "VOP_CLOSEEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "commit:0x%jX", a->a_commit, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_closeextattr != NULL)
+		rc = vop->vop_closeextattr(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_closeextattr, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_CLOSEEXTATTR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_CLOSEEXTATTR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_CLOSEEXTATTR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_CLOSEEXTATTR");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_CLOSEEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "commit:0x%jX", a->a_commit, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_closeextattr_desc = {
+	"vop_closeextattr",
+	0,
+	(vop_bypass_t *)VOP_CLOSEEXTATTR_AP,
+	vop_closeextattr_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_closeextattr_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_closeextattr_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_getextattr_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_getextattr_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_getextattr, entry, "struct vnode *", "struct vop_getextattr_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_getextattr, return, "struct vnode *", "struct vop_getextattr_args *", "int");
+
+
+int
+VOP_GETEXTATTR_AP(struct vop_getextattr_args *a)
+{
+
+	return(VOP_GETEXTATTR_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_GETEXTATTR_APV(struct vop_vector *vop, struct vop_getextattr_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_getextattr_desc, a->a_vp,
+	    ("Wrong a_desc in vop_getextattr(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_getextattr == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_getextattr(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_getextattr, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETEXTATTR");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETEXTATTR");
+	KTR_START4(KTR_VOP, "VOP", "VOP_GETEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "attrnamespace:0x%jX", a->a_attrnamespace, "name:0x%jX", a->a_name, "uio:0x%jX", a->a_uio);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_getextattr != NULL)
+		rc = vop->vop_getextattr(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_getextattr, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETEXTATTR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETEXTATTR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GETEXTATTR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GETEXTATTR");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_GETEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "attrnamespace:0x%jX", a->a_attrnamespace, "name:0x%jX", a->a_name, "uio:0x%jX", a->a_uio);
+	return (rc);
+}
+
+struct vnodeop_desc vop_getextattr_desc = {
+	"vop_getextattr",
+	0,
+	(vop_bypass_t *)VOP_GETEXTATTR_AP,
+	vop_getextattr_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_getextattr_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_getextattr_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_listextattr_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_listextattr_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_listextattr, entry, "struct vnode *", "struct vop_listextattr_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_listextattr, return, "struct vnode *", "struct vop_listextattr_args *", "int");
+
+
+int
+VOP_LISTEXTATTR_AP(struct vop_listextattr_args *a)
+{
+
+	return(VOP_LISTEXTATTR_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_LISTEXTATTR_APV(struct vop_vector *vop, struct vop_listextattr_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_listextattr_desc, a->a_vp,
+	    ("Wrong a_desc in vop_listextattr(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_listextattr == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_listextattr(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_listextattr, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_LISTEXTATTR");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_LISTEXTATTR");
+	KTR_START4(KTR_VOP, "VOP", "VOP_LISTEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "attrnamespace:0x%jX", a->a_attrnamespace, "uio:0x%jX", a->a_uio, "size:0x%jX", a->a_size);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_listextattr != NULL)
+		rc = vop->vop_listextattr(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_listextattr, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_LISTEXTATTR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_LISTEXTATTR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_LISTEXTATTR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_LISTEXTATTR");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_LISTEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "attrnamespace:0x%jX", a->a_attrnamespace, "uio:0x%jX", a->a_uio, "size:0x%jX", a->a_size);
+	return (rc);
+}
+
+struct vnodeop_desc vop_listextattr_desc = {
+	"vop_listextattr",
+	0,
+	(vop_bypass_t *)VOP_LISTEXTATTR_AP,
+	vop_listextattr_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_listextattr_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_listextattr_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_openextattr_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_openextattr_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_openextattr, entry, "struct vnode *", "struct vop_openextattr_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_openextattr, return, "struct vnode *", "struct vop_openextattr_args *", "int");
+
+
+int
+VOP_OPENEXTATTR_AP(struct vop_openextattr_args *a)
+{
+
+	return(VOP_OPENEXTATTR_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_OPENEXTATTR_APV(struct vop_vector *vop, struct vop_openextattr_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_openextattr_desc, a->a_vp,
+	    ("Wrong a_desc in vop_openextattr(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_openextattr == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_openextattr(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_openextattr, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_OPENEXTATTR");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_OPENEXTATTR");
+	KTR_START3(KTR_VOP, "VOP", "VOP_OPENEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_openextattr != NULL)
+		rc = vop->vop_openextattr(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_openextattr, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_OPENEXTATTR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_OPENEXTATTR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_OPENEXTATTR");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_OPENEXTATTR");
+	}
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_OPENEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_openextattr_desc = {
+	"vop_openextattr",
+	0,
+	(vop_bypass_t *)VOP_OPENEXTATTR_AP,
+	vop_openextattr_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_openextattr_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_openextattr_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_deleteextattr_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_deleteextattr_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_deleteextattr, entry, "struct vnode *", "struct vop_deleteextattr_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_deleteextattr, return, "struct vnode *", "struct vop_deleteextattr_args *", "int");
+
+
+int
+VOP_DELETEEXTATTR_AP(struct vop_deleteextattr_args *a)
+{
+
+	return(VOP_DELETEEXTATTR_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_DELETEEXTATTR_APV(struct vop_vector *vop, struct vop_deleteextattr_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_deleteextattr_desc, a->a_vp,
+	    ("Wrong a_desc in vop_deleteextattr(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_deleteextattr == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_deleteextattr(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_deleteextattr, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_DELETEEXTATTR");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_DELETEEXTATTR");
+	KTR_START4(KTR_VOP, "VOP", "VOP_DELETEEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "attrnamespace:0x%jX", a->a_attrnamespace, "name:0x%jX", a->a_name, "cred:0x%jX", a->a_cred);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_deleteextattr != NULL)
+		rc = vop->vop_deleteextattr(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_deleteextattr, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_DELETEEXTATTR");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_DELETEEXTATTR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_DELETEEXTATTR");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_DELETEEXTATTR");
+	}
+	vop_deleteextattr_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_DELETEEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "attrnamespace:0x%jX", a->a_attrnamespace, "name:0x%jX", a->a_name, "cred:0x%jX", a->a_cred);
+	return (rc);
+}
+
+struct vnodeop_desc vop_deleteextattr_desc = {
+	"vop_deleteextattr",
+	0,
+	(vop_bypass_t *)VOP_DELETEEXTATTR_AP,
+	vop_deleteextattr_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_deleteextattr_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_deleteextattr_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_setextattr_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_setextattr_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_setextattr, entry, "struct vnode *", "struct vop_setextattr_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_setextattr, return, "struct vnode *", "struct vop_setextattr_args *", "int");
+
+
+int
+VOP_SETEXTATTR_AP(struct vop_setextattr_args *a)
+{
+
+	return(VOP_SETEXTATTR_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_SETEXTATTR_APV(struct vop_vector *vop, struct vop_setextattr_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_setextattr_desc, a->a_vp,
+	    ("Wrong a_desc in vop_setextattr(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_setextattr == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_setextattr(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_setextattr, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETEXTATTR");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETEXTATTR");
+	KTR_START4(KTR_VOP, "VOP", "VOP_SETEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "attrnamespace:0x%jX", a->a_attrnamespace, "name:0x%jX", a->a_name, "uio:0x%jX", a->a_uio);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_setextattr != NULL)
+		rc = vop->vop_setextattr(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_setextattr, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETEXTATTR");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETEXTATTR");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETEXTATTR");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETEXTATTR");
+	}
+	vop_setextattr_post(a, rc);
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_SETEXTATTR", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "attrnamespace:0x%jX", a->a_attrnamespace, "name:0x%jX", a->a_name, "uio:0x%jX", a->a_uio);
+	return (rc);
+}
+
+struct vnodeop_desc vop_setextattr_desc = {
+	"vop_setextattr",
+	0,
+	(vop_bypass_t *)VOP_SETEXTATTR_AP,
+	vop_setextattr_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_setextattr_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_setextattr_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_setlabel_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_setlabel_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_setlabel, entry, "struct vnode *", "struct vop_setlabel_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_setlabel, return, "struct vnode *", "struct vop_setlabel_args *", "int");
+
+
+int
+VOP_SETLABEL_AP(struct vop_setlabel_args *a)
+{
+
+	return(VOP_SETLABEL_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_SETLABEL_APV(struct vop_vector *vop, struct vop_setlabel_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_setlabel_desc, a->a_vp,
+	    ("Wrong a_desc in vop_setlabel(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_setlabel == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_setlabel(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_setlabel, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETLABEL");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETLABEL");
+	KTR_START4(KTR_VOP, "VOP", "VOP_SETLABEL", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "label:0x%jX", a->a_label, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_setlabel != NULL)
+		rc = vop->vop_setlabel(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_setlabel, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETLABEL");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETLABEL");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SETLABEL");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_SETLABEL");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_SETLABEL", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "label:0x%jX", a->a_label, "cred:0x%jX", a->a_cred, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_setlabel_desc = {
+	"vop_setlabel",
+	0,
+	(vop_bypass_t *)VOP_SETLABEL_AP,
+	vop_setlabel_vp_offsets,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_setlabel_args,a_cred),
+	VOPARG_OFFSETOF(struct vop_setlabel_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_vptofh_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_vptofh_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_vptofh, entry, "struct vnode *", "struct vop_vptofh_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_vptofh, return, "struct vnode *", "struct vop_vptofh_args *", "int");
+
+
+int
+VOP_VPTOFH_AP(struct vop_vptofh_args *a)
+{
+
+	return(VOP_VPTOFH_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_VPTOFH_APV(struct vop_vector *vop, struct vop_vptofh_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_vptofh_desc, a->a_vp,
+	    ("Wrong a_desc in vop_vptofh(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_vptofh == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_vptofh(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_vptofh, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_VPTOFH");
+	KTR_START2(KTR_VOP, "VOP", "VOP_VPTOFH", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "fhp:0x%jX", a->a_fhp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_vptofh != NULL)
+		rc = vop->vop_vptofh(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_vptofh, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_VPTOFH");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_VPTOFH");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_VPTOFH", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "fhp:0x%jX", a->a_fhp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_vptofh_desc = {
+	"vop_vptofh",
+	0,
+	(vop_bypass_t *)VOP_VPTOFH_AP,
+	vop_vptofh_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_vptocnp_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_vptocnp_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_vptocnp, entry, "struct vnode *", "struct vop_vptocnp_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_vptocnp, return, "struct vnode *", "struct vop_vptocnp_args *", "int");
+
+
+int
+VOP_VPTOCNP_AP(struct vop_vptocnp_args *a)
+{
+
+	return(VOP_VPTOCNP_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_VPTOCNP_APV(struct vop_vector *vop, struct vop_vptocnp_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_vptocnp_desc, a->a_vp,
+	    ("Wrong a_desc in vop_vptocnp(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_vptocnp == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_vptocnp(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_vptocnp, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_VPTOCNP");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_VPTOCNP");
+	KTR_START4(KTR_VOP, "VOP", "VOP_VPTOCNP", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "vpp:0x%jX", a->a_vpp, "cred:0x%jX", a->a_cred, "buf:0x%jX", a->a_buf);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_vptocnp != NULL)
+		rc = vop->vop_vptocnp(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_vptocnp, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_VPTOCNP");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_VPTOCNP");
+		ASSERT_VI_UNLOCKED(*a->a_vpp, "VOP_VPTOCNP");
+		ASSERT_VOP_UNLOCKED(*a->a_vpp, "VOP_VPTOCNP");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_VPTOCNP");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_VPTOCNP");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_VPTOCNP", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "vpp:0x%jX", a->a_vpp, "cred:0x%jX", a->a_cred, "buf:0x%jX", a->a_buf);
+	return (rc);
+}
+
+struct vnodeop_desc vop_vptocnp_desc = {
+	"vop_vptocnp",
+	0,
+	(vop_bypass_t *)VOP_VPTOCNP_AP,
+	vop_vptocnp_vp_offsets,
+	VOPARG_OFFSETOF(struct vop_vptocnp_args,a_vpp),
+	VOPARG_OFFSETOF(struct vop_vptocnp_args,a_cred),
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_allocate_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_allocate_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_allocate, entry, "struct vnode *", "struct vop_allocate_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_allocate, return, "struct vnode *", "struct vop_allocate_args *", "int");
+
+
+int
+VOP_ALLOCATE_AP(struct vop_allocate_args *a)
+{
+
+	return(VOP_ALLOCATE_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_ALLOCATE_APV(struct vop_vector *vop, struct vop_allocate_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_allocate_desc, a->a_vp,
+	    ("Wrong a_desc in vop_allocate(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_allocate == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_allocate(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_allocate, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ALLOCATE");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_ALLOCATE");
+	KTR_START3(KTR_VOP, "VOP", "VOP_ALLOCATE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "offset:0x%jX", a->a_offset, "len:0x%jX", a->a_len);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_allocate != NULL)
+		rc = vop->vop_allocate(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_allocate, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ALLOCATE");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_ALLOCATE");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ALLOCATE");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_ALLOCATE");
+	}
+	KTR_STOP3(KTR_VOP, "VOP", "VOP_ALLOCATE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "offset:0x%jX", a->a_offset, "len:0x%jX", a->a_len);
+	return (rc);
+}
+
+struct vnodeop_desc vop_allocate_desc = {
+	"vop_allocate",
+	0,
+	(vop_bypass_t *)VOP_ALLOCATE_AP,
+	vop_allocate_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_advise_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_advise_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_advise, entry, "struct vnode *", "struct vop_advise_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_advise, return, "struct vnode *", "struct vop_advise_args *", "int");
+
+
+int
+VOP_ADVISE_AP(struct vop_advise_args *a)
+{
+
+	return(VOP_ADVISE_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_ADVISE_APV(struct vop_vector *vop, struct vop_advise_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_advise_desc, a->a_vp,
+	    ("Wrong a_desc in vop_advise(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_advise == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_advise(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_advise, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVISE");
+	ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_ADVISE");
+	KTR_START4(KTR_VOP, "VOP", "VOP_ADVISE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "start:0x%jX", a->a_start, "end:0x%jX", a->a_end, "advice:0x%jX", a->a_advice);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_advise != NULL)
+		rc = vop->vop_advise(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_advise, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVISE");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_ADVISE");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADVISE");
+		ASSERT_VOP_UNLOCKED(a->a_vp, "VOP_ADVISE");
+	}
+	KTR_STOP4(KTR_VOP, "VOP", "VOP_ADVISE", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "start:0x%jX", a->a_start, "end:0x%jX", a->a_end, "advice:0x%jX", a->a_advice);
+	return (rc);
+}
+
+struct vnodeop_desc vop_advise_desc = {
+	"vop_advise",
+	0,
+	(vop_bypass_t *)VOP_ADVISE_AP,
+	vop_advise_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_unp_bind_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_unp_bind_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_unp_bind, entry, "struct vnode *", "struct vop_unp_bind_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_unp_bind, return, "struct vnode *", "struct vop_unp_bind_args *", "int");
+
+
+int
+VOP_UNP_BIND_AP(struct vop_unp_bind_args *a)
+{
+
+	return(VOP_UNP_BIND_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_UNP_BIND_APV(struct vop_vector *vop, struct vop_unp_bind_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_unp_bind_desc, a->a_vp,
+	    ("Wrong a_desc in vop_unp_bind(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_unp_bind == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_unp_bind(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_unp_bind, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_UNP_BIND");
+	ASSERT_VOP_ELOCKED(a->a_vp, "VOP_UNP_BIND");
+	KTR_START2(KTR_VOP, "VOP", "VOP_UNP_BIND", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "unpcb:0x%jX", a->a_unpcb);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_unp_bind != NULL)
+		rc = vop->vop_unp_bind(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_unp_bind, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_UNP_BIND");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_UNP_BIND");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_UNP_BIND");
+		ASSERT_VOP_ELOCKED(a->a_vp, "VOP_UNP_BIND");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_UNP_BIND", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "unpcb:0x%jX", a->a_unpcb);
+	return (rc);
+}
+
+struct vnodeop_desc vop_unp_bind_desc = {
+	"vop_unp_bind",
+	0,
+	(vop_bypass_t *)VOP_UNP_BIND_AP,
+	vop_unp_bind_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_unp_connect_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_unp_connect_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_unp_connect, entry, "struct vnode *", "struct vop_unp_connect_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_unp_connect, return, "struct vnode *", "struct vop_unp_connect_args *", "int");
+
+
+int
+VOP_UNP_CONNECT_AP(struct vop_unp_connect_args *a)
+{
+
+	return(VOP_UNP_CONNECT_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_UNP_CONNECT_APV(struct vop_vector *vop, struct vop_unp_connect_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_unp_connect_desc, a->a_vp,
+	    ("Wrong a_desc in vop_unp_connect(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_unp_connect == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_unp_connect(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_unp_connect, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_UNP_CONNECT");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_UNP_CONNECT");
+	KTR_START2(KTR_VOP, "VOP", "VOP_UNP_CONNECT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "unpcb:0x%jX", a->a_unpcb);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_unp_connect != NULL)
+		rc = vop->vop_unp_connect(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_unp_connect, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_UNP_CONNECT");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_UNP_CONNECT");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_UNP_CONNECT");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_UNP_CONNECT");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_UNP_CONNECT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "unpcb:0x%jX", a->a_unpcb);
+	return (rc);
+}
+
+struct vnodeop_desc vop_unp_connect_desc = {
+	"vop_unp_connect",
+	0,
+	(vop_bypass_t *)VOP_UNP_CONNECT_AP,
+	vop_unp_connect_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_unp_detach_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_unp_detach_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_unp_detach, entry, "struct vnode *", "struct vop_unp_detach_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_unp_detach, return, "struct vnode *", "struct vop_unp_detach_args *", "int");
+
+
+int
+VOP_UNP_DETACH_AP(struct vop_unp_detach_args *a)
+{
+
+	return(VOP_UNP_DETACH_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_UNP_DETACH_APV(struct vop_vector *vop, struct vop_unp_detach_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_unp_detach_desc, a->a_vp,
+	    ("Wrong a_desc in vop_unp_detach(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_unp_detach == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_unp_detach(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_unp_detach, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_UNP_DETACH");
+	KTR_START1(KTR_VOP, "VOP", "VOP_UNP_DETACH", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_unp_detach != NULL)
+		rc = vop->vop_unp_detach(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_unp_detach, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_UNP_DETACH");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_UNP_DETACH");
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_UNP_DETACH", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_unp_detach_desc = {
+	"vop_unp_detach",
+	0,
+	(vop_bypass_t *)VOP_UNP_DETACH_AP,
+	vop_unp_detach_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_is_text_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_is_text_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_is_text, entry, "struct vnode *", "struct vop_is_text_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_is_text, return, "struct vnode *", "struct vop_is_text_args *", "int");
+
+
+int
+VOP_IS_TEXT_AP(struct vop_is_text_args *a)
+{
+
+	return(VOP_IS_TEXT_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_IS_TEXT_APV(struct vop_vector *vop, struct vop_is_text_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_is_text_desc, a->a_vp,
+	    ("Wrong a_desc in vop_is_text(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_is_text == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_is_text(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_is_text, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_IS_TEXT");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_IS_TEXT");
+	KTR_START1(KTR_VOP, "VOP", "VOP_IS_TEXT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_is_text != NULL)
+		rc = vop->vop_is_text(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_is_text, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_IS_TEXT");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_IS_TEXT");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_IS_TEXT");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_IS_TEXT");
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_IS_TEXT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_is_text_desc = {
+	"vop_is_text",
+	0,
+	(vop_bypass_t *)VOP_IS_TEXT_AP,
+	vop_is_text_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_set_text_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_set_text_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_set_text, entry, "struct vnode *", "struct vop_set_text_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_set_text, return, "struct vnode *", "struct vop_set_text_args *", "int");
+
+
+int
+VOP_SET_TEXT_AP(struct vop_set_text_args *a)
+{
+
+	return(VOP_SET_TEXT_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_SET_TEXT_APV(struct vop_vector *vop, struct vop_set_text_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_set_text_desc, a->a_vp,
+	    ("Wrong a_desc in vop_set_text(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_set_text == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_set_text(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_set_text, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SET_TEXT");
+	KTR_START1(KTR_VOP, "VOP", "VOP_SET_TEXT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_set_text != NULL)
+		rc = vop->vop_set_text(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_set_text, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SET_TEXT");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_SET_TEXT");
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_SET_TEXT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_set_text_desc = {
+	"vop_set_text",
+	0,
+	(vop_bypass_t *)VOP_SET_TEXT_AP,
+	vop_set_text_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_unset_text_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_unset_text_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_unset_text, entry, "struct vnode *", "struct vop_unset_text_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_unset_text, return, "struct vnode *", "struct vop_unset_text_args *", "int");
+
+
+int
+VOP_UNSET_TEXT_AP(struct vop_unset_text_args *a)
+{
+
+	return(VOP_UNSET_TEXT_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_UNSET_TEXT_APV(struct vop_vector *vop, struct vop_unset_text_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_unset_text_desc, a->a_vp,
+	    ("Wrong a_desc in vop_unset_text(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_unset_text == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_unset_text(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_unset_text, entry, a->a_vp, a);
+
+	KTR_START1(KTR_VOP, "VOP", "VOP_UNSET_TEXT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_unset_text != NULL)
+		rc = vop->vop_unset_text(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_unset_text, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_UNSET_TEXT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_unset_text_desc = {
+	"vop_unset_text",
+	0,
+	(vop_bypass_t *)VOP_UNSET_TEXT_AP,
+	vop_unset_text_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_get_writecount_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_get_writecount_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_get_writecount, entry, "struct vnode *", "struct vop_get_writecount_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_get_writecount, return, "struct vnode *", "struct vop_get_writecount_args *", "int");
+
+
+int
+VOP_GET_WRITECOUNT_AP(struct vop_get_writecount_args *a)
+{
+
+	return(VOP_GET_WRITECOUNT_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_GET_WRITECOUNT_APV(struct vop_vector *vop, struct vop_get_writecount_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_get_writecount_desc, a->a_vp,
+	    ("Wrong a_desc in vop_get_writecount(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_get_writecount == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_get_writecount(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_get_writecount, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GET_WRITECOUNT");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_GET_WRITECOUNT");
+	KTR_START2(KTR_VOP, "VOP", "VOP_GET_WRITECOUNT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "writecount:0x%jX", a->a_writecount);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_get_writecount != NULL)
+		rc = vop->vop_get_writecount(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_get_writecount, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GET_WRITECOUNT");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GET_WRITECOUNT");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_GET_WRITECOUNT");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_GET_WRITECOUNT");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_GET_WRITECOUNT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "writecount:0x%jX", a->a_writecount);
+	return (rc);
+}
+
+struct vnodeop_desc vop_get_writecount_desc = {
+	"vop_get_writecount",
+	0,
+	(vop_bypass_t *)VOP_GET_WRITECOUNT_AP,
+	vop_get_writecount_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_add_writecount_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_add_writecount_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_add_writecount, entry, "struct vnode *", "struct vop_add_writecount_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_add_writecount, return, "struct vnode *", "struct vop_add_writecount_args *", "int");
+
+
+int
+VOP_ADD_WRITECOUNT_AP(struct vop_add_writecount_args *a)
+{
+
+	return(VOP_ADD_WRITECOUNT_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_ADD_WRITECOUNT_APV(struct vop_vector *vop, struct vop_add_writecount_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_add_writecount_desc, a->a_vp,
+	    ("Wrong a_desc in vop_add_writecount(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_add_writecount == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_add_writecount(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_add_writecount, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADD_WRITECOUNT");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_ADD_WRITECOUNT");
+	KTR_START2(KTR_VOP, "VOP", "VOP_ADD_WRITECOUNT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "inc:0x%jX", a->a_inc);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_add_writecount != NULL)
+		rc = vop->vop_add_writecount(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_add_writecount, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADD_WRITECOUNT");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_ADD_WRITECOUNT");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_ADD_WRITECOUNT");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_ADD_WRITECOUNT");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_ADD_WRITECOUNT", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "inc:0x%jX", a->a_inc);
+	return (rc);
+}
+
+struct vnodeop_desc vop_add_writecount_desc = {
+	"vop_add_writecount",
+	0,
+	(vop_bypass_t *)VOP_ADD_WRITECOUNT_AP,
+	vop_add_writecount_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_fdatasync_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_fdatasync_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_fdatasync, entry, "struct vnode *", "struct vop_fdatasync_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_fdatasync, return, "struct vnode *", "struct vop_fdatasync_args *", "int");
+
+
+int
+VOP_FDATASYNC_AP(struct vop_fdatasync_args *a)
+{
+
+	return(VOP_FDATASYNC_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_FDATASYNC_APV(struct vop_vector *vop, struct vop_fdatasync_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_fdatasync_desc, a->a_vp,
+	    ("Wrong a_desc in vop_fdatasync(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_fdatasync == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_fdatasync(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_fdatasync, entry, a->a_vp, a);
+
+	ASSERT_VI_UNLOCKED(a->a_vp, "VOP_FDATASYNC");
+	ASSERT_VOP_LOCKED(a->a_vp, "VOP_FDATASYNC");
+	KTR_START2(KTR_VOP, "VOP", "VOP_FDATASYNC", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "td:0x%jX", a->a_td);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_fdatasync != NULL)
+		rc = vop->vop_fdatasync(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_fdatasync, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_FDATASYNC");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_FDATASYNC");
+	} else {
+		ASSERT_VI_UNLOCKED(a->a_vp, "VOP_FDATASYNC");
+		ASSERT_VOP_LOCKED(a->a_vp, "VOP_FDATASYNC");
+	}
+	KTR_STOP2(KTR_VOP, "VOP", "VOP_FDATASYNC", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp, "td:0x%jX", a->a_td);
+	return (rc);
+}
+
+struct vnodeop_desc vop_fdatasync_desc = {
+	"vop_fdatasync",
+	0,
+	(vop_bypass_t *)VOP_FDATASYNC_AP,
+	vop_fdatasync_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VOPARG_OFFSETOF(struct vop_fdatasync_args,a_td),
+	VDESC_NO_OFFSET,
+};
+
+static int vop_spare1_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_spare1_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_spare1, entry, "struct vnode *", "struct vop_spare1_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_spare1, return, "struct vnode *", "struct vop_spare1_args *", "int");
+
+
+int
+VOP_SPARE1_AP(struct vop_spare1_args *a)
+{
+
+	return(VOP_SPARE1_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_SPARE1_APV(struct vop_vector *vop, struct vop_spare1_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_spare1_desc, a->a_vp,
+	    ("Wrong a_desc in vop_spare1(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_spare1 == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_spare1(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_spare1, entry, a->a_vp, a);
+
+	KTR_START1(KTR_VOP, "VOP", "VOP_SPARE1", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_spare1 != NULL)
+		rc = vop->vop_spare1(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_spare1, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_SPARE1", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_spare1_desc = {
+	"vop_spare1",
+	0,
+	(vop_bypass_t *)VOP_SPARE1_AP,
+	vop_spare1_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_spare2_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_spare2_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_spare2, entry, "struct vnode *", "struct vop_spare2_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_spare2, return, "struct vnode *", "struct vop_spare2_args *", "int");
+
+
+int
+VOP_SPARE2_AP(struct vop_spare2_args *a)
+{
+
+	return(VOP_SPARE2_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_SPARE2_APV(struct vop_vector *vop, struct vop_spare2_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_spare2_desc, a->a_vp,
+	    ("Wrong a_desc in vop_spare2(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_spare2 == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_spare2(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_spare2, entry, a->a_vp, a);
+
+	KTR_START1(KTR_VOP, "VOP", "VOP_SPARE2", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_spare2 != NULL)
+		rc = vop->vop_spare2(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_spare2, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_SPARE2", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_spare2_desc = {
+	"vop_spare2",
+	0,
+	(vop_bypass_t *)VOP_SPARE2_AP,
+	vop_spare2_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_spare3_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_spare3_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_spare3, entry, "struct vnode *", "struct vop_spare3_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_spare3, return, "struct vnode *", "struct vop_spare3_args *", "int");
+
+
+int
+VOP_SPARE3_AP(struct vop_spare3_args *a)
+{
+
+	return(VOP_SPARE3_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_SPARE3_APV(struct vop_vector *vop, struct vop_spare3_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_spare3_desc, a->a_vp,
+	    ("Wrong a_desc in vop_spare3(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_spare3 == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_spare3(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_spare3, entry, a->a_vp, a);
+
+	KTR_START1(KTR_VOP, "VOP", "VOP_SPARE3", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_spare3 != NULL)
+		rc = vop->vop_spare3(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_spare3, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_SPARE3", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_spare3_desc = {
+	"vop_spare3",
+	0,
+	(vop_bypass_t *)VOP_SPARE3_AP,
+	vop_spare3_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_spare4_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_spare4_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_spare4, entry, "struct vnode *", "struct vop_spare4_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_spare4, return, "struct vnode *", "struct vop_spare4_args *", "int");
+
+
+int
+VOP_SPARE4_AP(struct vop_spare4_args *a)
+{
+
+	return(VOP_SPARE4_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_SPARE4_APV(struct vop_vector *vop, struct vop_spare4_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_spare4_desc, a->a_vp,
+	    ("Wrong a_desc in vop_spare4(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_spare4 == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_spare4(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_spare4, entry, a->a_vp, a);
+
+	KTR_START1(KTR_VOP, "VOP", "VOP_SPARE4", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_spare4 != NULL)
+		rc = vop->vop_spare4(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_spare4, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_SPARE4", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_spare4_desc = {
+	"vop_spare4",
+	0,
+	(vop_bypass_t *)VOP_SPARE4_AP,
+	vop_spare4_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
+
+static int vop_spare5_vp_offsets[] = {
+	VOPARG_OFFSETOF(struct vop_spare5_args,a_vp),
+	VDESC_NO_OFFSET
+};
+
+
+SDT_PROBE_DEFINE2(vfs, vop, vop_spare5, entry, "struct vnode *", "struct vop_spare5_args *");
+
+SDT_PROBE_DEFINE3(vfs, vop, vop_spare5, return, "struct vnode *", "struct vop_spare5_args *", "int");
+
+
+int
+VOP_SPARE5_AP(struct vop_spare5_args *a)
+{
+
+	return(VOP_SPARE5_APV(a->a_vp->v_op, a));
+}
+
+int
+VOP_SPARE5_APV(struct vop_vector *vop, struct vop_spare5_args *a)
+{
+	int rc;
+
+	VNASSERT(a->a_gen.a_desc == &vop_spare5_desc, a->a_vp,
+	    ("Wrong a_desc in vop_spare5(%p, %p)", a->a_vp, a));
+	while(vop != NULL && \
+	    vop->vop_spare5 == NULL && vop->vop_bypass == NULL)
+		vop = vop->vop_default;
+	VNASSERT(vop != NULL, a->a_vp, ("No vop_spare5(%p, %p)", a->a_vp, a));
+	SDT_PROBE2(vfs, vop, vop_spare5, entry, a->a_vp, a);
+
+	KTR_START1(KTR_VOP, "VOP", "VOP_SPARE5", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	VFS_PROLOGUE(a->a_vp->v_mount);
+	if (vop->vop_spare5 != NULL)
+		rc = vop->vop_spare5(a);
+	else
+		rc = vop->vop_bypass(&a->a_gen);
+	VFS_EPILOGUE(a->a_vp->v_mount);
+	SDT_PROBE3(vfs, vop, vop_spare5, return, a->a_vp, a, rc);
+
+	if (rc == 0) {
+	} else {
+	}
+	KTR_STOP1(KTR_VOP, "VOP", "VOP_SPARE5", (uintptr_t)a,
+	    "vp:0x%jX", (uintptr_t)a->a_vp);
+	return (rc);
+}
+
+struct vnodeop_desc vop_spare5_desc = {
+	"vop_spare5",
+	0,
+	(vop_bypass_t *)VOP_SPARE5_AP,
+	vop_spare5_vp_offsets,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+	VDESC_NO_OFFSET,
+};
diff --git a/testsuite/include/rtems/bsd/test/default-init.h b/testsuite/include/rtems/bsd/test/default-init.h
index f8ea3acd..fd96805b 100644
--- a/testsuite/include/rtems/bsd/test/default-init.h
+++ b/testsuite/include/rtems/bsd/test/default-init.h
@@ -14,6 +14,13 @@
 #include <rtems/stackchk.h>
 #include <rtems/bsd/bsd.h>
 
+/*
+ * Work around the need for this declr and not being able to include sys/ioctl.h.
+ *
+ * rtems/bdbuf.h have a call to it
+ */
+int ioctl(int fd, unsigned long request, ...);
+
 static void default_set_self_prio( rtems_task_priority prio )
 {
   rtems_status_code sc;
diff --git a/testsuite/swi01/init.c b/testsuite/swi01/init.c
index d1de191a..af6f07c6 100644
--- a/testsuite/swi01/init.c
+++ b/testsuite/swi01/init.c
@@ -50,9 +50,6 @@
 
 #define TEST_NAME "LIBBSD SOFTWARE INTERRUPT 1"
 
-uintptr_t rtems_bsd_allocator_domain_page_mbuf_size =
-    RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT;
-
 static void Init(rtems_task_argument arg)
 {
 	rtems_status_code sc;
diff --git a/testsuite/syscalls01/test_main.c b/testsuite/syscalls01/test_main.c
index 1116890f..3cfda667 100644
--- a/testsuite/syscalls01/test_main.c
+++ b/testsuite/syscalls01/test_main.c
@@ -65,6 +65,8 @@
 #include <rtems/bsd/modules.h>
 #include <rtems/libcsupport.h>
 
+#include <rtems/libio_.h>
+
 #define TEST_NAME "LIBBSD SYSCALLS 1"
 
 typedef void (*no_mem_test_body)(int fd);
@@ -94,6 +96,7 @@ static socket_test socket_tests[] = {
 	{ PF_INET, SOCK_DGRAM, 0, 0 },
 	{ PF_INET, SOCK_SEQPACKET, 0, EPROTOTYPE },
 	{ PF_INET, SOCK_RAW, IPPROTO_3PC, 0 },
+
 	{ PF_INET, SOCK_RAW, IPPROTO_ADFS, 0 },
 	{ PF_INET, SOCK_RAW, IPPROTO_AH, 0 },
 	{ PF_INET, SOCK_RAW, IPPROTO_AHIP, 0 },
@@ -104,6 +107,7 @@ static socket_test socket_tests[] = {
 	{ PF_INET, SOCK_RAW, IPPROTO_BLT, 0 },
 	{ PF_INET, SOCK_RAW, IPPROTO_BRSATMON, 0 },
 	{ PF_INET, SOCK_RAW, IPPROTO_CARP, 0 },
+
 	{ PF_INET, SOCK_RAW, IPPROTO_CFTP, 0 },
 	{ PF_INET, SOCK_RAW, IPPROTO_CHAOS, 0 },
 	{ PF_INET, SOCK_RAW, IPPROTO_CMTP, 0 },
@@ -112,6 +116,7 @@ static socket_test socket_tests[] = {
 	{ PF_INET, SOCK_RAW, IPPROTO_DDP, 0 },
 	{ PF_INET, SOCK_RAW, IPPROTO_DGP, 0 },
 	{ PF_INET, SOCK_RAW, IPPROTO_DSTOPTS, 0 },
+
 	{ PF_INET, SOCK_RAW, IPPROTO_EGP, 0 },
 	{ PF_INET, SOCK_RAW, IPPROTO_EMCON, 0 },
 	{ PF_INET, SOCK_RAW, IPPROTO_ENCAP, 0 },
@@ -368,7 +373,7 @@ test_sockets(void)
 	size_t n = sizeof(socket_tests) / sizeof(socket_tests[0]);
 	size_t i;
 
-	puts("test sockets");
+	puts("Test Sockets");
 
 	for (i = 0; i < n; ++i) {
 		const socket_test *st = &socket_tests[i];
@@ -441,7 +446,8 @@ no_mem_socket_fstat(int fd)
 	int rv;
 
 	rv = fstat(fd, &st);
-	assert(rv == 0);
+	assert(rv == -1);
+	assert(errno == ENOMEM);
 }
 
 static void
@@ -450,7 +456,8 @@ no_mem_socket_shutdown(int fd)
 	int rv;
 
 	rv = shutdown(fd, SHUT_RDWR);
-	assert(rv == 0);
+	assert(rv == -1);
+	assert(errno == ENOMEM);
 }
 
 static void
@@ -1591,12 +1598,12 @@ test_kqueue_unsupported_ops(void)
 	errno = 0;
 	n = read(kq, &buf[0], sizeof(buf));
 	assert(n == -1);
-	assert(errno == ENOTSUP);
+	assert(errno == EOPNOTSUPP);
 
 	errno = 0;
 	n = write(kq, &buf[0], sizeof(buf));
 	assert(n == -1);
-	assert(errno == ENOTSUP);
+	assert(errno == EOPNOTSUPP);
 
 	errno = 0;
 	rv = ioctl(kq, 0);
@@ -1636,7 +1643,8 @@ no_mem_kqueue_fstat(int fd)
 	int rv;
 
 	rv = fstat(fd, &st);
-	assert(rv == 0);
+	assert(rv == -1);
+	assert(errno == ENOMEM);
 }
 
 static void
diff --git a/testsuite/thread01/test_main.c b/testsuite/thread01/test_main.c
index 9d5e5bba..8dd77e88 100644
--- a/testsuite/thread01/test_main.c
+++ b/testsuite/thread01/test_main.c
@@ -278,6 +278,16 @@ test_kthread_add(void)
 static void
 test_rtems_bsd_get_curthread_or_null(void)
 {
+#ifdef TEST_IS_BROKEN
+	/*
+	 * This part of test relies on nothing calling
+	 * rtems_bsd_get_current.*() before getting here so the workspace
+	 * can be consumed and the allocation fails. Changes in other
+	 * areas of libbsd have resulted in `Init` having a struct thread
+	 * object allocated.
+	 *
+	 * Maybe creating a new thread and using that would be a more stable test.
+	 */
 	rtems_resource_snapshot snapshot;
 	void *greedy;
 
@@ -290,12 +300,12 @@ test_rtems_bsd_get_curthread_or_null(void)
 	rtems_workspace_greedy_free(greedy);
 
 	rtems_resource_snapshot_take(&snapshot);
+#endif
 }
 
 static void
 test_main(void)
 {
-
 	main_task_id = rtems_task_self();
 
 	/*
diff --git a/testsuite/timeout01/init.c b/testsuite/timeout01/init.c
index 6dfacd34..b2162038 100644
--- a/testsuite/timeout01/init.c
+++ b/testsuite/timeout01/init.c
@@ -48,9 +48,6 @@
 
 #define TEST_NAME "LIBBSD TIMEOUT 1"
 
-uintptr_t rtems_bsd_allocator_domain_page_mbuf_size =
-    RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT;
-
 static void Init(rtems_task_argument arg)
 {
 	rtems_status_code sc;
diff --git a/wscript b/wscript
index f1577224..bfdcc91c 100644
--- a/wscript
+++ b/wscript
@@ -145,7 +145,9 @@ def options(opt):
                    action="store",
                    default="",
                    dest="freebsd_options",
-                   help="Set FreeBSD options (developer option).")
+                   help="Set FreeBSD options (developer option). Supported: " + \
+                   "bootverbose,verbose_sysinit,debug_locks,ktr,ktr_verbose," + \
+                   "rtems_bsd_descrip_trace,rtems_bsd_syscall_trace,rtems_bsd_vfs_trace")
     opt.add_option(
         "--optimization",
         action="store",
-- 
2.24.1

