[bug#73494,v2,2/3] services: cleanup: Make /var/run a symlink of /run.

Message ID af5066577037c92049a2d571f36b2dc2a68ccedb.1741228110.git.hako@ultrarare.space
State New
Headers
Series tmpfs /run |

Commit Message

Hilton Chain March 6, 2025, 2:38 a.m. UTC
  * gnu/services.scm (cleanup-gexp): Make /var/run a symlink of /run.
* doc/guix.texi (File Systems): Document it.
* gnu/system/file-systems.scm (file-system-mapping->bind-mount): Use
canonicalized source path.
* gnu/services/dbus.scm (dbus-activation): Adjust accordingly.

Change-Id: I7b94d3e2fe1bef66f435e84bc77f32311dddd0ce
---
 doc/guix.texi               |  3 +++
 gnu/services.scm            |  5 +++--
 gnu/services/dbus.scm       | 31 -------------------------------
 gnu/system/file-systems.scm |  2 +-
 4 files changed, 7 insertions(+), 34 deletions(-)
  

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 70e5db4156..3cec887591 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18231,6 +18231,9 @@  File Systems
 @defvar %runtime-variable-data
 This file system is mounted as @file{/run} and contains system
 information data describing the system since it was booted.
+
+Additionally, another directory with same role, @file{/var/run}, is
+implemented as a symlink to @file{/run}.
 @end defvar
 
 @defvar %binary-format-file-system
diff --git a/gnu/services.scm b/gnu/services.scm
index ea855ad193..7805cae971 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -668,8 +668,9 @@  (define (cleanup-gexp _)
            ;; hence the 'chmod' calls.
            (mkdir "/tmp" #o1777)
            (chmod "/tmp" #o1777)
-           (mkdir "/var/run" #o755)
-           (chmod "/var/run" #o755))))))
+           ;; /run is implemented as tmpfs mounted at early boot.
+           (mkdir-p "/var")
+           (symlink "/run" "/var/run"))))))
 
 (define cleanup-service-type
   ;; Service that cleans things up in /tmp and similar.
diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
index 76e04bf221..9292172e01 100644
--- a/gnu/services/dbus.scm
+++ b/gnu/services/dbus.scm
@@ -190,37 +190,6 @@  (define (dbus-activation config)
           ;; world-readable.
           (mkdir-p/perms "/run/dbus" user #o755))
 
-        (catch 'system-error
-          (lambda ()
-            (symlink "/run/dbus" "/var/run/dbus"))
-          (lambda args
-            (let ((errno (system-error-errno args)))
-              (cond
-               ((= errno EEXIST)
-                (let ((existing-name
-                       (false-if-exception
-                        (readlink "/var/run/dbus"))))
-                  (unless (equal? existing-name "/run/dbus")
-                    ;; Move the content of /var/run/dbus to /run/dbus, and
-                    ;; retry.
-                    (let ((dir (opendir "/var/run/dbus")))
-                      (let loop ((next (readdir dir)))
-                        (cond
-                         ((eof-object? next) (closedir dir))
-                         ((member next '("." "..")) (loop (readdir dir)))
-                         (else
-                          (begin
-                            (rename-file (string-append "/var/run/dbus/" next)
-                                         (string-append "/run/dbus/" next))
-                            (loop (readdir dir)))))))
-                    (rmdir "/var/run/dbus")
-                    (symlink "/run/dbus" "/var/run/dbus"))))
-               (else
-                (format (current-error-port)
-                        "Failed to symlink /run/dbus to /var/run/dbus: ~s~%"
-                        (strerror errno))
-                (error "cannot create /var/run/dbus"))))))
-
         (unless (file-exists? "/etc/machine-id")
           (format #t "creating /etc/machine-id...~%")
           (invoke (string-append #$(dbus-configuration-dbus config)
diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm
index b2766707a3..8b11489968 100644
--- a/gnu/system/file-systems.scm
+++ b/gnu/system/file-systems.scm
@@ -594,7 +594,7 @@  (define (file-system-mapping->bind-mount mapping)
     (($ <file-system-mapping> source target writable?)
      (file-system
        (mount-point target)
-       (device source)
+       (device (canonicalize-path source))
        (type "none")
        (flags (if writable?
                   '(bind-mount)