Commit | Line | Data |
---|---|---|
805e021f CE |
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 | * This file contains any necessary C glue to allow programs to communicate | |
10 | * with the AFS kernel module. The necessary lower-level glue is defined in | |
11 | * syscall.s. | |
12 | */ | |
13 | ||
14 | #include <afsconfig.h> | |
15 | #include <afs/param.h> | |
16 | ||
17 | #include <roken.h> | |
18 | ||
19 | #include <afs/afs_args.h> | |
20 | ||
21 | #include "afssyscalls.h" | |
22 | ||
23 | #ifdef AFS_LINUX20_ENV | |
24 | int proc_afs_syscall(long syscall, long param1, long param2, long param3, | |
25 | long param4, int *rval) { | |
26 | struct afsprocdata syscall_data; | |
27 | int fd = open(PROC_SYSCALL_FNAME, O_RDONLY); | |
28 | if(fd < 0) | |
29 | fd = open(PROC_SYSCALL_ARLA_FNAME, O_RDONLY); | |
30 | if(fd < 0) | |
31 | return -1; | |
32 | ||
33 | syscall_data.syscall = syscall; | |
34 | syscall_data.param1 = param1; | |
35 | syscall_data.param2 = param2; | |
36 | syscall_data.param3 = param3; | |
37 | syscall_data.param4 = param4; | |
38 | ||
39 | *rval = ioctl(fd, VIOC_SYSCALL, &syscall_data); | |
40 | ||
41 | close(fd); | |
42 | ||
43 | return 0; | |
44 | } | |
45 | #endif | |
46 | ||
47 | #if defined(AFS_DARWIN80_ENV) | |
48 | int ioctl_afs_syscall(long syscall, long param1, long param2, long param3, | |
49 | long param4, long param5, long param6, int *rval) { | |
50 | struct afssysargs syscall_data; | |
51 | void *ioctldata; | |
52 | int code; | |
53 | int fd = open(SYSCALL_DEV_FNAME, O_RDONLY); | |
54 | int syscallnum; | |
55 | #ifdef AFS_DARWIN100_ENV | |
56 | struct afssysargs64 syscall64_data; | |
57 | if (sizeof(param1) == 8) { | |
58 | syscallnum = VIOC_SYSCALL64; | |
59 | ioctldata = &syscall64_data; | |
60 | syscall64_data.syscall = (int)syscall; | |
61 | syscall64_data.param1 = param1; | |
62 | syscall64_data.param2 = param2; | |
63 | syscall64_data.param3 = param3; | |
64 | syscall64_data.param4 = param4; | |
65 | syscall64_data.param5 = param5; | |
66 | syscall64_data.param6 = param6; | |
67 | } else { | |
68 | #endif | |
69 | syscallnum = VIOC_SYSCALL; | |
70 | ioctldata = &syscall_data; | |
71 | syscall_data.syscall = syscall; | |
72 | syscall_data.param1 = param1; | |
73 | syscall_data.param2 = param2; | |
74 | syscall_data.param3 = param3; | |
75 | syscall_data.param4 = param4; | |
76 | syscall_data.param5 = param5; | |
77 | syscall_data.param6 = param6; | |
78 | #ifdef AFS_DARWIN100_ENV | |
79 | } | |
80 | #endif | |
81 | if(fd >= 0) { | |
82 | code = ioctl(fd, syscallnum, ioctldata); | |
83 | close(fd); | |
84 | } else | |
85 | code = -1; | |
86 | ||
87 | if (code) | |
88 | return code; | |
89 | #ifdef AFS_DARWIN100_ENV | |
90 | if (sizeof(param1) == 8) | |
91 | *rval=syscall64_data.retval; | |
92 | else | |
93 | #endif | |
94 | *rval=syscall_data.retval; | |
95 | return 0; | |
96 | } | |
97 | #endif | |
98 | ||
99 | #ifdef AFS_SUN511_ENV | |
100 | int | |
101 | ioctl_sun_afs_syscall(long syscall, uintptr_t param1, uintptr_t param2, | |
102 | uintptr_t param3, uintptr_t param4, uintptr_t param5, | |
103 | uintptr_t param6, int *error) | |
104 | { | |
105 | void *ioctldata; | |
106 | long callnum; | |
107 | int fd; | |
108 | ||
109 | # ifdef _ILP32 | |
110 | struct afssysargs32 sargs32; | |
111 | sargs32.syscall = syscall; | |
112 | sargs32.param1 = param1; | |
113 | sargs32.param2 = param2; | |
114 | sargs32.param3 = param3; | |
115 | sargs32.param4 = param4; | |
116 | sargs32.param5 = param5; | |
117 | sargs32.param6 = param6; | |
118 | ||
119 | ioctldata = &sargs32; | |
120 | callnum = VIOC_SYSCALL32; | |
121 | # else /* _ILP32 */ | |
122 | struct afssysargs sargs; | |
123 | sargs.syscall = syscall; | |
124 | sargs.param1 = param1; | |
125 | sargs.param2 = param2; | |
126 | sargs.param3 = param3; | |
127 | sargs.param4 = param4; | |
128 | sargs.param5 = param5; | |
129 | sargs.param6 = param6; | |
130 | ||
131 | ioctldata = &sargs; | |
132 | callnum = VIOC_SYSCALL; | |
133 | # endif /* !_ILP32 */ | |
134 | ||
135 | fd = open(SYSCALL_DEV_FNAME, O_RDONLY); | |
136 | if (fd < 0) { | |
137 | return -1; | |
138 | } | |
139 | ||
140 | *error = ioctl(fd, callnum, ioctldata); | |
141 | close(fd); | |
142 | ||
143 | return 0; | |
144 | } | |
145 | #endif /* AFS_SUN511_ENV */ |