1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-24 03:35:38 +03:00
aports/community/booster/0001-generator-normalize-both-module-and-pattern-names-fr.patch
Sören Tempel 76f1ad9b6d community/booster: backport module normalization patch
Fixes loading of sd_mod module on some Alpine Kernel flavors.
2022-11-29 19:52:20 +01:00

62 lines
2.1 KiB
Diff

From 3816cfcc580090ab4bfef451968812892aaf7bdd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Tue, 29 Nov 2022 21:26:56 +0100
Subject: [PATCH] generator: normalize both module and pattern names from
modules.alias
From modprobe.d(5):
Note that module and alias names (like other module names) can
have - or _ in them: both are interchangeable throughout all the
module commands as underscore conversion happens automatically.
For this reason, we need to make sure that everywhere where module or
pattern names are compared that this comparison is always performed on a
normalized string. This commit adds several normalizations for module
and pattern names that were previously not performed.
Fixes #185
---
generator/kmod.go | 8 +++++++-
init/udev.go | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/generator/kmod.go b/generator/kmod.go
index a26e823..cfcd5a1 100644
--- a/generator/kmod.go
+++ b/generator/kmod.go
@@ -250,6 +250,12 @@ func (k *Kmod) readKernelAliases() error {
}
pattern := line[:idx]
module := line[idx+1:]
+
+ // As per modprobe.d(5), - and _ can be used
+ // interchangeably in both module and alias names.
+ pattern = normalizeModuleName(pattern)
+ module = normalizeModuleName(module)
+
k.aliases = append(k.aliases, alias{pattern, module})
}
@@ -704,7 +710,7 @@ func readDeviceAliases() (set, error) {
if err != nil {
return err
}
- al := strings.TrimSpace(string(b))
+ al := normalizeModuleName(strings.TrimSpace(string(b)))
if al == "" {
return nil
}
diff --git a/init/udev.go b/init/udev.go
index a1d2cfc..cbddd1f 100644
--- a/init/udev.go
+++ b/init/udev.go
@@ -109,7 +109,7 @@ func handleUdevEvent(ev netlink.UEvent) {
debug("udev event %+v", ev)
if modalias, ok := ev.Env["MODALIAS"]; ok {
- go func() { check(loadModalias(modalias)) }()
+ go func() { check(loadModalias(normalizeModuleName(modalias))) }()
} else if ev.Env["SUBSYSTEM"] == "block" {
go func() { check(handleBlockDeviceUevent(ev)) }()
} else if ev.Env["SUBSYSTEM"] == "net" {