-
Notifications
You must be signed in to change notification settings - Fork 1
/
0022-skip-not-present-ACPI-devices.patch
55 lines (48 loc) · 1.85 KB
/
0022-skip-not-present-ACPI-devices.patch
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
52
53
54
From 9380d230e9e307c9fe81a777eb7a421b39e47698 Mon Sep 17 00:00:00 2001
From: Auke Kok <[email protected]>
Date: Fri, 14 Jul 2017 11:33:26 -0700
Subject: [PATCH 22/38] skip not-present ACPI devices
Xen and older Qemu expose a boatload (253) ACPI devices to the guest
that are not present; these show up in sysfs but there's nothing
meaningful one can do with them.
This patch will have udev skip these devices to save the 100ms+
boot time
---
src/libsystemd/sd-device/device-enumerator.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c
index 39f769c35c..38734e0145 100644
--- a/src/libsystemd/sd-device/device-enumerator.c
+++ b/src/libsystemd/sd-device/device-enumerator.c
@@ -665,6 +665,22 @@ static bool relevant_sysfs_subdir(const struct dirent *de) {
return IN_SET(de->d_type, DT_DIR, DT_LNK);
}
+static int acpi_status_disabled(char *sysfspath) {
+ FILE *file;
+ unsigned int i;
+ char newpath[4096];
+ char line[128];
+ sprintf(newpath, "%s/status", sysfspath);
+ file = fopen(newpath, "r");
+ if (!file)
+ return 0;
+ fclose(file);
+
+ if (strstr(sysfspath, "acpi") && strstr(sysfspath, "device:"))
+ return 1;
+ return 0;
+}
+
static int enumerator_scan_dir_and_add_devices(
sd_device_enumerator *enumerator,
const char *basedir,
@@ -703,6 +719,9 @@ static int enumerator_scan_dir_and_add_devices(
(void) sprintf(syspath, "%s%s", path, de->d_name);
+ if (acpi_status_disabled(syspath))
+ continue;
+
k = sd_device_new_from_syspath(&device, syspath);
if (k < 0) {
if (k != -ENODEV)
--
2.36.1