sparc64-linux26-20050508
[openafs.git] / src / afs / afs_pioctl.c
index 1987ea2..e6d734c 100644 (file)
@@ -195,7 +195,7 @@ static int (*(CpioctlSw[])) () = {
 #define PSetClientContext 99   /*  Special pioctl to setup caller's creds  */
 int afs_nobody = NFS_NOBODY;
 
-#if (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) || defined(AFS_HPUX_64BIT_ENV) || defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV))
+#if (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) || defined(AFS_HPUX_64BIT_ENV) || defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64)) || defined(NEED_IOCTL32)
 static void
 afs_ioctl32_to_afs_ioctl(const struct afs_ioctl32 *src, struct afs_ioctl *dst)
 {
@@ -263,7 +263,9 @@ copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst)
 #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
     struct afs_ioctl32 dst32;
 
-#ifdef AFS_SPARC64_LINUX24_ENV
+#ifdef AFS_SPARC64_LINUX26_ENV
+    if (test_thread_flag(TIF_32BIT))
+#elif AFS_SPARC64_LINUX24_ENV
     if (current->thread.flags & SPARC_FLAG_32BIT)
 #elif defined(AFS_SPARC64_LINUX20_ENV)
     if (current->tss.flags & SPARC_FLAG_32BIT)
@@ -528,16 +530,16 @@ afs_xioctl(void)
     register int ioctlDone = 0, code = 0;
 
     AFS_STATCNT(afs_xioctl);
-#if defined(AFS_XBSD_ENV)
+#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_DARWIN_ENV)
-    if ((code = fdgetf(p, uap->fd, &fd)))
-       return code;
 #elif defined(AFS_LINUX22_ENV)
     ua.com = com;
     ua.arg = arg;
@@ -597,21 +599,13 @@ afs_xioctl(void)
 #endif
 #endif /* AFS_LINUX22_ENV */
        if (tvc && IsAfsVnode(AFSTOV(tvc))) {
-#ifdef AFS_DEC_ENV
-           tvc = VTOAFS(afs_gntovn((struct gnode *)tvc));
-           if (!tvc) {         /* shouldn't happen with held gnodes */
-               u.u_error = ENOENT;
-               return;
-           }
-#endif
            /* 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);
-               AFS_COPYIN((char *)uap->arg, (caddr_t) datap,
-                          sizeof(struct afs_ioctl), code);
+               code=copyin_afs_ioctl((char *)uap->arg, datap);
                if (code) {
                    osi_FreeSmallSpace(datap);
                    AFS_GUNLOCK();
@@ -860,9 +854,6 @@ afs_syscall_pioctl(path, com, cmarg, follow)
     struct AFS_UCRED *foreigncreds = NULL;
     register afs_int32 code = 0;
     struct vnode *vp = NULL;
-#ifdef AFS_DEC_ENV
-    struct vnode *gp;
-#endif
 #ifdef AFS_AIX41_ENV
     struct ucred *credp = crref();     /* don't free until done! */
 #endif
@@ -976,18 +967,7 @@ afs_syscall_pioctl(path, com, cmarg, follow)
 
     /* now make the call if we were passed no file, or were passed an AFS file */
     if (!vp || IsAfsVnode(vp)) {
-#if defined(AFS_DEC_ENV)
-       /* Ultrix 4.0: can't get vcache entry unless we've got an AFS gnode.
-        * So, we must test in this part of the code.  Also, must arrange to
-        * GRELE the original gnode pointer when we're done, since in Ultrix 4.0,
-        * we hold gnodes, whose references hold our vcache entries.
-        */
-       if (vp) {
-           gp = vp;            /* remember for "put" */
-           vp = (struct vnode *)afs_gntovn(vp);        /* get vcache from gp */
-       } else
-           gp = NULL;
-#elif defined(AFS_SUN5_ENV)
+#if defined(AFS_SUN5_ENV)
        code = afs_HandlePioctl(vp, com, &data, follow, &credp);
 #elif defined(AFS_AIX41_ENV)
        {
@@ -1026,12 +1006,6 @@ afs_syscall_pioctl(path, com, cmarg, follow)
 #else
        code = EINVAL;          /* not in /afs */
 #endif
-#ifdef AFS_DEC_ENV
-       if (vp) {
-           GRELE(vp);
-           vp = NULL;
-       }
-#endif
     }
 
   rescred:
@@ -1682,7 +1656,7 @@ DECL_PIOCTL(PFlush)
     AFS_STATCNT(PFlush);
     if (!avc)
        return EINVAL;
-#if    defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
+#ifdef AFS_BOZONLOCK_ENV
     afs_BozonLock(&avc->pvnLock, avc); /* Since afs_TryToSmush will do a pvn_vptrunc */
 #endif
     ObtainWriteLock(&avc->lock, 225);
@@ -1699,7 +1673,7 @@ DECL_PIOCTL(PFlush)
        avc->linkData = NULL;
     }
     ReleaseWriteLock(&avc->lock);
-#if    defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
+#ifdef AFS_BOZONLOCK_ENV
     afs_BozonUnlock(&avc->pvnLock, avc);
 #endif
     return 0;
@@ -2570,17 +2544,17 @@ DECL_PIOCTL(PFlushVolumeData)
     for (i = 0; i < VCSIZE; i++) {
        for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
            if (tvc->fid.Fid.Volume == volume && tvc->fid.Cell == cell) {
-#if    defined(AFS_SGI_ENV) || defined(AFS_ALPHA_ENV)  || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
+#if    defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV)  || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
                VN_HOLD(AFSTOV(tvc));
 #else
 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
                osi_vnhold(tvc, 0);
 #else
-               VREFCOUNT_INC(tvc);
+               VREFCOUNT_INC(tvc); /* AIX, apparently */
 #endif
 #endif
                ReleaseReadLock(&afs_xvcache);
-#if    defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
+#ifdef AFS_BOZONLOCK_ENV
                afs_BozonLock(&tvc->pvnLock, tvc);      /* Since afs_TryToSmush will do a pvn_vptrunc */
 #endif
                ObtainWriteLock(&tvc->lock, 232);
@@ -2593,7 +2567,7 @@ DECL_PIOCTL(PFlushVolumeData)
                    osi_dnlc_purgedp(tvc);
                afs_TryToSmush(tvc, *acred, 1);
                ReleaseWriteLock(&tvc->lock);
-#if    defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
+#ifdef AFS_BOZONLOCK_ENV
                afs_BozonUnlock(&tvc->pvnLock, tvc);
 #endif
                ObtainReadLock(&afs_xvcache);
@@ -3353,6 +3327,9 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
        uid = afs_nobody;       /* NFS_NOBODY == -2 */
     }
     newcred = crget();
+#if defined(AFS_LINUX26_ENV)
+    newcred->cr_group_info = groups_alloc(0);
+#endif
 #ifdef AFS_AIX41_ENV
     setuerror(0);
 #endif
@@ -3374,7 +3351,7 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
        newcred->cr_groups[i] = NOGROUP;
 #endif
 #endif
-#if    !defined(AFS_OSF_ENV) && !defined(AFS_DEC_ENV)
+#if    !defined(AFS_OSF_ENV) 
     afs_nfsclient_init();      /* before looking for exporter, ensure one exists */
 #endif
     if (!(exporter = exporter_find(exporter_type))) {
@@ -3540,7 +3517,7 @@ DECL_PIOCTL(PFlushMount)
        code = EINVAL;
        goto out;
     }
-#if    defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
+#ifdef AFS_BOZONLOCK_ENV
     afs_BozonLock(&tvc->pvnLock, tvc); /* Since afs_TryToSmush will do a pvn_vptrunc */
 #endif
     ObtainWriteLock(&tvc->lock, 649);
@@ -3557,7 +3534,7 @@ DECL_PIOCTL(PFlushMount)
        tvc->linkData = NULL;
     }
     ReleaseWriteLock(&tvc->lock);
-#if    defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
+#ifdef AFS_BOZONLOCK_ENV
     afs_BozonUnlock(&tvc->pvnLock, tvc);
 #endif
     afs_PutVCache(tvc);