summaryrefslogtreecommitdiff
path: root/sys/compat/linux
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2002-03-29 20:49:40 +0000
committerchristos <christos@NetBSD.org>2002-03-29 20:49:40 +0000
commit018a4082cc6a7b2c73d4a8bd39bb7030944d2cb3 (patch)
tree749ed7d858137525b99ee9b4840c17c6f8c247e3 /sys/compat/linux
parenta0453e4c6750aa5771dd8e81f0858721068cc80a (diff)
- #undef DPRINTF for files that are included from other files.
- more debugging for socketcalls - fix sa_len if AF_INET; somehow we get passed 28 instead of 16?
Diffstat (limited to 'sys/compat/linux')
-rw-r--r--sys/compat/linux/common/linux_oldmmap.c5
-rw-r--r--sys/compat/linux/common/linux_socket.c31
-rw-r--r--sys/compat/linux/common/linux_socketcall.c115
3 files changed, 104 insertions, 47 deletions
diff --git a/sys/compat/linux/common/linux_oldmmap.c b/sys/compat/linux/common/linux_oldmmap.c
index 49a401ce8ed..f3945a2bfc3 100644
--- a/sys/compat/linux/common/linux_oldmmap.c
+++ b/sys/compat/linux/common/linux_oldmmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_oldmmap.c,v 1.57 2002/03/22 17:14:19 christos Exp $ */
+/* $NetBSD: linux_oldmmap.c,v 1.58 2002/03/29 20:49:40 christos Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_oldmmap.c,v 1.57 2002/03/22 17:14:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_oldmmap.c,v 1.58 2002/03/29 20:49:40 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_oldmmap.c,v 1.57 2002/03/22 17:14:19 christos
/* Used on: arm, i386, m68k */
/* Not used on: alpha, mips, pcc, sparc, sparc64 */
+#undef DPRINTF
#ifdef DEBUG_LINUX
#define DPRINTF(a) uprintf a
#else
diff --git a/sys/compat/linux/common/linux_socket.c b/sys/compat/linux/common/linux_socket.c
index ad1f79c2385..180a6804cf5 100644
--- a/sys/compat/linux/common/linux_socket.c
+++ b/sys/compat/linux/common/linux_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.c,v 1.36 2002/03/16 20:43:54 christos Exp $ */
+/* $NetBSD: linux_socket.c,v 1.37 2002/03/29 20:49:40 christos Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.36 2002/03/16 20:43:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.37 2002/03/29 20:49:40 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -90,6 +90,12 @@ __KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.36 2002/03/16 20:43:54 christos E
#include <compat/linux/linux_syscallargs.h>
+#ifdef DEBUG_LINUX
+#define DPRINTF(a) uprintf a
+#else
+#define DPRINTF(a)
+#endif
+
/*
* The calls in this file are entered either via the linux_socketcall()
* interface or, on the Alpha, as individual syscalls. The
@@ -1012,8 +1018,10 @@ linux_sa_get(p, sgp, sap, osa, osalen)
struct sockaddr_in6 *sin6;
#endif
- if (*osalen < 2 || *osalen > UCHAR_MAX || !osa)
+ if (*osalen < 2 || *osalen > UCHAR_MAX || !osa) {
+ DPRINTF(("bad osa=%p osalen=%d\n", osa, *osalen));
return (EINVAL);
+ }
alloclen = *osalen;
#ifdef INET6
@@ -1031,11 +1039,14 @@ linux_sa_get(p, sgp, sap, osa, osalen)
kosa = (struct osockaddr *) malloc(alloclen, M_TEMP, M_WAITOK);
- if ((error = copyin(osa, (caddr_t) kosa, *osalen)))
+ if ((error = copyin(osa, (caddr_t) kosa, *osalen))) {
+ DPRINTF(("error copying osa %d\n", error));
goto out;
+ }
bdom = linux_to_bsd_domain(kosa->sa_family);
if (bdom == -1) {
+ DPRINTF(("bad linux family=%d\n", kosa->sa_family));
error = EINVAL;
goto out;
}
@@ -1069,12 +1080,20 @@ linux_sa_get(p, sgp, sap, osa, osalen)
error = EINVAL;
goto out;
}
+ } else if (bdom == AF_INET) {
+ alloclen = sizeof(struct sockaddr_in);
}
#endif
sa = (struct sockaddr *) kosa;
sa->sa_family = bdom;
sa->sa_len = alloclen;
+#ifdef DEBUG_LINUX
+ DPRINTF(("family %d, len = %d [ ", sa->sa_family, sa->sa_len));
+ for (bdom = 0; bdom < sizeof(sa->sa_data); bdom++)
+ DPRINTF(("%02x ", sa->sa_data[bdom]));
+ DPRINTF(("\n"));
+#endif
usa = (struct sockaddr *) stackgap_alloc(p, sgp, alloclen);
if (!usa) {
@@ -1082,8 +1101,10 @@ linux_sa_get(p, sgp, sap, osa, osalen)
goto out;
}
- if ((error = copyout(sa, usa, alloclen)))
+ if ((error = copyout(sa, usa, alloclen))) {
+ DPRINTF(("error copying out socket %d\n", error));
goto out;
+ }
*sap = usa;
diff --git a/sys/compat/linux/common/linux_socketcall.c b/sys/compat/linux/common/linux_socketcall.c
index 0fc08744f67..56d6c0e0e12 100644
--- a/sys/compat/linux/common/linux_socketcall.c
+++ b/sys/compat/linux/common/linux_socketcall.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socketcall.c,v 1.23 2001/11/13 02:09:00 lukem Exp $ */
+/* $NetBSD: linux_socketcall.c,v 1.24 2002/03/29 20:49:41 christos Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.23 2001/11/13 02:09:00 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.24 2002/03/29 20:49:41 christos Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -71,6 +71,13 @@ __KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.23 2001/11/13 02:09:00 lukem
#include <compat/linux/linux_syscallargs.h>
+#undef DPRINTF
+#ifdef DEBUG_LINUX
+#define DPRINTF(a) uprintf a
+#else
+#define DPRINTF(a)
+#endif
+
/* Used on: arm, i386, m68k, mips, ppc, sparc, sparc64 */
/* Not used on: alpha */
@@ -82,25 +89,28 @@ __KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.23 2001/11/13 02:09:00 lukem
*/
/* The sizes of the arguments. Used for copyin. */
-static const int linux_socketcall_argsize[LINUX_MAX_SOCKETCALL+1] = {
- -1,
- sizeof(struct linux_sys_socket_args), /* 1 */
- sizeof(struct linux_sys_bind_args),
- sizeof(struct linux_sys_connect_args),
- sizeof(struct linux_sys_listen_args),
- sizeof(struct linux_sys_accept_args), /* 5 */
- sizeof(struct linux_sys_getsockname_args),
- sizeof(struct linux_sys_getpeername_args),
- sizeof(struct linux_sys_socketpair_args),
- sizeof(struct linux_sys_send_args),
- sizeof(struct linux_sys_recv_args), /* 10 */
- sizeof(struct linux_sys_sendto_args),
- sizeof(struct linux_sys_recvfrom_args),
- sizeof(struct linux_sys_shutdown_args),
- sizeof(struct linux_sys_setsockopt_args),
- sizeof(struct linux_sys_getsockopt_args), /* 15 */
- sizeof(struct linux_sys_sendmsg_args),
- sizeof(struct linux_sys_recvmsg_args), /* 17 */
+static const struct {
+ char *name;
+ int argsize;
+} linux_socketcall[LINUX_MAX_SOCKETCALL+1] = {
+ {"invalid", -1}, /* 0 */
+ {"socket", sizeof(struct linux_sys_socket_args)}, /* 1 */
+ {"bind", sizeof(struct linux_sys_bind_args)}, /* 2 */
+ {"connect", sizeof(struct linux_sys_connect_args)}, /* 3 */
+ {"listen", sizeof(struct linux_sys_listen_args)}, /* 4 */
+ {"accept", sizeof(struct linux_sys_accept_args)}, /* 5 */
+ {"getsockname", sizeof(struct linux_sys_getsockname_args)}, /* 6 */
+ {"getpeername", sizeof(struct linux_sys_getpeername_args)}, /* 7 */
+ {"socketpair", sizeof(struct linux_sys_socketpair_args)}, /* 8 */
+ {"send", sizeof(struct linux_sys_send_args)}, /* 9 */
+ {"recv", sizeof(struct linux_sys_recv_args)}, /* 10 */
+ {"sendto", sizeof(struct linux_sys_sendto_args)}, /* 11 */
+ {"recvfrom", sizeof(struct linux_sys_recvfrom_args)}, /* 12 */
+ {"shutdown", sizeof(struct linux_sys_shutdown_args)}, /* 13 */
+ {"setsockopt", sizeof(struct linux_sys_setsockopt_args)}, /* 14 */
+ {"getsockopt", sizeof(struct linux_sys_getsockopt_args)}, /* 15 */
+ {"sendmsg", sizeof(struct linux_sys_sendmsg_args)}, /* 16 */
+ {"recvmsg", sizeof(struct linux_sys_recvmsg_args)}, /* 17 */
};
/*
@@ -124,45 +134,70 @@ linux_sys_socketcall(p, v, retval)
return ENOSYS;
if ((error = copyin((caddr_t) SCARG(uap, args), (caddr_t) &lda,
- linux_socketcall_argsize[SCARG(uap, what)])))
+ linux_socketcall[SCARG(uap, what)].argsize))) {
+ DPRINTF(("copyin for %s failed %d\n",
+ linux_socketcall[SCARG(uap, what)].name, error));
return error;
+ }
switch (SCARG(uap, what)) {
case LINUX_SYS_socket:
- return linux_sys_socket(p, (void *)&lda, retval);
+ error = linux_sys_socket(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_bind:
- return linux_sys_bind(p, (void *)&lda, retval);
+ error = linux_sys_bind(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_connect:
- return linux_sys_connect(p, (void *)&lda, retval);
+ error = linux_sys_connect(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_listen:
- return sys_listen(p, (void *)&lda, retval);
+ error = sys_listen(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_accept:
- return linux_sys_accept(p, (void *)&lda, retval);
+ error = linux_sys_accept(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_getsockname:
- return linux_sys_getsockname(p, (void *)&lda, retval);
+ error = linux_sys_getsockname(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_getpeername:
- return linux_sys_getpeername(p, (void *)&lda, retval);
+ error = linux_sys_getpeername(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_socketpair:
- return linux_sys_socketpair(p, (void *)&lda, retval);
+ error = linux_sys_socketpair(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_send:
- return linux_sys_send(p, (void *)&lda, retval);
+ error = linux_sys_send(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_recv:
- return linux_sys_recv(p, (void *)&lda, retval);
+ error = linux_sys_recv(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_sendto:
- return linux_sys_sendto(p, (void *)&lda, retval);
+ error = linux_sys_sendto(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_recvfrom:
- return linux_sys_recvfrom(p, (void *)&lda, retval);
+ error = linux_sys_recvfrom(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_shutdown:
- return sys_shutdown(p, (void *)&lda, retval);
+ error = sys_shutdown(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_setsockopt:
- return linux_sys_setsockopt(p, (void *)&lda, retval);
+ error = linux_sys_setsockopt(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_getsockopt:
- return linux_sys_getsockopt(p, (void *)&lda, retval);
+ error = linux_sys_getsockopt(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_sendmsg:
- return linux_sys_sendmsg(p, (void *)&lda, retval);
+ error = linux_sys_sendmsg(p, (void *)&lda, retval);
+ break;
case LINUX_SYS_recvmsg:
- return linux_sys_recvmsg(p, (void *)&lda, retval);
+ error = linux_sys_recvmsg(p, (void *)&lda, retval);
+ break;
default:
- return ENOSYS;
+ error = ENOSYS;
+ break;
}
+
+ DPRINTF(("sys_%s() = %d\n", linux_socketcall[SCARG(uap, what)].name,
+ error));
+ return error;
}