From 98b9ef74cf06f764fe026ca4b5fc017d5bf6edc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 15 Aug 2023 20:10:01 +0800 Subject: [PATCH] Disk (Linux): fix label detection --- CHANGELOG.md | 3 +++ src/detection/disk/disk_linux.c | 12 ++++-------- src/modules/disk/disk.c | 5 +++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83883afcb..041f0f97f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ Changes: Features: * Add `--key-width` for aligning the left edge of values +Bugfixes: +* Fix label detection (Disk, Linux) + # 2.0.0-beta Fastfetch v2 introduces a new configuration file format: JSON config. Please refer to for details. diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index afde1887e..424107331 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -122,20 +122,16 @@ static void detectName(FFDisk* disk, const FFstrbuf* device) FF_STRBUF_AUTO_DESTROY basePath = ffStrbufCreate(); - //Try partlabel first - ffStrbufSetS(&basePath, "/dev/disk/by-partlabel/"); + //Try label first + ffStrbufSetS(&basePath, "/dev/disk/by-label/"); detectNameFromPath(disk, &deviceStat, &basePath); - //Try label second if(disk->name.length == 0) { - ffStrbufSetS(&basePath, "/dev/disk/by-label/"); + //Try partlabel second + ffStrbufSetS(&basePath, "/dev/disk/by-partlabel/"); detectNameFromPath(disk, &deviceStat, &basePath); } - - //Use the mountpoint as a last resort - if(disk->name.length == 0) - ffStrbufAppend(&disk->name, &disk->mountpoint); } #ifdef __ANDROID__ diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index 151596c27..8346f38a4 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -34,8 +34,9 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) } else { - ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountpoint} + ffParseFormatString(&key, &options->moduleArgs.key, 2, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountpoint}, + {FF_FORMAT_ARG_TYPE_STRBUF, &disk->name}, }); }