]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
pioctl.c: restore required result variable
authorMark Vitale <mvitale@sinenomine.net>
Mon, 9 Feb 2015 23:16:16 +0000 (18:16 -0500)
committerStephan Wiesand <stephan.wiesand@desy.de>
Fri, 4 Mar 2016 12:34:18 +0000 (07:34 -0500)
Commit b9fb9c62a6779aa997259ddf2a83a90b08e04d5f refactored lpioctl()
so that LINUX would have its own implementation. This also simplified
the other lpioctl() implementations by removing superfluous variable
'rval'.

Unfortunately, 'rval' was actually required for both DARWIN and SUN511.
On both of these platforms, the address of 'errcode' is passed
to the respective ioctl_*() routine so its value may be passed back
to lpioctl().   Therefore, 'errcode' must not also be used for the
return value from these functions;  doing so results in the return
value from the function overwriting the intended value of 'errcode' upon
return to lpioctl().

In the case of Solaris 11, ioctl_sun_afs_syscall() always returns zero
(as long as the ioctl device 'dev/afs' opened successfully).
So 'errcode' was always being set to zero, even if the pioctl had
actually failed.  For example, without this fix, 'fs listcells'
loops forever on Solaris 11, listing an infinite number of "cells",
because it will never "see" the EDOM that informs it of the last defined
cell.

Partially revert b9fb9c62a6779aa997259ddf2a83a90b08e04d5f by restoring
the 'rval' variable and logic for DARWIN and SUN511.

Reviewed-on: http://gerrit.openafs.org/11734
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
(cherry picked from commit 7ae8e64d1ee79c23da96c326111fdc40015ed5a6)

Change-Id: I6a4b8817f02522144b3adbbae06b3737e6c62585
Reviewed-on: http://gerrit.openafs.org/11795
Reviewed-by: Daria Phoebe Brashear <shadow@your-file-system.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/sys/pioctl.c

index aabfd09950ec16057c7a8ec3e1b11fe5e51477d8..fb987c26cb89763842da4d262c24d4f5a43a30e8 100644 (file)
@@ -74,15 +74,23 @@ lpioctl(char *path, int cmd, void *cmarg, int follow)
      * exists (yet). */
     void (*old)(int) = signal(SIGSYS, SIG_IGN);
 
-#if defined(AFS_DARWIN80_ENV)
-    errcode = ioctl_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg,
+# if defined(AFS_DARWIN80_ENV) || defined(AFS_SUN511_ENV)
+    {
+       int rval;       /* rval and errcode are distinct for pioctl platforms */
+#  if defined(AFS_DARWIN80_ENV)
+       rval = ioctl_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg,
                                follow, 0, 0, &errcode);
-#elif defined(AFS_SUN511_ENV)
-    errcode = ioctl_sun_afs_syscall(AFSCALL_PIOCTL, (uintptr_t)path, cmd,
+#  elif defined(AFS_SUN511_ENV)
+       rval = ioctl_sun_afs_syscall(AFSCALL_PIOCTL, (uintptr_t)path, cmd,
                                    (uintptr_t)cmarg, follow, 0, 0, &errcode);
-#else
+#  endif  /* !AFS_DARWIN80_ENV */
+       /* non-zero rval takes precedence over errcode */
+       if (rval)
+           errcode = rval;
+    }
+# else   /* ! AFS_DARWIN80_ENV || AFS_SUN511_ENV */
     errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, follow);
-#endif
+# endif
 
     signal(SIGSYS, old);