Module Name: src Committed By: ryo Date: Sat Nov 27 21:15:07 UTC 2021
Modified Files: src/sys/compat/linux32/arch/aarch64: syscalls.master src/sys/compat/linux32/arch/amd64: syscalls.master src/sys/compat/linux32/common: linux32_signal.h linux32_types.h linux32_unistd.c Log Message: Add pselect6(2) system call to COMPAT_LINUX32 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/compat/linux32/arch/aarch64/syscalls.master cvs rdiff -u -r1.75 -r1.76 src/sys/compat/linux32/arch/amd64/syscalls.master cvs rdiff -u -r1.5 -r1.6 src/sys/compat/linux32/common/linux32_signal.h cvs rdiff -u -r1.17 -r1.18 src/sys/compat/linux32/common/linux32_types.h cvs rdiff -u -r1.43 -r1.44 src/sys/compat/linux32/common/linux32_unistd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/linux32/arch/aarch64/syscalls.master diff -u src/sys/compat/linux32/arch/aarch64/syscalls.master:1.1 src/sys/compat/linux32/arch/aarch64/syscalls.master:1.2 --- src/sys/compat/linux32/arch/aarch64/syscalls.master:1.1 Thu Nov 25 03:08:04 2021 +++ src/sys/compat/linux32/arch/aarch64/syscalls.master Sat Nov 27 21:15:07 2021 @@ -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 Index: src/sys/compat/linux32/arch/amd64/syscalls.master diff -u src/sys/compat/linux32/arch/amd64/syscalls.master:1.75 src/sys/compat/linux32/arch/amd64/syscalls.master:1.76 --- src/sys/compat/linux32/arch/amd64/syscalls.master:1.75 Mon Sep 20 02:20:03 2021 +++ src/sys/compat/linux32/arch/amd64/syscalls.master Sat Nov 27 21:15:07 2021 @@ -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 Index: src/sys/compat/linux32/common/linux32_signal.h diff -u src/sys/compat/linux32/common/linux32_signal.h:1.5 src/sys/compat/linux32/common/linux32_signal.h:1.6 --- src/sys/compat/linux32/common/linux32_signal.h:1.5 Thu Nov 25 03:08:04 2021 +++ src/sys/compat/linux32/common/linux32_signal.h Sat Nov 27 21:15:07 2021 @@ -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); Index: src/sys/compat/linux32/common/linux32_types.h diff -u src/sys/compat/linux32/common/linux32_types.h:1.17 src/sys/compat/linux32/common/linux32_types.h:1.18 --- src/sys/compat/linux32/common/linux32_types.h:1.17 Thu Nov 25 03:08:04 2021 +++ src/sys/compat/linux32/common/linux32_types.h Sat Nov 27 21:15:07 2021 @@ -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_statf 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; Index: src/sys/compat/linux32/common/linux32_unistd.c diff -u src/sys/compat/linux32/common/linux32_unistd.c:1.43 src/sys/compat/linux32/common/linux32_unistd.c:1.44 --- src/sys/compat/linux32/common/linux32_unistd.c:1.43 Thu Nov 25 03:08:04 2021 +++ src/sys/compat/linux32/common/linux32_unistd.c Sat Nov 27 21:15:07 2021 @@ -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 @@ linux32_select1(struct lwp *l, register_ } 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) {