b1d64e5f96a424aaeb13b2940b945461413632e3
[openafs.git] / src / sys / pioctl.c
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 #include <signal.h>
20
21 #include <afs/afs_args.h>
22 #if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
23 #include <unistd.h>
24 #else
25 #include <stdio.h>
26 #endif
27 #include "afssyscalls.h"
28
29 #ifdef AFS_AIX32_ENV
30 /*
31  * in VRMIX, system calls look just like function calls, so we don't
32  * need to do anything!
33  */
34
35 #else
36 #if defined(AFS_SGI_ENV)
37
38 #pragma weak xlpioctl = lpioctl
39
40 int
41 lpioctl(char *path, int cmd, char *cmarg, int follow)
42 {
43     return (syscall(AFS_PIOCTL, path, cmd, cmarg, follow));
44 }
45
46 #else /* AFS_SGI_ENV */
47
48 int
49 lpioctl(char *path, int cmd, char *cmarg, int follow)
50 {
51     int errcode, rval;
52 #ifndef AFS_LINUX20_ENV
53     /* As kauth/user.c says, handle smoothly the case where no AFS system call
54      * exists (yet). */
55     sig_t old = signal(SIGSYS, SIG_IGN);
56 #endif
57
58 #if defined(AFS_LINUX20_ENV)
59     rval = proc_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg, 
60                             follow, &errcode);
61
62     if(rval)
63         errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, 
64                           follow);
65 #elif defined(AFS_DARWIN80_ENV)
66     rval = ioctl_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg,
67                              follow, 0, 0, &errcode);
68     if (rval)
69         errcode = rval;
70 #else
71     errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, follow);
72 #endif
73
74 #ifndef AFS_LINUX20_ENV
75     signal(SIGSYS, old);
76 #endif
77
78     return (errcode);
79 }
80
81 #endif /* !AFS_SGI_ENV */
82 #endif /* !AFS_AIX32_ENV */