From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
To: 41541@debbugs.gnu.org
Cc: "Mathieu Othacehe" <othacehe@gnu.org>, "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#41541] [PATCH 1/4] hurd-boot: Create individual translators instead of running MAKEDEV.
Date: Mon, 8 Jun 2020 14:57:59 +0200 [thread overview]
Message-ID: <20200608125802.10617-2-janneke@gnu.org> (raw)
In-Reply-To: <20200608125802.10617-1-janneke@gnu.org>
* gnu/build/hurd-boot.scm (make-hurd-device-nodes): Do not create
dev/{null,zero,full,random,urandom} mount points.
(setup-translator, xattr-translator,
showtrans-translator?, translated?, set-hurd-device-translators): New
procedures.
(boot-hurd-system): Use them instead of running MAKEDEV.
---
gnu/build/hurd-boot.scm | 172 +++++++++++++++++++++++++++++-----------
1 file changed, 125 insertions(+), 47 deletions(-)
diff --git a/gnu/build/hurd-boot.scm b/gnu/build/hurd-boot.scm
index 09326233d2..398cee1395 100644
--- a/gnu/build/hurd-boot.scm
+++ b/gnu/build/hurd-boot.scm
@@ -80,16 +80,8 @@ Return the value associated with OPTION, or #f on failure."
(string-append root (if (string-suffix? "/" root) "" "/") dir))
(mkdir (scope "dev"))
- (for-each (lambda (file)
- (call-with-output-file (scope file)
- (lambda (port)
- (display file port) ;avoid hard-linking
- (chmod port #o666))))
- '("dev/null"
- "dev/zero"
- "dev/full"
- "dev/random"
- "dev/urandom"))
+ ;; Don't create /dev/null etc just yet; the store
+ ;; messes-up the permission bits.
;; Don't create /dev/console, /dev/vcs, etc.: they are created by
;; console-run on first boot.
@@ -115,6 +107,125 @@ Return the value associated with OPTION, or #f on failure."
;; settings?
)
+(define (xattr-translator? file-name)
+ "Return true if FILE-NAME has an extended @code{gnu.translator} attribute
+set."
+ (false-if-exception
+ (not (string-null? (getxattr file-name "gnu.translator")))))
+
+(define (showtrans-translator? file-name)
+ "Return true if @file{showtrans} finds a translator installed on FILE-NAME."
+ (with-output-to-port (%make-void-port "w")
+ (lambda _
+ (with-error-to-port (%make-void-port "w")
+ (lambda _
+ (zero? (system* "showtrans" "--silent" file-name)))))))
+
+(define (translated? file-name)
+ "Return true if a translator is installed on FILE-NAME."
+ (if (string-contains %host-type "linux-gnu")
+ (xattr-translator? file-name)
+ (showtrans-translator? file-name)))
+
+(define* (setup-translator file-name command #:optional (mode #o600))
+ "Setup translator COMMAND on FILE-NAME."
+ (unless (translated? file-name)
+ (let ((dir (dirname file-name)))
+ (unless (directory-exists? dir)
+ (mkdir-p dir))
+ (unless (file-exists? file-name)
+ (call-with-output-file file-name
+ (lambda (port)
+ (display file-name port) ;avoid hard-linking
+ (chmod port mode)))))
+ (catch 'system-error
+ (lambda _
+ (apply invoke "settrans" "--create" file-name command))
+ (lambda (key . args)
+ (let ((errno (system-error-errno (cons key args))))
+ (format (current-error-port) "~a: ~a\n"
+ (strerror errno) file-name)
+ (format (current-error-port) "Ignoring...Good Luck!\n"))))))
+
+(define* (set-hurd-device-translators #:optional (root "/"))
+ "Make some of the device nodes needed on GNU/Hurd."
+
+ (define (scope dir)
+ (string-append root (if (string-suffix? "/" root) "" "/") dir))
+
+ (define scope-setup-translator
+ (match-lambda
+ ((file-name command)
+ (scope-setup-translator (list file-name command #o600)))
+ ((file-name command mode)
+ (let ((mount-point (scope file-name)))
+ (setup-translator mount-point command mode)))))
+
+ (define servers
+ '(("servers/crash-dump-core" ("/hurd/crash" "--dump-core"))
+ ("servers/crash-kill" ("/hurd/crash" "--kill"))
+ ("servers/crash-suspend" ("/hurd/crash" "--suspend"))
+ ("servers/password" ("/hurd/password"))
+ ("servers/socket/1" ("/hurd/pflocal"))
+ ("servers/socket/2" ("/hurd/pfinet"
+ "--interface" "eth0"
+ "--address"
+ "10.0.2.15" ;the default QEMU guest IP
+ "--netmask" "255.255.255.0"
+ "--gateway" "10.0.2.2"
+ "--ipv6" "/servers/socket/16"))))
+
+ (define devices
+ '(("dev/full" ("/hurd/null" "--full") #o666)
+ ("dev/null" ("/hurd/null") #o666)
+ ("dev/random" ("/hurd/random" "--seed-file" "/var/lib/random-seed")
+ #o644)
+ ("dev/zero" ("/hurd/storeio" "--store-type=zero") #o666)
+
+ ("dev/console" ("/hurd/term" "/dev/console" "device" "console"))
+
+ ("dev/klog" ("/hurd/streamio" "kmsg"))
+ ("dev/mem" ("/hurd/storeio" "--no-cache" "mem") #o660)
+ ("dev/shm" ("/hurd/tmpfs" "--mode=1777" "50%") #o644)
+ ("dev/time" ("/hurd/storeio" "--no-cache" "time") #o644)
+
+ ("dev/vcs" ("/hurd/console"))
+ ("dev/tty" ("/hurd/magic" "tty") #o666)
+
+ ("dev/tty1" ("/hurd/term" "/dev/tty1" "hurdio" "/dev/vcs/1/console")
+ #o666)
+ ("dev/tty2" ("/hurd/term" "/dev/tty2" "hurdio" "/dev/vcs/2/console")
+ #o666)
+ ("dev/tty3" ("/hurd/term" "/dev/tty3" "hurdio" "/dev/vcs/3/console")
+ #o666)
+
+ ("dev/ptyp0" ("/hurd/term" "/dev/ptyp0" "pty-master" "/dev/ttyp0")
+ #o666)
+ ("dev/ptyp1" ("/hurd/term" "/dev/ptyp1" "pty-master" "/dev/ttyp1")
+ #o666)
+ ("dev/ptyp2" ("/hurd/term" "/dev/ptyp2" "pty-master" "/dev/ttyp2")
+ #o666)
+
+ ("dev/ttyp0" ("/hurd/term" "/dev/ttyp0" "pty-slave" "/dev/ptyp0")
+ #o666)
+ ("dev/ttyp1" ("/hurd/term" "/dev/ttyp1" "pty-slave" "/dev/ptyp1")
+ #o666)
+ ("dev/ttyp2" ("/hurd/term" "/dev/ttyp2" "pty-slave" "/dev/ptyp2")
+ #o666)))
+
+ (for-each scope-setup-translator servers)
+ (false-if-exception (mkdir-p (scope "dev/vcs/1")))
+ (false-if-exception (mkdir-p (scope "dev/vcs/2")))
+ (false-if-exception (mkdir-p (scope "dev/vcs/3")))
+ (false-if-exception (rename-file "/dev/console" "/dev/console-"))
+ (for-each scope-setup-translator devices)
+
+ (false-if-exception (symlink "/dev/random" "/dev/urandom"))
+ (false-if-exception (mkdir-p "/dev/fd"))
+ (false-if-exception (symlink "/dev/fd/0" "/dev/stdin"))
+ (false-if-exception (symlink "/dev/fd/1" "/dev/stdout"))
+ (false-if-exception (symlink "/dev/fd/2" "/dev/stderr")))
+
\f
(define* (boot-hurd-system #:key (on-error 'debug))
"This procedure is meant to be called from an early RC script.
@@ -126,20 +237,9 @@ starting the Shepherd.
XXX TODO: see linux-boot.scm:boot-system.
XXX TODO: add proper file-system checking, mounting
XXX TODO: move bits to (new?) (hurd?) (activation?) services
-XXX TODO: use settrans/setxattr instead of MAKEDEV
+XXX TODO: use Linux xattr/setxattr to remove (settrans in) /libexec/RUNSYSTEM
"
- (define translators
- '(("/servers/crash-dump-core" ("/hurd/crash" "--dump-core"))
- ("/servers/crash-kill" ("/hurd/crash" "--kill"))
- ("/servers/crash-suspend" ("/hurd/crash" "--suspend"))
- ("/servers/password" ("/hurd/password"))
- ("/servers/socket/1" ("/hurd/pflocal"))
- ("/servers/socket/2" ("/hurd/pfinet" "--interface" "eth0"
- "--address" "10.0.2.15" ;the default QEMU guest IP
- "--netmask" "255.255.255.0"
- "--gateway" "10.0.2.2"
- "--ipv6" "/servers/socket/16"))))
(display "Welcome, this is GNU's early boot Guile.\n")
(display "Use '--repl' for an initrd REPL.\n\n")
@@ -147,35 +247,13 @@ XXX TODO: use settrans/setxattr instead of MAKEDEV
(call-with-error-handling
(lambda ()
- (define (translated? node)
- ;; Return true if a translator is installed on NODE.
- (with-output-to-port (%make-void-port "w")
- (lambda ()
- (with-error-to-port (%make-void-port "w")
- (lambda ()
- (zero? (system* "showtrans" "--silent" node)))))))
-
(let* ((args (command-line))
(system (find-long-option "--system" args))
(to-load (find-long-option "--load" args)))
- (format #t "Creating essential servers...\n")
- (setenv "PATH" (string-append system "/profile/bin"
- ":" system "/profile/sbin"))
- (for-each (match-lambda
- ((node command)
- (unless (translated? node)
- (mkdir-p (dirname node))
- (apply invoke "settrans" "--create" node command))))
- translators)
-
- (format #t "Creating essential device nodes...\n")
- (with-directory-excursion "/dev"
- (invoke "MAKEDEV" "--devdir=/dev" "std")
- (invoke "MAKEDEV" "--devdir=/dev" "vcs")
- (invoke "MAKEDEV" "--devdir=/dev" "tty1""tty2" "tty3" "tty4" "tty5" "tty6")
- (invoke "MAKEDEV" "--devdir=/dev" "ptyp0" "ptyp1" "ptyp2")
- (invoke "MAKEDEV" "--devdir=/dev" "console"))
+ (format #t "Setting-up essential translators...\n")
+ (setenv "PATH" (string-append system "/profile/bin"))
+ (set-hurd-device-translators)
(false-if-exception (delete-file "/hurd"))
(let ((hurd/hurd (readlink* (string-append system "/profile/hurd"))))
--
2.26.2
next prev parent reply other threads:[~2020-06-08 12:59 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-26 14:21 bug#41541: merge wip-hurd-vm Jan Nieuwenhuizen
2020-05-27 10:01 ` Mathieu Othacehe
2020-05-27 11:11 ` Jan Nieuwenhuizen
2020-05-30 14:40 ` Jan Nieuwenhuizen
2020-06-02 8:48 ` Mathieu Othacehe
2020-06-02 9:24 ` Jan Nieuwenhuizen
2020-06-02 10:16 ` Mathieu Othacehe
2020-06-02 12:23 ` Jan Nieuwenhuizen
2020-06-02 12:40 ` Ludovic Courtès
2020-06-02 13:39 ` Jan Nieuwenhuizen
2020-06-03 9:18 ` Ludovic Courtès
2020-06-03 15:22 ` Jan Nieuwenhuizen
2020-06-03 15:38 ` Mathieu Othacehe
2020-06-03 20:27 ` Jan Nieuwenhuizen
2020-06-04 9:32 ` Ludovic Courtès
2020-06-04 11:33 ` Jan Nieuwenhuizen
2020-06-05 16:08 ` Ludovic Courtès
2020-06-05 16:24 ` Jan Nieuwenhuizen
2020-06-04 13:59 ` bug#41541: [PATCH 0/9] Merge wip-hurd-vm "last review round" Jan (janneke) Nieuwenhuizen
2020-06-04 13:59 ` bug#41541: [PATCH 1/8] system: Add 'hurd' field to <operating-system> Jan (janneke) Nieuwenhuizen
2020-06-06 7:21 ` Mathieu Othacehe
2020-06-06 8:26 ` Jan Nieuwenhuizen
2020-06-06 10:45 ` [bug#41541] " Ludovic Courtès
2020-06-06 11:14 ` Jan Nieuwenhuizen
2020-06-04 13:59 ` bug#41541: [PATCH 2/8] bootloader: Extend `<menu-entry>' for multiboot Jan (janneke) Nieuwenhuizen
2020-06-06 10:48 ` [bug#41541] " Ludovic Courtès
2020-06-06 12:00 ` Jan Nieuwenhuizen
2020-06-04 13:59 ` bug#41541: [PATCH 3/8] system: Add 'multiboot-modules' field to <boot-parameters> Jan (janneke) Nieuwenhuizen
2020-06-06 7:32 ` Mathieu Othacehe
2020-06-06 10:13 ` Jan Nieuwenhuizen
2020-06-06 10:55 ` [bug#41541] " Ludovic Courtès
2020-06-07 7:39 ` Jan Nieuwenhuizen
2020-06-04 13:59 ` bug#41541: [PATCH 4/8] bootloader: grub: Add support for multiboot Jan (janneke) Nieuwenhuizen
2020-06-06 7:47 ` Mathieu Othacehe
2020-06-06 8:46 ` Jan Nieuwenhuizen
2020-06-06 10:57 ` [bug#41541] " Ludovic Courtès
2020-06-06 12:08 ` Jan Nieuwenhuizen
2020-06-04 13:59 ` bug#41541: [PATCH 5/8] system: Use 'hurd' package in label Jan (janneke) Nieuwenhuizen
2020-06-06 10:57 ` [bug#41541] " Ludovic Courtès
2020-06-04 13:59 ` bug#41541: [PATCH 6/8] system: examples: Add bare-hurd.tmpl Jan (janneke) Nieuwenhuizen
2020-06-06 7:56 ` Mathieu Othacehe
2020-06-06 10:58 ` [bug#41541] " Jan Nieuwenhuizen
2020-06-06 16:49 ` Mathieu Othacehe
2020-06-06 22:44 ` Jan Nieuwenhuizen
2020-06-06 10:59 ` Ludovic Courtès
2020-06-06 12:34 ` Jan Nieuwenhuizen
2020-06-04 13:59 ` bug#41541: [PATCH 7/8] services: hurd: Add `hurd-etc-service' Jan (janneke) Nieuwenhuizen
2020-06-06 11:08 ` [bug#41541] " Ludovic Courtès
2020-06-06 14:31 ` Jan Nieuwenhuizen
2020-06-07 20:02 ` Ludovic Courtès
2020-06-07 20:31 ` Jan Nieuwenhuizen
2020-06-04 13:59 ` bug#41541: [PATCH 8/8] system: Add `hurd-activation' Jan (janneke) Nieuwenhuizen
2020-06-06 8:03 ` Mathieu Othacehe
2020-06-06 8:54 ` Jan Nieuwenhuizen
2020-06-06 11:05 ` [bug#41541] " Ludovic Courtès
2020-06-06 14:21 ` Jan Nieuwenhuizen
2020-06-08 12:57 ` [bug#41541] [PATCH 0/4] Final wip-hurd-vm batch Jan (janneke) Nieuwenhuizen
2020-06-08 12:57 ` Jan (janneke) Nieuwenhuizen [this message]
2020-06-08 12:58 ` [bug#41541] [PATCH 2/4] system: hurd: Remove 'cross-hurd-image' hack Jan (janneke) Nieuwenhuizen
2020-06-13 10:49 ` Jan Nieuwenhuizen
2020-06-14 16:46 ` bug#41541: " Jan Nieuwenhuizen
2020-06-14 17:48 ` [bug#41541] " Mathieu Othacehe
2020-06-14 20:29 ` Ludovic Courtès
2020-06-08 12:58 ` [bug#41541] [PATCH 3/4] system: bare-hurd.tmpl: Add openssh client and service Jan (janneke) Nieuwenhuizen
2020-06-08 13:23 ` Jan Nieuwenhuizen
2020-06-13 7:24 ` Jan Nieuwenhuizen
2020-06-08 12:58 ` [bug#41541] [PATCH 4/4] hurd-boot: Use 'setxattr' instead of invoking settrans Jan (janneke) Nieuwenhuizen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200608125802.10617-2-janneke@gnu.org \
--to=janneke@gnu.org \
--cc=41541@debbugs.gnu.org \
--cc=ludo@gnu.org \
--cc=othacehe@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.