mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Linux: uses the standard /sys/firmware/devicetree/base instead of the outdated /proc/device-tree
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
#include "common/io.h"
|
||||
#include "common/smbiosHelper.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
const char* ffDetectBoard(FFBoardResult* board)
|
||||
{
|
||||
if (ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_name", "/sys/class/dmi/id/board_name", &board->name))
|
||||
@@ -12,11 +10,17 @@ const char* ffDetectBoard(FFBoardResult* board)
|
||||
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_vendor", "/sys/class/dmi/id/board_vendor", &board->vendor);
|
||||
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_version", "/sys/class/dmi/id/board_version", &board->version);
|
||||
}
|
||||
else if (ffReadFileBuffer("/proc/device-tree/board", &board->name))
|
||||
else if (ffReadFileBuffer("/sys/firmware/devicetree/base/smbios/smbios/baseboard/product", &board->name))
|
||||
{
|
||||
ffStrbufTrimRight(&board->name, '\0');
|
||||
if (ffReadFileBuffer("/sys/firmware/devicetree/base/smbios/smbios/baseboard/manufacturer", &board->vendor))
|
||||
ffStrbufTrimRight(&board->vendor, '\0');
|
||||
}
|
||||
else if (ffReadFileBuffer("/sys/firmware/devicetree/base/board", &board->name))
|
||||
{
|
||||
ffStrbufTrimRightSpace(&board->name);
|
||||
}
|
||||
else if (ffReadFileBuffer("/proc/device-tree/compatible", &board->vendor))
|
||||
else if (ffReadFileBuffer("/sys/firmware/devicetree/base/compatible", &board->vendor))
|
||||
{
|
||||
uint32_t comma = ffStrbufFirstIndexC(&board->vendor, ',');
|
||||
if (comma < board->vendor.length)
|
||||
|
||||
@@ -23,17 +23,17 @@ const char* ffDetectChassis(FFChassisResult* result)
|
||||
{
|
||||
// Available on Asahi Linux
|
||||
uint32_t chassisType = 0;
|
||||
if (ffReadFileData("/proc/device-tree/smbios/smbios/chassis/chassis-type", sizeof(chassisType), &chassisType)) // big endian
|
||||
if (ffReadFileData("/sys/firmware/devicetree/base/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)
|
||||
if(ffReadFileBuffer("/sys/firmware/devicetree/base/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)
|
||||
else if(ffReadFileBuffer("/sys/firmware/devicetree/base/chassis-type", &result->type) && result->type.length > 0)
|
||||
{
|
||||
ffStrbufTrimRight(&result->type, '\0');
|
||||
result->type.chars[0] = (char) toupper(result->type.chars[0]);
|
||||
|
||||
@@ -741,7 +741,7 @@ FF_MAYBE_UNUSED static void detectSocName(FFCPUResult* cpu)
|
||||
|
||||
// [x-vendor,x-model\0]*N
|
||||
char content[512];
|
||||
ssize_t length = ffReadFileData("/proc/device-tree/compatible", ARRAY_SIZE(content), content);
|
||||
ssize_t length = ffReadFileData("/sys/firmware/devicetree/base/compatible", ARRAY_SIZE(content), content);
|
||||
if (length < 4) return; // v,m\0
|
||||
|
||||
if (content[length - 1] != '\0') return; // must end with \0
|
||||
|
||||
Reference in New Issue
Block a user