Index: Makefile.am
===================================================================
RCS file: /stacken-cvs/arla/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- Makefile.am	25 Jan 2007 11:23:05 -0000	1.5
+++ Makefile.am	16 Feb 2008 03:49:49 -0000
@@ -19,6 +19,7 @@
 		lib/bufdir \
 		$(rxkad) \
 		nnpfs \
+		appl/lib \
 		arlad \
 		conf \
 		appl \
Index: configure.in
===================================================================
RCS file: /stacken-cvs/arla/configure.in,v
retrieving revision 1.758
diff -u -r1.758 configure.in
--- configure.in	25 Jan 2007 09:28:46 -0000	1.758
+++ configure.in	16 Feb 2008 03:49:52 -0000
@@ -396,7 +396,7 @@
   KERNEL=`sysctl -n kern.bootfile`
   AC_WERROR(BSD_WERROR)
   NNPFS_SUBDIR=freebsd
-  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/nnpfs/bsd
+  KERNEL_INCLUDE=-I/usr/include -I`(cd $srcdir; pwd)`/nnpfs/bsd
   KERNEL_SRCS='bsd-subr.c'
 
   KERNEL=`sysctl -n kern.bootfile`
@@ -433,7 +433,7 @@
 	esac
 	shift
   done
-  KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} -I. $defs${defs:+ }$flags${flags:+ }$incl"
+  KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} -I/usr/include -I. $defs${defs:+ }$flags${flags:+ }$incl"
   test_KERNEL_CFLAGS="${KERNEL_CFLAGS}"
   KERNEL_LD='ld'
 
@@ -867,6 +867,7 @@
 		sys/mutex.h			\
 		sys/param.h			\
 		sys/prctl.h			\
+		sys/priv.h			\
 		sys/poll.h			\
 		sys/pool.h			\
 		sys/queue.h			\
@@ -1356,11 +1357,13 @@
 udev2dev					\
 snprintf					\
 suser_ucred					\
+priv_check					\
 namei_hash					\
 nosys						\
 sys_nosys					\
 sys_lkmnosys					\
 cache_purgevfs					\
+insmntque					\
 ])
 AC_CHECK_KERNEL_FUNC(memcpy, [0,0,0])
 
@@ -1446,8 +1449,12 @@
 AC_CHECK_KERNEL_VOP_T
 AC_BSD_FUNC_VFS_OBJECT_CREATE
 AC_BSD_FUNC_VOP_LOCK
+AC_BSD_FUNC_VOP_UNLOCK
+AC_BSD_FUNC_VOP_OPEN
 AC_BSD_FUNC_VFS_BUSY
+AC_BSD_FUNC_VFS_QUOTACTL
 AC_BSD_FUNC_VGET
+AC_BSD_FUNC_VNODE_CREATE_VOBJECT
 AC_BSD_FUNC_SUSER
 AC_BSD_FUNC_VFS_GETNEWFSID
 AC_BSD_FUNC_LOCKMGR
Index: appl/fs/fs_local.h
===================================================================
RCS file: /stacken-cvs/arla/appl/fs/fs_local.h,v
retrieving revision 1.38
diff -u -r1.38 fs_local.h
--- appl/fs/fs_local.h	16 Mar 2006 14:38:28 -0000	1.38
+++ appl/fs/fs_local.h	16 Feb 2008 03:49:53 -0000
@@ -43,7 +43,6 @@
 #endif
 #include <parse_units.h>
 #include <nnpfs/nnpfs_debug.h>
-#include <nnpfs/nnpfs_deb.h>
 #include <arladeb.h>
 
 #include <vers.h>
Index: cf/bsd-vfs-quotactl.m4
===================================================================
RCS file: cf/bsd-vfs-quotactl.m4
diff -N cf/bsd-vfs-quotactl.m4
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ cf/bsd-vfs-quotactl.m4	16 Feb 2008 03:49:53 -0000
@@ -0,0 +1,38 @@
+dnl
+dnl $Id$
+dnl
+
+dnl
+dnl Find out if VFS_QUOTACTL accepts a void * or a caddr_t argument.
+dnl
+
+AC_DEFUN([AC_BSD_FUNC_VFS_QUOTACTL], [
+AC_CACHE_CHECK(if VFS_QUOTACTL takes caddr_t argument, ac_cv_func_vfs_quotactl_caddr,
+AC_TRY_COMPILE_KERNEL([
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/vnode.h>
+#include <sys/mount.h>
+
+vfs_quotactl_t foo_quotactl;
+
+int
+foo_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg,
+    struct thread *td)
+{
+
+	return (0);
+}
+],[],
+ac_cv_func_vfs_quotctl_caddr=yes,
+ac_cv_func_vfs_quotactl_caddr=no))
+if test "$ac_cv_func_vfs_quotactl_caddr" = yes; then
+	AC_DEFINE(HAVE_VFS_QUOTACTL_CADDR, 1,
+	[define if VFS_QUOTACTL takes a caddr_t argument])
+fi
+])
Index: cf/bsd-vnode-create-vobject.m4
===================================================================
RCS file: cf/bsd-vnode-create-vobject.m4
diff -N cf/bsd-vnode-create-vobject.m4
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ cf/bsd-vnode-create-vobject.m4	16 Feb 2008 03:49:53 -0000
@@ -0,0 +1,28 @@
+dnl
+dnl $Id$
+dnl
+
+dnl
+dnl Find out if vnode_create_vobject() takes one argument or two on BSD; if
+dnl two then we need to use vnode_create_vobject_off() instead.
+dnl
+
+AC_DEFUN([AC_BSD_FUNC_VNODE_CREATE_VOBJECT], [
+AC_CACHE_CHECK(if vnode_create_vobject takes three arguments, ac_cv_func_vnode_create_vobject,
+AC_TRY_COMPILE_KERNEL([
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/vnode.h>
+],[vnode_create_vobject(0, 0, 0)],
+ac_cv_func_vnode_create_vobject_three_args=yes,
+ac_cv_func_vnode_create_vobject_three_args=no))
+if test "$ac_cv_func_vnode_create_vobject_three_args" = yes; then
+	AC_DEFINE(HAVE_THREE_ARGUMENT_VNODE_CREATE_VOBJ, 1,
+	[define if vnode_create_vobject takes three arguments])
+fi
+])
Index: cf/bsd-vop-open.m4
===================================================================
RCS file: cf/bsd-vop-open.m4
diff -N cf/bsd-vop-open.m4
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ cf/bsd-vop-open.m4	16 Feb 2008 03:49:53 -0000
@@ -0,0 +1,28 @@
+dnl
+dnl $Id$
+dnl
+
+dnl
+dnl Find out if VOP_OPEN takes a struct file or an integer final argument on
+dnl FreeBSD.
+dnl
+
+AC_DEFUN([AC_BSD_FUNC_VOP_OPEN], [
+AC_CACHE_CHECK(if VOP_OPEN takes a struct file final argument, ac_cv_func_vop_open_file_arg,
+AC_TRY_COMPILE_KERNEL([
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/vnode.h>
+],[VOP_OPEN(NULL, 0, NULL, NULL, (struct file *)NULL)],
+ac_cv_func_vop_open_file_arg=yes,
+ac_cv_func_vop_open_file_arg=no))
+if test "$ac_cv_func_vop_open_file_arg" = yes; then
+	AC_DEFINE(HAVE_FINAL_ARG_FILE_VOP_OPEN, 1,
+	[define if VOP_OPEN takes a file final argument])
+fi
+])
Index: cf/bsd-vop-unlock.m4
===================================================================
RCS file: cf/bsd-vop-unlock.m4
diff -N cf/bsd-vop-unlock.m4
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ cf/bsd-vop-unlock.m4	16 Feb 2008 03:49:53 -0000
@@ -0,0 +1,45 @@
+dnl
+dnl $Id$
+dnl
+
+dnl
+dnl Find out if VOP_UNLOCK takes two or three arguments
+dnl
+
+AC_DEFUN([AC_BSD_FUNC_VOP_UNLOCK], [
+AC_CACHE_CHECK(if VOP_UNLOCK takes two arguments, ac_cv_func_vop_unlock_two_args,
+AC_TRY_COMPILE_KERNEL([
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/vnode.h>
+],[VOP_UNLOCK(0, 0)],
+ac_cv_func_vop_unlock_two_args=yes,
+ac_cv_func_vop_unlock_two_args=no))
+if test "$ac_cv_func_vop_unlock_two_args" = yes; then
+	AC_DEFINE(HAVE_TWO_ARGUMENT_VOP_UNLOCK, 1,
+	[define if VOP_UNLOCK takes two arguments])
+fi
+
+AC_CACHE_CHECK(if VOP_UNLOCK takes three arguments, ac_cv_func_vop_unlock_three_args,
+AC_TRY_COMPILE_KERNEL([
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/vnode.h>
+],[VOP_UNLOCK(0, 0, 0)],
+ac_cv_func_vop_unlock_three_args=yes,
+ac_cv_func_vop_unlock_three_args=no))
+if test "$ac_cv_func_vop_unlock_three_args" = yes; then
+	AC_DEFINE(HAVE_THREE_ARGUMENT_VOP_UNLOCK, 1,
+	[define if VOP_UNLOCK takes three arguments])
+fi
+])
Index: cf/try-compile-kernel.m4
===================================================================
RCS file: /stacken-cvs/arla/cf/try-compile-kernel.m4,v
retrieving revision 1.4
diff -u -r1.4 try-compile-kernel.m4
--- cf/try-compile-kernel.m4	12 Feb 2004 16:28:18 -0000	1.4
+++ cf/try-compile-kernel.m4	16 Feb 2008 03:49:53 -0000
@@ -8,7 +8,7 @@
 if test "X${KERNEL_CC}" != "X"; then
   CC="$KERNEL_CC"
 fi
-CFLAGS="$CFLAGS $test_KERNEL_CFLAGS $KERNEL_CPPFLAGS"
+CFLAGS="$CFLAGS -I/usr/include $test_KERNEL_CFLAGS $KERNEL_CPPFLAGS"
 AC_TRY_COMPILE([$1], [$2], [$3], [$4])
 CFLAGS="$save_CFLAGS"
 CC="$save_CC"
Index: include/afssysdefs.h
===================================================================
RCS file: /stacken-cvs/arla/include/afssysdefs.h,v
retrieving revision 1.9
diff -u -r1.9 afssysdefs.h
--- include/afssysdefs.h	9 Aug 2004 13:42:32 -0000	1.9
+++ include/afssysdefs.h	16 Feb 2008 03:49:53 -0000
@@ -42,6 +42,7 @@
  * entry point syscalls.
  */
 
+#if defined(SunOS)
 #if SunOS == 40
 #define AFS_SYSCALL	31
 #endif
@@ -56,6 +57,7 @@
 
 #if SunOS >= 58
 #define AFS_SYSCALL	65
+#endif
 #endif
 
 #if defined(__hpux)
Index: nnpfs/bsd/nnpfs_blocks.c
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs_blocks.c,v
retrieving revision 1.10
diff -u -r1.10 nnpfs_blocks.c
--- nnpfs/bsd/nnpfs_blocks.c	28 Mar 2007 12:05:45 -0000	1.10
+++ nnpfs/bsd/nnpfs_blocks.c	16 Feb 2008 03:49:54 -0000
@@ -306,8 +306,13 @@
 		      LEASE_WRITE);
 	    
 	    ret = nnpfs_block_extend_int(node, vp, p);
-	    
+
+#ifdef HAVE_TWO_ARGUMENT_VOP_UNLOCK
+	    VOP_UNLOCK(vp, 0);
+#endif
+#ifdef HAVE_THREE_ARGUMENT_VOP_UNLOCK
 	    VOP_UNLOCK(vp, 0, p);
+#endif
 	    vn_finished_write(mp);
 	}
 #else
@@ -500,7 +505,11 @@
 #endif
 
 #ifdef __FreeBSD__
+#ifdef HAVE_FINAL_ARG_FILE_VOP_OPEN
+	error = VOP_OPEN(*vpp, fmode, cred, p, NULL);
+#else
 	error = VOP_OPEN(*vpp, fmode, cred, p, -1);
+#endif
 #else
 	error = VOP_OPEN(*vpp, fmode, cred, p);
 #endif
Index: nnpfs/bsd/nnpfs_common-bsd.c
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs_common-bsd.c,v
retrieving revision 1.33
diff -u -r1.33 nnpfs_common-bsd.c
--- nnpfs/bsd/nnpfs_common-bsd.c	24 Oct 2006 16:33:02 -0000	1.33
+++ nnpfs/bsd/nnpfs_common-bsd.c	16 Feb 2008 03:49:54 -0000
@@ -72,10 +72,33 @@
 #endif /* NNPFS_DEBUG */
 
 int
-nnpfs_suser(d_thread_t *p)
+nnpfs_priv_check_debug(d_thread_t *p)
 {
 #if defined(__APPLE__)
     return proc_suser(p);
+#elif defined(HAVE_KERNEL_PRIV_CHECK)
+    return (priv_check(p, PRIV_NNPFS_DEBUG));
+#elif defined(HAVE_KERNEL_KAUTH_CRED_GETUID)
+    uid_t uid = kauth_cred_getuid(p->l_proc->p_cred);
+    if (uid == 0)
+	return 0;
+    return EPERM;
+#elif defined(HAVE_KERNEL_SUSER_UCRED)
+    return suser_ucred (nnpfs_proc_to_cred(p));
+#elif defined(HAVE_TWO_ARGUMENT_SUSER)
+    return suser (nnpfs_proc_to_cred(p), NULL);
+#else
+    return suser (p);
+#endif
+}
+
+int
+nnpfs_priv_check_fhlookup(d_thread_t *p)
+{
+#if defined(__APPLE__)
+    return proc_suser(p);
+#elif defined(HAVE_KERNEL_PRIV_CHECK)
+    return (priv_check(p, PRIV_VFS_GETFH));
 #elif defined(HAVE_KERNEL_KAUTH_CRED_GETUID)
     uid_t uid = kauth_cred_getuid(p->l_proc->p_cred);
     if (uid == 0)
Index: nnpfs/bsd/nnpfs_message.c
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs_message.c,v
retrieving revision 1.109
diff -u -r1.109 nnpfs_message.c
--- nnpfs/bsd/nnpfs_message.c	28 Mar 2007 12:05:46 -0000	1.109
+++ nnpfs/bsd/nnpfs_message.c	16 Feb 2008 03:49:55 -0000
@@ -483,7 +483,7 @@
 	
 	nnpfs_block_free_all(VNODE_TO_XNODE(vp));
 	
-#if HAVE_KERNEL_VGONEL
+#ifdef HAVE_KERNEL_VGONEL
 	vgonel (vp, p);
 #else /* !have vgonel */
 	nnpfs_interlock_unlock(&vp->v_interlock);
Index: nnpfs/bsd/nnpfs_node-bsd.c
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs_node-bsd.c,v
retrieving revision 1.99
diff -u -r1.99 nnpfs_node-bsd.c
--- nnpfs/bsd/nnpfs_node-bsd.c	14 Mar 2007 16:44:30 -0000	1.99
+++ nnpfs/bsd/nnpfs_node-bsd.c	16 Feb 2008 03:49:55 -0000
@@ -169,6 +169,15 @@
     genfs_node_init(*vpp, &nnpfs_genfsops);
 #endif
 
+#ifdef HAVE_KERNEL_INSMNTQUE
+    error = insmntque(*vpp, NNPFS_TO_VFS(nnpfsp));
+    if (error) {
+      nnpfs_free(result, sizeof(*result), M_NNPFS_NODE);
+      *vpp = NULL;
+      return error;
+    }
+#endif
+
  retry:
     error = nnpfs_node_find(nnpfsp, handle, &check);
     if (error == ENOENT) {
@@ -756,7 +765,7 @@
  * The real change is sys/kern/vfs_cache:1.20
  */
 
-#if __NetBSD_Version__ >= 104120000 || OpenBSD > 200211
+#if (defined(__NetBSD_Version__) && __NetBSD_Version__ >= 104120000) || (defined(OpenBSD) && OpenBSD > 200211)
 	if (cache_lookup(dvp, &dummy, cnp) != -1) {
 	    nnpfs_vfs_unlock(dummy, nnpfs_cnp_to_proc(cnp));
 	    printf ("NNPFS PANIC WARNING! nnpfs_dnlc_enter: %s already in cache\n",
@@ -801,7 +810,7 @@
     cn->cn_nameptr = (char *)name;
     cn->cn_namelen = strlen(name);
     cn->cn_flags   = 0;
-#if __APPLE__
+#ifdef __APPLE__
     cn->cn_hash = 0; /* Let the vfs compute the hash */
 #elif defined(HAVE_KERNEL_NAMEI_HASH)
     {
Index: nnpfs/bsd/nnpfs_syscalls-common.c
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs_syscalls-common.c,v
retrieving revision 1.85
diff -u -r1.85 nnpfs_syscalls-common.c
--- nnpfs/bsd/nnpfs_syscalls-common.c	28 Mar 2007 12:05:46 -0000	1.85
+++ nnpfs/bsd/nnpfs_syscalls-common.c	16 Feb 2008 03:49:55 -0000
@@ -484,7 +484,7 @@
 	if (vice_ioctl->in_size < sizeof(int32_t))
 	    return EINVAL;
 	
-	error = nnpfs_suser(p);
+	error = nnpfs_priv_check_debug(p);
 	if (error)
 	    return error;
 
Index: nnpfs/bsd/nnpfs_vfsops-bsd.c
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs_vfsops-bsd.c,v
retrieving revision 1.103
diff -u -r1.103 nnpfs_vfsops-bsd.c
--- nnpfs/bsd/nnpfs_vfsops-bsd.c	27 Mar 2007 13:26:58 -0000	1.103
+++ nnpfs/bsd/nnpfs_vfsops-bsd.c	16 Feb 2008 03:49:56 -0000
@@ -84,7 +84,11 @@
 }
 
 int
+#ifdef HAVE_VFS_QUOTACTL_CADDR
 nnpfs_quotactl(struct mount *mp, int cmd, uid_t uid, caddr_t arg, d_thread_t *p)
+#else
+nnpfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg, d_thread_t *p)
+#endif
 {
     NNPFSDEB(XDEBVFOPS, ("nnpfs_quotactl: mp = %lx, cmd = %d, uid = %u, "
 		       "arg = %lx, proc = %lx\n", 
@@ -225,6 +229,7 @@
     return 0;
 }
 
+#ifndef HAVE_VOP_VPTOFH
 int
 nnpfs_vptofh(struct vnode * vp,
 	     struct fid * fhp
@@ -236,6 +241,7 @@
     NNPFSDEB(XDEBVFOPS, ("nnpfs_vptofh\n"));
     return EOPNOTSUPP;
 }
+#endif
 
 #endif /* !__APPLE__ */
 
@@ -321,7 +327,7 @@
 
     NNPFSDEB(XDEBVFOPS, ("nnpfs_fhlookup (nnpfs)\n"));
 
-    error = nnpfs_suser (proc);
+    error = nnpfs_priv_check_fhlookup(proc);
     if (error)
 	return EPERM;
 
@@ -484,7 +490,11 @@
 	goto out;
 
 #if defined(__FreeBSD__) && __FreeBSD_version >= 502000
+#ifdef HAVE_FINAL_ARG_FILE_VOP_OPEN
+    error = VOP_OPEN(vp, flags, cred, proc, fp);
+#else
     error = VOP_OPEN(vp, flags, cred, proc, index);
+#endif
 #else
     error = VOP_OPEN(vp, flags, cred, proc);
 #endif
Index: nnpfs/bsd/nnpfs_vfsops-freebsd.c
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs_vfsops-freebsd.c,v
retrieving revision 1.37
diff -u -r1.37 nnpfs_vfsops-freebsd.c
--- nnpfs/bsd/nnpfs_vfsops-freebsd.c	6 Mar 2007 16:00:57 -0000	1.37
+++ nnpfs/bsd/nnpfs_vfsops-freebsd.c	16 Feb 2008 03:49:56 -0000
@@ -60,7 +60,12 @@
     .vop_default = &default_vnodeops,
     .vop_lookup = nnpfs_dead_lookup,
     .vop_reclaim = nnpfs_dead_reclaim,
+#ifdef HAVE_VOP_LOCK1
+    .vop_lock1 = vop_stdlock,
+#endif
+#ifdef HAVE_VOP_LOCK
     .vop_lock = vop_stdlock,
+#endif
     .vop_unlock = vop_stdunlock,
     .vop_islocked = vop_stdislocked,
 };
@@ -76,6 +81,15 @@
     if (error == 0)
 	NNPFS_MAKE_VROOT(*vpp);
 
+#ifdef HAVE_KERNEL_INSMNTQUE
+    /* XXX: Possibly should lock with lockmgr here. */
+    error = insmntque(*vpp, mp);
+    if (error) {
+      *vpp = NULL;
+      return error;
+    }
+#endif
+
     nnpfs_vfs_writelock(*vpp, nnpfs_curproc());
 
     return error;
@@ -163,7 +177,9 @@
     .vfs_vget = nnpfs_vget_freebsd,
     .vfs_fhtovp = nnpfs_fhtovp,
     .vfs_checkexp = nnpfs_checkexp,
+#ifndef HAVE_VOP_VPTOFH
     .vfs_vptofh = nnpfs_vptofh,
+#endif
     .vfs_init = nnpfs_init
 };
 /*VFS_SET(nnpfs_vfsops, arlannpfsdev, 0);*/
Index: nnpfs/bsd/nnpfs_vnodeops-bsd.c
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs_vnodeops-bsd.c,v
retrieving revision 1.161
diff -u -r1.161 nnpfs_vnodeops-bsd.c
--- nnpfs/bsd/nnpfs_vnodeops-bsd.c	6 Mar 2007 16:00:57 -0000	1.161
+++ nnpfs/bsd/nnpfs_vnodeops-bsd.c	16 Feb 2008 03:49:57 -0000
@@ -85,7 +85,11 @@
     ret = nnpfs_open_common(ap->a_vp, ap->a_mode, ctx);
 #ifdef __FreeBSD__
     if (!ret)
+#ifdef HAVE_THREE_ARGUMENT_VNODE_CREATE_VOBJ
+	vnode_create_vobject(ap->a_vp,
+#else
 	vnode_create_vobject_off(ap->a_vp,
+#endif
 				 nnpfs_vattr_get_size(&VNODE_TO_XNODE(ap->a_vp)->attr),
 				 ap->a_td);
 #endif
@@ -793,16 +797,25 @@
 #ifdef __FreeBSD__
 
 int
+#ifdef HAVE_VOP_LOCK1
+nnpfs_lock1(struct vop_lock1_args * ap)
+#else
 nnpfs_lock(struct vop_lock_args * ap)
+#endif
 {               
     struct vnode *vp = ap->a_vp;
     int ret;
 
     nnpfs_assert(vp);
+#ifdef HAVE_VOP_LOCK1
+    NNPFSDEB(XDEBVNOPS, ("nnpfs_lock1: %lx, flags 0x%x\n",
+			 (unsigned long)vp, ap->a_flags));
+#else
     nnpfs_assert(ap->a_td);
     NNPFSDEB(XDEBVNOPS, ("nnpfs_lock: %lx, td %p, flags 0x%x, nlocks %d\n",
 			 (unsigned long)vp, NNPFS_AP_PROC(ap), ap->a_flags,
 			 NNPFS_AP_PROC(ap)->td_locks));
+#endif
 
     nnpfs_lk_info("nnpfs_lock before", vp);
     ret = vop_stdlock(ap);
@@ -817,16 +830,26 @@
     struct vnode *vp = ap->a_vp;
     int ret;
 
+#ifdef HAVE_TWO_ARGUMENT_VOP_UNLOCK
+    NNPFSDEB(XDEBVNOPS,
+	     ("nnpfs_unlock: %lx, flags 0x%x\n", (unsigned long)vp,
+	      ap->a_flags));
+#else
     NNPFSDEB(XDEBVNOPS,
 	     ("nnpfs_unlock: %lx, td %p, flags 0x%x, nlocks %d\n",
 	      (unsigned long)vp, ap->a_td, ap->a_flags,
 	      NNPFS_AP_PROC(ap)->td_locks));
+#endif
     
     nnpfs_lk_info("nnpfs_unlock before", vp);
     ret = vop_stdunlock(ap);
 
+#ifdef HAVE_TWO_ARGUMENT_VOP_UNLOCK
+    NNPFSDEB(XDEBVNOPS, ("nnpfs_unlock: return %d\n", ret));
+#else
     NNPFSDEB(XDEBVNOPS, ("nnpfs_unlock: return %d, td %p, nlocks %d\n",
 			 ret, NNPFS_AP_PROC(ap), NNPFS_AP_PROC(ap)->td_locks));
+#endif
     return ret;
 }
 
@@ -1313,6 +1336,23 @@
 }
 #endif
 
+#ifdef HAVE_VOP_VPTOFH
+int
+nnpfs_vptofh(struct vop_vptofh_args *ap)
+/*
+struct vop_vptofh_args {
+	struct vnodeop_desc *a_desc;
+	struct vnode *a_vp;
+	struct fid *a_fhp;
+};
+*/
+{
+    NNPFSDEB(XDEBVNOPS, ("nnpfs_vptofh\n"));
+
+    return EOPNOTSUPP;
+}
+#endif
+
 
 
 vop_t **nnpfs_vnodeop_p;
@@ -1466,7 +1506,12 @@
 	.vop_bmap =		nnpfs_bmap,
 
 	.vop_poll =		nnpfs_poll,
+#ifdef HAVE_VOP_LOCK1
+	.vop_lock1 =		nnpfs_lock1,
+#endif
+#ifdef HAVE_VOP_LOCK
 	.vop_lock =		nnpfs_lock,  
+#endif
 	.vop_unlock =		nnpfs_unlock,
 	.vop_islocked =		nnpfs_islocked,
 	.vop_revoke =		nnpfs_revoke,
@@ -1605,6 +1650,9 @@
 #endif
 #ifdef HAVE_VOP_PATHCONF
     {&vop_pathconf_desc, (vop_t *) nnpfs_pathconf },
+#endif
+#ifdef HAVE_VOP_VPTOFH
+    {&vop_vptofh_desc, (vop_t *) nnpfs_vptofh },
 #endif
     {(struct vnodeop_desc *) NULL, (int (*) (void *)) NULL}
 };
Index: nnpfs/bsd/nnpfs_vnodeops-common.c
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs_vnodeops-common.c,v
retrieving revision 1.121
diff -u -r1.121 nnpfs_vnodeops-common.c
--- nnpfs/bsd/nnpfs_vnodeops-common.c	28 Mar 2007 12:05:46 -0000	1.121
+++ nnpfs/bsd/nnpfs_vnodeops-common.c	16 Feb 2008 03:49:57 -0000
@@ -50,7 +50,7 @@
 static void
 nnpfs_handle_stale(struct nnpfs_node *xn)
 {
-#if __APPLE__
+#ifdef __APPLE__
     struct vnode *vp = XNODE_TO_VNODE(xn);
 #endif
 
@@ -1438,7 +1438,9 @@
     int error = 0;
     nnpfs_cred cred;
     struct nnpfs *nnpfsp = NNPFS_FROM_VNODE(vp);
+#ifdef HAVE_THREE_ARGUMENT_VOP_UNLOCK
     d_thread_t *proc = nnpfs_vfs_context_proc(ctx);
+#endif
 
     NNPFSDEB(XDEBVNOPS, ("nnpfs_readlink\n"));
 
Index: nnpfs/bsd/bin/mntopts.h
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/bin/mntopts.h,v
retrieving revision 1.7
diff -u -r1.7 mntopts.h
--- nnpfs/bsd/bin/mntopts.h	28 Dec 2005 14:32:03 -0000	1.7
+++ nnpfs/bsd/bin/mntopts.h	16 Feb 2008 03:49:58 -0000
@@ -48,7 +48,9 @@
 #define MOPT_NOACCESSTIME	{ "accesstime",	1, MNT_NOATIME }
 #define MOPT_NOATIME		{ "atime",	1, MNT_NOATIME }
 #endif
+#ifdef MOPT_NODEV
 #define MOPT_NODEV		{ "dev",	1, MNT_NODEV }
+#endif
 #define MOPT_NOEXEC		{ "exec",	1, MNT_NOEXEC }
 #define MOPT_NOSUID		{ "suid",	1, MNT_NOSUID }
 #define MOPT_RDONLY		{ "rdonly",	0, MNT_RDONLY }
@@ -78,6 +80,7 @@
 
 /* Standard options which all mounts can understand. */
 
+#ifdef MOPT_NODEV
 #define MOPT_STDOPTS							\
 	MOPT_USERQUOTA,							\
 	MOPT_GROUPQUOTA,						\
@@ -86,5 +89,14 @@
 	MOPT_NOEXEC,							\
 	MOPT_NOSUID,							\
 	MOPT_RDONLY
+#else
+#define MOPT_STDOPTS							\
+	MOPT_USERQUOTA,							\
+	MOPT_GROUPQUOTA,						\
+	MOPT_FSTAB_COMPAT,						\
+	MOPT_NOEXEC,							\
+	MOPT_NOSUID,							\
+	MOPT_RDONLY
+#endif
 
 void getmntopts (const char *, const struct mntopt *, int *);
Index: nnpfs/bsd/nnpfs/nnpfs_common.h
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs/nnpfs_common.h,v
retrieving revision 1.22
diff -u -r1.22 nnpfs_common.h
--- nnpfs/bsd/nnpfs/nnpfs_common.h	24 Oct 2006 16:33:14 -0000	1.22
+++ nnpfs/bsd/nnpfs/nnpfs_common.h	16 Feb 2008 03:49:58 -0000
@@ -59,7 +59,8 @@
 #define nnpfs_free(a, size,t) free(a, t)
 #endif /* NNPFS_DEBUG */
 
-int nnpfs_suser(d_thread_t *p);
+int nnpfs_priv_check_debug(d_thread_t *p);
+int nnpfs_priv_check_fhlookup(d_thread_t *p);
 
 #ifndef HAVE_KERNEL_MEMCPY
 void *
Index: nnpfs/bsd/nnpfs/nnpfs_locl.h
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs/nnpfs_locl.h,v
retrieving revision 1.113
diff -u -r1.113 nnpfs_locl.h
--- nnpfs/bsd/nnpfs/nnpfs_locl.h	6 Mar 2007 16:01:56 -0000	1.113
+++ nnpfs/bsd/nnpfs/nnpfs_locl.h	16 Feb 2008 03:49:58 -0000
@@ -121,6 +121,9 @@
 #ifdef HAVE_SYS_KAUTH_H
 #include <sys/kauth.h>
 #endif
+#ifdef HAVE_SYS_PRIV_H
+#include <sys/priv.h>
+#endif
 
 #ifdef HAVE_MISCFS_GENFS_GENFS_H
 #include <miscfs/genfs/genfs.h>
@@ -296,7 +299,7 @@
 struct genfs_ops nnpfs_genfsops;
 #endif
 
-#if __NetBSD_Version__ >= 399001900 /* NetBSD 3.99.19 */
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 399001900 /* NetBSD 3.99.19 */
 typedef struct kauth_cred *nnpfs_kernel_cred;
 #define nnpfs_cred_get_uid(cred) kauth_cred_getuid(cred)
 #else
Index: nnpfs/bsd/nnpfs/nnpfs_vfsops-bsd.h
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/bsd/nnpfs/nnpfs_vfsops-bsd.h,v
retrieving revision 1.25
diff -u -r1.25 nnpfs_vfsops-bsd.h
--- nnpfs/bsd/nnpfs/nnpfs_vfsops-bsd.h	6 Mar 2007 16:01:56 -0000	1.25
+++ nnpfs/bsd/nnpfs/nnpfs_vfsops-bsd.h	16 Feb 2008 03:49:58 -0000
@@ -79,7 +79,11 @@
 nnpfs_root(struct mount *mp, struct vnode **vpp);
 
 int
+#ifdef HAVE_VFS_QUOTACTL_CADDR
 nnpfs_quotactl(struct mount *mp, int cmd, uid_t uid, caddr_t arg, d_thread_t *p);
+#else
+nnpfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg, d_thread_t *p);
+#endif
 
 int
 nnpfs_statfs(struct mount *mp, nnpfs_statvfs *sbp, d_thread_t *p);
@@ -114,6 +118,7 @@
 	     struct ucred ** credanonp);
 #endif
 
+#ifndef HAVE_VOP_VPTOFH
 int
 nnpfs_vptofh(struct vnode * vp,
 	     struct fid * fhp
@@ -121,6 +126,7 @@
 	     ,size_t * fidsz
 #endif
 	     );
+#endif
 
 int
 nnpfs_dead_lookup(struct vop_lookup_args *ap);
Index: nnpfs/freebsd/FreeBSD-Makefile
===================================================================
RCS file: /stacken-cvs/arla/nnpfs/freebsd/FreeBSD-Makefile,v
retrieving revision 1.7
diff -u -r1.7 FreeBSD-Makefile
--- nnpfs/freebsd/FreeBSD-Makefile	6 Mar 2007 12:54:00 -0000	1.7
+++ nnpfs/freebsd/FreeBSD-Makefile	16 Feb 2008 03:49:58 -0000
@@ -29,6 +29,7 @@
 bsdsrcdir=	$(srcdir)/../bsd
 
 CFLAGS= -g \
+	-I/usr/include \
 	-I${.CURDIR} \
 	-I${.CURDIR}/../../include \
 	-I${.CURDIR}/../include \
@@ -45,6 +46,6 @@
 .PATH:	$(bsdsrcdir)
 
 nnpfs_vopdefs.h: vnode_if.h
-	awk '/^struct vop_[a-z]*_args/ { vop=substr($$2,5,length($$2)-9); printf("#define HAVE_VOP_%s 1\n", toupper(vop)); printf("NNPFS_VOP_DEF(%s);\n", vop); }' vnode_if.h > ${.TARGET}
+	awk '/^struct vop_[a-z0-9]*_args/ { vop=substr($$2,5,length($$2)-9); printf("#define HAVE_VOP_%s 1\n", toupper(vop)); printf("NNPFS_VOP_DEF(%s);\n", vop); }' vnode_if.h > ${.TARGET}
 	-mkdir nnpfs
 	test -d nnpfs && ( test -f nnpfs/nnpfs_vopdefs.h || ln -s ../nnpfs_vopdefs.h nnpfs/nnpfs_vopdefs.h )
