summaryrefslogtreecommitdiff
path: root/gnu/build
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/build')
-rw-r--r--gnu/build/linux-boot.scm73
1 files changed, 72 insertions, 1 deletions
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 61fa6716dba..e0743eae55a 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -46,7 +46,26 @@
46 make-static-device-nodes 46 make-static-device-nodes
47 configure-qemu-networking 47 configure-qemu-networking
48 48
49 boot-system)) 49 boot-system
50
51 linux-console
52
53 linux-console?
54 linux-console-device
55 linux-console-can-read?
56 linux-console-can-write?
57 linux-console-can-unblank?
58 linux-console-enabled?
59 linux-console-preferred?
60 linux-console-primary?
61 linux-console-printk?
62 linux-console-braille?
63 linux-console-safe-when-cpu-offline?
64 linux-console-major
65 linux-console-minor
66 linux-console-virtual?
67
68 read-linux-consoles))
50 69
51;;; Commentary: 70;;; Commentary:
52;;; 71;;;
@@ -675,4 +694,56 @@ the root file system...\n" root-delay)
675 (start-repl))))) 694 (start-repl)))))
676 #:on-error on-error)) 695 #:on-error on-error))
677 696
697(define-record-type <linux-console>
698 (make-linux-console device can-read? can-write? can-unblank?
699 enabled? preferred? primary? printk? braille?
700 safe-when-cpu-offline? major minor virtual?)
701 linux-console?
702 (device linux-console-device)
703 (can-read? linux-console-can-read?)
704 (can-write? linux-console-can-write?)
705 (can-unblank? linux-console-can-unblank?)
706 (enabled? linux-console-enabled?)
707 (preferred? linux-console-preferred?)
708 (primary? linux-console-primary?)
709 (printk? linux-console-printk?)
710 (braille? linux-console-braille?)
711 (safe-when-cpu-offline? linux-console-safe-when-cpu-offline?)
712 (major linux-console-major)
713 (minor linux-console-minor)
714 (virtual? linux-console-virtual?))
715
716(define* (read-linux-consoles #:optional (consoles-file "/proc/consoles"))
717 "Parses CONSOLES-FILE and returns a list of <linux-console> records."
718 (if (not (file-exists? consoles-file))
719 '()
720 (with-input-from-file consoles-file
721 (lambda ()
722 (let ((line-regex (make-regexp
723 "^([^ ]+)[ ]+(.+)[ ]+([0-9]+):([0-9]+)$"))
724 (virt-regex (make-regexp "^tty[0-9]+$")))
725 (let loop ((line (read-line))
726 (results '()))
727 (cond
728 ((eof-object? line)
729 (reverse results))
730 ((regexp-exec line-regex line)
731 => (lambda (m)
732 (let* ((dev (match:substring m 1))
733 (flags (match:substring m 2))
734 (major (string->number (match:substring m 3)))
735 (minor (string->number (match:substring m 4)))
736 (virtual? (regexp-exec virt-regex dev))
737 (has? (lambda (c)
738 (string-any (lambda (f) (char=? f c)) flags))))
739 (loop (read-line)
740 (cons (make-linux-console
741 dev
742 (has? #\R) (has? #\W) (has? #\U) (has? #\E)
743 (has? #\C) (has? #\B) (has? #\p) (has? #\b)
744 (has? #\a)
745 major minor virtual?)
746 results)))))
747 (else (loop (read-line) results)))))))))
748
678;;; linux-boot.scm ends here 749;;; linux-boot.scm ends here