From root@freebuild.mit.edu Sat Oct  8 17:16:37 2011
Date: Sat,  8 Oct 2011 17:16:26 -0400
From: Charlie <root@freebuild.mit.edu>
To: kaduk@mit.edu
Cc: Charlie <root@freebuild.mit.edu>
Subject: [PATCH] FBSD: deal with kernel API rename

Upstream decided to rename the kernel functions that implement
syscalls to have a sys_prefix (including afs3_syscall!).
We use a couple of them, so we need to conditionalize accordingly.
Unfortunately, __FreeBSD_version was not bumped with the change,
so we use something close to it and hope it's close enough.
---
 src/afs/FBSD/osi_groups.c |    8 ++++++++
 src/afs/afs_pioctl.c      |    4 ++++
 src/afs/afs_prototypes.h  |    5 +++--
 src/rx/FBSD/rx_knet.c     |    4 ++++
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/afs/FBSD/osi_groups.c b/src/afs/FBSD/osi_groups.c
index ef62478..e897f46 100644
--- a/src/afs/FBSD/osi_groups.c
+++ b/src/afs/FBSD/osi_groups.c
@@ -48,9 +48,17 @@ Afs_xsetgroups(struct thread *td, struct setgroups_args *uap)
     AFS_GUNLOCK();
     crfree(cr);
     if (code)
+#if (__FreeBSD_version >= 900044)
+	return sys_setgroups(td, uap);	/* afs has shut down */
+#else
 	return setgroups(td, uap);	/* afs has shut down */
+#endif
 
+#if (__FreeBSD_version >= 900044)
+    code = sys_setgroups(td, uap);
+#else
     code = setgroups(td, uap);
+#endif
     /* Note that if there is a pag already in the new groups we don't
      * overwrite it with the old pag.
      */
diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c
index cf432d6..2589b79 100644
--- a/src/afs/afs_pioctl.c
+++ b/src/afs/afs_pioctl.c
@@ -874,7 +874,11 @@ afs_xioctl(afs_proc_t *p, const struct ioctl_args *uap, register_t *retval)
 
     if (!ioctlDone) {
 # if defined(AFS_FBSD_ENV)
+#  if (__FreeBSD_version >= 900044)
+	return sys_ioctl(td, uap);
+#  else
 	return ioctl(td, uap);
+#  endif
 # elif defined(AFS_OBSD_ENV)
 	code = sys_ioctl(p, uap, retval);
 # elif defined(AFS_NBSD_ENV)
diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h
index 04f13ad..dbb4ad6 100644
--- a/src/afs/afs_prototypes.h
+++ b/src/afs/afs_prototypes.h
@@ -935,8 +935,9 @@ extern int copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst);
 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 #ifdef AFS_DARWIN100_ENV
 extern int afs3_syscall(afs_proc_t *p, void *args, unsigned int *retval);
-#elif defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)
-/* afs3_syscall prototype is in sys/sysproto.h */
+#elif (defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)) && (__FreeBSD_version < 900044)
+/* afs3_syscall prototype is in sys/sysproto.h
+   Yes, they put it in, then took it out again (by renaming with sys_ prefix */
 #elif defined(AFS_FBSD_ENV)
 extern int afs3_syscall(struct thread *p, void *args);
 #elif defined(AFS_NBSD50_ENV)
diff --git a/src/rx/FBSD/rx_knet.c b/src/rx/FBSD/rx_knet.c
index c6d2d84..ded3f7c 100644
--- a/src/rx/FBSD/rx_knet.c
+++ b/src/rx/FBSD/rx_knet.c
@@ -92,7 +92,11 @@ osi_StopListener(void)
     p = pfind(rxk_ListenerPid);
     if (p) {
 	afs_warn("osi_StopListener: rxk_ListenerPid %u\n", rxk_ListenerPid);
+#if (__FreeBSD_version >= 90004)
+	kern_psignal(p, SIGUSR1);
+#else
 	psignal(p, SIGUSR1);
+#endif
 	PROC_UNLOCK(p);
     } else
 	afs_warn("osi_StopListener: rxk_Listener not found (pid %u)\n",
-- 
1.7.1

