Chassis (Linux): uses /proc/device-tree/smbios if available

This commit is contained in:
Carter Li
2026-01-20 08:59:22 +08:00
parent 3b9a91e8af
commit 927d44d919
+19 -5
View File
@@ -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;
}