aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2025-05-14 15:37:01 +0900
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2025-05-14 22:10:44 +0900
commit3bb6147fdcba173708da33cc7d33124ebc639e56 (patch)
tree035f6547974699810288b919c42066ddfb085d31
parent9b281fd484ceef8bbb31c776231c544d7b8044fb (diff)
downloadguix-3bb6147fdcba173708da33cc7d33124ebc639e56.tar.gz
guix-3bb6147fdcba173708da33cc7d33124ebc639e56.zip
services: udev: Also create subsystem nodes at boot.
This is a more correct fix to CDROM/DVDROM events/auto-mounting than was made in the now-reverted commit 670724edcfe7d ("gnu: eudev: Fix optical discs detection/auto-mounting.") This changes causes the 60-block.rules udev rules file shipped with eudev to correctly set the default polling period to 2000 ms on block devices, which is necessary for kernel events to be fired for CDROM drives for example. To validate it is set: # cat /sys/module/block/parameters/events_dfl_poll_msecs 2000 Before, it would return 0. * gnu/services/base.scm (udev-shepherd-service): <#:start>: Add a 'udevadm trigger --change=add --type=subsystems' invocation, so that it also creates subsystem nodes, as done in Void Linux or LinuxFromScratch init scripts for example. * gnu/tests/base.scm (run-basic-test): Add test. Fixes: <https://issues.guix.gnu.org/35584> Change-Id: Idc0eb5640163b27e41b72cc0c1885412a60805c1
-rw-r--r--gnu/services/base.scm15
-rw-r--r--gnu/tests/base.scm15
2 files changed, 23 insertions, 7 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index dfb96b1f0c..5a3dd2f555 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2740,19 +2740,22 @@ item of PACKAGES."
(cons*
(string-append "LINUX_MODULE_DIRECTORY="
(getenv "LINUX_MODULE_DIRECTORY"))
- (default-environment-variables)))))
+ (default-environment-variables))))
+ (udevadm #$(file-append udev "/bin/udevadm")))
;; Wait until udevd is up and running. This appears to
;; be needed so that the events triggered below are
;; actually handled.
(wait-for-udevd)
- ;; Trigger device node creation.
- (system* #$(file-append udev "/bin/udevadm")
- "trigger" "--action=add")
+ ;; Trigger device and subsystem nodes creation. Note that as
+ ;; of eudev v3.2.14, it is missing the '--type=all' found in
+ ;; systemd.
+ (system* udevadm "trigger" "--action=add" "--type=devices")
+ (system* udevadm "trigger" "--action=add" "--type=subsystems")
;; Wait for things to settle down.
- (system* #$(file-append udev "/bin/udevadm")
- "settle")
+ (system* udevadm "settle")
+
pid))))
(stop #~(make-kill-destructor))
diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm
index 20fc848e5c..f28c610ccb 100644
--- a/gnu/tests/base.scm
+++ b/gnu/tests/base.scm
@@ -1,7 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016-2020, 2022, 2024-2025 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
-;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2022, 2025 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2022 Marius Bakke <marius@gnu.org>
;;; Copyright © 2024 Dariqq <dariqq@posteo.net>
;;;
@@ -546,6 +546,19 @@ info --version")
#$(operating-system-host-name os)))))
#:ocr #$(file-append ocrad "/bin/ocrad")))
+ (test-equal "block devices have correct default polling value"
+ "2000"
+ ;; This tests that the 'udevadm trigger' correctly creates the
+ ;; subsystems nodes, by checking that the standard 60-block.rules
+ ;; udev rules was applied.
+ (marionette-eval
+ '(begin
+ (use-modules (ice-9 textual-ports))
+ (call-with-input-file
+ "/sys/module/block/parameters/events_dfl_poll_msecs"
+ (compose string-trim-right get-string-all)))
+ marionette))
+
(test-end))))
(gexp->derivation name test))