[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26341: [PATCH 1/5] build: syscalls: Add reboot.
From: |
Mathieu Othacehe |
Subject: |
bug#26341: [PATCH 1/5] build: syscalls: Add reboot. |
Date: |
Sat, 8 Apr 2017 18:03:25 +0200 |
* guix/build/syscalls.scm (static-or-ffi): New macro. Used to dispatch between
static Guile core implementation and FFI version.
(reboot): New export procedure. Reimplemented from guile-linux-syscalls.patch.
(RB_AUTOBOOT, ..., RB_KEXEC): New exported flags replacing static Guile flags.
---
guix/build/syscalls.scm | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 4bcb2a871..af5ec4b6a 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <address@hidden>
;;; Copyright © 2015 David Thompson <address@hidden>
;;; Copyright © 2015 Mark H Weaver <address@hidden>
+;;; Copyright © 2017 Mathieu Othacehe <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -144,7 +145,15 @@
utmpx-address
login-type
utmpx-entries
- (read-utmpx-from-port . read-utmpx)))
+ (read-utmpx-from-port . read-utmpx))
+ #:replace (RB_AUTOBOOT
+ RB_HALT_SYSTEM
+ RB_ENABLED_CAD
+ RB_DISABLE_CAD
+ RB_POWER_OFF
+ RB_SW_SUSPEND
+ RB_KEXEC
+ reboot))
;;; Commentary:
;;;
@@ -409,6 +418,13 @@ the returned procedure is called."
(error (format #f "~a: syscall->procedure failed: ~s"
name args))))))
+(define-syntax-rule (static-or-ffi symbol ffi-procedure)
+ "If SYMBOL is defined in the core Guile module, return the associated
+procedure, otherwise return FFI-PROCEDURE."
+ (if (module-defined? the-scm-module symbol)
+ (module-ref the-scm-module symbol)
+ ffi-procedure))
+
;;;
;;; File systems.
@@ -547,6 +563,24 @@ constants from <sys/mount.h>."
(list device (strerror err))
(list err)))))))
+(define RB_AUTOBOOT #x01234567)
+(define RB_HALT_SYSTEM #xcdef0123)
+(define RB_ENABLED_CAD #x89abcdef)
+(define RB_DISABLE_CAD 0)
+(define RB_POWER_OFF #x4321fedc)
+(define RB_SW_SUSPEND #xd000fce2)
+(define RB_KEXEC #x45584543)
+
+(define reboot
+ (static-or-ffi
+ 'reboot
+ (let ((proc (syscall->procedure int "reboot" (list int))))
+ (lambda* (#:optional (cmd RB_AUTOBOOT))
+ (let-values (((ret err) (proc cmd)))
+ (unless (zero? ret)
+ (throw 'system-error "reboot" "~S: ~A"
+ (list cmd (strerror err))
+ (list err))))))))
(define (kernel? pid)
"Return #t if PID designates a \"kernel thread\" rather than a normal
user-land process."
--
2.12.2
- bug#26341: [PATCH] build: vm: Add missing module., (continued)
- bug#26341: [PATCH] build: vm: Add missing module., Mathieu Othacehe, 2017/04/05
- bug#26341: [PATCH] build: vm: Add missing module., Ludovic Courtès, 2017/04/05
- bug#26341: [PATCH] build: vm: Add missing module., Mathieu Othacehe, 2017/04/06
- bug#26341: [PATCH] build: vm: Add missing module., Ludovic Courtès, 2017/04/06
- bug#26341: [PATCH] build: vm: Add missing module., Ludovic Courtès, 2017/04/07
- bug#26341: [PATCH] build: vm: Add missing module., Mathieu Othacehe, 2017/04/08
- bug#26341: [PATCH] build: vm: Add missing module., Ludovic Courtès, 2017/04/05
bug#26341: [PATCH 1/2] build: syscalls: Allow mount and umount use from static Guile., Mathieu Othacehe, 2017/04/06
bug#26341: [PATCH 0/5] Fix warnings related to syscalls in static Guile., Mathieu Othacehe, 2017/04/08
- bug#26341: [PATCH 1/5] build: syscalls: Add reboot.,
Mathieu Othacehe <=
bug#26341: [PATCH 3/5] build: syscalls: Add mount and umount to #:replace list., Mathieu Othacehe, 2017/04/08
bug#26341: [PATCH 4/5] build: syscalls: Add load-linux-module., Mathieu Othacehe, 2017/04/08
bug#26341: [PATCH 5/5] build: Fix compilation warnings., Mathieu Othacehe, 2017/04/08
bug#26341: [PATCH 2/5] build: syscalls: Allow use to network-interface syscalls independently of calling context., Mathieu Othacehe, 2017/04/08
bug#26341: [PATCH 1/5] build: syscalls: Add reboot., Mathieu Othacehe, 2017/04/10