Remove one more AFS_UCRED struct
[openafs.git] / src / afs / afs_pioctl.c
index 88b0888..bd4a5f2 100644 (file)
@@ -10,8 +10,6 @@
 #include <afsconfig.h>
 #include "afs/param.h"
 
-RCSID
-    ("$Header$");
 
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
 #ifdef AFS_OBSD_ENV
@@ -57,7 +55,7 @@ afs_int32 afs_in_sync = 0;
 
 #define DECL_PIOCTL(x) static int x(struct vcache *avc, int afun, struct vrequest *areq, \
        char *ain, char *aout, afs_int32 ainSize, afs_int32 *aoutSize, \
-       struct AFS_UCRED **acred)
+       AFS_UCRED **acred)
 
 /* Prototypes for pioctl routines */
 DECL_PIOCTL(PGetFID);
@@ -113,12 +111,13 @@ DECL_PIOCTL(PFlushMount);
 DECL_PIOCTL(PRxStatProc);
 DECL_PIOCTL(PRxStatPeer);
 DECL_PIOCTL(PPrefetchFromTape);
-DECL_PIOCTL(PResidencyCmd);
+DECL_PIOCTL(PFsCmd);
 DECL_PIOCTL(PCallBackAddr);
 DECL_PIOCTL(PDiscon);
 DECL_PIOCTL(PNFSNukeCreds);
 DECL_PIOCTL(PNewUuid);
 DECL_PIOCTL(PPrecache); 
+DECL_PIOCTL(PGetPAG);
 #if defined(AFS_CACHE_BYPASS)
 DECL_PIOCTL(PSetCachingThreshold);
 DECL_PIOCTL(PSetCachingBlkSize);
@@ -135,20 +134,20 @@ DECL_PIOCTL(PSetCachingBlkSize);
 /* Prototypes for private routines */
 #ifdef AFS_NEED_CLIENTCONTEXT
 static int HandleClientContext(struct afs_ioctl *ablob, int *com,
-                              struct AFS_UCRED **acred,
-                              struct AFS_UCRED *credp);
+                              AFS_UCRED **acred,
+                              AFS_UCRED *credp);
 #endif
 int HandleIoctl(register struct vcache *avc, register afs_int32 acom,
                struct afs_ioctl *adata);
 int afs_HandlePioctl(struct vnode *avp, afs_int32 acom,
                     register struct afs_ioctl *ablob, int afollow,
-                    struct AFS_UCRED **acred);
-static int Prefetch(char *apath, struct afs_ioctl *adata, int afollow,
-                   struct AFS_UCRED *acred);
+                    AFS_UCRED **acred);
+static int Prefetch(iparmtype apath, struct afs_ioctl *adata, int afollow,
+                   AFS_UCRED *acred);
 
 typedef int (*pioctlFunction) (struct vcache *, int, struct vrequest *,
                               char *, char *, afs_int32, afs_int32 *,
-                              struct AFS_UCRED **);
+                              AFS_UCRED **);
 
 static pioctlFunction VpioctlSw[] = {
     PBogus,                    /* 0 */
@@ -218,7 +217,7 @@ static pioctlFunction VpioctlSw[] = {
        PBogus,                 /* 64 -- arla: force cache check */
        PBogus,                 /* 65 -- arla: break callback */
        PPrefetchFromTape,      /* 66 -- MR-AFS: prefetch file from tape */
-       PResidencyCmd,          /* 67 -- MR-AFS: generic commnd interface */
+       PFsCmd,                 /* 67 -- RXOSD: generic commnd interface */
        PBogus,                 /* 68 -- arla: fetch stats */
        PGetVnodeXStatus2,      /* 69 - get caller access and some vcache status */
 };
@@ -237,9 +236,10 @@ static pioctlFunction CpioctlSw[] = {
     PBogus,                     /* 0 */
     PBogus,                     /* 0 */
     PPrecache,                  /* 12 */
+    PGetPAG,                    /* 13 */
 };
 
-static int (*(OpioctlSw[])) () = {
+static pioctlFunction OpioctlSw[]  = {
     PBogus,                    /* 0 */
     PNFSNukeCreds,             /* 1 -- nuke all creds for NFS client */
 #if defined(AFS_CACHE_BYPASS)
@@ -315,7 +315,6 @@ HandleIoctl(register struct vcache *avc, register afs_int32 acom,
     return code;               /* so far, none implemented */
 }
 
-
 #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
@@ -581,8 +580,7 @@ afs_xioctl(void)
 #ifdef AFS_LINUX22_ENV
                    return -code;
 #else
-                   setuerror(code);
-                   return;
+                   return (setuerror(code), code);
 #endif
 #endif
 #endif
@@ -681,6 +679,8 @@ afs_xioctl(void)
 #endif /* AFS_SUN5_ENV */
 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
     return (code);
+#else
+    return 0;
 #endif
 }
 #endif /* AFS_SGI_ENV */
@@ -776,11 +776,14 @@ afs_pioctl(struct proc *p, void *args, int *retval)
 int
 #ifdef AFS_SUN5_ENV
 afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow, 
-                  rval_t *vvp, struct AFS_UCRED *credp)
+                  rval_t *vvp, AFS_UCRED *credp)
 #else
-#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#ifdef AFS_DARWIN100_ENV
+afs_syscall64_pioctl(user_addr_t path, unsigned int com, user_addr_t cmarg,
+                  int follow, AFS_UCRED *credp)
+#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow, 
-                  struct AFS_UCRED *credp)
+                  AFS_UCRED *credp)
 #else
 afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow)
 #endif
@@ -788,9 +791,11 @@ afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow)
 {
     struct afs_ioctl data;
 #ifdef AFS_NEED_CLIENTCONTEXT
-    struct AFS_UCRED *tmpcred = NULL;
+    AFS_UCRED *tmpcred = NULL;
+#endif
+#if defined(AFS_NEED_CLIENTCONTEXT) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+    AFS_UCRED *foreigncreds = NULL;
 #endif
-    struct AFS_UCRED *foreigncreds = NULL;
     register afs_int32 code = 0;
     struct vnode *vp = NULL;
 #ifdef AFS_AIX41_ENV
@@ -886,11 +891,11 @@ afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow)
                       foreigncreds ? foreigncreds : credp);
 #else
 #ifdef AFS_LINUX22_ENV
-       code = gop_lookupname(path, AFS_UIOUSER, follow, &dp);
+       code = gop_lookupname_user(path, AFS_UIOUSER, follow, &dp);
        if (!code)
            vp = (struct vnode *)dp->d_inode;
 #else
-       code = gop_lookupname(path, AFS_UIOUSER, follow, &vp);
+       code = gop_lookupname_user(path, AFS_UIOUSER, follow, &vp);
 #endif /* AFS_LINUX22_ENV */
 #endif /* AFS_AIX41_ENV */
        AFS_GLOCK();
@@ -1001,13 +1006,24 @@ afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow)
 #endif
 }
 
+#ifdef AFS_DARWIN100_ENV
+int
+afs_syscall_pioctl(char * path, unsigned int com, caddr_t cmarg,
+                  int follow, AFS_UCRED *credp)
+{
+    return afs_syscall64_pioctl(CAST_USER_ADDR_T(path), com,
+                               CAST_USER_ADDR_T((unsigned int)cmarg), follow,
+                               credp);
+}
+#endif
+
 #define MAXPIOCTLTOKENLEN \
 (3*sizeof(afs_int32)+MAXKTCTICKETLEN+sizeof(struct ClearToken)+MAXKTCREALMLEN)
 
 int
 afs_HandlePioctl(struct vnode *avp, afs_int32 acom,
                 register struct afs_ioctl *ablob, int afollow,
-                struct AFS_UCRED **acred)
+                AFS_UCRED **acred)
 {
     struct vcache *avc;
     struct vrequest treq;
@@ -1548,7 +1564,7 @@ DECL_PIOCTL(PSetTokens)
     i = tcell->cellNum;
     afs_PutCell(tcell, READ_LOCK);
     if (set_parent_pag) {
-       afs_int32 pag;
+       afs_uint32 pag;
 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 #if defined(AFS_DARWIN_ENV)
        struct proc *p = current_proc();        /* XXX */
@@ -2273,8 +2289,8 @@ DECL_PIOCTL(PCheckAuth)
 }
 
 static int
-Prefetch(char *apath, struct afs_ioctl *adata, int afollow,
-        struct AFS_UCRED *acred)
+Prefetch(iparmtype apath, struct afs_ioctl *adata, int afollow,
+        AFS_UCRED *acred)
 {
     register char *tp;
     register afs_int32 code;
@@ -2382,6 +2398,33 @@ DECL_PIOCTL(PViceAccess)
        return EACCES;
 }
 
+/*!
+ * VIOC_GETPAG (13) - Get PAG value
+ *
+ * \ingroup pioctl
+ *
+ * \param[in] ain      not in use
+ * \param[out] aout    PAG value or NOPAG
+ *
+ * \retval E2BIG       Error not enough space to copy out value
+ *
+ * \post get PAG value for the caller's cred
+ */
+DECL_PIOCTL(PGetPAG)
+{
+    afs_int32 pag;
+
+    if (*aoutSize < sizeof(afs_int32)) {
+       return E2BIG;
+    }
+
+    pag = PagInCred(*acred);
+
+    memcpy(aout, (char *)&pag, sizeof(afs_int32));
+    *aoutSize = sizeof(afs_int32);
+    return 0;
+}
+
 DECL_PIOCTL(PPrecache)
 {
     afs_int32 newValue;
@@ -3927,13 +3970,13 @@ DECL_PIOCTL(PSetRxkcrypt)
 #define        PIOCTL_HEADER   6
 static int
 HandleClientContext(struct afs_ioctl *ablob, int *com,
-                   struct AFS_UCRED **acred, struct AFS_UCRED *credp)
+                   AFS_UCRED **acred, AFS_UCRED *credp)
 {
     char *ain, *inData;
     afs_uint32 hostaddr;
     afs_int32 uid, g0, g1, i, code, pag, exporter_type, isroot = 0;
     struct afs_exporter *exporter, *outexporter;
-    struct AFS_UCRED *newcred;
+    AFS_UCRED *newcred;
     struct unixuser *au;
     afs_uint32 comp = *com & 0xff00;
     afs_uint32 h, l;
@@ -4423,21 +4466,21 @@ DECL_PIOCTL(PPrefetchFromTape)
     return code;
 }
 
-DECL_PIOCTL(PResidencyCmd)
+DECL_PIOCTL(PFsCmd)
 {
     register afs_int32 code;
     struct afs_conn *tc;
     struct vcache *tvc;
-    struct ResidencyCmdInputs *Inputs;
-    struct ResidencyCmdOutputs *Outputs;
+    struct FsCmdInputs *Inputs;
+    struct FsCmdOutputs *Outputs;
     struct VenusFid tfid;
     struct AFSFid *Fid;
 
-    Inputs = (struct ResidencyCmdInputs *)ain;
-    Outputs = (struct ResidencyCmdOutputs *)aout;
+    Inputs = (struct FsCmdInputs *)ain;
+    Outputs = (struct FsCmdOutputs *)aout;
     if (!avc)
        return EINVAL;
-    if (!ain || ainSize != sizeof(struct ResidencyCmdInputs))
+    if (!ain || ainSize != sizeof(struct FsCmdInputs))
        return EINVAL;
 
     Fid = &Inputs->fid;
@@ -4461,8 +4504,8 @@ DECL_PIOCTL(PResidencyCmd)
            if (tc) {
                RX_AFS_GUNLOCK();
                code =
-                   RXAFS_ResidencyCmd(tc->id, Fid, Inputs,
-                                      (struct ResidencyCmdOutputs *)aout);
+                   RXAFS_FsCmd(tc->id, Fid, Inputs, 
+                                       (struct FsCmdOutputs *)aout);
                RX_AFS_GLOCK();
            } else
                code = -1;
@@ -4486,7 +4529,7 @@ DECL_PIOCTL(PResidencyCmd)
     afs_PutVCache(tvc);
 
     if (!code) {
-       *aoutSize = sizeof(struct ResidencyCmdOutputs);
+       *aoutSize = sizeof(struct FsCmdOutputs);
     }
     return code;
 }
@@ -4725,7 +4768,7 @@ DECL_PIOCTL(PDiscon)
 
 DECL_PIOCTL(PNFSNukeCreds)
 {
-    afs_uint32 addr, code;
+    afs_uint32 addr;
     register afs_int32 i;
     register struct unixuser *tu;