syscalls: Add load-linux-module.
authorMathieu Othacehe <m.othacehe@gmail.com>
Mon, 10 Apr 2017 17:18:13 +0000 (19:18 +0200)
committerLudovic Courtès <ludo@gnu.org>
Tue, 11 Apr 2017 09:13:26 +0000 (11:13 +0200)
* guix/build/syscalls.scm (load-linux-module): New procedure. Reimplemented
from guile-linux-syscalls.patch.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
guix/build/syscalls.scm

index d1f3cd6..0529c22 100644 (file)
@@ -578,6 +578,18 @@ constants from <sys/mount.h>."
                (list cmd (strerror err))
                (list err))))))
 
+(define-as-needed (load-linux-module data #:optional (options ""))
+  (let ((proc (syscall->procedure int "init_module"
+                                  (list '* unsigned-long '*))))
+    (let-values (((ret err)
+                  (proc (bytevector->pointer data)
+                        (bytevector-length data)
+                        (string->pointer options))))
+      (unless (zero? ret)
+        (throw 'system-error "load-linux-module" "~A"
+               (list (strerror err))
+               (list err))))))
+
 (define (kernel? pid)
   "Return #t if PID designates a \"kernel thread\" rather than a normal
 user-land process."