Skip to content
Snippets Groups Projects
Commit 39e336b5 authored by David Thompson's avatar David Thompson
Browse files

syscalls: setns: Skip binding if there is no such C function.

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'.
parent 12a9f4af
No related branches found
No related tags found
No related merge requests found
...@@ -328,19 +328,22 @@ (define clone ...@@ -328,19 +328,22 @@ (define clone
(proc syscall-id flags %null-pointer)))) (proc syscall-id flags %null-pointer))))
(define setns (define setns
(let* ((ptr (dynamic-func "setns" (dynamic-link))) ;; Some systems may be using an old (pre-2.14) version of glibc where there
(proc (pointer->procedure int ptr (list int int)))) ;; is no 'setns' function available.
(lambda (fdes nstype) (false-if-exception
"Reassociate the current process with the namespace specified by FDES, a (let* ((ptr (dynamic-func "setns" (dynamic-link)))
(proc (pointer->procedure int ptr (list int int))))
(lambda (fdes nstype)
"Reassociate the current process with the namespace specified by FDES, a
file descriptor obtained by opening a /proc/PID/ns/* file. NSTYPE specifies file descriptor obtained by opening a /proc/PID/ns/* file. NSTYPE specifies
which type of namespace the current process may be reassociated with, or 0 if which type of namespace the current process may be reassociated with, or 0 if
there is no such limitation." there is no such limitation."
(let ((ret (proc fdes nstype)) (let ((ret (proc fdes nstype))
(err (errno))) (err (errno)))
(unless (zero? ret) (unless (zero? ret)
(throw 'system-error "setns" "~d ~d: ~A" (throw 'system-error "setns" "~d ~d: ~A"
(list fdes nstype (strerror err)) (list fdes nstype (strerror err))
(list err))))))) (list err))))))))
(define pivot-root (define pivot-root
(let* ((ptr (dynamic-func "pivot_root" (dynamic-link))) (let* ((ptr (dynamic-func "pivot_root" (dynamic-link)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment