Merge 1.8.0~pre4 packaging into master
[pkg-k5-afs_openafs.git] / src / afs / afs_syscall.c
blobb2b644ae1394d1542bc01cb4babdb3819adfd647
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
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 */
10 #include <afsconfig.h>
11 #include "afs/param.h"
13 #ifdef IGNORE_SOME_GCC_WARNINGS
14 # pragma GCC diagnostic warning "-Wold-style-definition"
15 # pragma GCC diagnostic warning "-Wstrict-prototypes"
16 #endif
18 #include "afs/sysincludes.h" /* Standard vendor system headers */
19 #include "afsincludes.h" /* Afs-based standard headers */
20 #include "afs/afs_stats.h"
21 #include "rx/rx_globals.h"
22 #if !defined(UKERNEL) && !defined(AFS_LINUX20_ENV)
23 #include "net/if.h"
24 #ifdef AFS_SGI62_ENV
25 #include "h/hashing.h"
26 #endif
27 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN_ENV)
28 #include "netinet/in_var.h"
29 #endif
30 #endif /* !defined(UKERNEL) */
32 #if (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) || defined(AFS_HPUX_64BIT_ENV) || defined(AFS_SUN5_64BIT_ENV) || (defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64)) || defined(NEED_IOCTL32)
33 static void
34 afs_ioctl32_to_afs_ioctl(const struct afs_ioctl32 *src, struct afs_ioctl *dst)
36 #ifdef AFS_DARWIN100_ENV
37 dst->in = CAST_USER_ADDR_T(src->in);
38 dst->out = CAST_USER_ADDR_T(src->out);
39 #else
40 dst->in = (char *)(unsigned long)src->in;
41 dst->out = (char *)(unsigned long)src->out;
42 #endif
43 dst->in_size = src->in_size;
44 dst->out_size = src->out_size;
46 #endif
49 * If you need to change copyin_afs_ioctl(), you may also need to change
50 * copyin_iparam().
53 int
54 #ifdef AFS_DARWIN100_ENV
55 copyin_afs_ioctl(user_addr_t cmarg, struct afs_ioctl *dst)
56 #else
57 copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst)
58 #endif
60 int code;
61 #if defined(AFS_DARWIN100_ENV)
62 struct afs_ioctl32 dst32;
64 if (!proc_is64bit(current_proc())) {
65 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
66 if (!code)
67 afs_ioctl32_to_afs_ioctl(&dst32, dst);
68 return code;
70 #endif
71 #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
72 struct afs_ioctl32 dst32;
74 if (!(IS64U)) {
75 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
76 if (!code)
77 afs_ioctl32_to_afs_ioctl(&dst32, dst);
78 return code;
80 #endif /* defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) */
83 #if defined(AFS_HPUX_64BIT_ENV)
84 struct afs_ioctl32 dst32;
86 if (is_32bit(u.u_procp)) { /* is_32bit() in proc_iface.h */
87 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
88 if (!code)
89 afs_ioctl32_to_afs_ioctl(&dst32, dst);
90 return code;
92 #endif /* defined(AFS_HPUX_64BIT_ENV) */
94 #if defined(AFS_SUN5_64BIT_ENV)
95 struct afs_ioctl32 dst32;
97 if (get_udatamodel() == DATAMODEL_ILP32) {
98 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
99 if (!code)
100 afs_ioctl32_to_afs_ioctl(&dst32, dst);
101 return code;
103 #endif /* defined(AFS_SUN5_64BIT_ENV) */
105 #if defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64)
106 struct afs_ioctl32 dst32;
108 if (!ABI_IS_64BIT(get_current_abi())) {
109 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
110 if (!code)
111 afs_ioctl32_to_afs_ioctl(&dst32, dst);
112 return code;
114 #endif /* defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64) */
116 #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
117 struct afs_ioctl32 dst32;
119 #ifdef AFS_SPARC64_LINUX26_ENV
120 if (test_thread_flag(TIF_32BIT))
121 #elif defined(AFS_SPARC64_LINUX24_ENV)
122 if (current->thread.flags & SPARC_FLAG_32BIT)
123 #elif defined(AFS_SPARC64_LINUX20_ENV)
124 if (current->tss.flags & SPARC_FLAG_32BIT)
126 #elif defined(AFS_AMD64_LINUX26_ENV)
127 if (test_thread_flag(TIF_IA32))
128 #elif defined(AFS_AMD64_LINUX20_ENV)
129 if (current->thread.flags & THREAD_IA32)
131 #elif defined(AFS_PPC64_LINUX26_ENV)
132 #if defined(STRUCT_TASK_STRUCT_HAS_THREAD_INFO)
133 if (current->thread_info->flags & _TIF_32BIT)
134 #else
135 if (task_thread_info(current)->flags & _TIF_32BIT)
136 #endif
137 #elif defined(AFS_PPC64_LINUX20_ENV)
138 if (current->thread.flags & PPC_FLAG_32BIT)
140 #elif defined(AFS_S390X_LINUX26_ENV)
141 if (test_thread_flag(TIF_31BIT))
142 #elif defined(AFS_S390X_LINUX20_ENV)
143 if (current->thread.flags & S390_FLAG_31BIT)
145 #else
146 #error pioctl32 not done for this linux
147 #endif
149 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
150 if (!code)
151 afs_ioctl32_to_afs_ioctl(&dst32, dst);
152 return code;
154 #endif /* defined(AFS_LINUX_64BIT_KERNEL) */
156 AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code);
157 return code;
161 #ifdef AFS_AIX32_ENV
163 #include "sys/lockl.h"
166 * syscall - this is the VRMIX system call entry point.
168 * NOTE:
169 * THIS SHOULD BE CHANGED TO afs_syscall(), but requires
170 * all the user-level calls to `syscall' to change.
172 syscall(syscall, p1, p2, p3, p4, p5, p6)
174 int rval1 = 0, code;
175 int monster;
176 int retval = 0;
177 #ifndef AFS_AIX41_ENV
178 extern lock_t kernel_lock;
179 monster = lockl(&kernel_lock, LOCK_SHORT);
180 #endif /* !AFS_AIX41_ENV */
182 AFS_STATCNT(syscall);
183 setuerror(0);
184 switch (syscall) {
185 case AFSCALL_CALL:
186 rval1 = afs_syscall_call(p1, p2, p3, p4, p5, p6);
187 break;
189 case AFSCALL_SETPAG:
190 AFS_GLOCK();
191 rval1 = afs_setpag();
192 AFS_GUNLOCK();
193 break;
195 case AFSCALL_PIOCTL:
196 AFS_GLOCK();
197 rval1 = afs_syscall_pioctl(p1, p2, p3, p4);
198 AFS_GUNLOCK();
199 break;
201 case AFSCALL_ICREATE:
202 rval1 = afs_syscall_icreate(p1, p2, p3, p4, p5, p6);
203 break;
205 case AFSCALL_IOPEN:
206 rval1 = afs_syscall_iopen(p1, p2, p3);
207 break;
209 case AFSCALL_IDEC:
210 rval1 = afs_syscall_iincdec(p1, p2, p3, -1);
211 break;
213 case AFSCALL_IINC:
214 rval1 = afs_syscall_iincdec(p1, p2, p3, 1);
215 break;
217 case AFSCALL_ICL:
218 AFS_GLOCK();
219 code = Afscall_icl(p1, p2, p3, p4, p5, &retval);
220 AFS_GUNLOCK();
221 if (!code)
222 rval1 = retval;
223 if (!rval1)
224 rval1 = code;
225 break;
227 default:
228 rval1 = EINVAL;
229 setuerror(EINVAL);
230 break;
233 out:
234 #ifndef AFS_AIX41_ENV
235 if (monster != LOCK_NEST)
236 unlockl(&kernel_lock);
237 #endif /* !AFS_AIX41_ENV */
238 return getuerror()? -1 : rval1;
242 * lsetpag - interface to afs_setpag().
245 lsetpag(void)
248 AFS_STATCNT(lsetpag);
249 return syscall(AFSCALL_SETPAG, 0, 0, 0, 0, 0);
253 * lpioctl - interface to pioctl()
256 lpioctl(char *path, int cmd, void *cmarg, int follow)
259 AFS_STATCNT(lpioctl);
260 return syscall(AFSCALL_PIOCTL, path, cmd, cmarg, follow);
263 #else /* !AFS_AIX32_ENV */
265 #if defined(AFS_SGI_ENV)
266 struct afsargs {
267 sysarg_t syscall;
268 sysarg_t parm1;
269 sysarg_t parm2;
270 sysarg_t parm3;
271 sysarg_t parm4;
272 sysarg_t parm5;
277 Afs_syscall(struct afsargs *uap, rval_t * rvp)
279 int error;
280 long retval;
282 AFS_STATCNT(afs_syscall);
283 switch (uap->syscall) {
284 case AFSCALL_ICL:
285 retval = 0;
286 AFS_GLOCK();
287 error =
288 Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
289 uap->parm5, &retval);
290 AFS_GUNLOCK();
291 rvp->r_val1 = retval;
292 break;
293 #ifdef AFS_SGI_XFS_IOPS_ENV
294 case AFSCALL_IDEC64:
295 error =
296 afs_syscall_idec64(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
297 uap->parm5);
298 break;
299 case AFSCALL_IINC64:
300 error =
301 afs_syscall_iinc64(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
302 uap->parm5);
303 break;
304 case AFSCALL_ILISTINODE64:
305 error =
306 afs_syscall_ilistinode64(uap->parm1, uap->parm2, uap->parm3,
307 uap->parm4, uap->parm5);
308 break;
309 case AFSCALL_ICREATENAME64:
310 error =
311 afs_syscall_icreatename64(uap->parm1, uap->parm2, uap->parm3,
312 uap->parm4, uap->parm5);
313 break;
314 #endif
315 #ifdef AFS_SGI_VNODE_GLUE
316 case AFSCALL_INIT_KERNEL_CONFIG:
317 error = afs_init_kernel_config(uap->parm1);
318 break;
319 #endif
320 default:
321 error =
322 afs_syscall_call(uap->syscall, uap->parm1, uap->parm2, uap->parm3,
323 uap->parm4, uap->parm5);
325 return error;
328 #else /* AFS_SGI_ENV */
330 struct iparam {
331 iparmtype param1;
332 iparmtype param2;
333 iparmtype param3;
334 iparmtype param4;
337 struct iparam32 {
338 int param1;
339 int param2;
340 int param3;
341 int param4;
345 #if defined(AFS_HPUX_64BIT_ENV) || defined(AFS_SUN5_64BIT_ENV) || (defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)) || defined(NEED_IOCTL32)
346 static void
347 iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst)
349 dst->param1 = (iparmtype)(uintptrsz)src->param1;
350 dst->param2 = (iparmtype)(uintptrsz)src->param2;
351 dst->param3 = (iparmtype)(uintptrsz)src->param3;
352 dst->param4 = (iparmtype)(uintptrsz)src->param4;
354 #endif
357 * If you need to change copyin_iparam(), you may also need to change
358 * copyin_afs_ioctl().
360 * This function is needed only for icreate, meaning, only on platforms
361 * providing the inode fileserver.
364 static int
365 copyin_iparam(caddr_t cmarg, struct iparam *dst)
367 int code;
369 #if defined(AFS_HPUX_64BIT_ENV)
370 struct iparam32 dst32;
372 if (is_32bit(u.u_procp)) { /* is_32bit() in proc_iface.h */
373 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
374 if (!code)
375 iparam32_to_iparam(&dst32, dst);
376 return code;
378 #endif /* AFS_HPUX_64BIT_ENV */
380 #if defined(AFS_SUN5_64BIT_ENV)
381 struct iparam32 dst32;
383 if (get_udatamodel() == DATAMODEL_ILP32) {
384 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
385 if (!code)
386 iparam32_to_iparam(&dst32, dst);
387 return code;
389 #endif /* AFS_SUN5_64BIT_ENV */
391 #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
392 struct iparam32 dst32;
394 #ifdef AFS_SPARC64_LINUX26_ENV
395 if (test_thread_flag(TIF_32BIT))
396 #elif defined(AFS_SPARC64_LINUX24_ENV)
397 if (current->thread.flags & SPARC_FLAG_32BIT)
398 #elif defined(AFS_SPARC64_LINUX20_ENV)
399 if (current->tss.flags & SPARC_FLAG_32BIT)
401 #elif defined(AFS_AMD64_LINUX26_ENV)
402 if (test_thread_flag(TIF_IA32))
403 #elif defined(AFS_AMD64_LINUX20_ENV)
404 if (current->thread.flags & THREAD_IA32)
406 #elif defined(AFS_PPC64_LINUX26_ENV)
407 #if defined(STRUCT_TASK_STRUCT_HAS_THREAD_INFO)
408 if (current->thread_info->flags & _TIF_32BIT)
409 #else
410 if (task_thread_info(current)->flags & _TIF_32BIT)
411 #endif
412 #elif defined(AFS_PPC64_LINUX20_ENV)
413 if (current->thread.flags & PPC_FLAG_32BIT)
415 #elif defined(AFS_S390X_LINUX26_ENV)
416 if (test_thread_flag(TIF_31BIT))
417 #elif defined(AFS_S390X_LINUX20_ENV)
418 if (current->thread.flags & S390_FLAG_31BIT)
420 #else
421 #error iparam32 not done for this linux platform
422 #endif
424 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
425 if (!code)
426 iparam32_to_iparam(&dst32, dst);
427 return code;
429 #endif /* AFS_LINUX_64BIT_KERNEL */
431 AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code);
432 return code;
435 /* Main entry of all afs system calls */
436 #ifdef AFS_SUN5_ENV
437 extern int afs_sinited;
439 Afs_syscall(struct afssysa *uap, rval_t * rvp)
441 int *retval = &rvp->r_val1;
442 #elif defined(AFS_DARWIN100_ENV)
443 struct afssysa {
444 afs_int32 syscall;
445 afs_int32 parm1;
446 afs_int32 parm2;
447 afs_int32 parm3;
448 afs_int32 parm4;
449 afs_int32 parm5;
450 afs_int32 parm6;
452 struct afssysa64 {
453 afs_int64 parm1;
454 afs_int64 parm2;
455 afs_int64 parm3;
456 afs_int64 parm4;
457 afs_int64 parm5;
458 afs_int64 parm6;
459 afs_int32 syscall;
462 afs3_syscall(afs_proc_t *p, void *args, unsigned int *retval)
464 struct afssysa64 *uap64 = NULL;
465 struct afssysa *uap = NULL;
466 #elif defined(AFS_FBSD_ENV)
468 afs3_syscall(struct thread *p, void *args)
470 struct a {
471 long syscall;
472 long parm1;
473 long parm2;
474 long parm3;
475 long parm4;
476 long parm5;
477 long parm6;
478 } *uap = (struct a *)args;
479 long fbsd_ret = 0;
480 long *retval = &fbsd_ret;
481 #elif defined(AFS_NBSD40_ENV)
483 afs3_syscall(struct lwp *p, const void *args, register_t *retval)
485 /* see osi_machdep.h */
486 struct afs_sysargs *uap = (struct afs_sysargs *) args;
487 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
489 afs3_syscall(afs_proc_t *p, void *args, long *retval)
491 struct a {
492 long syscall;
493 long parm1;
494 long parm2;
495 long parm3;
496 long parm4;
497 long parm5;
498 long parm6;
499 } *uap = (struct a *)args;
500 #elif defined(AFS_LINUX20_ENV)
501 struct afssysargs {
502 long syscall;
503 long parm1;
504 long parm2;
505 long parm3;
506 long parm4;
507 long parm5;
508 long parm6; /* not actually used - should be removed */
510 /* Linux system calls only set up for 5 arguments. */
511 asmlinkage long
512 afs_syscall(long syscall, long parm1, long parm2, long parm3, long parm4)
514 struct afssysargs args, *uap = &args;
515 long linux_ret = 0;
516 long *retval = &linux_ret;
517 long eparm[4]; /* matches AFSCALL_ICL in fstrace.c */
518 # ifdef AFS_SPARC64_LINUX24_ENV
519 afs_int32 eparm32[4];
520 # endif
521 /* eparm is also used by AFSCALL_CALL in afsd.c */
522 #else
523 # if defined(UKERNEL)
525 Afs_syscall(void)
527 struct a {
528 long syscall;
529 long parm1;
530 long parm2;
531 long parm3;
532 long parm4;
533 long parm5;
534 long parm6;
535 } *uap = (struct a *)get_user_struct()->u_ap;
536 # else /* UKERNEL */
538 Afs_syscall()
540 struct a {
541 long syscall;
542 long parm1;
543 long parm2;
544 long parm3;
545 long parm4;
546 long parm5;
547 long parm6;
548 } *uap = (struct a *)u.u_ap;
549 # endif /* UKERNEL */
550 # if defined(AFS_HPUX_ENV)
551 long *retval = &u.u_rval1;
552 # elif defined(UKERNEL)
553 int *retval = &(get_user_struct()->u_rval1);
554 # else
555 int *retval = &u.u_rval1;
556 # endif
557 #endif
558 int code = 0;
560 AFS_STATCNT(afs_syscall);
561 #ifdef AFS_SUN5_ENV
562 rvp->r_vals = 0;
563 if (!afs_sinited) {
564 return (ENODEV);
566 #endif
567 #ifdef AFS_LINUX20_ENV
568 /* setup uap for use below - pull out the magic decoder ring to know
569 * which syscalls have folded argument lists.
571 uap->syscall = syscall;
572 uap->parm1 = parm1;
573 uap->parm2 = parm2;
574 uap->parm3 = parm3;
575 if (syscall == AFSCALL_ICL || syscall == AFSCALL_CALL) {
576 #ifdef AFS_SPARC64_LINUX24_ENV
577 /* from arch/sparc64/kernel/sys_sparc32.c */
578 #define AA(__x) \
579 ({ unsigned long __ret; \
580 __asm__ ("srl %0, 0, %0" \
581 : "=r" (__ret) \
582 : "0" (__x)); \
583 __ret; \
587 #ifdef AFS_SPARC64_LINUX26_ENV
588 if (test_thread_flag(TIF_32BIT))
589 #else
590 if (current->thread.flags & SPARC_FLAG_32BIT)
591 #endif
593 AFS_COPYIN((char *)parm4, (char *)eparm32, sizeof(eparm32), code);
594 eparm[0] = AA(eparm32[0]);
595 eparm[1] = AA(eparm32[1]);
596 eparm[2] = AA(eparm32[2]);
597 #undef AA
598 } else
599 #endif
600 AFS_COPYIN((char *)parm4, (char *)eparm, sizeof(eparm), code);
601 uap->parm4 = eparm[0];
602 uap->parm5 = eparm[1];
603 uap->parm6 = eparm[2];
604 } else {
605 uap->parm4 = parm4;
606 uap->parm5 = 0;
607 uap->parm6 = 0;
609 #endif
610 #if defined(AFS_DARWIN80_ENV)
611 get_vfs_context();
612 osi_Assert(*retval == 0);
613 #ifdef AFS_DARWIN100_ENV
614 if (proc_is64bit(p)) {
615 uap64 = (struct afssysa64 *)args;
616 if (uap64->syscall == AFSCALL_CALL) {
617 code =
618 afs_syscall64_call(uap64->parm1, uap64->parm2, uap64->parm3,
619 uap64->parm4, uap64->parm5, uap64->parm6);
620 /* pass back the code as syscall retval */
621 if (code < 0) {
622 *retval = code;
623 code = 0;
625 } else if (uap64->syscall == AFSCALL_SETPAG) {
626 AFS_GLOCK();
627 code = afs_setpag(p, args, retval);
628 AFS_GUNLOCK();
629 } else if (uap64->syscall == AFSCALL_PIOCTL) {
630 AFS_GLOCK();
631 code =
632 afs_syscall64_pioctl(uap64->parm1, (unsigned int)uap64->parm2,
633 uap64->parm3, (int)uap64->parm4,
634 kauth_cred_get());
635 AFS_GUNLOCK();
636 } else if (uap64->syscall == AFSCALL_ICL) {
637 AFS_GLOCK();
638 code =
639 Afscall64_icl(uap64->parm1, uap64->parm2, uap64->parm3,
640 uap64->parm4, uap64->parm5, retval);
641 AFS_GUNLOCK();
642 } else
643 code = EINVAL;
644 if (uap64->syscall != AFSCALL_CALL)
645 put_vfs_context();
646 } else { /* and the default case for 32 bit procs */
647 #endif
648 uap = (struct afssysa *)args;
649 #endif
650 #if defined(AFS_HPUX_ENV)
652 * There used to be code here (duplicated from osi_Init()) for
653 * initializing the semaphore used by AFS_GLOCK(). Was the
654 * duplication to handle the case of a dynamically loaded kernel
655 * module?
657 osi_InitGlock();
658 #endif
660 #if defined(AFS_NBSD40_ENV)
661 if (SCARG(uap, syscall) == AFSCALL_CALL) {
662 code =
663 afs_syscall_call(SCARG(uap, parm1), SCARG(uap, parm2),
664 SCARG(uap, parm3), SCARG(uap, parm4),
665 SCARG(uap, parm5), SCARG(uap, parm6));
666 } else if (SCARG(uap, syscall) == AFSCALL_SETPAG) {
667 #else
668 if (uap->syscall == AFSCALL_CALL) {
669 code =
670 afs_syscall_call(uap->parm1, uap->parm2, uap->parm3,
671 uap->parm4, uap->parm5, uap->parm6);
672 #ifdef AFS_DARWIN_ENV
673 /* pass back the code as syscall retval */
674 if (code < 0) {
675 *retval = code;
676 code = 0;
678 #endif
679 } else if (uap->syscall == AFSCALL_SETPAG) {
680 #endif
681 #ifdef AFS_SUN5_ENV
682 proc_t *procp;
684 procp = ttoproc(curthread);
685 AFS_GLOCK();
686 code = afs_setpag(&procp->p_cred);
687 AFS_GUNLOCK();
688 #else
689 AFS_GLOCK();
690 #if defined(AFS_FBSD_ENV)
691 code = afs_setpag(p, args);
692 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
693 code = afs_setpag(p, args, retval);
694 #else /* AFS_DARWIN_ENV || AFS_XBSD_ENV */
695 code = afs_setpag();
696 #endif
697 AFS_GUNLOCK();
698 #endif
699 } else if
700 #if defined(AFS_NBSD40_ENV)
701 (SCARG(uap, syscall) == AFSCALL_PIOCTL) {
702 #else
703 (uap->syscall == AFSCALL_PIOCTL) {
704 #endif
705 AFS_GLOCK();
706 #if defined(AFS_SUN5_ENV)
707 code =
708 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3,
709 uap->parm4, rvp, CRED());
710 #elif defined(AFS_FBSD_ENV)
711 code =
712 afs_syscall_pioctl((void *)uap->parm1, uap->parm2, (void *)uap->parm3,
713 uap->parm4, p->td_ucred);
714 #elif defined(AFS_DARWIN80_ENV)
715 code =
716 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3,
717 uap->parm4, kauth_cred_get());
718 #elif defined(AFS_NBSD40_ENV)
719 code =
720 afs_syscall_pioctl((char *)SCARG(uap, parm1), SCARG(uap, parm2),
721 (void *)SCARG(uap, parm3), SCARG(uap, parm4),
722 kauth_cred_get());
723 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
724 code =
725 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3,
726 uap->parm4, p->p_cred->pc_ucred);
727 #else
728 code =
729 afs_syscall_pioctl((char *)uap->parm1,
730 (unsigned int)uap->parm2,
731 (caddr_t)uap->parm3,
732 (int) uap->parm4);
733 #endif
734 AFS_GUNLOCK();
736 #ifdef AFS_NBSD40_ENV
737 } else if (SCARG(uap, syscall) == AFSCALL_ICREATE) {
738 struct iparam iparams;
739 code = copyin_iparam((char *) SCARG(uap, parm3), &iparams);
740 #else
741 } else if (uap->syscall == AFSCALL_ICREATE) {
742 struct iparam iparams;
744 code = copyin_iparam((char *)uap->parm3, &iparams);
745 #endif
746 if (code) {
747 #if defined(KERNEL_HAVE_UERROR)
748 setuerror(code);
749 #endif
750 } else {
751 #if defined(AFS_SUN5_ENV)
752 code =
753 afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1,
754 iparams.param2, iparams.param3,
755 iparams.param4, rvp, CRED());
756 #elif defined(AFS_NBSD40_ENV)
757 code =
758 afs_syscall_icreate(SCARG(uap, parm1), SCARG(uap, parm2),
759 iparams.param1, iparams.param2, iparams.param3,
760 iparams.param4, retval
762 #else
763 code =
764 afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1,
765 iparams.param2, iparams.param3,
766 iparams.param4
767 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
768 , retval
769 #endif
771 #endif /* AFS_SUN5_ENV */
773 #if defined(AFS_NBSD40_ENV)
774 } else if (SCARG(uap, syscall) == AFSCALL_IOPEN) {
775 #else
776 } else if (uap->syscall == AFSCALL_IOPEN) {
777 #endif /* !AFS_NBSD40_ENV */
778 #if defined(AFS_SUN5_ENV)
779 code =
780 afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp,
781 CRED());
782 #elif defined(AFS_NBSD40_ENV)
783 code = afs_syscall_iopen(SCARG(uap, parm1), SCARG(uap, parm2),
784 SCARG(uap, parm3), retval);
785 #else
786 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3
787 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
788 , retval
789 #endif
791 #endif /* AFS_SUN5_ENV */
792 #if defined(AFS_NBSD40_ENV)
793 } else if (SCARG(uap, syscall) == AFSCALL_IDEC) {
794 #else
795 } else if (uap->syscall == AFSCALL_IDEC) {
796 #endif
797 #if defined(AFS_NBSD40_ENV)
798 code = afs_syscall_iincdec(SCARG(uap, parm1), SCARG(uap, parm2),
799 SCARG(uap, parm3), -1);
800 #else
803 code =
804 afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1
805 #if defined(AFS_SUN5_ENV)
806 , rvp, CRED()
807 #endif
810 #endif /* !AFS_NBSD40_ENV */
811 #if defined(AFS_NBSD40_ENV)
812 } else if (SCARG(uap, syscall) == AFSCALL_IINC) {
813 #else
814 } else if (uap->syscall == AFSCALL_IINC) {
815 #endif
816 #if defined(AFS_NBSD40_ENV)
817 code = afs_syscall_iincdec(SCARG(uap, parm1), SCARG(uap, parm2),
818 SCARG(uap, parm3), 1);
819 #else
820 code =
821 afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1
822 #ifdef AFS_SUN5_ENV
823 , rvp, CRED()
824 #endif
826 #endif /* !AFS_NBSD40_ENV */
827 #if defined(AFS_NBSD40_ENV)
828 } else if (SCARG(uap, syscall) == AFSCALL_ICL) {
829 #else
830 } else if (uap->syscall == AFSCALL_ICL) {
831 #endif
832 AFS_GLOCK();
833 code =
834 #if defined(AFS_NBSD40_ENV)
835 Afscall_icl(SCARG(uap, parm1), SCARG(uap, parm2),
836 SCARG(uap, parm3), SCARG(uap, parm4),
837 SCARG(uap, parm5), retval);
838 #else
839 Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
840 uap->parm5, (long *)retval);
841 #endif /* !AFS_NBSD40_ENV */
842 AFS_GUNLOCK();
843 #ifdef AFS_LINUX20_ENV
844 if (!code) {
845 /* ICL commands can return values. */
846 code = -linux_ret; /* Gets negated again at exit below */
848 #else
849 if (code) {
850 #if defined(KERNEL_HAVE_UERROR)
851 setuerror(code);
852 #endif
854 #endif /* !AFS_LINUX20_ENV */
855 } else {
856 #if defined(KERNEL_HAVE_UERROR)
857 setuerror(EINVAL);
858 #else
859 code = EINVAL;
860 #endif
862 #if defined(AFS_DARWIN80_ENV)
863 if (uap->syscall != AFSCALL_CALL)
864 put_vfs_context();
865 #ifdef AFS_DARWIN100_ENV
866 } /* 32 bit procs */
867 #endif
868 #endif
869 #ifdef AFS_LINUX20_ENV
870 code = -code;
871 #endif
872 return code;
874 #endif /* AFS_SGI_ENV */
875 #endif /* !AFS_AIX32_ENV */