unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] syscalls: setns: Skip binding if there is no such C function.
@ 2015-08-16 12:18 David Thompson
  2015-08-17 18:54 ` Thompson, David
  0 siblings, 1 reply; 2+ messages in thread
From: David Thompson @ 2015-08-16 12:18 UTC (permalink / raw)
  To: guix-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-syscalls-setns-Skip-binding-if-there-is-no-such-C-fu.patch --]
[-- Type: text/x-patch, Size: 2182 bytes --]

From 57faa1368cb96dd94cc32c18a0e6b63285ca8e1d Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
Date: Sun, 16 Aug 2015 08:08:34 -0400
Subject: [PATCH] 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'.
---
 guix/build/syscalls.scm | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 68f340c..fc801a5 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -328,19 +328,22 @@ are shared between the parent and child processes."
       (proc syscall-id flags %null-pointer))))
 
 (define setns
-  (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
+  ;; Some systems may be using an old (pre-2.14) version of glibc where there
+  ;; is no 'setns' function available.
+  (false-if-exception
+   (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
 which type of namespace the current process may be reassociated with, or 0 if
 there is no such limitation."
-      (let ((ret (proc fdes nstype))
-            (err (errno)))
-        (unless (zero? ret)
-          (throw 'system-error "setns" "~d ~d: ~A"
-                 (list fdes nstype (strerror err))
-                 (list err)))))))
+       (let ((ret (proc fdes nstype))
+             (err (errno)))
+         (unless (zero? ret)
+           (throw 'system-error "setns" "~d ~d: ~A"
+                  (list fdes nstype (strerror err))
+                  (list err))))))))
 
 (define pivot-root
   (let* ((ptr  (dynamic-func "pivot_root" (dynamic-link)))
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] syscalls: setns: Skip binding if there is no such C function.
  2015-08-16 12:18 [PATCH] syscalls: setns: Skip binding if there is no such C function David Thompson
@ 2015-08-17 18:54 ` Thompson, David
  0 siblings, 0 replies; 2+ messages in thread
From: Thompson, David @ 2015-08-17 18:54 UTC (permalink / raw)
  To: David Thompson; +Cc: guix-devel

Eric confirmed that this patch solved his issue so I've pushed it as
commit 39e336b.

- Dave

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-17 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-16 12:18 [PATCH] syscalls: setns: Skip binding if there is no such C function David Thompson
2015-08-17 18:54 ` Thompson, David

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).