pioctl-return-negative-errors-on-linux-20030522
[openafs.git] / src / afs / afs_pioctl.c
index ae1f184..230ad5e 100644 (file)
@@ -229,16 +229,18 @@ copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst)
        }
 #endif /* defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64) */
 
-#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) && !defined(AFS_AMD64_LINUX20_ENV)
+#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
         if (current->thread.flags & SPARC_FLAG_32BIT)
-#elif AFS_SPARC64_LINUX20_ENV
+#elif defined(AFS_SPARC64_LINUX20_ENV)
        if (current->tss.flags & SPARC_FLAG_32BIT)
+#elif defined(AFS_AMD64_LINUX20_ENV)
+        if (current->thread.flags & THREAD_IA32)
 #else
 #error Not done for this linux type
-#endif /* AFS_SPARC64_LINUX20_ENV */
+#endif
          {
                AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
                if (!code)
@@ -1010,6 +1012,9 @@ afs_syscall_pioctl(path, com, cmarg, follow)
 #endif
     }
     PIOCTL_FREE_CRED();
+#ifdef AFS_LINUX22_ENV
+    return -code;
+#else
 #if defined(KERNEL_HAVE_UERROR)
     if (!getuerror())
        setuerror(code);
@@ -1017,6 +1022,7 @@ afs_syscall_pioctl(path, com, cmarg, follow)
 #else
     return (code);
 #endif
+#endif
 }
 
 
@@ -1066,10 +1072,10 @@ int afs_HandlePioctl(struct vnode *avp, afs_int32 acom,
        return EINVAL;          /* out of range */
     }
     inSize = ablob->in_size;
-    
+
     /* Do all range checking before continuing */
-    if ((inSize >= PIGGYSIZE) || (inSize < 0)) return E2BIG;
-    if ((ablob->out_size >= PIGGYSIZE) || (ablob->out_size < 0)) return E2BIG;
+    if (inSize >= PIGGYSIZE || inSize < 0 || ablob->out_size < 0)
+       return E2BIG;
 
     inData = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
     if (inSize > 0) {