~ruther/guix-local

23e525e1097f6f993aecd4f0b14d518546b876a4 — Mathieu Othacehe 9 years ago c5cd4fa
syscalls: Add load-linux-module.

* guix/build/syscalls.scm (load-linux-module): New procedure. Reimplemented
from guile-linux-syscalls.patch.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
1 files changed, 12 insertions(+), 0 deletions(-)

M guix/build/syscalls.scm
M guix/build/syscalls.scm => guix/build/syscalls.scm +12 -0
@@ 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."