From: Simon Wilkinson Date: Tue, 15 Mar 2011 00:06:19 +0000 (+0000) Subject: Revert "Linux: normalize error return for emulated syscalls" X-Git-Tag: debian/1.6.0.pre3-1~5^2^2~3 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=de478ca8ac14b991082bf0f26fb9807a913980a0;p=packages%2Fo%2Fopenafs.git Revert "Linux: normalize error return for emulated syscalls" 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 Tested-by: Marc Dionne Reviewed-by: Marc Dionne Reviewed-by: Derrick Brashear (cherry picked from commit ff2933a122ddf9421ebcacdc7e4ec5f44333f894) Change-Id: Ibfb050552f8b2357e57139976e2bc42ce6187f4f Reviewed-on: http://gerrit.openafs.org/4225 Tested-by: BuildBot Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/sys/glue.c b/src/sys/glue.c index 80330de9a..3ba696cb3 100644 --- a/src/sys/glue.c +++ b/src/sys/glue.c @@ -20,7 +20,6 @@ #include #include #include -#include #ifdef AFS_SUN5_ENV #include #endif @@ -29,29 +28,24 @@ #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