From 927d44d9191835a0ec3e469b81cf7d727407701f Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 20 Jan 2026 08:59:22 +0800 Subject: [PATCH] Chassis (Linux): uses `/proc/device-tree/smbios` if available --- src/detection/chassis/chassis_linux.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/detection/chassis/chassis_linux.c b/src/detection/chassis/chassis_linux.c index ce2b14eaf..4180629ee 100644 --- a/src/detection/chassis/chassis_linux.c +++ b/src/detection/chassis/chassis_linux.c @@ -16,14 +16,28 @@ const char* ffDetectChassis(FFChassisResult* result) { const char* typeStr = ffChassisTypeToString((uint32_t) ffStrbufToUInt(&result->type, 9999)); if(typeStr) - ffStrbufSetS(&result->type, typeStr); + ffStrbufSetStatic(&result->type, typeStr); } } - - else if(ffReadFileBuffer("/proc/device-tree/chassis-type", &result->type) && result->type.length > 0) + else { - ffStrbufTrimRight(&result->type, '\0'); - result->type.chars[0] = (char) toupper(result->type.chars[0]); + // Available on Asahi Linux + uint32_t chassisType = 0; + if (ffReadFileData("/proc/device-tree/smbios/smbios/chassis/chassis-type", sizeof(chassisType), &chassisType)) // big endian + { + chassisType = __builtin_bswap32(chassisType); + const char* typeStr = ffChassisTypeToString(chassisType); + if(typeStr) + ffStrbufSetStatic(&result->type, typeStr); + + if(ffReadFileBuffer("/proc/device-tree/smbios/smbios/chassis/manufacturer", &result->vendor) && result->vendor.length > 0) + ffStrbufTrimRight(&result->vendor, '\0'); + } + else if(ffReadFileBuffer("/proc/device-tree/chassis-type", &result->type) && result->type.length > 0) + { + ffStrbufTrimRight(&result->type, '\0'); + result->type.chars[0] = (char) toupper(result->type.chars[0]); + } } return NULL; }