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