* guix/build/syscalls.scm (define-c-struct)[read]: OFFSET defaults to 0.
(unfold-interface-list): Remove second argument to 'read-ifaddrs'.
(terminal-window-size): Remove second argument to 'read-winsize'.
* guix/build/syscalls.scm (syscall->procedure): New procedure.
(mount, umount, swapon, swapoff, clone, pivot-root): Use it.
(clone): Add case for nonexistent syscall id.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* guix/build/syscalls.scm (terminal-columns): Call
'terminal-window-size' only when PORT is a file port.
* tests/syscalls.scm ("terminal-columns non-file port"): New test.
* guix/build/syscalls.scm (TIOCGWINSZ): New macro.
(<window-size>): New record type.
(winsize): New C struct.
(winsize-struct): New variable.
(terminal-window-size, terminal-columns): New procedures.
This fixes interfaces with a dash or other characters being ignored.
Suggested by Jookia <166291@gmail.com>.
* guix/build/syscalls.scm (%interface-line): Use [[:graph:]] instead
of [[:alnum:]].
Fixes <http://bugs.gnu.org/21694>.
* guix/build/syscalls.scm (clone): Change 'syscall' parameter types to
LONG, UNSIGNED-LONG, or '*; make sure it has 6 parameters. Adjust
caller accordingly.
The intent is to make 'clone' behave a lot more like 'primitive-fork', which
calls clone(2) with SIGCHLD, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTID
flags. Notably, running 'clone' at the REPL without these flags would break
the REPL beyond repair.
* guix/build/syscalls.scm (CLONE_CHILD_CLEARTID, CLONE_CHILD_SETTID): New
variables.
* gnu/build/linux-container.scm (namespaces->bit-mask): Add
CLONE_CHILD_CLEARTID and CLONE_CHILD_SETTID to bit mask.
On systems with a glibc prior to 2.14, the 'setns' function is not available.
Thanks to Eric Bavier for reporting the issue.
* guix/build/syscalls.scm (setns): Wrap with 'false-if-exception'.
Based on discussions with Rohan Prinja <rohan.prinja@gmail.com>.
* guix/build/syscalls.scm (<interface>): New record type.
(write-interface, values->interface, unfold-interface-list,
network-interfaces, free-ifaddrs): New procedures.
(ifaddrs): New C struct.
(%struct-ifaddrs-type, %sizeof-ifaddrs): New macros.
* tests/syscalls.scm ("network-interfaces returns one or more interfaces",
"network-interfaces returns \"lo\""): New tests.
* guix/build/syscalls.scm (alignof*, align): New macros.
(write-types, read-types): Use 'align' to compute the actual offset to
read/write a value of TYPE0.
* guix/build/syscalls.scm (PF_PACKET, AF_PACKET): New variables.
(read-socket-address): Make 'index' optional. Return (vector FAMILY) when
FAMILY is neither AF_INET nor AF_INET6.
* guix/build/syscalls.scm (read-types): Add RETURN and VALUES parameters.
(define-c-struct): Add WRAP-FIELDS parameter and pass it to 'read-types'.
(sockaddr-in, sockaddr-in6): Add first argument that uses
'make-socket-address'.
(read-socket-address): Remove 'match' on the result of 'read-sockaddr-in'
and 'read-sockaddr-in6'.
* guix/build/syscalls.scm (network-interfaces): Update docstring.
(%interface-line): New variable.
(all-network-interfaces): New procedure.
* tests/syscalls.scm ("all-network-interfaces"): New test.
("network-interfaces"): Change to make sure the result is a subset
of (all-network-interfaces).