From e6cbe6970f8e642a2229e0631eaa743fa86fcd29 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 9 Nov 2021 10:21:23 +0900 Subject: [PATCH 1/3] hostnamed: use /proc/device-tree to get chassis type From https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-firmware-ofw --- Userspace must not use the /sys/firmware/devicetree/base path directly, but instead should follow /proc/device-tree symlink. It is possible that the absolute path will change in the future, but the symlink is the stable ABI. --- Addresses the comment https://github.com/systemd/systemd/pull/20731#discussion_r744095262. --- src/hostname/hostnamed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index bcd2449861..e2c9f8ab67 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -302,7 +302,7 @@ try_acpi: } try_devicetree: - r = read_one_line_file("/sys/firmware/devicetree/base/chassis-type", &type); + r = read_one_line_file("/proc/device-tree/chassis-type", &type); if (r < 0) { log_debug_errno(r, "Failed to read device-tree chassis type, ignoring: %m"); return NULL; From c6dce5720c409129319ccd26e4d1b7f8a17cc563 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 9 Nov 2021 10:28:43 +0900 Subject: [PATCH 2/3] condition: use /proc/device-tree/ --- src/shared/condition.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/shared/condition.c b/src/shared/condition.c index 1d28f7ba57..3e6ae79553 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -509,7 +509,7 @@ static int condition_test_architecture(Condition *c, char **env) { return a == b; } -#define DTCOMPAT_FILE "/sys/firmware/devicetree/base/compatible" +#define DTCOMPAT_FILE "/proc/device-tree/compatible" static int condition_test_firmware_devicetree_compatible(const char *dtcarg) { int r; _cleanup_free_ char *dtcompat = NULL; @@ -530,11 +530,8 @@ static int condition_test_firmware_devicetree_compatible(const char *dtcarg) { return false; } - /* - * /sys/firmware/devicetree/base/compatible consists of one or more - * strings, each ending in '\0'. So the last character in dtcompat must - * be a '\0'. - */ + /* /proc/device-tree/compatible consists of one or more strings, each ending in '\0'. + * So the last character in dtcompat must be a '\0'. */ if (dtcompat[size - 1] != '\0') { log_debug("%s is in an unknown format, assuming machine is incompatible", DTCOMPAT_FILE); return false; From e2b777f821cba44067a5c5a92c89f6d7deb18f4d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 9 Nov 2021 10:31:17 +0900 Subject: [PATCH 3/3] sd-id128: use /proc/device-tree --- src/libsystemd/sd-id128/id128-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsystemd/sd-id128/id128-util.c b/src/libsystemd/sd-id128/id128-util.c index 19937110b0..7c66d1c2db 100644 --- a/src/libsystemd/sd-id128/id128-util.c +++ b/src/libsystemd/sd-id128/id128-util.c @@ -219,7 +219,7 @@ int id128_get_product(sd_id128_t *ret) { r = id128_read("/sys/class/dmi/id/product_uuid", ID128_UUID, &uuid); if (r == -ENOENT) - r = id128_read("/sys/firmware/devicetree/base/vm,uuid", ID128_UUID, &uuid); + r = id128_read("/proc/device-tree/vm,uuid", ID128_UUID, &uuid); if (r < 0) return r;