1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
From a8b620140d19aaf1de8b200b42a4f69acac449b1 Mon Sep 17 00:00:00 2001
From: Arnaud Ferraris <aferraris@debian.org>
Date: Thu, 9 Feb 2023 19:38:53 +0100
Subject: [PATCH] pd-mapper: lookup firmware files under /lib/firmware/updates
`/lib/firmware/updates` is a legitimate location for firmware files,
`pd-mapper` should look there as well and avoid crashing if it can't
find a firmware folder.
---
pd-mapper.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/pd-mapper.c b/pd-mapper.c
index 10fe039..f6742b8 100644
--- a/pd-mapper.c
+++ b/pd-mapper.c
@@ -194,6 +194,7 @@ static int pd_load_map(const char *file)
}
#define FIRMWARE_BASE "/lib/firmware/"
+#define UPDATES_DIR "updates/"
static int pd_enumerate_jsons(struct assoc *json_set)
{
@@ -244,13 +245,23 @@ static int pd_enumerate_jsons(struct assoc *json_set)
firmware_value[n] = '\0';
- if (strlen(FIRMWARE_BASE) + strlen(firmware_value) + 1 > sizeof(path))
+ if (strlen(FIRMWARE_BASE) + strlen(UPDATES_DIR) + strlen(firmware_value) + 1 > sizeof(path))
continue;
strcpy(path, FIRMWARE_BASE);
+ strcat(path, UPDATES_DIR);
strcat(path, dirname(firmware_value));
fw_dir = opendir(path);
+ if (fw_dir == NULL) {
+ strcpy(path, FIRMWARE_BASE);
+ strcat(path, firmware_value);
+
+ fw_dir = opendir(path);
+ if (fw_dir == NULL)
+ continue;
+ }
+
while ((fw_de = readdir(fw_dir)) != NULL) {
if (!strcmp(fw_de->d_name, ".") || !strcmp(fw_de->d_name, ".."))
continue;
--
2.39.1
|