apteryx pushed a commit to branch kernel-team
in repository guix.

commit 4acbceed261bd020fc194133e2196eb2da872240
Author: Maxim Cournoyer <maxim.courno...@gmail.com>
AuthorDate: Wed May 14 15:37:01 2025 +0900

    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
---
 gnu/services/base.scm | 15 +++++++++------
 gnu/tests/base.scm    | 15 ++++++++++++++-
 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 <l...@gnu.org>
 ;;; Copyright © 2018 Clément Lassieur <clem...@lassieur.org>
-;;; Copyright © 2022 Maxim Cournoyer <maxim.courno...@gmail.com>
+;;; Copyright © 2022, 2025 Maxim Cournoyer <maxim.courno...@gmail.com>
 ;;; Copyright © 2022 Marius Bakke <mar...@gnu.org>
 ;;; Copyright © 2024 Dariqq <dar...@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))

Reply via email to