Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/linux32/common Add pselect6(2) system call to COM...
details: https://anonhg.NetBSD.org/src/rev/8427bb03ac5e
branches: trunk
changeset: 1026523:8427bb03ac5e
user: ryo <ryo%NetBSD.org@localhost>
date: Sat Nov 27 21:15:07 2021 +0000
description:
Add pselect6(2) system call to COMPAT_LINUX32
diffstat:
sys/compat/linux32/arch/aarch64/syscalls.master | 9 ++-
sys/compat/linux32/arch/amd64/syscalls.master | 9 ++-
sys/compat/linux32/common/linux32_signal.h | 7 +-
sys/compat/linux32/common/linux32_types.h | 3 +-
sys/compat/linux32/common/linux32_unistd.c | 81 ++++++++++++++++++++++++-
5 files changed, 101 insertions(+), 8 deletions(-)
diffs (186 lines):
diff -r 062f253597fe -r 8427bb03ac5e sys/compat/linux32/arch/aarch64/syscalls.master
--- a/sys/compat/linux32/arch/aarch64/syscalls.master Sat Nov 27 20:58:16 2021 +0000
+++ b/sys/compat/linux32/arch/aarch64/syscalls.master Sat Nov 27 21:15:07 2021 +0000
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.1 2021/11/25 03:08:04 ryo Exp $
+ $NetBSD: syscalls.master,v 1.2 2021/11/27 21:15:07 ryo Exp $
; NetBSD aarch64 COMPAT_LINUX32 system call name/number "master" file.
;
@@ -584,7 +584,12 @@
linux_umode_t mode); }
334 STD { int|linux32_sys||faccessat(int fd, netbsd32_charp path, \
int amode); }
-335 UNIMPL pselect6
+335 STD { int|linux32_sys||pselect6(int nfds, \
+ netbsd32_fd_setp_t readfds, \
+ netbsd32_fd_setp_t writefds, \
+ netbsd32_fd_setp_t exceptfds, \
+ linux32_timespecp_t timeout, \
+ linux32_sized_sigsetp_t ss); }
336 STD { int|linux32_sys||ppoll(netbsd32_pollfdp_t fds, u_int nfds, \
linux32_timespecp_t timeout, linux32_sigsetp_t sigset); }
337 UNIMPL unshare
diff -r 062f253597fe -r 8427bb03ac5e sys/compat/linux32/arch/amd64/syscalls.master
--- a/sys/compat/linux32/arch/amd64/syscalls.master Sat Nov 27 20:58:16 2021 +0000
+++ b/sys/compat/linux32/arch/amd64/syscalls.master Sat Nov 27 21:15:07 2021 +0000
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.75 2021/09/20 02:20:03 thorpej Exp $
+ $NetBSD: syscalls.master,v 1.76 2021/11/27 21:15:07 ryo Exp $
; NetBSD i386 COMPAT_LINUX32 system call name/number "master" file.
; (See syscalls.conf to see what it is processed into.)
@@ -527,7 +527,12 @@
linux_umode_t mode); }
307 STD { int|linux32_sys||faccessat(int fd, netbsd32_charp path, \
int amode); }
-308 UNIMPL pselect6
+308 STD { int|linux32_sys||pselect6(int nfds, \
+ netbsd32_fd_setp_t readfds, \
+ netbsd32_fd_setp_t writefds, \
+ netbsd32_fd_setp_t exceptfds, \
+ linux32_timespecp_t timeout, \
+ linux32_sized_sigsetp_t ss); }
309 STD { int|linux32_sys||ppoll(netbsd32_pollfdp_t fds, u_int nfds, \
linux32_timespecp_t timeout, linux32_sigsetp_t sigset); }
310 UNIMPL unshare
diff -r 062f253597fe -r 8427bb03ac5e sys/compat/linux32/common/linux32_signal.h
--- a/sys/compat/linux32/common/linux32_signal.h Sat Nov 27 20:58:16 2021 +0000
+++ b/sys/compat/linux32/common/linux32_signal.h Sat Nov 27 21:15:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_signal.h,v 1.5 2021/11/25 03:08:04 ryo Exp $ */
+/* $NetBSD: linux32_signal.h,v 1.6 2021/11/27 21:15:07 ryo Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -42,6 +42,11 @@
#error Undefined linux32_signal.h machine type.
#endif
+typedef struct {
+ linux32_sigsetp_t ss;
+ netbsd32_size_t ss_len;
+} linux32_sized_sigset_t;
+
void linux32_to_native_sigset(sigset_t *, const linux32_sigset_t *);
void native_to_linux32_sigset(linux32_sigset_t *, const sigset_t *);
int linux32_to_native_sigflags(const unsigned long);
diff -r 062f253597fe -r 8427bb03ac5e sys/compat/linux32/common/linux32_types.h
--- a/sys/compat/linux32/common/linux32_types.h Sat Nov 27 20:58:16 2021 +0000
+++ b/sys/compat/linux32/common/linux32_types.h Sat Nov 27 21:15:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_types.h,v 1.17 2021/11/25 03:08:04 ryo Exp $ */
+/* $NetBSD: linux32_types.h,v 1.18 2021/11/27 21:15:07 ryo Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -54,6 +54,7 @@
typedef netbsd32_pointer_t linux32_statxp;
typedef netbsd32_pointer_t linux32_sigactionp_t;
typedef netbsd32_pointer_t linux32_sigsetp_t;
+typedef netbsd32_pointer_t linux32_sized_sigsetp_t;
typedef netbsd32_pointer_t linux32___sysctlp_t;
typedef netbsd32_pointer_t linux32_direntp_t;
typedef netbsd32_pointer_t linux32_dirent64p_t;
diff -r 062f253597fe -r 8427bb03ac5e sys/compat/linux32/common/linux32_unistd.c
--- a/sys/compat/linux32/common/linux32_unistd.c Sat Nov 27 20:58:16 2021 +0000
+++ b/sys/compat/linux32/common/linux32_unistd.c Sat Nov 27 21:15:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_unistd.c,v 1.43 2021/11/25 03:08:04 ryo Exp $ */
+/* $NetBSD: linux32_unistd.c,v 1.44 2021/11/27 21:15:07 ryo Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.43 2021/11/25 03:08:04 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.44 2021/11/27 21:15:07 ryo Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -227,6 +227,83 @@
}
int
+linux32_sys_pselect6(struct lwp *l, const struct linux32_sys_pselect6_args *uap,
+ register_t *retval)
+{
+ /* {
+ syscallarg(int) nfds;
+ syscallarg(netbsd32_fd_setp_t) readfds;
+ syscallarg(netbsd32_fd_setp_t) writefds;
+ syscallarg(netbsd32_fd_setp_t) exceptfds;
+ syscallarg(linux32_timespecp_t) timeout;
+ syscallarg(linux32_sized_sigsetp_t) ss;
+ } */
+ struct timespec uts, ts0, ts1, *tsp;
+ linux32_sized_sigset_t lsss;
+ struct linux32_timespec lts;
+ linux32_sigset_t lss;
+ sigset_t *ssp;
+ sigset_t ss;
+ int error;
+ void *p;
+
+ ssp = NULL;
+ if ((p = SCARG_P32(uap, ss)) != NULL) {
+ if ((error = copyin(p, &lsss, sizeof(lsss))) != 0)
+ return (error);
+ if (lsss.ss_len != sizeof(lss))
+ return (EINVAL);
+ if ((p = NETBSD32PTR64(lsss.ss)) != NULL) {
+ if ((error = copyin(p, &lss, sizeof(lss))) != 0)
+ return (error);
+ linux32_to_native_sigset(&ss, &lss);
+ ssp = &ss;
+ }
+ }
+
+ if ((p = SCARG_P32(uap, timeout)) != NULL) {
+ error = copyin(p, <s, sizeof(lts));
+ if (error != 0)
+ return (error);
+ linux32_to_native_timespec(&uts, <s);
+
+ if (itimespecfix(&uts))
+ return (EINVAL);
+
+ nanotime(&ts0);
+ tsp = &uts;
+ } else {
+ tsp = NULL;
+ }
+
+ error = selcommon(retval, SCARG(uap, nfds), SCARG_P32(uap, readfds),
+ SCARG_P32(uap, writefds), SCARG_P32(uap, exceptfds), tsp, ssp);
+
+ if (error == 0 && tsp != NULL) {
+ if (retval != 0) {
+ /*
+ * Compute how much time was left of the timeout,
+ * by subtracting the current time and the time
+ * before we started the call, and subtracting
+ * that result from the user-supplied value.
+ */
+ nanotime(&ts1);
+ timespecsub(&ts1, &ts0, &ts1);
+ timespecsub(&uts, &ts1, &uts);
+ if (uts.tv_sec < 0)
+ timespecclear(&uts);
+ } else {
+ timespecclear(&uts);
+ }
+
+ native_to_linux32_timespec(<s, &uts);
+ error = copyout(<s, SCARG_P32(uap, timeout), sizeof(lts));
+ }
+
+ return (error);
+}
+
+int
linux32_sys_pipe(struct lwp *l, const struct linux32_sys_pipe_args *uap,
register_t *retval)
{
Home |
Main Index |
Thread Index |
Old Index