/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#ifdef AFS_SGI62_ENV
#include "h/hashing.h"
#endif
-#if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN60_ENV)
+#if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN_ENV)
#include "netinet/in_var.h"
#endif
#endif /* !defined(UKERNEL) */
-#ifdef AFS_LINUX22_ENV
-#include "h/smp_lock.h"
-#endif
-#if (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) || defined(AFS_HPUX_64BIT_ENV) || defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64)) || defined(NEED_IOCTL32)
+#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)
static void
afs_ioctl32_to_afs_ioctl(const struct afs_ioctl32 *src, struct afs_ioctl *dst)
{
+#ifdef AFS_DARWIN100_ENV
+ dst->in = CAST_USER_ADDR_T(src->in);
+ dst->out = CAST_USER_ADDR_T(src->out);
+#else
dst->in = (char *)(unsigned long)src->in;
dst->out = (char *)(unsigned long)src->out;
+#endif
dst->in_size = src->in_size;
dst->out_size = src->out_size;
}
int code;
#if defined(AFS_DARWIN100_ENV)
struct afs_ioctl32 dst32;
-
+
if (!proc_is64bit(current_proc())) {
AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
if (!code)
}
#endif /* defined(AFS_HPUX_64BIT_ENV) */
-#if defined(AFS_SUN57_64BIT_ENV)
+#if defined(AFS_SUN5_64BIT_ENV)
struct afs_ioctl32 dst32;
if (get_udatamodel() == DATAMODEL_ILP32) {
afs_ioctl32_to_afs_ioctl(&dst32, dst);
return code;
}
-#endif /* defined(AFS_SUN57_64BIT_ENV) */
+#endif /* defined(AFS_SUN5_64BIT_ENV) */
#if defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64)
struct afs_ioctl32 dst32;
#elif defined(AFS_PPC64_LINUX26_ENV)
#if defined(STRUCT_TASK_STRUCT_HAS_THREAD_INFO)
- if (current->thread_info->flags & _TIF_32BIT)
+ if (current->thread_info->flags & _TIF_32BIT)
#else
- if (task_thread_info(current)->flags & _TIF_32BIT)
-#endif
+ if (task_thread_info(current)->flags & _TIF_32BIT)
+#endif
#elif defined(AFS_PPC64_LINUX20_ENV)
if (current->thread.flags & PPC_FLAG_32BIT)
if (test_thread_flag(TIF_31BIT))
#elif defined(AFS_S390X_LINUX20_ENV)
if (current->thread.flags & S390_FLAG_31BIT)
+#elif defined(AFS_ARM64_LINUX26_ENV)
+ if (is_compat_task())
#else
#error pioctl32 not done for this linux
*/
syscall(syscall, p1, p2, p3, p4, p5, p6)
{
- register rval1 = 0, code;
- register monster;
+ int rval1 = 0, code;
+ int monster;
int retval = 0;
#ifndef AFS_AIX41_ENV
extern lock_t kernel_lock;
};
-#if defined(AFS_HPUX_64BIT_ENV) || defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)) || defined(NEED_IOCTL32)
+#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)
static void
iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst)
{
- dst->param1 = src->param1;
- dst->param2 = src->param2;
- dst->param3 = src->param3;
- dst->param4 = src->param4;
+ dst->param1 = (iparmtype)(uintptrsz)src->param1;
+ dst->param2 = (iparmtype)(uintptrsz)src->param2;
+ dst->param3 = (iparmtype)(uintptrsz)src->param3;
+ dst->param4 = (iparmtype)(uintptrsz)src->param4;
}
#endif
}
#endif /* AFS_HPUX_64BIT_ENV */
-#if defined(AFS_SUN57_64BIT_ENV)
+#if defined(AFS_SUN5_64BIT_ENV)
struct iparam32 dst32;
if (get_udatamodel() == DATAMODEL_ILP32) {
iparam32_to_iparam(&dst32, dst);
return code;
}
-#endif /* AFS_SUN57_64BIT_ENV */
+#endif /* AFS_SUN5_64BIT_ENV */
#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
struct iparam32 dst32;
#elif defined(AFS_PPC64_LINUX26_ENV)
#if defined(STRUCT_TASK_STRUCT_HAS_THREAD_INFO)
- if (current->thread_info->flags & _TIF_32BIT)
+ if (current->thread_info->flags & _TIF_32BIT)
#else
- if (task_thread_info(current)->flags & _TIF_32BIT)
-#endif
+ if (task_thread_info(current)->flags & _TIF_32BIT)
+#endif
#elif defined(AFS_PPC64_LINUX20_ENV)
- if (current->thread.flags & PPC_FLAG_32BIT)
+ if (current->thread.flags & PPC_FLAG_32BIT)
#elif defined(AFS_S390X_LINUX26_ENV)
if (test_thread_flag(TIF_31BIT))
#elif defined(AFS_S390X_LINUX20_ENV)
- if (current->thread.flags & S390_FLAG_31BIT)
+ if (current->thread.flags & S390_FLAG_31BIT)
+#elif defined(AFS_ARM64_LINUX26_ENV)
+ if (is_compat_task())
#else
#error iparam32 not done for this linux platform
#ifdef AFS_SUN5_ENV
extern int afs_sinited;
-/** The 32 bit OS expects the members of this structure to be 32 bit
- * quantities and the 64 bit OS expects them as 64 bit quanties. Hence
- * to accomodate both, *long* is used instead of afs_int32
- */
-
-#ifdef AFS_SUN57_ENV
-struct afssysa {
- long syscall;
- long parm1;
- long parm2;
- long parm3;
- long parm4;
- long parm5;
- long parm6;
-};
-#else
-struct afssysa {
- afs_int32 syscall;
- afs_int32 parm1;
- afs_int32 parm2;
- afs_int32 parm3;
- afs_int32 parm4;
- afs_int32 parm5;
- afs_int32 parm6;
-};
-#endif
-
-Afs_syscall(register struct afssysa *uap, rval_t * rvp)
+Afs_syscall(struct afssysa *uap, rval_t * rvp)
{
int *retval = &rvp->r_val1;
-#else /* AFS_SUN5_ENV */
-#ifdef AFS_DARWIN100_ENV
+#elif defined(AFS_DARWIN100_ENV)
struct afssysa {
afs_int32 syscall;
afs_int32 parm1;
afs_int32 syscall;
};
int
-afs3_syscall(struct proc *p, void *args, unsigned int *retval)
+afs3_syscall(afs_proc_t *p, void *args, unsigned int *retval)
{
struct afssysa64 *uap64 = NULL;
struct afssysa *uap = NULL;
-#elif defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#elif defined(AFS_FBSD_ENV)
int
-afs3_syscall(p, args, retval)
-#ifdef AFS_FBSD50_ENV
- struct thread *p;
-#else
- struct proc *p;
-#endif
- void *args;
- long *retval;
+afs3_syscall(struct thread *p, void *args)
{
- register struct a {
+ struct a {
long syscall;
long parm1;
long parm2;
long parm5;
long parm6;
} *uap = (struct a *)args;
-#else /* AFS_OSF_ENV */
-#ifdef AFS_LINUX20_ENV
+ long fbsd_ret = 0;
+ long *retval = &fbsd_ret;
+#elif defined(AFS_NBSD40_ENV)
+int
+afs3_syscall(struct lwp *p, const void *args, register_t *retval)
+{
+ /* see osi_machdep.h */
+ struct afs_sysargs *uap = (struct afs_sysargs *) args;
+#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+int
+afs3_syscall(afs_proc_t *p, void *args, long *retval)
+{
+ struct a {
+ long syscall;
+ long parm1;
+ long parm2;
+ long parm3;
+ long parm4;
+ long parm5;
+ long parm6;
+ } *uap = (struct a *)args;
+#elif defined(AFS_LINUX20_ENV)
struct afssysargs {
long syscall;
long parm1;
long linux_ret = 0;
long *retval = &linux_ret;
long eparm[4]; /* matches AFSCALL_ICL in fstrace.c */
-#ifdef AFS_SPARC64_LINUX24_ENV
+# ifdef AFS_SPARC64_LINUX24_ENV
afs_int32 eparm32[4];
-#endif
+# endif
/* eparm is also used by AFSCALL_CALL in afsd.c */
#else
-#if defined(UKERNEL)
+# if defined(UKERNEL)
int
-Afs_syscall()
+Afs_syscall(void)
{
- register struct a {
+ struct a {
long syscall;
long parm1;
long parm2;
long parm4;
long parm5;
long parm6;
- } *uap = (struct a *)u.u_ap;
-#else /* UKERNEL */
+ } *uap = (struct a *)get_user_struct()->u_ap;
+# else /* UKERNEL */
int
Afs_syscall()
{
- register struct a {
+ struct a {
long syscall;
long parm1;
long parm2;
long parm5;
long parm6;
} *uap = (struct a *)u.u_ap;
-#endif /* UKERNEL */
-#if defined(AFS_HPUX_ENV)
+# endif /* UKERNEL */
+# if defined(AFS_HPUX_ENV)
long *retval = &u.u_rval1;
-#else
+# elif defined(UKERNEL)
+ int *retval = &(get_user_struct()->u_rval1);
+# else
int *retval = &u.u_rval1;
+# endif
#endif
-#endif /* AFS_LINUX20_ENV */
-#endif /* AFS_OSF_ENV */
-#endif /* AFS_SUN5_ENV */
- register int code = 0;
+ int code = 0;
AFS_STATCNT(afs_syscall);
#ifdef AFS_SUN5_ENV
}
#endif
#ifdef AFS_LINUX20_ENV
- lock_kernel();
/* setup uap for use below - pull out the magic decoder ring to know
* which syscalls have folded argument lists.
*/
code =
afs_syscall64_call(uap64->parm1, uap64->parm2, uap64->parm3,
uap64->parm4, uap64->parm5, uap64->parm6);
+ /* pass back the code as syscall retval */
+ if (code < 0) {
+ *retval = code;
+ code = 0;
+ }
} else if (uap64->syscall == AFSCALL_SETPAG) {
AFS_GLOCK();
code = afs_setpag(p, args, retval);
*/
osi_InitGlock();
#endif
+
+#if defined(AFS_NBSD40_ENV)
+ if (SCARG(uap, syscall) == AFSCALL_CALL) {
+ code =
+ afs_syscall_call(SCARG(uap, parm1), SCARG(uap, parm2),
+ SCARG(uap, parm3), SCARG(uap, parm4),
+ SCARG(uap, parm5), SCARG(uap, parm6));
+ } else if (SCARG(uap, syscall) == AFSCALL_SETPAG) {
+#else
if (uap->syscall == AFSCALL_CALL) {
code =
afs_syscall_call(uap->parm1, uap->parm2, uap->parm3,
uap->parm4, uap->parm5, uap->parm6);
+#ifdef AFS_DARWIN_ENV
+ /* pass back the code as syscall retval */
+ if (code < 0) {
+ *retval = code;
+ code = 0;
+ }
+#endif
} else if (uap->syscall == AFSCALL_SETPAG) {
+#endif
#ifdef AFS_SUN5_ENV
- register proc_t *procp;
+ proc_t *procp;
procp = ttoproc(curthread);
AFS_GLOCK();
AFS_GUNLOCK();
#else
AFS_GLOCK();
-#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_FBSD_ENV)
+ code = afs_setpag(p, args);
+#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
code = afs_setpag(p, args, retval);
-#else /* AFS_OSF_ENV */
+#else /* AFS_DARWIN_ENV || AFS_XBSD_ENV */
code = afs_setpag();
#endif
AFS_GUNLOCK();
#endif
- } else if (uap->syscall == AFSCALL_PIOCTL) {
+ } else if
+#if defined(AFS_NBSD40_ENV)
+ (SCARG(uap, syscall) == AFSCALL_PIOCTL) {
+#else
+ (uap->syscall == AFSCALL_PIOCTL) {
+#endif
AFS_GLOCK();
#if defined(AFS_SUN5_ENV)
code =
afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3,
uap->parm4, rvp, CRED());
-#elif defined(AFS_FBSD50_ENV)
+#elif defined(AFS_FBSD_ENV)
code =
- afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3,
+ afs_syscall_pioctl((void *)uap->parm1, uap->parm2, (void *)uap->parm3,
uap->parm4, p->td_ucred);
#elif defined(AFS_DARWIN80_ENV)
code =
afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3,
uap->parm4, kauth_cred_get());
+#elif defined(AFS_NBSD40_ENV)
+ code =
+ afs_syscall_pioctl((char *)SCARG(uap, parm1), SCARG(uap, parm2),
+ (void *)SCARG(uap, parm3), SCARG(uap, parm4),
+ kauth_cred_get());
#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
code =
afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3,
(int) uap->parm4);
#endif
AFS_GUNLOCK();
+
+#ifdef AFS_NBSD40_ENV
+ } else if (SCARG(uap, syscall) == AFSCALL_ICREATE) {
+ struct iparam iparams;
+ code = copyin_iparam((char *) SCARG(uap, parm3), &iparams);
+#else
} else if (uap->syscall == AFSCALL_ICREATE) {
struct iparam iparams;
code = copyin_iparam((char *)uap->parm3, &iparams);
+#endif
if (code) {
#if defined(KERNEL_HAVE_UERROR)
setuerror(code);
#endif
} else {
-#ifdef AFS_SUN5_ENV
+#if defined(AFS_SUN5_ENV)
code =
afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1,
iparams.param2, iparams.param3,
iparams.param4, rvp, CRED());
+#elif defined(AFS_NBSD40_ENV)
+ code =
+ afs_syscall_icreate(SCARG(uap, parm1), SCARG(uap, parm2),
+ iparams.param1, iparams.param2, iparams.param3,
+ iparams.param4, retval
+ );
#else
code =
afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1,
iparams.param2, iparams.param3,
iparams.param4
-#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
, retval
#endif
);
#endif /* AFS_SUN5_ENV */
}
- } else if (uap->syscall == AFSCALL_IOPEN) {
-#ifdef AFS_SUN5_ENV
+#if defined(AFS_NBSD40_ENV)
+ } else if (SCARG(uap, syscall) == AFSCALL_IOPEN) {
+#else
+ } else if (uap->syscall == AFSCALL_IOPEN) {
+#endif /* !AFS_NBSD40_ENV */
+#if defined(AFS_SUN5_ENV)
code =
afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp,
CRED());
+#elif defined(AFS_NBSD40_ENV)
+ code = afs_syscall_iopen(SCARG(uap, parm1), SCARG(uap, parm2),
+ SCARG(uap, parm3), retval);
#else
code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3
-#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
, retval
#endif
);
#endif /* AFS_SUN5_ENV */
+#if defined(AFS_NBSD40_ENV)
+ } else if (SCARG(uap, syscall) == AFSCALL_IDEC) {
+#else
} else if (uap->syscall == AFSCALL_IDEC) {
+#endif
+#if defined(AFS_NBSD40_ENV)
+ code = afs_syscall_iincdec(SCARG(uap, parm1), SCARG(uap, parm2),
+ SCARG(uap, parm3), -1);
+#else
+
+
code =
afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1
-#ifdef AFS_SUN5_ENV
+#if defined(AFS_SUN5_ENV)
, rvp, CRED()
#endif
);
- } else if (uap->syscall == AFSCALL_IINC) {
+
+#endif /* !AFS_NBSD40_ENV */
+#if defined(AFS_NBSD40_ENV)
+ } else if (SCARG(uap, syscall) == AFSCALL_IINC) {
+#else
+ } else if (uap->syscall == AFSCALL_IINC) {
+#endif
+#if defined(AFS_NBSD40_ENV)
+ code = afs_syscall_iincdec(SCARG(uap, parm1), SCARG(uap, parm2),
+ SCARG(uap, parm3), 1);
+#else
code =
afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1
#ifdef AFS_SUN5_ENV
, rvp, CRED()
#endif
);
- } else if (uap->syscall == AFSCALL_ICL) {
+#endif /* !AFS_NBSD40_ENV */
+#if defined(AFS_NBSD40_ENV)
+ } else if (SCARG(uap, syscall) == AFSCALL_ICL) {
+#else
+ } else if (uap->syscall == AFSCALL_ICL) {
+#endif
AFS_GLOCK();
code =
+#if defined(AFS_NBSD40_ENV)
+ Afscall_icl(SCARG(uap, parm1), SCARG(uap, parm2),
+ SCARG(uap, parm3), SCARG(uap, parm4),
+ SCARG(uap, parm5), retval);
+#else
Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
uap->parm5, (long *)retval);
+#endif /* !AFS_NBSD40_ENV */
AFS_GUNLOCK();
#ifdef AFS_LINUX20_ENV
if (!code) {
#endif
#ifdef AFS_LINUX20_ENV
code = -code;
- unlock_kernel();
#endif
return code;
}