| 1 | /* |
| 2 | * Copyright 2000, International Business Machines Corporation and others. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This software has been released under the terms of the IBM Public |
| 6 | * License. For details, see the LICENSE file in the top-level source |
| 7 | * directory or online at http://www.openafs.org/dl/license10.html |
| 8 | */ |
| 9 | |
| 10 | /* |
| 11 | * The lpioctl system call. (pioctl is handled by the rmtsys layer and turned |
| 12 | * into either lpioctl or a remote call as appropriate.) It is kept separate |
| 13 | * to allow for the creation of the libkopenafs shared library without |
| 14 | * including the other system calls. |
| 15 | */ |
| 16 | |
| 17 | #include <afsconfig.h> |
| 18 | #include <afs/param.h> |
| 19 | |
| 20 | #include <roken.h> |
| 21 | |
| 22 | #include <afs/afs_args.h> |
| 23 | |
| 24 | #include "afssyscalls.h" |
| 25 | #include "sys_prototypes.h" |
| 26 | |
| 27 | #ifdef AFS_AIX32_ENV |
| 28 | /* |
| 29 | * in VRMIX, system calls look just like function calls, so we don't |
| 30 | * need to do anything! |
| 31 | */ |
| 32 | |
| 33 | #elif defined(AFS_SGI_ENV) |
| 34 | |
| 35 | #pragma weak xlpioctl = lpioctl |
| 36 | |
| 37 | int |
| 38 | lpioctl(char *path, int cmd, void *cmarg, int follow) |
| 39 | { |
| 40 | return (syscall(AFS_PIOCTL, path, cmd, cmarg, follow)); |
| 41 | } |
| 42 | |
| 43 | #elif defined(AFS_LINUX20_ENV) |
| 44 | |
| 45 | int |
| 46 | lpioctl(char *path, int cmd, void *cmarg, int follow) |
| 47 | { |
| 48 | int errcode = 0; |
| 49 | int rval; |
| 50 | |
| 51 | rval = proc_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg, |
| 52 | follow, &errcode); |
| 53 | |
| 54 | if(rval) { |
| 55 | # ifdef AFS_SYSCALL |
| 56 | errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, |
| 57 | follow); |
| 58 | # else |
| 59 | errcode = -1; |
| 60 | # endif |
| 61 | } |
| 62 | |
| 63 | return (errcode); |
| 64 | } |
| 65 | |
| 66 | #else /* AFS_AIX32_ENV */ |
| 67 | |
| 68 | int |
| 69 | lpioctl(char *path, int cmd, void *cmarg, int follow) |
| 70 | { |
| 71 | int errcode = 0; |
| 72 | /* As kauth/user.c says, handle smoothly the case where no AFS system call |
| 73 | * exists (yet). */ |
| 74 | void (*old)(int) = signal(SIGSYS, SIG_IGN); |
| 75 | |
| 76 | # if defined(AFS_DARWIN80_ENV) || defined(AFS_SUN511_ENV) |
| 77 | { |
| 78 | int rval; /* rval and errcode are distinct for pioctl platforms */ |
| 79 | # if defined(AFS_DARWIN80_ENV) |
| 80 | rval = ioctl_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg, |
| 81 | follow, 0, 0, &errcode); |
| 82 | # elif defined(AFS_SUN511_ENV) |
| 83 | rval = ioctl_sun_afs_syscall(AFSCALL_PIOCTL, (uintptr_t)path, cmd, |
| 84 | (uintptr_t)cmarg, follow, 0, 0, &errcode); |
| 85 | # endif /* !AFS_DARWIN80_ENV */ |
| 86 | /* non-zero rval takes precedence over errcode */ |
| 87 | if (rval) |
| 88 | errcode = rval; |
| 89 | } |
| 90 | # else /* ! AFS_DARWIN80_ENV || AFS_SUN511_ENV */ |
| 91 | errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, follow); |
| 92 | # endif |
| 93 | |
| 94 | signal(SIGSYS, old); |
| 95 | |
| 96 | return (errcode); |
| 97 | } |
| 98 | |
| 99 | #endif /* !AFS_AIX32_ENV */ |