Subject: [PATCH 3/3] guix: gc: Support for the Hurd.

From: "Jan (janneke) Nieuwenhuizen" <[email-masked]>
Date: Thu, 25 Jun 2020 22:38:50 +0200

* guix/store/roots.scm (proc-environ-roots): Handle EIO, for the Hurd.
* gnu/build/hurd-boot.scm (set-hurd-device-translators): Mount /proc.  Add
symlink to /etc/mtab.  Remove duplicate calls to 'scope'.
---
 gnu/build/hurd-boot.scm | 21 ++++++++++++++-------
 guix/store/roots.scm    | 13 ++++++++++---
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/gnu/build/hurd-boot.scm b/gnu/build/hurd-boot.scm
index aea2ac3307..2db99cdcce 100644
--- a/gnu/build/hurd-boot.scm
+++ b/gnu/build/hurd-boot.scm
@@ -191,7 +191,8 @@ set."
                                   "10.0.2.15" ;the default QEMU guest IP
                                   "--netmask" "255.255.255.0"
                                   "--gateway" "10.0.2.2"
-                                  "--ipv6" "/servers/socket/16"))))
+                                  "--ipv6" "/servers/socket/16"))
+      ("proc"                    ("/hurd/procfs" "--stat-mode=444"))))
 
   (define devices
     '(("dev/full"    ("/hurd/null"     "--full")            #o666)
@@ -232,17 +233,23 @@ set."
                                                             #o666)))
 
   (for-each scope-set-translator servers)
-  (mkdir* (scope "dev/vcs/1"))
-  (mkdir* (scope "dev/vcs/2"))
-  (mkdir* (scope "dev/vcs/2"))
-  (rename-file (scope "/dev/console") (scope "/dev/console-"))
+  (mkdir* "dev/vcs/1")
+  (mkdir* "dev/vcs/2")
+  (mkdir* "dev/vcs/2")
+  (rename-file (scope "/dev/console") (scope "dev/console-"))
   (for-each scope-set-translator devices)
 
   (false-if-EEXIST (symlink "/dev/random" (scope "dev/urandom")))
-  (mkdir* (scope "dev/fd"))
+  (mkdir* "dev/fd")
   (false-if-EEXIST (symlink "/dev/fd/0" (scope "dev/stdin")))
   (false-if-EEXIST (symlink "/dev/fd/1" (scope "dev/stdout")))
-  (false-if-EEXIST (symlink "/dev/fd/2" (scope "dev/stderr"))))
+  (false-if-EEXIST (symlink "/dev/fd/2" (scope "dev/stderr")))
+
+  ;; Make sure /etc/mtab is a symlink to /proc/mounts.
+  (false-if-exception
+   (delete-file (scope "etc/mtab")))
+  (mkdir* (scope "etc"))
+  (symlink "/proc/mounts" (scope "etc/mtab")))
 
 
 (define* (boot-hurd-system #:key (on-error 'debug))
diff --git a/guix/store/roots.scm b/guix/store/roots.scm
index 58653507f8..9b4a05b149 100644
--- a/guix/store/roots.scm
+++ b/guix/store/roots.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2017, 2019 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -197,9 +198,15 @@ or the empty list."
     (string-append dir "/environ"))
 
   (append-map rhs-file-names
-              (split-on-nul
-               (call-with-input-file environ
-                 get-string-all))))
+              (catch 'system-error
+                (lambda _
+                  (split-on-nul
+                   (call-with-input-file environ
+                     get-string-all)))
+                (lambda args
+                  (if (= EIO (system-error-errno args))
+                      '()
+                      (apply throw args))))))
 
 (define (referenced-files)
   "Return the list of referenced store items."
-- 
Jan Nieuwenhuizen <[email-masked]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com