Debian Codegraph @

lib/kafs/afssys.c

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*
2 * Copyright (c) 1995 - 2000, 2002, 2004, 2005 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34 #include "kafs_locl.h"cxx . . $ `<file>/lib/kafs/kafs_locl.h`/
35
36 struct procdatacxx . . $ procdata# {
37 unsigned long param4cxx . . $ procdata#param4.;
38 unsigned long param3cxx . . $ procdata#param3.;
39 unsigned long param2cxx . . $ procdata#param2.;
40 unsigned long param1cxx . . $ procdata#param1.;
41 unsigned long syscallcxx . . $ procdata#syscall.;
42 };
43 #ifdef __GNU__
44 #define _IOT_procdata _IOT(_IOTS(long), 5, 0, 0, 0, 0)
45 #define VIOC_SYSCALL_PROC _IOW('C', 1, struct procdata)
46 #else
47 #define VIOC_SYSCALL_PROCcxx . . $ `lib/kafs/afssys.c:47:9`! _IOWcxx . . $ `<external>/9493957431124703620/ioctl.h:85:9`!('C', 1, void *)
48 #endif
49
50 struct devdatacxx . . $ devdata# {
51 unsigned long syscallcxx . . $ devdata#syscall.;
52 unsigned long param1cxx . . $ devdata#param1.;
53 unsigned long param2cxx . . $ devdata#param2.;
54 unsigned long param3cxx . . $ devdata#param3.;
55 unsigned long param4cxx . . $ devdata#param4.;
56 unsigned long param5cxx . . $ devdata#param5.;
57 unsigned long param6cxx . . $ devdata#param6.;
58 unsigned long retvalcxx . . $ devdata#retval.;
59 };
60 #ifdef __GNU__
61 #define _IOT_devdata _IOT(_IOTS(long), 8, 0, 0, 0, 0)
62 #endif
63 #ifdef _IOWRcxx . . $ `<external>/9493957431124703620/ioctl.h:86:9`!
64 #define VIOC_SYSCALL_DEVcxx . . $ `lib/kafs/afssys.c:64:9`! _IOWRcxx . . $ `<external>/9493957431124703620/ioctl.h:86:9`!('C', 2, struct devdata)
65 #define VIOC_SYSCALL_DEV_OPENAFScxx . . $ `lib/kafs/afssys.c:65:9`! _IOWRcxx . . $ `<external>/9493957431124703620/ioctl.h:86:9`!('C', 1, struct devdata)
66 #endif
67
68 #ifdef _IOWcxx . . $ `<external>/9493957431124703620/ioctl.h:85:9`!
69 #ifdef _ILP32
70 struct sundevdata {
71 uint32_t param6;
72 uint32_t param5;
73 uint32_t param4;
74 uint32_t param3;
75 uint32_t param2;
76 uint32_t param1;
77 uint32_t syscall;
78 };
•79 #ifdef __GNU__
80 #define _IOT_sundevdata _IOT(_IOTS(uint32_t), 7, 0, 0, 0, 0)
81 #endif
82 #define VIOC_SUN_SYSCALL_DEV _IOW('C', 2, struct sundevdata)
83 #else
84 struct sundevdatacxx . . $ sundevdata# {
85 uint64_tcxx . . $ uint64_t# param6cxx . . $ sundevdata#param6.;
86 uint64_tcxx . . $ uint64_t# param5cxx . . $ sundevdata#param5.;
87 uint64_tcxx . . $ uint64_t# param4cxx . . $ sundevdata#param4.;
88 uint64_tcxx . . $ uint64_t# param3cxx . . $ sundevdata#param3.;
89 uint64_tcxx . . $ uint64_t# param2cxx . . $ sundevdata#param2.;
90 uint64_tcxx . . $ uint64_t# param1cxx . . $ sundevdata#param1.;
91 uint64_tcxx . . $ uint64_t# syscallcxx . . $ sundevdata#syscall.;
92 };
•93 #ifdef __GNU__
94 #define _IOT_sundevdata _IOT(_IOTS(uint64_t), 7, 0, 0, 0, 0)
95 #endif
96 #define VIOC_SUN_SYSCALL_DEVcxx . . $ `lib/kafs/afssys.c:96:9`! _IOWcxx . . $ `<external>/9493957431124703620/ioctl.h:85:9`!('C', 1, struct sundevdata)
97 #endif
98 #endif /* _IOW */
99
100
101 int _kafs_debugcxx . . $ _kafs_debug.; /* this should be done in a better way */
102
103 #define UNKNOWN_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:103:9`! (-1)
104 #define NO_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:104:9`! 0
105 #define SINGLE_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:105:9`! 1
106 #define MULTIPLE_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:106:9`! 2
107 #define SINGLE_ENTRY_POINT2cxx . . $ `lib/kafs/afssys.c:107:9`! 3
108 #define SINGLE_ENTRY_POINT3cxx . . $ `lib/kafs/afssys.c:108:9`! 4
109 #define LINUX_PROC_POINTcxx . . $ `lib/kafs/afssys.c:109:9`! 5
110 #define AIX_ENTRY_POINTScxx . . $ `lib/kafs/afssys.c:110:9`! 6
111 #define MACOS_DEV_POINTcxx . . $ `lib/kafs/afssys.c:111:9`! 7
112 #define SUN_PROC_POINTcxx . . $ `lib/kafs/afssys.c:112:9`! 8
113
114 static int afs_entry_pointcxx . . $ afs_entry_point. = UNKNOWN_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:103:9`!;
115 static int afs_syscallscxx . . $ afs_syscalls.[2];
116 static char *afs_ioctlpathcxx . . $ afs_ioctlpath.;
117 static unsigned long afs_ioctlnumcxx . . $ afs_ioctlnum.;
118
119 /* Magic to get AIX syscalls to work */
120 #ifdef _AIX
121
122 static int (*Pioctl)(char*, int, struct ViceIoctl*, int);
123 static int (*Setpag)(void);
124
125 #include "dlfcn.h"
126
127 /*
128 *
129 */
130
131 static int
132 try_aix(void)
133 {
134 #ifdef STATIC_AFS_SYSCALLS
135 Pioctl = aix_pioctl;
136 Setpag = aix_setpag;
137 #else
138 void *ptr;
139 char path[MaxPathLen], *p;
140 /*
141 * If we are root or running setuid don't trust AFSLIBPATH!
142 */
143 if (getuid() != 0 && !issuid() && (p = getenv("AFSLIBPATH")) != NULL)
144 strlcpy(path, p, sizeof(path));
145 else
146 snprintf(path, sizeof(path), "%s/afslib.so", LIBDIR);
147
148 ptr = dlopen(path, RTLD_NOW);
149 if(ptr == NULL) {
150 if(_kafs_debug) {
151 if(errno == ENOEXEC && (p = dlerror()) != NULL)
152 fprintf(stderr, "dlopen(%s): %s\n", path, p);
153 else if (errno != ENOENT)
154 fprintf(stderr, "dlopen(%s): %s\n", path, strerror(errno));
155 }
156 return 1;
157 }
158 Setpag = (int (*)(void))dlsym(ptr, "aix_setpag");
159 Pioctl = (int (*)(char*, int,
160 struct ViceIoctl*, int))dlsym(ptr, "aix_pioctl");
161 #endif
162 afs_entry_point = AIX_ENTRY_POINTS;
163 return 0;
164 }
165 #endif /* _AIX */
166
167 /*
168 * This probably only works under Solaris and could get confused if
169 * there's a /etc/name_to_sysnum file.
170 */
171
172 #if defined(AFS_SYSCALL) || defined(AFS_SYSCALL2) || defined(AFS_SYSCALL3cxx . . $ `lib/kafs/afssysdefs.h:108:9`!)
173
174 #define _PATH_ETC_NAME_TO_SYSNUMcxx . . $ `lib/kafs/afssys.c:174:9`! "/etc/name_to_sysnum"
175
176 static int
177 map_syscall_name_to_numbercxx . . $ map_syscall_name_to_number(7436bf38bddd805d). (const char *str, int *res)
178 {
179 FILEcxx . . $ FILE# *f;
180 char buf[256];
181 size_t str_len = strlencxx . . $ strlen(751346f8406fd082). (str);
182
183 f = fopencxx . . $ fopen(82ec0787cd37e0a3). (_PATH_ETC_NAME_TO_SYSNUMcxx . . $ `lib/kafs/afssys.c:174:9`!, "r");
184 if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)
185 return -1;
186 while (fgetscxx . . $ fgets(efb0aaba7ac866ae). (buf, sizeof(buf), f) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
187 if (buf[0] == '#')
188 continue;
189
190 if (strncmpcxx . . $ strncmp(fd278af2f295fa2e). (str, buf, str_len) == 0) {
191 char *begptr = buf + str_len;
192 char *endptr;
193 long val = strtolcxx . . $ strtol(44bbb87609b212fc). (begptr, &endptr, 0);
194
195 if (val != 0 && endptr != begptr) {
196 fclosecxx . . $ fclose(89bc1efcdac0ca22). (f);
197 *res = val;
198 return 0;
199 }
200 }
201 }
202 fclosecxx . . $ fclose(89bc1efcdac0ca22). (f);
203 return -1;
204 }
205 #endif
206
207 static int
208 try_ioctlpathcxx . . $ try_ioctlpath(57a7b535b7b38491).(const char *path, unsigned long ioctlnum, int entrypoint)
209 {
210 int fd, ret, saved_errno;
211
212 fd = opencxx . . $ open(e156e3aa1e5c4ad1).(path, O_RDWRcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:45:9`!);
213 if (fd < 0)
214 return 1;
215 switch (entrypoint) {
216 case LINUX_PROC_POINTcxx . . $ `lib/kafs/afssys.c:109:9`!: {
217 struct procdatacxx . . $ procdata# data = { 0, 0, 0, 0, AFSCALL_PIOCTLcxx . . $ `lib/kafs/kafs.h:45:9`! };
218 data.param2cxx . . $ procdata#param2. = (unsigned long)VIOCGETTOKcxx . . $ `lib/kafs/kafs.h:62:9`!;
219 ret = ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, ioctlnum, &data);
220 break;
221 }
222 case MACOS_DEV_POINTcxx . . $ `lib/kafs/afssys.c:111:9`!: {
223 struct devdatacxx . . $ devdata# data = { AFSCALL_PIOCTLcxx . . $ `lib/kafs/kafs.h:45:9`!, 0, 0, 0, 0, 0, 0, 0 };
224 data.param2cxx . . $ devdata#param2. = (unsigned long)VIOCGETTOKcxx . . $ `lib/kafs/kafs.h:62:9`!;
225 ret = ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, ioctlnum, &data);
226 break;
227 }
228 case SUN_PROC_POINTcxx . . $ `lib/kafs/afssys.c:112:9`!: {
229 struct sundevdatacxx . . $ sundevdata# data = { 0, 0, 0, 0, 0, 0, AFSCALL_PIOCTLcxx . . $ `lib/kafs/kafs.h:45:9`! };
230 data.param2cxx . . $ sundevdata#param2. = (unsigned long)VIOCGETTOKcxx . . $ `lib/kafs/kafs.h:62:9`!;
231 ret = ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, ioctlnum, &data);
232 break;
233 }
234 default:
235 abortcxx . . $ abort(8df32a62017fbbf6).();
236 }
237 saved_errno = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
238 closecxx . . $ close(7864480464b09eea).(fd);
239 /*
240 * Be quite liberal in what error are ok, the first is the one
241 * that should trigger given that params is NULL.
242 */
243 if (ret &&
244 (saved_errno != EFAULTcxx . . $ `<external>/8987895939074593727/errno-base.h:18:9`! &&
245 saved_errno != EDOMcxx . . $ `<external>/8987895939074593727/errno-base.h:37:9`! &&
246 saved_errno != ENOTCONNcxx . . $ `<external>/17922322188510340118/errno.h:91:9`!))
247 return 1;
248 afs_ioctlnumcxx . . $ afs_ioctlnum. = ioctlnum;
249 afs_ioctlpathcxx . . $ afs_ioctlpath. = strdupcxx . . $ strdup(a8b8e32347182212).(path);
250 if (afs_ioctlpathcxx . . $ afs_ioctlpath. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)
251 return 1;
252 afs_entry_pointcxx . . $ afs_entry_point. = entrypoint;
253 return 0;
254 }
255
256 static int
257 do_ioctlcxx . . $ do_ioctl(dedf1e9b1c614a07).(void *data)
258 {
259 int fd, ret, saved_errno;
260 fd = opencxx . . $ open(e156e3aa1e5c4ad1).(afs_ioctlpathcxx . . $ afs_ioctlpath., O_RDWRcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:45:9`!);
261 if (fd < 0) {
262 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
263 return -1;
264 }
265 ret = ioctlcxx . . $ ioctl(67fa1c773b05068c).(fd, afs_ioctlnumcxx . . $ afs_ioctlnum., data);
266 saved_errno = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
267 closecxx . . $ close(7864480464b09eea).(fd);
268 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = saved_errno;
269 return ret;
270 }
271
272 int
273 k_pioctlcxx . . $ k_pioctl(f52ac27348578211).(char *a_path,
274 int o_opcode,
275 struct ViceIoctlcxx . . $ ViceIoctl# *a_paramsP,
276 int a_followSymlinks)
277 {
278 #ifndef NO_AFS
279 switch(afs_entry_pointcxx . . $ afs_entry_point.){
280 #if defined(AFS_SYSCALL) || defined(AFS_SYSCALL2) || defined(AFS_SYSCALL3cxx . . $ `lib/kafs/afssysdefs.h:108:9`!)
281 case SINGLE_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:105:9`!:
282 case SINGLE_ENTRY_POINT2cxx . . $ `lib/kafs/afssys.c:107:9`!:
283 case SINGLE_ENTRY_POINT3cxx . . $ `lib/kafs/afssys.c:108:9`!:
284 return syscallcxx . . $ syscall(523f12be2d96faea).(afs_syscallscxx . . $ afs_syscalls.[0], AFSCALL_PIOCTLcxx . . $ `lib/kafs/kafs.h:45:9`!,
285 a_path, o_opcode, a_paramsP, a_followSymlinks);
286 #endif
287 #if defined(AFS_PIOCTL)
288 case MULTIPLE_ENTRY_POINT:
289 return syscall(afs_syscalls[0],
290 a_path, o_opcode, a_paramsP, a_followSymlinks);
291 #endif
292 case LINUX_PROC_POINTcxx . . $ `lib/kafs/afssys.c:109:9`!: {
293 struct procdatacxx . . $ procdata# data = { 0, 0, 0, 0, AFSCALL_PIOCTLcxx . . $ `lib/kafs/kafs.h:45:9`! };
294 data.param1cxx . . $ procdata#param1. = (unsigned long)a_path;
295 data.param2cxx . . $ procdata#param2. = (unsigned long)o_opcode;
296 data.param3cxx . . $ procdata#param3. = (unsigned long)a_paramsP;
297 data.param4cxx . . $ procdata#param4. = (unsigned long)a_followSymlinks;
298 return do_ioctlcxx . . $ do_ioctl(dedf1e9b1c614a07).(&data);
299 }
300 case MACOS_DEV_POINTcxx . . $ `lib/kafs/afssys.c:111:9`!: {
301 struct devdatacxx . . $ devdata# data = { AFSCALL_PIOCTLcxx . . $ `lib/kafs/kafs.h:45:9`!, 0, 0, 0, 0, 0, 0, 0 };
302 int ret;
303
304 data.param1cxx . . $ devdata#param1. = (unsigned long)a_path;
305 data.param2cxx . . $ devdata#param2. = (unsigned long)o_opcode;
306 data.param3cxx . . $ devdata#param3. = (unsigned long)a_paramsP;
307 data.param4cxx . . $ devdata#param4. = (unsigned long)a_followSymlinks;
308
309 ret = do_ioctlcxx . . $ do_ioctl(dedf1e9b1c614a07).(&data);
310 if (ret)
311 return ret;
312
313 return data.retvalcxx . . $ devdata#retval.;
314 }
315 case SUN_PROC_POINTcxx . . $ `lib/kafs/afssys.c:112:9`!: {
316 struct sundevdatacxx . . $ sundevdata# data = { 0, 0, 0, 0, 0, 0, AFSCALL_PIOCTLcxx . . $ `lib/kafs/kafs.h:45:9`! };
317 data.param1cxx . . $ sundevdata#param1. = (unsigned long)a_path;
318 data.param2cxx . . $ sundevdata#param2. = (unsigned long)o_opcode;
319 data.param3cxx . . $ sundevdata#param3. = (unsigned long)a_paramsP;
320 data.param4cxx . . $ sundevdata#param4. = (unsigned long)a_followSymlinks;
321 return do_ioctlcxx . . $ do_ioctl(dedf1e9b1c614a07).(&data);
322 }
323 #ifdef _AIX
324 case AIX_ENTRY_POINTS:
325 return Pioctl(a_path, o_opcode, a_paramsP, a_followSymlinks);
326 #endif
327 }
328 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ENOSYScxx . . $ `<external>/17922322188510340118/errno.h:18:9`!;
329 #ifdef SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!
330 killcxx . . $ kill(9b79fb6aee4c0440).(getpidcxx . . $ getpid(b126dc7c1de90089).(), SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!); /* You lose! */
331 #endif
332 #endif /* NO_AFS */
333 return -1;
334 }
335
336 int
337 k_afs_cell_of_filecxx . . $ k_afs_cell_of_file(89c8e27db0bdb94e).(const char *path, char *cell, int len)
338 {
339 struct ViceIoctlcxx . . $ ViceIoctl# parms;
340 parms.incxx . . $ ViceIoctl#in. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
341 parms.in_sizecxx . . $ ViceIoctl#in_size. = 0;
342 parms.outcxx . . $ ViceIoctl#out. = cell;
343 parms.out_sizecxx . . $ ViceIoctl#out_size. = len;
344 return k_pioctlcxx . . $ k_pioctl(f52ac27348578211).(rk_UNCONSTcxx . . $ `include/roken.h:107:9`!(path), VIOC_FILE_CELL_NAMEcxx . . $ `lib/kafs/kafs.h:77:9`!, &parms, 1);
345 }
346
347 int
348 k_unlogcxx . . $ k_unlog(b126dc7c1de90089).(void)
349 {
350 struct ViceIoctlcxx . . $ ViceIoctl# parms;
351 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&parms, 0, sizeof(parms));
352 return k_pioctlcxx . . $ k_pioctl(f52ac27348578211).(0, VIOCUNLOGcxx . . $ `lib/kafs/kafs.h:63:9`!, &parms, 0);
353 }
354
355 int
356 k_setpagcxx . . $ k_setpag(b126dc7c1de90089).(void)
357 {
358 #ifndef NO_AFS
359 switch(afs_entry_pointcxx . . $ afs_entry_point.){
360 #if defined(AFS_SYSCALL) || defined(AFS_SYSCALL2) || defined(AFS_SYSCALL3cxx . . $ `lib/kafs/afssysdefs.h:108:9`!)
361 case SINGLE_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:105:9`!:
362 case SINGLE_ENTRY_POINT2cxx . . $ `lib/kafs/afssys.c:107:9`!:
363 case SINGLE_ENTRY_POINT3cxx . . $ `lib/kafs/afssys.c:108:9`!:
364 return syscallcxx . . $ syscall(523f12be2d96faea).(afs_syscallscxx . . $ afs_syscalls.[0], AFSCALL_SETPAGcxx . . $ `lib/kafs/kafs.h:46:9`!);
365 #endif
366 #if defined(AFS_PIOCTL)
367 case MULTIPLE_ENTRY_POINT:
368 return syscall(afs_syscalls[1]);
369 #endif
370 case LINUX_PROC_POINTcxx . . $ `lib/kafs/afssys.c:109:9`!: {
371 struct procdatacxx . . $ procdata# data = { 0, 0, 0, 0, AFSCALL_SETPAGcxx . . $ `lib/kafs/kafs.h:46:9`! };
372 return do_ioctlcxx . . $ do_ioctl(dedf1e9b1c614a07).(&data);
373 }
374 case MACOS_DEV_POINTcxx . . $ `lib/kafs/afssys.c:111:9`!: {
375 struct devdatacxx . . $ devdata# data = { AFSCALL_SETPAGcxx . . $ `lib/kafs/kafs.h:46:9`!, 0, 0, 0, 0, 0, 0, 0 };
376 int ret = do_ioctlcxx . . $ do_ioctl(dedf1e9b1c614a07).(&data);
377 if (ret)
378 return ret;
379 return data.retvalcxx . . $ devdata#retval.;
380 }
381 case SUN_PROC_POINTcxx . . $ `lib/kafs/afssys.c:112:9`!: {
382 struct sundevdatacxx . . $ sundevdata# data = { 0, 0, 0, 0, 0, 0, AFSCALL_SETPAGcxx . . $ `lib/kafs/kafs.h:46:9`! };
383 return do_ioctlcxx . . $ do_ioctl(dedf1e9b1c614a07).(&data);
384 }
385 #ifdef _AIX
386 case AIX_ENTRY_POINTS:
387 return Setpag();
388 #endif
389 }
390
391 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ENOSYScxx . . $ `<external>/17922322188510340118/errno.h:18:9`!;
392 #ifdef SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!
393 killcxx . . $ kill(9b79fb6aee4c0440).(getpidcxx . . $ getpid(b126dc7c1de90089).(), SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!); /* You lose! */
394 #endif
395 #endif /* NO_AFS */
396 return -1;
397 }
398
399 static jmp_bufcxx . . $ jmp_buf# catch_SIGSYScxx . . $ catch_SIGSYS.;
400
401 #ifdef SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!
402
403 static RETSIGTYPEcxx . . $ `include/config.h:1448:9`!
404 SIGSYS_handlercxx . . $ SIGSYS_handler(d4f767463ce0a6b3).(int sig)
405 {
406 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
407 signalcxx . . $ signal(c2d516773f91faf8).(SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!, SIGSYS_handlercxx . . $ SIGSYS_handler(d4f767463ce0a6b3).); /* Need to reinstall handler on SYSV */
408 longjmpcxx . . $ longjmp(d25daf25a2f573dc).(catch_SIGSYScxx . . $ catch_SIGSYS., 1);
409 }
410
411 #endif
412
413 /*
414 * Try to see if `syscall' is a pioctl. Return 0 iff succesful.
415 */
416
417 #if defined(AFS_SYSCALL) || defined(AFS_SYSCALL2) || defined(AFS_SYSCALL3cxx . . $ `lib/kafs/afssysdefs.h:108:9`!)
418 static int
419 try_onecxx . . $ try_one(7864480464b09eea). (int syscall_num)
420 {
421 struct ViceIoctlcxx . . $ ViceIoctl# parms;
422 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&parms, 0, sizeof(parms));
423
424 if (setjmpcxx . . $ `<external>/4367339001007250937/setjmp.h:53:9`!(catch_SIGSYS) == 0) {
425 syscallcxx . . $ syscall(523f12be2d96faea).(syscall_num, AFSCALL_PIOCTLcxx . . $ `lib/kafs/kafs.h:45:9`!,
426 0, VIOCSETTOKcxx . . $ `lib/kafs/kafs.h:58:9`!, &parms, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
427 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!) {
428 afs_entry_pointcxx . . $ afs_entry_point. = SINGLE_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:105:9`!;
429 afs_syscallscxx . . $ afs_syscalls.[0] = syscall_num;
430 return 0;
431 }
432 }
433 return 1;
434 }
435 #endif
436
437 /*
438 * Try to see if `syscall_pioctl' is a pioctl syscall. Return 0 iff
439 * succesful.
440 *
441 */
442
443 #ifdef AFS_PIOCTL
444 static int
445 try_two (int syscall_pioctl, int syscall_setpag)
446 {
447 struct ViceIoctl parms;
448 memset(&parms, 0, sizeof(parms));
449
450 if (setjmp(catch_SIGSYS) == 0) {
451 syscall(syscall_pioctl,
452 0, VIOCSETTOK, &parms, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
453 if (errno == EINVAL) {
454 afs_entry_point = MULTIPLE_ENTRY_POINT;
455 afs_syscalls[0] = syscall_pioctl;
456 afs_syscalls[1] = syscall_setpag;
457 return 0;
458 }
459 }
460 return 1;
461 }
462 #endif
463
464 int
465 k_hasafscxx . . $ k_hasafs(b126dc7c1de90089).(void)
466 {
467 #if !defined(NO_AFS) && defined(SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!)
468 RETSIGTYPEcxx . . $ `include/config.h:1448:9`! (*saved_func)(int);
469 #endif
470 int saved_errno, ret;
471 char *env = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
472
473 if (!issuidcxx . . $ issuid(b126dc7c1de90089).())
474 env = getenvcxx . . $ getenv(a8b8e32347182212). ("AFS_SYSCALL");
475
476 /*
477 * Already checked presence of AFS syscalls?
478 */
479 if (afs_entry_pointcxx . . $ afs_entry_point. != UNKNOWN_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:103:9`!)
480 return afs_entry_pointcxx . . $ afs_entry_point. != NO_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:104:9`!;
481
482 /*
483 * Probe kernel for AFS specific syscalls,
484 * they (currently) come in two flavors.
485 * If the syscall is absent we recive a SIGSYS.
486 */
487 afs_entry_pointcxx . . $ afs_entry_point. = NO_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:104:9`!;
488
489 saved_errno = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
490 #ifndef NO_AFS
491 #ifdef SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!
492 saved_func = signalcxx . . $ signal(c2d516773f91faf8).(SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!, SIGSYS_handlercxx . . $ SIGSYS_handler(d4f767463ce0a6b3).);
493 #endif
494 if (env && strstrcxx . . $ `<external>/13506128340496143423/string.h:380:11`!(env, "..") == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
495
496 if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("/proc/", env, 6) == 0) {
497 if (try_ioctlpathcxx . . $ try_ioctlpath(57a7b535b7b38491).(env, VIOC_SYSCALL_PROCcxx . . $ `lib/kafs/afssys.c:47:9`!, LINUX_PROC_POINTcxx . . $ `lib/kafs/afssys.c:109:9`!) == 0)
498 goto done;
499 }
500 if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("/dev/", env, 5) == 0) {
501 #ifdef VIOC_SYSCALL_DEVcxx . . $ `lib/kafs/afssys.c:64:9`!
502 if (try_ioctlpathcxx . . $ try_ioctlpath(57a7b535b7b38491).(env, VIOC_SYSCALL_DEVcxx . . $ `lib/kafs/afssys.c:64:9`!, MACOS_DEV_POINTcxx . . $ `lib/kafs/afssys.c:111:9`!) == 0)
503 goto done;
504 #endif
505 #ifdef VIOC_SYSCALL_DEV_OPENAFScxx . . $ `lib/kafs/afssys.c:65:9`!
506 if (try_ioctlpathcxx . . $ try_ioctlpath(57a7b535b7b38491).(env,VIOC_SYSCALL_DEV_OPENAFScxx . . $ `lib/kafs/afssys.c:65:9`!,MACOS_DEV_POINTcxx . . $ `lib/kafs/afssys.c:111:9`!) ==0)
507 goto done;
508 #endif
509 }
510 }
511
512 ret = try_ioctlpathcxx . . $ try_ioctlpath(57a7b535b7b38491).("/proc/fs/openafs/afs_ioctl",
513 VIOC_SYSCALL_PROCcxx . . $ `lib/kafs/afssys.c:47:9`!, LINUX_PROC_POINTcxx . . $ `lib/kafs/afssys.c:109:9`!);
514 if (ret == 0)
515 goto done;
516 ret = try_ioctlpathcxx . . $ try_ioctlpath(57a7b535b7b38491).("/proc/fs/nnpfs/afs_ioctl",
517 VIOC_SYSCALL_PROCcxx . . $ `lib/kafs/afssys.c:47:9`!, LINUX_PROC_POINTcxx . . $ `lib/kafs/afssys.c:109:9`!);
518 if (ret == 0)
519 goto done;
520
521 #ifdef VIOC_SYSCALL_DEV_OPENAFScxx . . $ `lib/kafs/afssys.c:65:9`!
522 ret = try_ioctlpathcxx . . $ try_ioctlpath(57a7b535b7b38491).("/dev/openafs_ioctl",
523 VIOC_SYSCALL_DEV_OPENAFScxx . . $ `lib/kafs/afssys.c:65:9`!, MACOS_DEV_POINTcxx . . $ `lib/kafs/afssys.c:111:9`!);
524 if (ret == 0)
525 goto done;
526 #endif
527 #ifdef VIOC_SYSCALL_DEVcxx . . $ `lib/kafs/afssys.c:64:9`!
528 ret = try_ioctlpathcxx . . $ try_ioctlpath(57a7b535b7b38491).("/dev/nnpfs_ioctl", VIOC_SYSCALL_DEVcxx . . $ `lib/kafs/afssys.c:64:9`!, MACOS_DEV_POINTcxx . . $ `lib/kafs/afssys.c:111:9`!);
529 if (ret == 0)
530 goto done;
531 #endif
532 #ifdef VIOC_SUN_SYSCALL_DEVcxx . . $ `lib/kafs/afssys.c:96:9`!
533 ret = try_ioctlpathcxx . . $ try_ioctlpath(57a7b535b7b38491).("/dev/afs", VIOC_SUN_SYSCALL_DEVcxx . . $ `lib/kafs/afssys.c:96:9`!, SUN_PROC_POINTcxx . . $ `lib/kafs/afssys.c:112:9`!);
534 if (ret == 0)
535 goto done;
536 #endif
537
538
539 #if defined(AFS_SYSCALL) || defined(AFS_SYSCALL2) || defined(AFS_SYSCALL3cxx . . $ `lib/kafs/afssysdefs.h:108:9`!)
540 {
541 int tmp;
542
543 if (env != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
544 if (sscanfcxx . . $ sscanf(5e8a2c12db2ea735). (env, "%d", &tmp) == 1) {
545 if (try_onecxx . . $ try_one(7864480464b09eea). (tmp) == 0)
546 goto done;
547 } else {
548 char *end = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
549 char *p;
550 char *s = strdupcxx . . $ strdup(a8b8e32347182212). (env);
551
552 if (s != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
553 for (p = strtok_rcxx . . $ strtok_r(a42394c85d6397dd). (s, ",", &end);
554 p != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
555 p = strtok_rcxx . . $ strtok_r(a42394c85d6397dd). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, ",", &end)) {
556 if (map_syscall_name_to_numbercxx . . $ map_syscall_name_to_number(7436bf38bddd805d). (p, &tmp) == 0)
557 if (try_onecxx . . $ try_one(7864480464b09eea). (tmp) == 0) {
558 freecxx . . $ free(5d22bdacc48458e8). (s);
559 goto done;
560 }
561 }
562 freecxx . . $ free(5d22bdacc48458e8). (s);
563 }
564 }
565 }
566 }
567 #endif /* AFS_SYSCALL || AFS_SYSCALL2 || AFS_SYSCALL3 */
568
569 #ifdef AFS_SYSCALL
570 if (try_one (AFS_SYSCALL) == 0)
571 goto done;
572 #endif /* AFS_SYSCALL */
573
574 #ifdef AFS_PIOCTL
575 {
576 int tmp[2];
577
578 if (env != NULL && sscanf (env, "%d%d", &tmp[0], &tmp[1]) == 2)
579 if (try_two (tmp[0], tmp[1]) == 2)
580 goto done;
581 }
582 #endif /* AFS_PIOCTL */
583
584 #ifdef AFS_PIOCTL
585 if (try_two (AFS_PIOCTL, AFS_SETPAG) == 0)
586 goto done;
587 #endif /* AFS_PIOCTL */
588
589 #ifdef AFS_SYSCALL2
590 if (try_one (AFS_SYSCALL2) == 0)
591 goto done;
592 #endif /* AFS_SYSCALL2 */
593
594 #ifdef AFS_SYSCALL3cxx . . $ `lib/kafs/afssysdefs.h:108:9`!
595 if (try_onecxx . . $ try_one(7864480464b09eea). (AFS_SYSCALL3cxx . . $ `lib/kafs/afssysdefs.h:108:9`!) == 0)
596 goto done;
597 #endif /* AFS_SYSCALL3 */
598
599 #ifdef _AIX
600 #if 0
601 if (env != NULL) {
602 char *pos = NULL;
603 char *pioctl_name;
604 char *setpag_name;
605
606 pioctl_name = strtok_r (env, ", \t", &pos);
607 if (pioctl_name != NULL) {
608 setpag_name = strtok_r (NULL, ", \t", &pos);
609 if (setpag_name != NULL)
610 if (try_aix (pioctl_name, setpag_name) == 0)
611 goto done;
612 }
613 }
614 #endif
615
616 if(try_aix() == 0)
617 goto done;
618 #endif
619
620
621 done:
622 #ifdef SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!
623 signalcxx . . $ signal(c2d516773f91faf8).(SIGSYScxx . . $ `<external>/1457673850468744829/signum-arch.h:34:9`!, saved_func);
624 #endif
625 #endif /* NO_AFS */
626 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = saved_errno;
627 return afs_entry_pointcxx . . $ afs_entry_point. != NO_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:104:9`!;
628 }
629
630 int
631 k_hasafs_recheckcxx . . $ k_hasafs_recheck(b126dc7c1de90089).(void)
632 {
633 afs_entry_pointcxx . . $ afs_entry_point. = UNKNOWN_ENTRY_POINTcxx . . $ `lib/kafs/afssys.c:103:9`!;
634 return k_hasafscxx . . $ k_hasafs(b126dc7c1de90089).();
635 }