aix vnode hold simplification
[openafs.git] / src / afs / afs_pioctl.c
index 26f45c6..b0d690f 100644 (file)
@@ -250,7 +250,6 @@ DECL_PIOCTL(PNewAlias);
 DECL_PIOCTL(PListCells);
 DECL_PIOCTL(PListAliases);
 DECL_PIOCTL(PRemoveMount);
-DECL_PIOCTL(PVenusLogging);
 DECL_PIOCTL(PGetCellStatus);
 DECL_PIOCTL(PSetCellStatus);
 DECL_PIOCTL(PFlushVolumeData);
@@ -312,90 +311,90 @@ typedef int (*pioctlFunction) (struct vcache *, int, struct vrequest *,
 
 static pioctlFunction VpioctlSw[] = {
     PBogus,                    /* 0 */
-       PSetAcl,                /* 1 */
-       PGetAcl,                /* 2 */
-       PSetTokens,             /* 3 */
-       PGetVolumeStatus,       /* 4 */
-       PSetVolumeStatus,       /* 5 */
-       PFlush,                 /* 6 */
-       PBogus,                 /* 7 */
-       PGetTokens,             /* 8 */
-       PUnlog,                 /* 9 */
-       PCheckServers,          /* 10 */
-       PCheckVolNames,         /* 11 */
-       PCheckAuth,             /* 12 */
-       PBogus,                 /* 13 -- used to be quick check time */
-       PFindVolume,            /* 14 */
-       PBogus,                 /* 15 -- prefetch is now special-cased; see pioctl code! */
-       PBogus,                 /* 16 -- used to be testing code */
-       PNoop,                  /* 17 -- used to be enable group */
-       PNoop,                  /* 18 -- used to be disable group */
-       PBogus,                 /* 19 -- used to be list group */
-       PViceAccess,            /* 20 */
-       PUnlog,                 /* 21 -- unlog *is* unpag in this system */
-       PGetFID,                /* 22 -- get file ID */
-       PBogus,                 /* 23 -- used to be waitforever */
-       PSetCacheSize,          /* 24 */
-       PRemoveCallBack,        /* 25 -- flush only the callback */
-       PNewCell,               /* 26 */
-       PListCells,             /* 27 */
-       PRemoveMount,           /* 28 -- delete mount point */
-       PNewStatMount,          /* 29 -- new style mount point stat */
-       PGetFileCell,           /* 30 -- get cell name for input file */
-       PGetWSCell,             /* 31 -- get cell name for workstation */
-       PMariner,               /* 32 - set/get mariner host */
-       PGetUserCell,           /* 33 -- get cell name for user */
-       PVenusLogging,          /* 34 -- Enable/Disable logging */
-       PGetCellStatus,         /* 35 */
-       PSetCellStatus,         /* 36 */
-       PFlushVolumeData,       /* 37 -- flush all data from a volume */
-       PSetSysName,            /* 38 - Set system name */
-       PExportAfs,             /* 39 - Export Afs to remote nfs clients */
-       PGetCacheSize,          /* 40 - get cache size and usage */
-       PGetVnodeXStatus,       /* 41 - get vcache's special status */
-       PSetSPrefs33,           /* 42 - Set CM Server preferences... */
-       PGetSPrefs,             /* 43 - Get CM Server preferences... */
-       PGag,                   /* 44 - turn off/on all CM messages */
-       PTwiddleRx,             /* 45 - adjust some RX params       */
-       PSetSPrefs,             /* 46 - Set CM Server preferences... */
-       PStoreBehind,           /* 47 - set degree of store behind to be done */
-       PGCPAGs,                /* 48 - disable automatic pag gc-ing */
-       PGetInitParams,         /* 49 - get initial cm params */
-       PGetCPrefs,             /* 50 - get client interface addresses */
-       PSetCPrefs,             /* 51 - set client interface addresses */
-       PFlushMount,            /* 52 - flush mount symlink data */
-       PRxStatProc,            /* 53 - control process RX statistics */
-       PRxStatPeer,            /* 54 - control peer RX statistics */
-       PGetRxkcrypt,           /* 55 -- Get rxkad encryption flag */
-       PSetRxkcrypt,           /* 56 -- Set rxkad encryption flag */
-       PBogus,                 /* 57 -- arla: set file prio */
-       PBogus,                 /* 58 -- arla: fallback getfh */
-       PBogus,                 /* 59 -- arla: fallback fhopen */
-       PBogus,                 /* 60 -- arla: controls xfsdebug */
-       PBogus,                 /* 61 -- arla: controls arla debug */
-       PBogus,                 /* 62 -- arla: debug interface */
-       PBogus,                 /* 63 -- arla: print xfs status */
-       PBogus,                 /* 64 -- arla: force cache check */
-       PBogus,                 /* 65 -- arla: break callback */
-       PPrefetchFromTape,      /* 66 -- MR-AFS: prefetch file from tape */
-       PFsCmd,                 /* 67 -- RXOSD: generic commnd interface */
-       PBogus,                 /* 68 -- arla: fetch stats */
-       PGetVnodeXStatus2,      /* 69 - get caller access and some vcache status */
+    PSetAcl,                   /* 1 */
+    PGetAcl,                   /* 2 */
+    PSetTokens,                        /* 3 */
+    PGetVolumeStatus,          /* 4 */
+    PSetVolumeStatus,          /* 5 */
+    PFlush,                    /* 6 */
+    PBogus,                    /* 7 */
+    PGetTokens,                        /* 8 */
+    PUnlog,                    /* 9 */
+    PCheckServers,             /* 10 */
+    PCheckVolNames,            /* 11 */
+    PCheckAuth,                        /* 12 */
+    PBogus,                    /* 13 -- used to be quick check time */
+    PFindVolume,               /* 14 */
+    PBogus,                    /* 15 -- prefetch is now special-cased; see pioctl code! */
+    PBogus,                    /* 16 -- used to be testing code */
+    PNoop,                     /* 17 -- used to be enable group */
+    PNoop,                     /* 18 -- used to be disable group */
+    PBogus,                    /* 19 -- used to be list group */
+    PViceAccess,               /* 20 */
+    PUnlog,                    /* 21 -- unlog *is* unpag in this system */
+    PGetFID,                   /* 22 -- get file ID */
+    PBogus,                    /* 23 -- used to be waitforever */
+    PSetCacheSize,             /* 24 */
+    PRemoveCallBack,           /* 25 -- flush only the callback */
+    PNewCell,                  /* 26 */
+    PListCells,                        /* 27 */
+    PRemoveMount,              /* 28 -- delete mount point */
+    PNewStatMount,             /* 29 -- new style mount point stat */
+    PGetFileCell,              /* 30 -- get cell name for input file */
+    PGetWSCell,                        /* 31 -- get cell name for workstation */
+    PMariner,                  /* 32 - set/get mariner host */
+    PGetUserCell,              /* 33 -- get cell name for user */
+    PBogus,                    /* 34 -- Enable/Disable logging */
+    PGetCellStatus,            /* 35 */
+    PSetCellStatus,            /* 36 */
+    PFlushVolumeData,          /* 37 -- flush all data from a volume */
+    PSetSysName,               /* 38 - Set system name */
+    PExportAfs,                        /* 39 - Export Afs to remote nfs clients */
+    PGetCacheSize,             /* 40 - get cache size and usage */
+    PGetVnodeXStatus,          /* 41 - get vcache's special status */
+    PSetSPrefs33,              /* 42 - Set CM Server preferences... */
+    PGetSPrefs,                        /* 43 - Get CM Server preferences... */
+    PGag,                      /* 44 - turn off/on all CM messages */
+    PTwiddleRx,                        /* 45 - adjust some RX params       */
+    PSetSPrefs,                        /* 46 - Set CM Server preferences... */
+    PStoreBehind,              /* 47 - set degree of store behind to be done */
+    PGCPAGs,                   /* 48 - disable automatic pag gc-ing */
+    PGetInitParams,            /* 49 - get initial cm params */
+    PGetCPrefs,                        /* 50 - get client interface addresses */
+    PSetCPrefs,                        /* 51 - set client interface addresses */
+    PFlushMount,               /* 52 - flush mount symlink data */
+    PRxStatProc,               /* 53 - control process RX statistics */
+    PRxStatPeer,               /* 54 - control peer RX statistics */
+    PGetRxkcrypt,              /* 55 -- Get rxkad encryption flag */
+    PSetRxkcrypt,              /* 56 -- Set rxkad encryption flag */
+    PBogus,                    /* 57 -- arla: set file prio */
+    PBogus,                    /* 58 -- arla: fallback getfh */
+    PBogus,                    /* 59 -- arla: fallback fhopen */
+    PBogus,                    /* 60 -- arla: controls xfsdebug */
+    PBogus,                    /* 61 -- arla: controls arla debug */
+    PBogus,                    /* 62 -- arla: debug interface */
+    PBogus,                    /* 63 -- arla: print xfs status */
+    PBogus,                    /* 64 -- arla: force cache check */
+    PBogus,                    /* 65 -- arla: break callback */
+    PPrefetchFromTape,         /* 66 -- MR-AFS: prefetch file from tape */
+    PFsCmd,                    /* 67 -- RXOSD: generic commnd interface */
+    PBogus,                    /* 68 -- arla: fetch stats */
+    PGetVnodeXStatus2,         /* 69 - get caller access and some vcache status */
 };
 
 static pioctlFunction CpioctlSw[] = {
-    PBogus,                    /* 0 */
-       PNewAlias,              /* 1 -- create new cell alias */
-       PListAliases,           /* 2 -- list cell aliases */
-       PCallBackAddr,          /* 3 -- request addr for callback rxcon */
-       PBogus,                 /* 4 */
-       PDiscon,                /* 5 -- get/set discon mode */
-        PBogus,                 /* 6 */
-        PBogus,                 /* 7 */
-        PBogus,                 /* 8 */
-        PNewUuid,               /* 9 */
-    PBogus,                     /* 0 */
     PBogus,                     /* 0 */
+    PNewAlias,                  /* 1 -- create new cell alias */
+    PListAliases,               /* 2 -- list cell aliases */
+    PCallBackAddr,              /* 3 -- request addr for callback rxcon */
+    PBogus,                     /* 4 */
+    PDiscon,                    /* 5 -- get/set discon mode */
+    PBogus,                     /* 6 */
+    PBogus,                     /* 7 */
+    PBogus,                     /* 8 */
+    PNewUuid,                   /* 9 */
+    PBogus,                     /* 10 */
+    PBogus,                     /* 11 */
     PPrecache,                  /* 12 */
     PGetPAG,                    /* 13 */
 };
@@ -476,7 +475,7 @@ HandleIoctl(register struct vcache *avc, register afs_int32 acom,
     return code;               /* so far, none implemented */
 }
 
-#ifdef AFS_AIX_ENV
+#ifdef AFS_AIX_ENV
 /* For aix we don't temporarily bypass ioctl(2) but rather do our
  * thing directly in the vnode layer call, VNOP_IOCTL; thus afs_ioctl
  * is now called from afs_gn_ioctl.
@@ -500,15 +499,111 @@ afs_ioctl(struct vcache *tvc, int cmd, int arg)
        return (ENOTTY);
     }
 }
-#endif /* AFS_AIX_ENV */
+# if defined(AFS_AIX32_ENV)
+#  if defined(AFS_AIX51_ENV)
+#   ifdef __64BIT__
+int
+kioctl(int fdes, int com, caddr_t arg, caddr_t ext, caddr_t arg2,
+          caddr_t arg3)
+#   else /* __64BIT__ */
+int
+kioctl32(int fdes, int com, caddr_t arg, caddr_t ext, caddr_t arg2,
+            caddr_t arg3)
+#   endif /* __64BIT__ */
+#  else
+int
+kioctl(int fdes, int com, caddr_t arg, caddr_t ext)
+#  endif /* AFS_AIX51_ENV */
+{
+    struct a {
+       int fd, com;
+       caddr_t arg, ext;
+#  ifdef AFS_AIX51_ENV
+       caddr_t arg2, arg3;
+#  endif
+    } u_uap, *uap = &u_uap;
+    struct file *fd;
+    register struct vcache *tvc;
+    register int ioctlDone = 0, code = 0;
 
-#if defined(AFS_SGI_ENV)
+    AFS_STATCNT(afs_xioctl);
+    uap->fd = fdes;
+    uap->com = com;
+    uap->arg = arg;
+#  ifdef AFS_AIX51_ENV
+    uap->arg2 = arg2;
+    uap->arg3 = arg3;
+#  endif
+    if (setuerror(getf(uap->fd, &fd))) {
+       return -1;
+    }
+    if (fd->f_type == DTYPE_VNODE) {
+       /* good, this is a vnode; next see if it is an AFS vnode */
+       tvc = VTOAFS(fd->f_vnode);      /* valid, given a vnode */
+       if (tvc && IsAfsVnode(AFSTOV(tvc))) {
+           /* This is an AFS vnode */
+           if (((uap->com >> 8) & 0xff) == 'V') {
+               register struct afs_ioctl *datap;
+               AFS_GLOCK();
+               datap =
+                   (struct afs_ioctl *)osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+               code=copyin_afs_ioctl((char *)uap->arg, datap);
+               if (code) {
+                   osi_FreeSmallSpace(datap);
+                   AFS_GUNLOCK();
+#  if defined(AFS_AIX41_ENV)
+                   ufdrele(uap->fd);
+#  endif
+                   return (setuerror(code), code);
+               }
+               code = HandleIoctl(tvc, uap->com, datap);
+               osi_FreeSmallSpace(datap);
+               AFS_GUNLOCK();
+               ioctlDone = 1;
+#  if defined(AFS_AIX41_ENV)
+               ufdrele(uap->fd);
+#  endif
+            }
+       }
+    }
+    if (!ioctlDone) {
+#  if defined(AFS_AIX41_ENV)
+       ufdrele(uap->fd);
+#   if defined(AFS_AIX51_ENV)
+#    ifdef __64BIT__
+       code = okioctl(fdes, com, arg, ext, arg2, arg3);
+#    else /* __64BIT__ */
+       code = okioctl32(fdes, com, arg, ext, arg2, arg3);
+#    endif /* __64BIT__ */
+#   else /* !AFS_AIX51_ENV */
+       code = okioctl(fdes, com, arg, ext);
+#   endif /* AFS_AIX51_ENV */
+       return code;
+#  elif defined(AFS_AIX32_ENV)
+       okioctl(fdes, com, arg, ext);
+#  endif
+    }
+#  if defined(KERNEL_HAVE_UERROR)
+    if (!getuerror())
+       setuerror(code);
+#   if !defined(AFS_AIX41_ENV)
+    return (getuerror()? -1 : u.u_ioctlrv);
+#   else
+    return getuerror()? -1 : 0;
+#   endif
+#  endif
+    return 0;
+}
+# endif
+
+#elif defined(AFS_SGI_ENV)
+# if defined(AFS_SGI65_ENV)
 afs_ioctl(OSI_VN_DECL(tvc), int cmd, void *arg, int flag, cred_t * cr,
-         rval_t * rvalp
-#ifdef AFS_SGI65_ENV
-         , struct vopbd * vbds
-#endif
-    )
+         rval_t * rvalp, struct vopbd * vbds)
+# else
+afs_ioctl(OSI_VN_DECL(tvc), int cmd, void *arg, int flag, cred_t * cr,
+         rval_t * rvalp, struct vopbd * vbds)
+# endif
 {
     struct afs_ioctl data;
     int error = 0;
@@ -534,41 +629,7 @@ afs_ioctl(OSI_VN_DECL(tvc), int cmd, void *arg, int flag, cred_t * cr,
        return (ENOTTY);
     }
 }
-#endif /* AFS_SGI_ENV */
-
-/* unlike most calls here, this one uses u.u_error to return error conditions,
-   since this is really an intercepted chapter 2 call, rather than a vnode
-   interface call.
-   */
-/* AFS_HPUX102 and up uses VNODE ioctl instead */
-#if !defined(AFS_HPUX102_ENV) && !defined(AFS_DARWIN80_ENV)
-# if !defined(AFS_SGI_ENV)
-#  ifdef       AFS_AIX32_ENV
-#   ifdef AFS_AIX51_ENV
-#    ifdef __64BIT__
-int
-kioctl(int fdes, int com, caddr_t arg, caddr_t ext, caddr_t arg2, 
-          caddr_t arg3)
-#    else /* __64BIT__ */
-int
-kioctl32(int fdes, int com, caddr_t arg, caddr_t ext, caddr_t arg2, 
-            caddr_t arg3)
-#    endif /* __64BIT__ */
-#   else
-int
-kioctl(int fdes, int com, caddr_t arg, caddr_t ext)
-#   endif
-{
-    struct a {
-       int fd, com;
-       caddr_t arg, ext;
-#   ifdef AFS_AIX51_ENV
-       caddr_t arg2, arg3;
-#   endif
-    } u_uap, *uap = &u_uap;
-#  else
-#   if defined(AFS_SUN5_ENV)
-
+#elif defined(AFS_SUN5_ENV)
 struct afs_ioctl_sys {
     int fd;
     int com;
@@ -578,14 +639,104 @@ struct afs_ioctl_sys {
 int 
 afs_xioctl(struct afs_ioctl_sys *uap, rval_t *rvp)
 {
-#   elif defined(AFS_FBSD50_ENV)
-#    define arg data
+    struct file *fd;
+    register struct vcache *tvc;
+    register int ioctlDone = 0, code = 0;
+
+    AFS_STATCNT(afs_xioctl);
+# if defined(AFS_SUN57_ENV)
+    fd = getf(uap->fd);
+    if (!fd)
+       return (EBADF);
+# elif defined(AFS_SUN54_ENV)
+    fd = GETF(uap->fd);
+    if (!fd)
+       return (EBADF);
+# else
+    if (code = getf(uap->fd, &fd)) {
+       return (code);
+    }
+# endif
+    if (fd->f_vnode->v_type == VREG || fd->f_vnode->v_type == VDIR) {
+       tvc = VTOAFS(fd->f_vnode);      /* valid, given a vnode */
+       if (tvc && IsAfsVnode(AFSTOV(tvc))) {
+           /* This is an AFS vnode */
+           if (((uap->com >> 8) & 0xff) == 'V') {
+               register struct afs_ioctl *datap;
+               AFS_GLOCK();
+               datap =
+                   (struct afs_ioctl *)osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+               code=copyin_afs_ioctl((char *)uap->arg, datap);
+               if (code) {
+                   osi_FreeSmallSpace(datap);
+                   AFS_GUNLOCK();
+# if defined(AFS_SUN54_ENV)
+                   releasef(uap->fd);
+# else
+                   releasef(fd);
+# endif
+                   return (EFAULT);
+               }
+               code = HandleIoctl(tvc, uap->com, datap);
+               osi_FreeSmallSpace(datap);
+               AFS_GUNLOCK();
+               ioctlDone = 1;
+           }
+       }
+    }
+# if defined(AFS_SUN57_ENV)
+    releasef(uap->fd);
+# elif defined(AFS_SUN54_ENV)
+    RELEASEF(uap->fd);
+# else
+    releasef(fd);
+# endif
+    if (!ioctlDone)
+       code = ioctl(uap, rvp);
+
+    return (code);
+}
+#elif defined(AFS_LINUX22_ENV)
+struct afs_ioctl_sys {
+    unsigned int com;
+    unsigned long arg;
+};
 int
-afs_xioctl(struct thread *td, register struct ioctl_args *uap, 
-          register_t *retval)
+afs_xioctl(struct inode *ip, struct file *fp, unsigned int com,
+          unsigned long arg)
 {
-    afs_proc_t *p = td->td_proc;
-#   elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+    struct afs_ioctl_sys ua, *uap = &ua;
+    register struct vcache *tvc;
+    register int ioctlDone = 0, code = 0;
+
+    AFS_STATCNT(afs_xioctl);
+    ua.com = com;
+    ua.arg = arg;
+
+    tvc = VTOAFS(ip);
+    if (tvc && IsAfsVnode(AFSTOV(tvc))) {
+       /* This is an AFS vnode */
+       if (((uap->com >> 8) & 0xff) == 'V') {
+           register struct afs_ioctl *datap;
+           AFS_GLOCK();
+           datap = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+           code = copyin_afs_ioctl((char *)uap->arg, datap);
+           if (code) {
+               osi_FreeSmallSpace(datap);
+               AFS_GUNLOCK();
+               return -code;
+           }
+           code = HandleIoctl(tvc, uap->com, datap);
+           osi_FreeSmallSpace(datap);
+           AFS_GUNLOCK();
+           ioctlDone = 1;
+       }
+       else
+           code = EINVAL;
+    }
+    return -code;
+}
+#elif defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN80_ENV)
 struct ioctl_args {
     int fd;
     u_long com;
@@ -595,210 +746,162 @@ struct ioctl_args {
 int
 afs_xioctl(afs_proc_t *p, register struct ioctl_args *uap, register_t *retval)
 {
-#   elif defined(AFS_LINUX22_ENV)
-struct afs_ioctl_sys {
-    unsigned int com;
-    unsigned long arg;
-};
+    struct file *fd;
+    register struct vcache *tvc;
+    register int ioctlDone = 0, code = 0;
+
+    AFS_STATCNT(afs_xioctl);
+    if ((code = fdgetf(p, uap->fd, &fd)))
+       return code;
+    if (fd->f_type == DTYPE_VNODE) {
+       tvc = VTOAFS((struct vnode *)fd->f_data);       /* valid, given a vnode */
+       if (tvc && IsAfsVnode(AFSTOV(tvc))) {
+           /* This is an AFS vnode */
+           if (((uap->com >> 8) & 0xff) == 'V') {
+               register struct afs_ioctl *datap;
+               AFS_GLOCK();
+               datap = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+               code = copyin_afs_ioctl((char *)uap->arg, datap);
+               if (code) {
+                   osi_FreeSmallSpace(datap);
+                   AFS_GUNLOCK();
+                   return code;
+               }
+               code = HandleIoctl(tvc, uap->com, datap);
+               osi_FreeSmallSpace(datap);
+               AFS_GUNLOCK();
+               ioctlDone = 1;
+           }
+       }
+    }
+
+    if (!ioctlDone)
+       return ioctl(p, uap, retval);
+
+    return (code);
+}
+#elif defined(AFS_XBSD_ENV)
+# if defined(AFS_FBSD50_ENV)
+#  define arg data
 int
-afs_xioctl(struct inode *ip, struct file *fp, unsigned int com,
-          unsigned long arg)
+afs_xioctl(struct thread *td, register struct ioctl_args *uap,
+          register_t *retval)
 {
-    struct afs_ioctl_sys ua, *uap = &ua;
-#   else
+    afs_proc_t *p = td->td_proc;
+# else
+struct ioctl_args {
+    int fd;
+    u_long com;
+    caddr_t arg;
+};
+
 int
-afs_xioctl(void)
+afs_xioctl(afs_proc_t *p, register struct ioctl_args *uap, register_t *retval)
 {
-    register struct a {
-       int fd;
-       int com;
-       caddr_t arg;
-    } *uap = (struct a *)u.u_ap;
-#   endif /* AFS_SUN5_ENV */
-#  endif
-#  if defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV)
-    struct file *fd;
-#  elif !defined(AFS_LINUX22_ENV)
-    register struct file *fd;
-#  endif
-#  if defined(AFS_XBSD_ENV)
+# endif
     register struct filedesc *fdp;
-#  endif
     register struct vcache *tvc;
     register int ioctlDone = 0, code = 0;
+    struct file *fd;
 
     AFS_STATCNT(afs_xioctl);
-#  if defined(AFS_DARWIN_ENV)
-    if ((code = fdgetf(p, uap->fd, &fd)))
-       return code;
-#  elif defined(AFS_XBSD_ENV)
     fdp = p->p_fd;
     if ((u_int) uap->fd >= fdp->fd_nfiles
        || (fd = fdp->fd_ofiles[uap->fd]) == NULL)
        return EBADF;
     if ((fd->f_flag & (FREAD | FWRITE)) == 0)
        return EBADF;
-#  elif defined(AFS_LINUX22_ENV)
-    ua.com = com;
-    ua.arg = arg;
-#  elif defined(AFS_AIX32_ENV)
-    uap->fd = fdes;
-    uap->com = com;
-    uap->arg = arg;
-#   ifdef AFS_AIX51_ENV
-    uap->arg2 = arg2;
-    uap->arg3 = arg3;
-#   endif
-    if (setuerror(getf(uap->fd, &fd))) {
-       return -1;
+    /* first determine whether this is any sort of vnode */
+    if (fd->f_type == DTYPE_VNODE) {
+       /* good, this is a vnode; next see if it is an AFS vnode */
+# if defined(AFS_OBSD_ENV)
+       tvc =
+           IsAfsVnode((struct vnode *)fd->
+                      f_data) ? VTOAFS((struct vnode *)fd->f_data) : NULL;
+# else
+       tvc = VTOAFS((struct vnode *)fd->f_data);       /* valid, given a vnode */
+# endif
+       if (tvc && IsAfsVnode(AFSTOV(tvc))) {
+           /* This is an AFS vnode */
+           if (((uap->com >> 8) & 0xff) == 'V') {
+               register struct afs_ioctl *datap;
+               AFS_GLOCK();
+               datap = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+               code = copyin_afs_ioctl((char *)uap->arg, datap);
+               if (code) {
+                   osi_FreeSmallSpace(datap);
+                   AFS_GUNLOCK();
+                   return code;
+               }
+               code = HandleIoctl(tvc, uap->com, datap);
+               osi_FreeSmallSpace(datap);
+               AFS_GUNLOCK();
+               ioctlDone = 1;
+           }
+       }
     }
-#  elif defined(AFS_SUN5_ENV)
-#   if defined(AFS_SUN57_ENV)
-    fd = getf(uap->fd);
-    if (!fd)
-       return (EBADF);
-#   elif defined(AFS_SUN54_ENV)
-    fd = GETF(uap->fd);
-    if (!fd)
-       return (EBADF);
-#   else
-    if (code = getf(uap->fd, &fd)) {
-       return (code);
+
+    if (!ioctlDone) {
+# if defined(AFS_FBSD50_ENV)
+       return ioctl(td, uap);
+# elif defined(AFS_FBSD_ENV)
+       return ioctl(p, uap);
+# elif defined(AFS_OBSD_ENV)
+       code = sys_ioctl(p, uap, retval);
+# endif
     }
-#   endif      /* AFS_SUN57_ENV */
-#  else
+
+    return (code);
+}
+#elif defined(UKERNEL)
+int
+afs_xioctl(void)
+{
+    register struct a {
+       int fd;
+       int com;
+       caddr_t arg;
+    } *uap = (struct a *)get_user_struct()->u_ap;
+    register struct file *fd;
+    register struct vcache *tvc;
+    register int ioctlDone = 0, code = 0;
+
+    AFS_STATCNT(afs_xioctl);
+
     fd = getf(uap->fd);
     if (!fd)
        return (EBADF);
-#  endif
     /* first determine whether this is any sort of vnode */
-#  if defined(AFS_LINUX22_ENV)
-    tvc = VTOAFS(ip);
-    {
-#  else
-#   ifdef AFS_SUN5_ENV
-    if (fd->f_vnode->v_type == VREG || fd->f_vnode->v_type == VDIR) {
-#   else
     if (fd->f_type == DTYPE_VNODE) {
-#   endif
        /* good, this is a vnode; next see if it is an AFS vnode */
-#   if defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV)
-       tvc = VTOAFS(fd->f_vnode);      /* valid, given a vnode */
-#   elif defined(AFS_OBSD_ENV)
-       tvc =
-           IsAfsVnode((struct vnode *)fd->
-                      f_data) ? VTOAFS((struct vnode *)fd->f_data) : NULL;
-#   else
        tvc = VTOAFS((struct vnode *)fd->f_data);       /* valid, given a vnode */
-#   endif
-#  endif /* AFS_LINUX22_ENV */
        if (tvc && IsAfsVnode(AFSTOV(tvc))) {
            /* This is an AFS vnode */
            if (((uap->com >> 8) & 0xff) == 'V') {
                register struct afs_ioctl *datap;
                AFS_GLOCK();
-               datap =
-                   (struct afs_ioctl *)osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+               datap = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
                code=copyin_afs_ioctl((char *)uap->arg, datap);
                if (code) {
                    osi_FreeSmallSpace(datap);
                    AFS_GUNLOCK();
-#  if defined(AFS_AIX41_ENV)
-                   ufdrele(uap->fd);
-#  elif defined(AFS_SUN54_ENV)
-                   releasef(uap->fd);
-#  elif defined(AFS_SUN5_ENV)
-                   releasef(fd);
-#  endif
 
-#  if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-                   return code;
-#  elif defined(AFS_SUN5_ENV)
-                   return (EFAULT);
-#  elif defined(AFS_LINUX22_ENV)
-                   return -code;
-#  else
                    return (setuerror(code), code);
-#  endif
                }
                code = HandleIoctl(tvc, uap->com, datap);
                osi_FreeSmallSpace(datap);
                AFS_GUNLOCK();
                ioctlDone = 1;
-#  if defined(AFS_AIX41_ENV)
-               ufdrele(uap->fd);
-#  endif
            }
-#  if defined(AFS_LINUX22_ENV)
-           else
-               code = EINVAL;
-#  endif
        }
     }
 
     if (!ioctlDone) {
-#  if defined(AFS_AIX41_ENV)
-       ufdrele(uap->fd);
-#   ifdef AFS_AIX51_ENV
-#    ifdef __64BIT__
-       code = okioctl(fdes, com, arg, ext, arg2, arg3);
-#    else /* __64BIT__ */
-       code = okioctl32(fdes, com, arg, ext, arg2, arg3);
-#    endif /* __64BIT__ */
-#   else /* !AFS_AIX51_ENV */
-       code = okioctl(fdes, com, arg, ext);
-#   endif /* AFS_AIX51_ENV */
-       return code;
-#  elif defined(AFS_AIX32_ENV)
-       okioctl(fdes, com, arg, ext);
-#  elif defined(AFS_SUN5_ENV)
-#   if defined(AFS_SUN57_ENV)
-       releasef(uap->fd);
-#   elif defined(AFS_SUN54_ENV)
-       RELEASEF(uap->fd);
-#   else
-       releasef(fd);
-#   endif
-       code = ioctl(uap, rvp);
-#  elif defined(AFS_FBSD50_ENV)
-       return ioctl(td, uap);
-#  elif defined(AFS_FBSD_ENV)
-       return ioctl(p, uap);
-#  elif defined(AFS_OBSD_ENV)
-       code = sys_ioctl(p, uap, retval);
-#  elif defined(AFS_DARWIN_ENV)
-       return ioctl(p, uap, retval);
-#  elif !defined(AFS_LINUX22_ENV)
        ioctl();
-#  endif
     }
-#  ifdef       AFS_SUN5_ENV
-    if (ioctlDone)
-#   ifdef      AFS_SUN54_ENV
-       releasef(uap->fd);
-#   else
-       releasef(fd);
-#   endif
-    return (code);
-#  elif defined(AFS_LINUX22_ENV)
-    return -code;
-#  elif defined(KERNEL_HAVE_UERROR)
-    if (!getuerror())
-       setuerror(code);
-#   if defined(AFS_AIX32_ENV) && !defined(AFS_AIX41_ENV)
-    return (getuerror()? -1 : u.u_ioctlrv);
-#   else
-    return getuerror()? -1 : 0;
-#   endif
-#  endif
 
-#  if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-    return (code);
-#  else
     return 0;
-#  endif
 }
-# endif /* AFS_SGI_ENV */
 #endif /* AFS_HPUX102_ENV */
 
 #if defined(AFS_SGI_ENV)
@@ -1063,6 +1166,9 @@ afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow)
        }
 #elif defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
        code = afs_HandlePioctl(vp, com, &data, follow, &credp);
+#elif defined(UKERNEL)
+       code = afs_HandlePioctl(vp, com, &data, follow,
+                               &(get_user_struct()->u_cred));
 #else
        code = afs_HandlePioctl(vp, com, &data, follow, &u.u_cred);
 #endif
@@ -1334,10 +1440,15 @@ int afs_defaultAsynchrony = 0;
  * \param[in] ain      sbstruct (store behind structure) input
  * \param[out] aout    resulting sbstruct
  *
- * \retval EPERM       Error if the user doesn't have super-user credentials
- * \retval EACCES      Error if there isn't enough access to not check the mode bits
+ * \retval EPERM
+ *     Error if the user doesn't have super-user credentials
+ * \retval EACCES
+ *     Error if there isn't enough access to not check the mode bits
  *
- * \post sets asynchrony based on a file, from a struct sbstruct "I THINK"
+ * \post
+ *     Changes either the default asynchrony (the amount of data that
+ *     can remain to be written when the cache manager returns control
+ *     to the user), or the asyncrony for the specified file.
  */
 DECL_PIOCTL(PStoreBehind)
 {
@@ -1405,7 +1516,10 @@ DECL_PIOCTL(PGCPAGs)
  *
  * \post Obtain the ACL, based on file ID
  *
- * \notes there is a hack to tell which type of ACL is being returned, checks the top 2-bytes to judge what type of ACL it is, only for dfs xlat or ACLs
+ * \notes
+ *     There is a hack to tell which type of ACL is being returned, checks
+ *     the top 2-bytes of the input size to judge what type of ACL it is,
+ *     only for dfs xlator ACLs
  */
 DECL_PIOCTL(PGetAcl)
 {
@@ -1461,11 +1575,18 @@ DECL_PIOCTL(PGetAcl)
 }
 
 /*!
- * PNoop returns success.  Used for functions which are not implemented or are no longer in use.
+ * PNoop returns success.  Used for functions which are not implemented
+ * or are no longer in use.
  *
  * \ingroup pioctl
  *
- * \notes Functions involved in this: 17 (VIOCENGROUP) -- used to be enable group; 18 (VIOCDISGROUP) -- used to be disable group; 2 (?) -- get/set cache-bypass size threshold
+ * \retval Always returns success
+ *
+ * \notes
+ *     Functions involved in this:
+ *     17 (VIOCENGROUP) -- used to be enable group;
+ *     18 (VIOCDISGROUP) -- used to be disable group;
+ *     2 (?) -- get/set cache-bypass size threshold
  */
 DECL_PIOCTL(PNoop)
 {
@@ -1474,13 +1595,35 @@ DECL_PIOCTL(PNoop)
 }
 
 /*!
- * PBogus returns fail.  Used for functions which are not implemented or are no longer in use.
+ * PBogus returns fail.  Used for functions which are not implemented or
+ * are no longer in use.
  *
  * \ingroup pioctl
  *
- * \retval EINVAL      Error if some of the standard args aren't set
- *
- * \notes Functions involved in this: 0 (?); 4 (?); 6 (?); 7 (VIOCSTAT); 8 (?); 13 (VIOCGETTIME) -- used to be quick check time; 15 (VIOCPREFETCH) -- prefetch is now special-cased; see pioctl code!; 16 (VIOCNOP) -- used to be testing code; 19 (VIOCLISTGROUPS) -- used to be list group; 23 (VIOCWAITFOREVER) -- used to be waitforever; 57 (VIOC_FPRIOSTATUS) -- arla: set file prio; 58 (VIOC_FHGET) -- arla: fallback getfh; 59 (VIOC_FHOPEN) -- arla: fallback fhopen; 60 (VIOC_XFSDEBUG) -- arla: controls xfsdebug; 61 (VIOC_ARLADEBUG) -- arla: controls arla debug; 62 (VIOC_AVIATOR) -- arla: debug interface; 63 (VIOC_XFSDEBUG_PRINT) -- arla: print xfs status; 64 (VIOC_CALCULATE_CACHE) -- arla: force cache check; 65 (VIOC_BREAKCELLBACK) -- arla: break callback; 68 (?) -- arla: fetch stats;
+ * \retval EINVAL      Always returns this value
+ *
+ * \notes
+ *     Functions involved in this:
+ *     0 (?);
+ *     4 (?);
+ *     6 (?);
+ *     7 (VIOCSTAT);
+ *     8 (?);
+ *     13 (VIOCGETTIME) -- used to be quick check time;
+ *     15 (VIOCPREFETCH) -- prefetch is now special-cased; see pioctl code!;
+ *     16 (VIOCNOP) -- used to be testing code;
+ *     19 (VIOCLISTGROUPS) -- used to be list group;
+ *     23 (VIOCWAITFOREVER) -- used to be waitforever;
+ *     57 (VIOC_FPRIOSTATUS) -- arla: set file prio;
+ *     58 (VIOC_FHGET) -- arla: fallback getfh;
+ *     59 (VIOC_FHOPEN) -- arla: fallback fhopen;
+ *     60 (VIOC_XFSDEBUG) -- arla: controls xfsdebug;
+ *     61 (VIOC_ARLADEBUG) -- arla: controls arla debug;
+ *     62 (VIOC_AVIATOR) -- arla: debug interface;
+ *     63 (VIOC_XFSDEBUG_PRINT) -- arla: print xfs status;
+ *     64 (VIOC_CALCULATE_CACHE) -- arla: force cache check;
+ *     65 (VIOC_BREAKCELLBACK) -- arla: break callback;
+ *     68 (?) -- arla: fetch stats;
  */
 DECL_PIOCTL(PBogus)
 {
@@ -1527,8 +1670,10 @@ DECL_PIOCTL(PGetFileCell)
  * \param[in] ain      not in use
  * \param[out] aout    cell name
  *
- * \retval EIO         Error if the afs daemon hasn't started yet
- * \retval ESRCH       Error if the machine isn't part of a cell, for whatever reason
+ * \retval EIO
+ *     Error if the afs daemon hasn't started yet
+ * \retval ESRCH
+ *     Error if the machine isn't part of a cell, for whatever reason
  *
  * \post Get the primary cell that the machine is a part of.
  */
@@ -1558,7 +1703,8 @@ DECL_PIOCTL(PGetWSCell)
  * \param[in] ain      not in use (user id found via areq)
  * \param[out] aout    cell name
  *
- * \retval ESRCH       Error if the user id doesn't have a primary cell specified
+ * \retval ESRCH
+ *     Error if the user id doesn't have a primary cell specified
  *
  * \post Get the primary cell for a certain user, based on the user's uid
  */
@@ -1606,11 +1752,16 @@ DECL_PIOCTL(PGetUserCell)
  * \param[in] ain      the krb tickets from which to set the afs tokens
  * \param[out] aout    not in use
  *
- * \retval EINVAL      Error if the ticket is either too long or too short
- * \retval EIO         Error if the AFS initState is below 101
- * \retval ESRCH       Error if the cell for which the Token is being set can't be found
+ * \retval EINVAL
+ *     Error if the ticket is either too long or too short
+ * \retval EIO
+ *     Error if the AFS initState is below 101
+ * \retval ESRCH
+ *     Error if the cell for which the Token is being set can't be found
  *
- * \post Set the Tokens for a specific cell name, unless there is none set, then default to primary
+ * \post
+ *     Set the Tokens for a specific cell name, unless there is none set,
+ *     then default to primary
  *
  */
 DECL_PIOCTL(PSetTokens)
@@ -1651,12 +1802,14 @@ DECL_PIOCTL(PSetTokens)
        clear.AuthHandle = 999; /* more rxvab compat stuff */
 
     if (afs_pd_remaining(ain) != 0) {
-       /* still stuff left?  we've got primary flag and cell name.  Set these */
+       /* still stuff left?  we've got primary flag and cell name.
+        * Set these */
 
        if (afs_pd_getInt(ain, &flag) != 0)
            return EINVAL;
 
-       /* some versions of gcc appear to need != 0 in order to get this right */
+       /* some versions of gcc appear to need != 0 in order to get this
+        * right */
        if ((flag & 0x8000) != 0) {     /* XXX Use Constant XXX */
            flag &= ~0x8000;
            set_parent_pag = 1;
@@ -1682,14 +1835,15 @@ DECL_PIOCTL(PSetTokens)
        afs_uint32 pag;
 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 # if defined(AFS_DARWIN_ENV)
-       afs_proc_t *p = current_proc(); /* XXX */
+       afs_proc_t *p = current_proc(); /* XXX */
+       char procname[256];
+       proc_selfname(procname, 256);
 # else
        afs_proc_t *p = curproc;        /* XXX */
+       char *procname = p->p_comm;
 # endif
-# ifndef AFS_DARWIN80_ENV
-       uprintf("Process %d (%s) tried to change pags in PSetTokens\n",
-               p->p_pid, p->p_comm);
-# endif
+       afs_warnuser("Process %d (%s) tried to change pags in PSetTokens\n",
+                    MyPidxx2Pid(MyPidxx), procname);
        if (!setpag(p, acred, -1, &pag, 1)) {
 #else
        if (!setpag(acred, -1, &pag, 1)) {
@@ -1745,7 +1899,9 @@ DECL_PIOCTL(PSetTokens)
  *
  * \retval EINVAL      Error if some of the standard args aren't set
  *
- * \post The status of a volume (based on the FID of the volume), or an offline message /motd
+ * \post
+ *     The status of a volume (based on the FID of the volume), or an
+ *     offline message /motd
  */
 DECL_PIOCTL(PGetVolumeStatus)
 {
@@ -1802,15 +1958,24 @@ DECL_PIOCTL(PGetVolumeStatus)
  *
  * \ingroup pioctl
  *
- * \param[in] ain      values to set the status at, offline message, message of the day, volume name, minimum quota, maximum quota
- * \param[out] aout    status of a volume, offlines messages, minimum quota, maximumm quota
- *
- * \retval EINVAL      Error if some of the standard args aren't set
- * \retval EROFS       Error if the volume is read only, or a backup volume
- * \retval ENODEV      Error if the volume can't be accessed
- * \retval E2BIG       Error if the volume name, offline message, and motd are too big
- *
- * \post Set the status of a volume, including any offline messages, a minimum quota, and a maximum quota
+ * \param[in] ain
+ *     values to set the status at, offline message, message of the day,
+ *     volume name, minimum quota, maximum quota
+ * \param[out] aout
+ *     status of a volume, offlines messages, minimum quota, maximumm quota
+ *
+ * \retval EINVAL
+ *     Error if some of the standard args aren't set
+ * \retval EROFS
+ *     Error if the volume is read only, or a backup volume
+ * \retval ENODEV
+ *     Error if the volume can't be accessed
+ * \retval E2BIG
+ *     Error if the volume name, offline message, and motd are too big
+ *
+ * \post
+ *     Set the status of a volume, including any offline messages,
+ *     a minimum quota, and a maximum quota
  */
 DECL_PIOCTL(PSetVolumeStatus)
 {
@@ -1887,10 +2052,9 @@ DECL_PIOCTL(PSetVolumeStatus)
     if (code)
        return code;
     /* we are sending parms back to make compat. with prev system.  should
-     * change interface later to not ask for current status, just set new status */
+     * change interface later to not ask for current status, just set new
+     * status */
 
-    /* XXX - We really need to check that this doesn't overflow, too, otherwise
-     * bad fileserver status could be _really_ bad */
     if (afs_pd_putBytes(aout, &volstat, sizeof(VolumeStatus)) != 0)
        return EINVAL;
     if (afs_pd_putString(aout, volName) != 0)
@@ -1937,8 +2101,11 @@ DECL_PIOCTL(PFlush)
  *
  * \ingroup pioctl
  *
- * \param[in] ain      the last component in a path, related to mountpoint that we're looking for information about
- * \param[out] aout    volume, cell, link data 
+ * \param[in] ain
+ *     the last component in a path, related to mountpoint that we're
+ *     looking for information about
+ * \param[out] aout
+ *     volume, cell, link data
  *
  * \retval EINVAL      Error if some of the standard args aren't set
  * \retval ENOTDIR     Error if the 'mount point' argument isn't a directory
@@ -2027,14 +2194,21 @@ DECL_PIOCTL(PNewStatMount)
  *  
  * \ingroup pioctl
  *      
- * \param[in] ain       userid
+ * \param[in] ain       cellid to return tokens for
  * \param[out] aout     token
  * 
- * \retval EIO         Error if the afs daemon hasn't started yet
- * \retval EDOM                Error if the input parameter is out of the bounds of the available tokens
- * \retval ENOTCONN    Error if there aren't tokens for this cell
+ * \retval EIO
+ *     Error if the afs daemon hasn't started yet
+ * \retval EDOM
+ *     Error if the input parameter is out of the bounds of the available
+ *     tokens
+ * \retval ENOTCONN
+ *     Error if there aren't tokens for this cell
  *  
- * \post If the input paramater exists, get the token that corresponds to the parameter value, if there is no token at this value, get the token for the first cell
+ * \post
+ *     If the input paramater exists, get the token that corresponds to
+ *     the parameter value, if there is no token at this value, get the
+ *     token for the first cell
  *
  * \notes "it's a weird interface (from comments in the code)"
  */
@@ -2171,13 +2345,13 @@ DECL_PIOCTL(PUnlog)
            memset(&tu->ct, 0, sizeof(struct ClearToken));
            tu->refCount++;
            ReleaseWriteLock(&afs_xuser);
-           /* We have to drop the lock over the call to afs_ResetUserConns, since
-            * it obtains the afs_xvcache lock.  We could also keep the lock, and
-            * modify ResetUserConns to take parm saying we obtained the lock
-            * already, but that is overkill.  By keeping the "tu" pointer
-            * held over the released lock, we guarantee that we won't lose our
-            * place, and that we'll pass over every user conn that existed when
-            * we began this call.
+           /* We have to drop the lock over the call to afs_ResetUserConns,
+            * since it obtains the afs_xvcache lock.  We could also keep
+            * the lock, and modify ResetUserConns to take parm saying we
+            * obtained the lock already, but that is overkill.  By keeping
+            * the "tu" pointer held over the released lock, we guarantee
+            * that we won't lose our place, and that we'll pass over
+            * every user conn that existed when we began this call.
             */
            afs_ResetUserConns(tu);
            tu->refCount--;
@@ -2203,7 +2377,10 @@ DECL_PIOCTL(PUnlog)
  * \param[in] ain      host address to be set
  * \param[out] aout    old host address
  *
- * \post depending on whether or not a variable is set, either get the host for the cache manager monitor, or set the old address and give it a new address
+ * \post
+ *     depending on whether or not a variable is set, either get the host
+ *     for the cache manager monitor, or set the old address and give it
+ *     a new address
  *
  * \notes Errors turn off mariner
  */
@@ -2248,7 +2425,9 @@ DECL_PIOCTL(PMariner)
  * \retval EACCES      Error if the user doesn't have super-user credentials
  * \retval ENOENT      Error if we are unable to obtain the cell
  *
- * \post Either a fast check (where it doesn't contact servers) or a local check (checks local cell only)
+ * \post
+ *     Either a fast check (where it doesn't contact servers) or a
+ *     local check (checks local cell only)
  */
 DECL_PIOCTL(PCheckServers)
 {
@@ -2345,7 +2524,10 @@ DECL_PIOCTL(PCheckServers)
  *
  * \retval EIO         Error if the afs daemon hasn't started yet
  *
- * \post Check the root volume, and then check the names if the volume check variable is set to force, has expired, is busy, or if the mount points variable is set
+ * \post
+ *     Check the root volume, and then check the names if the volume
+ *     check variable is set to force, has expired, is busy, or if
+ *     the mount points variable is set
  */
 DECL_PIOCTL(PCheckVolNames)
 {
@@ -2367,9 +2549,13 @@ DECL_PIOCTL(PCheckVolNames)
  * \param[in] ain      not in use
  * \param[out] aout    not in use
  *
- * \retval EACCESS Error if no user is specififed, the user has no tokens set, or if the user's tokens are bad
+ * \retval EACCESS
+ *     Error if no user is specififed, the user has no tokens set,
+ *     or if the user's tokens are bad
  *
- * \post check to see if a user has the correct authentication.  If so, allow access.
+ * \post
+ *     check to see if a user has the correct authentication.
+ *     If so, allow access.
  *
  * \notes Check the connections to all the servers specified
  */
@@ -2441,7 +2627,7 @@ Prefetch(uparmtype apath, struct afs_ioctl *adata, int afollow,
        return EWOULDBLOCK;     /* pretty close */
     }
     afs_BQueue(BOP_PATH, (struct vcache *)0, 0, 0, acred, (afs_size_t) 0,
-              (afs_size_t) 0, tp);
+              (afs_size_t) 0, tp, (void *)0, (void *)0);
     return 0;
 }
 
@@ -2576,9 +2762,12 @@ DECL_PIOCTL(PPrecache)
  * \retval EACCES      Error if the user doesn't have super-user credentials
  * \retval EROFS       Error if the cache is set to be in memory
  *
- * \post Set the cache size based on user input.  If no size is given, set it to the default OpenAFS cache size.
+ * \post
+ *     Set the cache size based on user input.  If no size is given,
+ *     set it to the default OpenAFS cache size.
  *
- * \notes recompute the general cache parameters for every single block allocated
+ * \notes
+ *     recompute the general cache parameters for every single block allocated
  */
 DECL_PIOCTL(PSetCacheSize)
 {
@@ -2685,7 +2874,10 @@ DECL_PIOCTL(PGetCacheSize)
  * \retval EINVAL      Error if some of the standard args aren't set
  * \retval 0           0 returned if the volume is set to read-only
  *
- * \post Flushes callbacks, by setting the length of callbacks to one, setting the next callback to be sent to the CB_DROPPED value, and then dequeues everything else.
+ * \post
+ *     Flushes callbacks, by setting the length of callbacks to one,
+ *     setting the next callback to be sent to the CB_DROPPED value,
+ *     and then dequeues everything else.
  */
 DECL_PIOCTL(PRemoveCallBack)
 {
@@ -2739,8 +2931,12 @@ DECL_PIOCTL(PRemoveCallBack)
  *
  * \ingroup pioctl
  *
- * \param[in] ain      the name of the cell, the hosts that will be a part of the cell, whether or not it's linked with another cell, the other cell it's linked with, the file server port, and the volume server port
- * \param[out] aout    not in use
+ * \param[in] ain
+ *     the name of the cell, the hosts that will be a part of the cell,
+ *     whether or not it's linked with another cell, the other cell it's
+ *     linked with, the file server port, and the volume server port
+ * \param[out] aout
+ *     not in use
  *
  * \retval EIO         Error if the afs daemon hasn't started yet
  * \retval EACCES      Error if the user doesn't have super-user cedentials
@@ -2931,11 +3127,17 @@ out:
  * \param[in] ain      the name of the file in this dir to remove
  * \param[out] aout    not in use
  *
- * \retval EINVAL      Error if some of the standard args aren't set
- * \retval ENOTDIR     Error if the argument to remove is not a directory
- * \retval ENOENT      Error if there is no cache to remove the mount point from or if a vcache doesn't exist
- *
- * \post Ensure that everything is OK before deleting the mountpoint.  If not, don't delete.  Delete a mount point based on a file id.
+ * \retval EINVAL
+ *     Error if some of the standard args aren't set
+ * \retval ENOTDIR
+ *     Error if the argument to remove is not a directory
+ * \retval ENOENT
+ *     Error if there is no cache to remove the mount point from or
+ *     if a vcache doesn't exist
+ *
+ * \post
+ *     Ensure that everything is OK before deleting the mountpoint.
+ *     If not, don't delete.  Delete a mount point based on a file id.
  */
 DECL_PIOCTL(PRemoveMount)
 {
@@ -3062,20 +3264,6 @@ DECL_PIOCTL(PRemoveMount)
 }
 
 /*!
- * VIOC_VENUSLOG (34) - Enable/Disable venus logging
- *
- * \ingroup pioctl
- *
- * \retval EINVAL      Error if some of the standard args aren't set
- *
- * \notes Obsoleted, perhaps should be PBogus
- */
-DECL_PIOCTL(PVenusLogging)
-{
-    return EINVAL;             /* OBSOLETE */
-}
-
-/*!
  * VIOC_GETCELLSTATUS (35) - Get cell status info
  *
  * \ingroup pioctl
@@ -3115,13 +3303,18 @@ DECL_PIOCTL(PGetCellStatus)
  *
  * \ingroup pioctl
  *
- * \param[in] ain      The cell you want to set information about, and the values you want to set
- * \param[out] aout    not in use
+ * \param[in] ain
+ *     The cell you want to set information about, and the values you
+ *     want to set
+ * \param[out] aout
+ *     not in use
  *
  * \retval EIO         Error if the afs daemon hasn't started yet
  * \retval EACCES      Error if the user doesn't have super-user credentials
  *
- * \post Set the state of the cell in a defined struct cell, based on whether or not SetUID is allowed
+ * \post
+ *     Set the state of the cell in a defined struct cell, based on
+ *     whether or not SetUID is allowed
  */
 DECL_PIOCTL(PSetCellStatus)
 {
@@ -3163,9 +3356,14 @@ DECL_PIOCTL(PSetCellStatus)
  * \retval EINVAL      Error if some of the standard args aren't set
  * \retval EIO         Error if the afs daemon hasn't started yet
  *
- * \post Wipe everything on the volume.  This is done dependent on which platform this is for.
+ * \post
+ *     Flush all cached contents of a volume.  Exactly what stays and what
+ *     goes depends on the platform.
  *
- * \notes Does not flush a file that a user has open and is using, because it will be re-created on next write.  Also purges the dnlc, because things are screwed up.
+ * \notes
+ *     Does not flush a file that a user has open and is using, because
+ *     it will be re-created on next write.  Also purges the dnlc,
+ *     because things are screwed up.
  */
 DECL_PIOCTL(PFlushVolumeData)
 {
@@ -3189,8 +3387,8 @@ DECL_PIOCTL(PFlushVolumeData)
     cell = avc->f.fid.Cell;
 
     /*
-     * Clear stat'd flag from all vnodes from this volume; this will invalidate all
-     * the vcaches associated with the volume.
+     * Clear stat'd flag from all vnodes from this volume; this will
+     * invalidate all the vcaches associated with the volume.
      */
  loop:
     ObtainReadLock(&afs_xvcache);
@@ -3205,11 +3403,13 @@ DECL_PIOCTL(PFlushVolumeData)
                    goto loop;
                }
 #ifdef AFS_DARWIN80_ENV
-               if (tvc->f.states & CDeadVnode) {
+           if (tvc->f.states & CDeadVnode) {
+               if (!(tvc->f.states & CBulkFetching)) {
                    ReleaseReadLock(&afs_xvcache);
                    afs_osi_Sleep(&tvc->f.states);
                    goto loop;
                }
+           }
 #endif
 #if    defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
                VN_HOLD(AFSTOV(tvc));
@@ -3223,10 +3423,13 @@ DECL_PIOCTL(PFlushVolumeData)
                    AFS_GLOCK();
                    continue;
                }
-#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-               osi_vnhold(tvc, 0);
+               if (tvc->f.states & (CBulkFetching|CDeadVnode)) {
+                   AFS_GUNLOCK();
+                   vnode_recycle(AFSTOV(tvc));
+                   AFS_GLOCK();
+               }
 #else
-               VREFCOUNT_INC(tvc); /* AIX, apparently */
+               AFS_FAST_HOLD(tvc);
 #endif
                ReleaseReadLock(&afs_xvcache);
 #ifdef AFS_BOZONLOCK_ENV
@@ -3257,22 +3460,22 @@ DECL_PIOCTL(PFlushVolumeData)
     ReleaseReadLock(&afs_xvcache);
 
 
-    ObtainWriteLock(&afs_xdcache, 328);        /* needed if you're going to flush any stuff */
+    ObtainWriteLock(&afs_xdcache, 328);        /* needed to flush any stuff */
     for (i = 0; i < afs_cacheFiles; i++) {
        if (!(afs_indexFlags[i] & IFEverUsed))
            continue;           /* never had any data */
        tdc = afs_GetDSlot(i, NULL);
-       if (tdc->refCount <= 1) {       /* too high, in use by running sys call */
+       if (tdc->refCount <= 1) {    /* too high, in use by running sys call */
            ReleaseReadLock(&tdc->tlock);
            if (tdc->f.fid.Fid.Volume == volume && tdc->f.fid.Cell == cell) {
                if (!(afs_indexFlags[i] & IFDataMod)) {
-                   /* if the file is modified, but has a ref cnt of only 1, then
-                    * someone probably has the file open and is writing into it.
-                    * Better to skip flushing such a file, it will be brought back
-                    * immediately on the next write anyway.
+                   /* if the file is modified, but has a ref cnt of only 1,
+                    * then someone probably has the file open and is writing
+                    * into it. Better to skip flushing such a file, it will be
+                    * brought back immediately on the next write anyway.
                     * 
-                    * If we *must* flush, then this code has to be rearranged to call
-                    * afs_storeAllSegments() first */
+                    * If we *must* flush, then this code has to be rearranged
+                    * to call afs_storeAllSegments() first */
                    afs_FlushDCache(tdc);
                }
            }
@@ -3306,13 +3509,22 @@ DECL_PIOCTL(PFlushVolumeData)
  *
  * \ingroup pioctl
  *
- * \param[in] ain      not in use (avc used)
- * \param[out] aout    vcxstat: the file id, the data version, any lock, the parent vnode, the parent unique id, the trunc position, the callback, cbExpires, what access is being made, what files are open, any users executing/writing, the flock ount, the states, the move stat
- *
- * \retval EINVAL      Error if some of the initial default arguments aren't set
- * \retval EACCES      Error if access to check the mode bits is denied
- *
- * \post gets stats for the vnode, a struct listed in vcxstat
+ * \param[in] ain
+ *     not in use (avc used)
+ * \param[out] aout
+ *     vcxstat: the file id, the data version, any lock, the parent vnode,
+ *     the parent unique id, the trunc position, the callback, cbExpires,
+ *     what access is being made, what files are open,
+ *     any users executing/writing, the flock count, the states,
+ *     the move stat
+ *
+ * \retval EINVAL
+ *     Error if some of the initial default arguments aren't set
+ * \retval EACCES
+ *     Error if access to check the mode bits is denied
+ *
+ * \post
+ *     gets stats for the vnode, a struct listed in vcxstat
  */
 DECL_PIOCTL(PGetVnodeXStatus)
 {
@@ -3342,7 +3554,7 @@ DECL_PIOCTL(PGetVnodeXStatus)
     hset(stat.flushDV, avc->flushDV);
     hset(stat.mapDV, avc->mapDV);
     stat.truncPos = avc->f.truncPos;
-    {                          /* just grab the first two - won't break anything... */
+    {                  /* just grab the first two - won't break anything... */
        struct axscache *ac;
 
        for (i = 0, ac = avc->Access; ac && i < CPSIZE; i++, ac = ac->next) {
@@ -3399,13 +3611,23 @@ DECL_PIOCTL(PGetVnodeXStatus2)
  * \param[in] ain      new value for @sys
  * \param[out] aout    count, entry, list (debug values?)
  *
- * \retval EINVAL      Error if afsd isn't running, the new sysname is too large, the new sysname causes issues (starts with a .0 or ..0), there is no PAG set in the credentials, the user of a PAG can't be found, (!(exporter = au->exporter)) "NOT SURE ON THIS"
- * \retval ENODEV      Error if there isn't already a system named that ("I THINK")
- * \retval EACCES      Error if the user doesn't have super-user credentials
- *
- * \post Set the value of @sys if these things work: if the input isn't too long or if input doesn't start with .0 or ..0
- *
- * \notes We require root for local sysname changes, but not for remote (since we don't really believe remote uids anyway) outname[] shouldn't really be needed- this is left as an exercise for the reader.
+ * \retval EINVAL
+ *     Error if afsd isn't running, the new sysname is too large,
+ *     the new sysname causes issues (starts with a . or ..),
+ *     there is no PAG set in the credentials, or the user of a PAG
+ *     can't be found
+ * \retval EACCES
+ *     Error if the user doesn't have super-user credentials
+ *
+ * \post
+ *     Set the value of @sys if these things work: if the input isn't
+ *     too long or if input doesn't start with . or ..
+ *
+ * \notes
+ *     We require root for local sysname changes, but not for remote
+ *     (since we don't really believe remote uids anyway)
+ *     outname[] shouldn't really be needed- this is left as an
+ *     exercise for the reader.
  */
 DECL_PIOCTL(PSetSysName)
 {
@@ -3459,7 +3681,7 @@ DECL_PIOCTL(PSetSysName)
        num = count;
     }
     if (afs_cr_gid(*acred) == RMTUSER_REQ ||
-       afs_cr_gid(*acred) == RMTUSER_REQ_PRIV) {       /* Handles all exporters */
+       afs_cr_gid(*acred) == RMTUSER_REQ_PRIV) {   /* Handles all exporters */
        if (allpags && afs_cr_gid(*acred) != RMTUSER_REQ_PRIV) {
            return EPERM;
        }
@@ -3518,7 +3740,7 @@ DECL_PIOCTL(PSetSysName)
                for (count = 1; count < setsysname; ++count) {
                    if (!afs_sysnamelist[count])
                        osi_Panic
-                           ("PSetSysName: no afs_sysnamelist entry to write\n");
+                          ("PSetSysName: no afs_sysnamelist entry to write\n");
                    if (afs_pd_getString(ain, afs_sysnamelist[count],
                                         MAXSYSNAME) != 0)
                        return EINVAL;
@@ -3534,7 +3756,7 @@ DECL_PIOCTL(PSetSysName)
        if (foundname) {
            if (afs_pd_putString(aout, outname) != 0)
                return E2BIG;
-           for (count = 1; count < foundname; ++count) {       /* ... or list. */
+           for (count = 1; count < foundname; ++count) {    /* ... or list. */
                if (!sysnamelist[count])
                    osi_Panic
                        ("PSetSysName: no afs_sysnamelist entry to read\n");
@@ -3622,7 +3844,7 @@ afs_setsprefs(struct spref *sp, unsigned int num, unsigned int vlonly)
     touchedSize = 0;
     for (k = 0; k < num; sp++, k++) {
        if (debugsetsp) {
-           printf("sp host=%x, rank=%d\n", sp->host.s_addr, sp->rank);
+           afs_warn("sp host=%x, rank=%d\n", sp->host.s_addr, sp->rank);
        }
        matches = 0;
        ObtainReadLock(&afs_xserver);
@@ -3642,7 +3864,7 @@ afs_setsprefs(struct spref *sp, unsigned int num, unsigned int vlonly)
 
        if (sa && matches) {    /* found one! */
            if (debugsetsp) {
-               printf("sa ip=%x, ip_rank=%d\n", sa->sa_ip, sa->sa_iprank);
+               afs_warn("sa ip=%x, ip_rank=%d\n", sa->sa_ip, sa->sa_iprank);
            }
            sa->sa_iprank = sp->rank + afs_randomMod15();
            afs_SortOneServer(sa->server);
@@ -3687,9 +3909,13 @@ afs_setsprefs(struct spref *sp, unsigned int num, unsigned int vlonly)
  * \param[in] ain      the sprefs value you want the sprefs to be set to
  * \param[out] aout    not in use
  *
- * \retval EIO         Error if the afs daemon hasn't started yet
- * \retval EACCES      Error if the user doesn't have super-user credentials
- * \retval EINVAL      Error if the struct setsprefs is too large or if it multiplied by the number of servers is too large
+ * \retval EIO
+ *     Error if the afs daemon hasn't started yet
+ * \retval EACCES
+ *     Error if the user doesn't have super-user credentials
+ * \retval EINVAL
+ *     Error if the struct setsprefs is too large or if it multiplied
+ *     by the number of servers is too large
  *
  * \post set the sprefs using the afs_setsprefs() function
  */
@@ -3767,7 +3993,12 @@ DECL_PIOCTL(PSetSPrefs33)
  *
  * \post Get the sprefs
  *
- * \notes in the hash table of server structs, all servers with the same IP address; will be on the same overflow chain; This could be sped slightly in some circumstances by having it cache the immediately previous slot in the hash table and some supporting information; Only reports file servers now.
+ * \notes
+ *     in the hash table of server structs, all servers with the same
+ *     IP address; will be on the same overflow chain; This could be
+ *     sped slightly in some circumstances by having it cache the
+ *     immediately previous slot in the hash table and some
+ *     supporting information; Only reports file servers now.
  */
 DECL_PIOCTL(PGetSPrefs)
 {
@@ -3852,20 +4083,24 @@ int afs_NFSRootOnly = 1;
  *
  * \ingroup pioctl
  *
- * \param[in] ain      a struct Vic * EIOctl containing export values needed to change between nfs and afs
- * \param[out] aout    a struct of the exporter states (exporter->exp_states)
+ * \param[in] ain
+ *     an integer containing the desired exportee flags
+ * \param[out] aout
+ *     an integer containing the current exporter flags
  *
  * \retval ENODEV      Error if the exporter doesn't exist
  * \retval EACCES      Error if the user doesn't have super-user credentials
  *
- * \post Changes the state of various values to reflect the change of the export values between nfs and afs.
+ * \post
+ *     Changes the state of various values to reflect the change
+ *     of the export values between nfs and afs.
  *
  * \notes Legacy code obtained from IBM.
  */
 DECL_PIOCTL(PExportAfs)
 {
-    afs_int32 export, newint =
-       0, type, changestate, handleValue, convmode, pwsync, smounts;
+    afs_int32 export, newint = 0;
+    afs_int32 type, changestate, handleValue, convmode, pwsync, smounts;
     afs_int32 rempags = 0, pagcb = 0;
     register struct afs_exporter *exporter;
 
@@ -4055,7 +4290,8 @@ DECL_PIOCTL(PTwiddleRx)
  * \param[in] ain      not in use
  * \param[out] aout    initial cache manager params
  *
- * \retval E2BIG       Error if the initial parameters are bigger than some PIGGYSIZE
+ * \retval E2BIG
+ *     Error if the initial parameters are bigger than some PIGGYSIZE
  *
  * \post return the initial cache manager parameters
  */
@@ -4092,7 +4328,7 @@ crget(void)
  * \param[in] ain      not in use
  * \param[out] aout    value of cryptall
  *
- * \post get the value of cryptall (presumably whether or not things should be encrypted)
+ * \post Turns on, or disables, rxkad encryption by setting the cryptall global
  */
 DECL_PIOCTL(PGetRxkcrypt)
 {
@@ -4107,12 +4343,17 @@ DECL_PIOCTL(PGetRxkcrypt)
  * \param[in] ain      the argument whether or not things should be encrypted
  * \param[out] aout    not in use
  *
- * \retval EPERM       Error if the user doesn't have super-user credentials
- * \retval EINVAL      Error if the input is too big, or if the input is outside the bounds of what it can be set to
+ * \retval EPERM
+ *     Error if the user doesn't have super-user credentials
+ * \retval EINVAL
+ *     Error if the input is too big, or if the input is outside the
+ *     bounds of what it can be set to
  *
  * \post set whether or not things should be encrypted
  *
- * \notes may need to be modified at a later date to take into account other values for cryptall (beyond true or false)
+ * \notes
+ *     may need to be modified at a later date to take into account
+ *     other values for cryptall (beyond true or false)
  */
 DECL_PIOCTL(PSetRxkcrypt)
 {
@@ -4159,7 +4400,8 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
 #endif
     AFS_STATCNT(HandleClientContext);
     if (ablob->in_size < PIOCTL_HEADER * sizeof(afs_int32)) {
-       /* Must at least include the PIOCTL_HEADER header words required by the protocol */
+       /* Must at least include the PIOCTL_HEADER header words
+        * required by the protocol */
        return EINVAL;          /* Too small to be good  */
     }
     ain = inData = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
@@ -4180,7 +4422,7 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
     ain += sizeof(g1);
     *com = *((afs_uint32 *) ain);
     ain += sizeof(afs_int32);
-    exporter_type = *((afs_uint32 *) ain);     /* In case we support more than NFS */
+    exporter_type = *((afs_uint32 *) ain);/* In case we support more than NFS */
 
     /*
      * Of course, one must be root for most of these functions, but
@@ -4224,7 +4466,7 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
     newcred->cr_groupset.gs_union.un_groups[1] = g1;
 #elif defined(AFS_LINUX26_ENV)
 # ifdef AFS_LINUX26_ONEGROUP_ENV
-    set_cr_group_info(newcred, groups_alloc(1)); /* not that anything sets this */
+    set_cr_group_info(newcred, groups_alloc(1)); /* nothing sets this */
     l = (((g0-0x3f00) & 0x3fff) << 14) | ((g1-0x3f00) & 0x3fff);
     h = ((g0-0x3f00) >> 14);
     h = ((g1-0x3f00) >> 14) + h + h + h;
@@ -4272,7 +4514,7 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
        /* Special case for 'setpag' */
        afs_uint32 pagvalue = genpag();
 
-       au = afs_GetUser(pagvalue, -1, WRITE_LOCK);     /* a new unixuser struct */
+       au = afs_GetUser(pagvalue, -1, WRITE_LOCK); /* a new unixuser struct */
        /*
         * Note that we leave the 'outexporter' struct held so it won't
         * dissappear on us
@@ -4307,7 +4549,9 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
  * \retval EIO         Error if the afs daemon hasn't started yet
  * \retval EINVAL      Error if some of the standard args aren't set
  *
- * \post get all interface addresses and other information of the client interface
+ * \post
+ *     get all interface addresses and other information of the client
+ *     interface
  */
 DECL_PIOCTL(PGetCPrefs)
 {
@@ -4335,7 +4579,7 @@ DECL_PIOCTL(PGetCPrefs)
     ObtainReadLock(&afs_xinterface);
 
     /* copy out the client interface information from the
-     ** kernel data structure "interface" to the output buffer
+     * kernel data structure "interface" to the output buffer
      */
     for (i = spin->offset, j = 0; (i < afs_cb_interface.numberOfInterfaces)
         && (j < maxNumber); i++, j++, srvout++)
@@ -4409,14 +4653,21 @@ DECL_PIOCTL(PSetCPrefs)
  *
  * \ingroup pioctl
  *
- * \param[in] ain      the last part of a path to a mount point, which tells us what to flush
- * \param[out] aout    not in use
+ * \param[in] ain
+ *     the last part of a path to a mount point, which tells us what to flush
+ * \param[out] aout
+ *     not in use
  *
- * \retval EINVAL      Error if some of the initial arguments aren't set
- * \retval ENOTDIR     Error if the initial argument for the mount point isn't a directory
- * \retval ENOENT      Error if the dcache entry isn't set
+ * \retval EINVAL
+ *     Error if some of the initial arguments aren't set
+ * \retval ENOTDIR
+ *     Error if the initial argument for the mount point isn't a directory
+ * \retval ENOENT
+ *     Error if the dcache entry isn't set
  *
- * \post remove all of the mount data from the dcache regarding a certain mount point
+ * \post
+ *     remove all of the mount data from the dcache regarding a
+ *     certain mount point
  */
 DECL_PIOCTL(PFlushMount)
 {
@@ -4509,7 +4760,9 @@ DECL_PIOCTL(PFlushMount)
  * \retval EACCES      Error if the user doesn't have super-user credentials
  * \retval EINVAL      Error if the flag input is too long
  *
- * \post either enable process RPCStats, disable process RPCStats, or clear the process RPCStats
+ * \post
+ *     either enable process RPCStats, disable process RPCStats,
+ *     or clear the process RPCStats
  */
 DECL_PIOCTL(PRxStatProc)
 {
@@ -4548,7 +4801,9 @@ DECL_PIOCTL(PRxStatProc)
  * \retval EACCES      Error if the user doesn't have super-user credentials
  * \retval EINVAL      Error if the flag input is too long
  *
- * \post either enable peer RPCStatws, disable peer RPCStats, or clear the peer RPCStats
+ * \post
+ *     either enable peer RPCStatws, disable peer RPCStats,
+ *     or clear the peer RPCStats
  */
 DECL_PIOCTL(PRxStatPeer)
 {
@@ -4693,7 +4948,7 @@ DECL_PIOCTL(PFsCmd)
                  AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, SHARED_LOCK, NULL));
        /* This call is done to have the callback things handled correctly */
        afs_FetchStatus(tvc, &tfid, areq, &Outputs->status);
-    } else {                   /* just a status request, return also link data */
+    } else {           /* just a status request, return also link data */
        code = 0;
        Outputs->code = afs_FetchStatus(tvc, &tfid, areq, &Outputs->status);
        Outputs->chars[0] = 0;
@@ -4756,8 +5011,8 @@ DECL_PIOCTL(PSetCachingThreshold)
     }
        
     /* Return the current size threshold */
-    if (getting) {
-       return afs_pd_putInt32(aout, cache_bypass_threshold);
+    if (getting)
+       return afs_pd_putInt(aout, cache_bypass_threshold);
 
     return(0);
 }
@@ -4903,7 +5158,7 @@ DECL_PIOCTL(PDiscon)
            afs_in_sync = 0;
 
            if (code && !force) {
-               printf("Files not synchronized properly, still in discon state. \n"
+               afs_warnuser("Files not synchronized properly, still in discon state. \n"
                       "Please retry or use \"force\".\n");
                mode = 0;
            } else {
@@ -4913,7 +5168,7 @@ DECL_PIOCTL(PDiscon)
                afs_ClearAllStatdFlag();
                afs_is_disconnected = 0;
                afs_is_discon_rw = 0;
-               printf("\nSync succeeded. You are back online.\n");
+               afs_warnuser("\nSync succeeded. You are back online.\n");
            }
 
            ReleaseWriteLock(&afs_discon_lock);