services/base: Only remount read-write if needed in run-with-writable-store.

* gnu/services/base.scm (run-with-writable-store): Make it a no-op when
the store is already writable (useful for testing).

Change-Id: If598638e9d3eeac242c265cba77f27e4a15f8d9b
This commit is contained in:
Maxim Cournoyer 2025-10-10 11:42:46 +09:00
parent 8cdc7108c1
commit 1d77413c56
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -1939,10 +1939,9 @@ read-only via %IMMUTABLE-STORE (this wrapper must run as root)."
(define (ensure-writable-store store)
;; Create a new mount namespace and remount STORE with
;; write permissions if it's read-only.
(unshare CLONE_NEWNS)
(let ((fs (statfs store)))
(unless (zero? (logand (file-system-mount-flags fs)
ST_RDONLY))
(when (logand (file-system-mount-flags fs) ST_RDONLY)
(unshare CLONE_NEWNS)
(mount store store "none"
(logior MS_BIND MS_REMOUNT)))))