diff mbox series

[bug#60129,1/2] activation: Firmware activation handles missing support in kernel.

Message ID 20221216221534.14500-1-marius@gnu.org
State New
Headers show
Series VM-optimized Linux-Libre variant | expand

Commit Message

Marius Bakke Dec. 16, 2022, 10:15 p.m. UTC
* gnu/build/activation.scm (activate-firmware): Check if firmware loading is
enabled before attempting to use it.
---
 gnu/build/activation.scm | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Tobias Geerinckx-Rice Dec. 16, 2022, 11:40 p.m. UTC | #1
Marius Bakke 写道:
> +  (when (file-exists? 
> "/sys/module/firmware_class/parameters/path")
> +    (call-with-output-file 
> "/sys/module/firmware_class/parameters/path"

LGTM (Let-binding Gets This Merged).

Kind regards,

T G-R
Marius Bakke Dec. 17, 2022, 4:10 p.m. UTC | #2
Tobias Geerinckx-Rice <me@tobias.gr> skriver:

> Marius Bakke 写道:
>> +  (when (file-exists? 
>> "/sys/module/firmware_class/parameters/path")
>> +    (call-with-output-file 
>> "/sys/module/firmware_class/parameters/path"
>
> LGTM (Let-binding Gets This Merged).

Heh :-)

Pushed in 4d94cdf69889043dd8d9b1305f5f3946ec0f8ff6.
diff mbox series

Patch

diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm
index 10c9045740..af1aa0f4c4 100644
--- a/gnu/build/activation.scm
+++ b/gnu/build/activation.scm
@@ -363,9 +363,12 @@  (define (activate-firmware directory)
   "Tell the kernel to look for device firmware under DIRECTORY.  This
 mechanism bypasses udev: it allows Linux to handle firmware loading directly
 by itself, without having to resort to a \"user helper\"."
-  (call-with-output-file "/sys/module/firmware_class/parameters/path"
-    (lambda (port)
-      (display directory port))))
+  ;; If the kernel was built without firmware loading support, this file
+  ;; does not exist.  Do nothing in that case.
+  (when (file-exists? "/sys/module/firmware_class/parameters/path")
+    (call-with-output-file "/sys/module/firmware_class/parameters/path"
+      (lambda (port)
+        (display directory port)))))
 
 (define (activate-ptrace-attach)
   "Allow users to PTRACE_ATTACH their own processes.