]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Revert "Linux: normalize error return for emulated syscalls"
authorSimon Wilkinson <sxw@your-file-system.com>
Tue, 15 Mar 2011 00:06:19 +0000 (00:06 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 15 Mar 2011 03:54:13 +0000 (20:54 -0700)
This reverts commit 0bc837f68a72ba1f75d940cc5dd057774d9f36bb.

Sadly, this change fixed setpag(), but broke all of the pioctls. The
problem is actually a little more nuanced than we at first thought.
What's happening is yet another case of Linux's special handling of
negative return values. When an ioctl handler returns a negative
return code to the kernel, it does errno = -code, and sets the
return code to -1. If you pass it a postive return code, however,
it just returns that straight to the application.

The pioctl code gets this right. However, the setpag code doesn't,
and so tries to return postive values, which is why ioctl appears
to be returning the error code in the return value, not in the
errno.

Reviewed-on: http://gerrit.openafs.org/4222
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Marc Dionne <marc.c.dionne@gmail.com>
Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit ff2933a122ddf9421ebcacdc7e4ec5f44333f894)

Change-Id: Ibfb050552f8b2357e57139976e2bc42ce6187f4f
Reviewed-on: http://gerrit.openafs.org/4225
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/sys/glue.c

index 80330de9a4c53afbc37ec3cf8e978b2fd11761f7..3ba696cb381886950ce99e7e217f47160df82e73 100644 (file)
@@ -20,7 +20,6 @@
 #include <sys/ioctl.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <errno.h>
 #ifdef AFS_SUN5_ENV
 #include <fcntl.h>
 #endif
 #ifdef AFS_LINUX20_ENV
 int proc_afs_syscall(long syscall, long param1, long param2, long param3,
                     long param4, int *rval) {
-    struct afsprocdata syscall_data;
-    int fd = open(PROC_SYSCALL_FNAME, O_RDWR);
-    if(fd < 0)
-       fd = open(PROC_SYSCALL_ARLA_FNAME, O_RDWR);
-    if(fd < 0)
-       return -1;
+  struct afsprocdata syscall_data;
+  int fd = open(PROC_SYSCALL_FNAME, O_RDWR);
+  if(fd < 0)
+      fd = open(PROC_SYSCALL_ARLA_FNAME, O_RDWR);
+  if(fd < 0)
+    return -1;
 
-    syscall_data.syscall = syscall;
-    syscall_data.param1 = param1;
-    syscall_data.param2 = param2;
-    syscall_data.param3 = param3;
-    syscall_data.param4 = param4;
+  syscall_data.syscall = syscall;
+  syscall_data.param1 = param1;
+  syscall_data.param2 = param2;
+  syscall_data.param3 = param3;
+  syscall_data.param4 = param4;
 
-    *rval = ioctl(fd, VIOC_SYSCALL, &syscall_data);
+  *rval = ioctl(fd, VIOC_SYSCALL, &syscall_data);
 
-    close(fd);
+  close(fd);
 
-    /* Callers expect us to emulate a syscall - return -1 on error, set errno */
-    if (*rval) {
-       errno = *rval;
-       *rval =  -1;
-    }
-    return 0;
+  return 0;
 }
 #endif