summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c3
-rw-r--r--sys/compat/linux/linux_socket.c62
-rw-r--r--sys/compat/linux/linux_socket.h123
3 files changed, 41 insertions, 147 deletions
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index b491a85..34eb6d7 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -489,7 +489,8 @@ freebsd32_mmap(struct thread *td, struct freebsd32_mmap_args *uap)
#ifdef COMPAT_FREEBSD6
int
-freebsd6_freebsd32_mmap(struct thread *td, struct freebsd6_freebsd32_mmap_args *uap)
+freebsd6_freebsd32_mmap(struct thread *td,
+ struct freebsd6_freebsd32_mmap_args *uap)
{
struct freebsd32_mmap_args ap;
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 680f3c0..7e65332 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -971,10 +971,10 @@ linux_socketpair(struct thread *td, struct linux_socketpair_args *args)
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
struct linux_send_args {
- int s;
- l_uintptr_t msg;
- int len;
- int flags;
+ register_t s;
+ register_t msg;
+ register_t len;
+ register_t flags;
};
static int
@@ -999,10 +999,10 @@ linux_send(struct thread *td, struct linux_send_args *args)
}
struct linux_recv_args {
- int s;
- l_uintptr_t msg;
- int len;
- int flags;
+ register_t s;
+ register_t msg;
+ register_t len;
+ register_t flags;
};
static int
@@ -1701,39 +1701,45 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
/* Argument list sizes for linux_socketcall */
-
-#define LINUX_AL(x) ((x) * sizeof(l_ulong))
-
-static const unsigned char lxs_args[] = {
- LINUX_AL(0) /* unused*/, LINUX_AL(3) /* socket */,
- LINUX_AL(3) /* bind */, LINUX_AL(3) /* connect */,
- LINUX_AL(2) /* listen */, LINUX_AL(3) /* accept */,
- LINUX_AL(3) /* getsockname */, LINUX_AL(3) /* getpeername */,
- LINUX_AL(4) /* socketpair */, LINUX_AL(4) /* send */,
- LINUX_AL(4) /* recv */, LINUX_AL(6) /* sendto */,
- LINUX_AL(6) /* recvfrom */, LINUX_AL(2) /* shutdown */,
- LINUX_AL(5) /* setsockopt */, LINUX_AL(5) /* getsockopt */,
- LINUX_AL(3) /* sendmsg */, LINUX_AL(3) /* recvmsg */,
- LINUX_AL(4) /* accept4 */, LINUX_AL(5) /* recvmmsg */,
- LINUX_AL(4) /* sendmmsg */
+static const unsigned char lxs_args_cnt[] = {
+ 0 /* unused*/, 3 /* socket */,
+ 3 /* bind */, 3 /* connect */,
+ 2 /* listen */, 3 /* accept */,
+ 3 /* getsockname */, 3 /* getpeername */,
+ 4 /* socketpair */, 4 /* send */,
+ 4 /* recv */, 6 /* sendto */,
+ 6 /* recvfrom */, 2 /* shutdown */,
+ 5 /* setsockopt */, 5 /* getsockopt */,
+ 3 /* sendmsg */, 3 /* recvmsg */,
+ 4 /* accept4 */, 5 /* recvmmsg */,
+ 4 /* sendmmsg */
};
-
-#define LINUX_AL_SIZE (nitems(lxs_args) - 1)
+#define LINUX_ARGS_CNT (nitems(lxs_args_cnt) - 1)
+#define LINUX_ARG_SIZE(x) (lxs_args_cnt[x] * sizeof(l_ulong))
int
linux_socketcall(struct thread *td, struct linux_socketcall_args *args)
{
l_ulong a[6];
+#if defined(__amd64__) && defined(COMPAT_LINUX32)
+ register_t l_args[6];
+#endif
void *arg;
int error;
- if (args->what < LINUX_SOCKET || args->what > LINUX_AL_SIZE)
+ if (args->what < LINUX_SOCKET || args->what > LINUX_ARGS_CNT)
return (EINVAL);
- error = copyin(PTRIN(args->args), a, lxs_args[args->what]);
- if (error)
+ error = copyin(PTRIN(args->args), a, LINUX_ARG_SIZE(args->what));
+ if (error != 0)
return (error);
+#if defined(__amd64__) && defined(COMPAT_LINUX32)
+ for (int i = 0; i < lxs_args_cnt[args->what]; ++i)
+ l_args[i] = a[i];
+ arg = l_args;
+#else
arg = a;
+#endif
switch (args->what) {
case LINUX_SOCKET:
return (linux_socket(td, arg));
diff --git a/sys/compat/linux/linux_socket.h b/sys/compat/linux/linux_socket.h
index 63fae69..9aff965 100644
--- a/sys/compat/linux/linux_socket.h
+++ b/sys/compat/linux/linux_socket.h
@@ -142,131 +142,18 @@ struct l_ucred {
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
-struct linux_sendto_args {
- int s;
- l_uintptr_t msg;
- int len;
- int flags;
- l_uintptr_t to;
- int tolen;
-};
-
-struct linux_socket_args {
- int domain;
- int type;
- int protocol;
-};
-
-struct linux_bind_args {
- int s;
- l_uintptr_t name;
- int namelen;
-};
-
-struct linux_connect_args {
- int s;
- l_uintptr_t name;
- int namelen;
-};
-
-struct linux_listen_args {
- int s;
- int backlog;
-};
-
struct linux_accept_args {
- int s;
- l_uintptr_t addr;
- l_uintptr_t namelen;
-};
-
-struct linux_accept4_args {
- int s;
- l_uintptr_t addr;
- l_uintptr_t namelen;
- int flags;
-};
-
-struct linux_getsockname_args {
- int s;
- l_uintptr_t addr;
- l_uintptr_t namelen;
-};
-
-struct linux_getpeername_args {
- int s;
- l_uintptr_t addr;
- l_uintptr_t namelen;
+ register_t s;
+ register_t addr;
+ register_t namelen;
};
-struct linux_socketpair_args {
- int domain;
- int type;
- int protocol;
- l_uintptr_t rsv;
-};
-
-struct linux_recvfrom_args {
- int s;
- l_uintptr_t buf;
- int len;
- int flags;
- l_uintptr_t from;
- l_uintptr_t fromlen;
-};
-
-struct linux_sendmsg_args {
- int s;
- l_uintptr_t msg;
- int flags;
-};
-
-struct linux_recvmsg_args {
- int s;
- l_uintptr_t msg;
- int flags;
-};
-
-struct linux_shutdown_args {
- int s;
- int how;
-};
-
-struct linux_setsockopt_args {
- int s;
- int level;
- int optname;
- l_uintptr_t optval;
- int optlen;
-};
-
-struct linux_getsockopt_args {
- int s;
- int level;
- int optname;
- l_uintptr_t optval;
- l_uintptr_t optlen;
-};
-
-int linux_socket(struct thread *td, struct linux_socket_args *args);
-int linux_bind(struct thread *td, struct linux_bind_args *args);
-int linux_connect(struct thread *, struct linux_connect_args *);
-int linux_listen(struct thread *td, struct linux_listen_args *args);
int linux_accept(struct thread *td, struct linux_accept_args *args);
-int linux_accept4(struct thread *td, struct linux_accept4_args *args);
-int linux_getsockname(struct thread *td, struct linux_getsockname_args *args);
-int linux_getpeername(struct thread *td, struct linux_getpeername_args *args);
-int linux_socketpair(struct thread *td, struct linux_socketpair_args *args);
-int linux_sendto(struct thread *td, struct linux_sendto_args *args);
-int linux_recvfrom(struct thread *td, struct linux_recvfrom_args *args);
-int linux_sendmsg(struct thread *td, struct linux_sendmsg_args *args);
-int linux_recvmsg(struct thread *td, struct linux_recvmsg_args *args);
-int linux_shutdown(struct thread *td, struct linux_shutdown_args *args);
-int linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args);
-int linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args);
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
+
+
/* Operations for socketcall */
#define LINUX_SOCKET 1
OpenPOWER on IntegriCloud