9260c06b453c9538e9b6be65427baa83fcbac605
[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
20 #include <afs/afs_args.h>
21 #if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
22 #include <unistd.h>
23 #else
24 #include <stdio.h>
25 #endif
26 #include "afssyscalls.h"
27
28 #ifdef AFS_AIX32_ENV
29 /*
30  * in VRMIX, system calls look just like function calls, so we don't
31  * need to do anything!
32  */
33
34 #else
35 #if defined(AFS_SGI_ENV)
36
37 #pragma weak xlpioctl = lpioctl
38
39 int
40 lpioctl(char *path, int cmd, char *cmarg, int follow)
41 {
42     return (syscall(AFS_PIOCTL, path, cmd, cmarg, follow));
43 }
44
45 #else /* AFS_SGI_ENV */
46
47 int
48 lpioctl(char *path, int cmd, char *cmarg, int follow)
49 {
50     int errcode, rval;
51
52 #if defined(AFS_LINUX20_ENV)
53     rval = proc_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg, 
54                             follow, &errcode);
55
56     if(rval)
57         errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, 
58                           follow);
59 #elif defined(AFS_DARWIN80_ENV)
60     rval = ioctl_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg,
61                              follow, 0, 0, &errcode);
62     if (rval)
63         errcode = rval;
64 #else
65     errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, follow);
66 #endif
67
68     return (errcode);
69 }
70
71 #endif /* !AFS_SGI_ENV */
72 #endif /* !AFS_AIX32_ENV */