From f703d9ac8956d2cd404e2e3ddc315f92b2e46fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 20 Nov 2025 18:18:25 +0800 Subject: [PATCH] Zpool: simplifies implementation by dropping platform-specific code --- CMakeLists.txt | 30 +------------------ src/common/init.c | 3 -- src/detection/zpool/libzfs_simplified.h | 2 +- .../zpool/{zpool_linux.c => zpool.c} | 1 - src/detection/zpool/zpool_nosupport.c | 6 ---- 5 files changed, 2 insertions(+), 40 deletions(-) rename src/detection/zpool/{zpool_linux.c => zpool.c} (99%) delete mode 100644 src/detection/zpool/zpool_nosupport.c diff --git a/CMakeLists.txt b/CMakeLists.txt index e1fe347ef..3890e73df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,7 +92,6 @@ cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF) cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF) cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly OR Haiku OR GNU" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) -cmake_dependent_option(ENABLE_LIBZFS "Enable libzfs" ON "LINUX OR FreeBSD OR SunOS OR NetBSD" OFF) cmake_dependent_option(ENABLE_PCIACCESS "Enable libpciaccess" ON "GNU" OFF) option(ENABLE_ZLIB "Enable zlib" ON) @@ -410,6 +409,7 @@ set(LIBFASTFETCH_SRC src/detection/version/version.c src/detection/vulkan/vulkan.c src/detection/weather/weather.c + src/detection/zpool/zpool.c src/logo/builtin.c src/logo/image/im6.c src/logo/image/im7.c @@ -582,7 +582,6 @@ if(LINUX) src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_linux.c - src/detection/zpool/zpool_linux.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c ) @@ -656,7 +655,6 @@ elseif(ANDROID) src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_android.c - src/detection/zpool/zpool_nosupport.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c ) @@ -739,7 +737,6 @@ elseif(FreeBSD) src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_linux.c - src/detection/zpool/zpool_linux.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c ) @@ -833,7 +830,6 @@ elseif(NetBSD) src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_linux.c - src/detection/zpool/zpool_linux.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c ) @@ -916,7 +912,6 @@ elseif(OpenBSD) src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_linux.c - src/detection/zpool/zpool_nosupport.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c src/util/smbiosHelper.c @@ -986,7 +981,6 @@ elseif(APPLE) src/detection/de/de_nosupport.c src/detection/wmtheme/wmtheme_apple.m src/detection/camera/camera_apple.m - src/detection/zpool/zpool_nosupport.c src/util/apple/cf_helpers.c src/util/apple/osascript.m src/util/apple/smc_temps.c @@ -1056,7 +1050,6 @@ elseif(WIN32) src/detection/de/de_nosupport.c src/detection/wmtheme/wmtheme_windows.c src/detection/camera/camera_windows.cpp - src/detection/zpool/zpool_nosupport.c src/util/windows/getline.c src/util/windows/com.cpp src/util/windows/registry.c @@ -1145,7 +1138,6 @@ elseif(SunOS) src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_nosupport.c - src/detection/zpool/zpool_linux.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c ) @@ -1214,7 +1206,6 @@ elseif(Haiku) src/detection/de/de_nosupport.c src/detection/wmtheme/wmtheme_nosupport.c src/detection/camera/camera_nosupport.c - src/detection/zpool/zpool_nosupport.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c src/util/haiku/version.cpp @@ -1294,7 +1285,6 @@ elseif(GNU) src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_nosupport.c - src/detection/zpool/zpool_nosupport.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c ) @@ -1611,24 +1601,6 @@ ff_lib_enable(PCIACCESS "pciaccess" "pciaccess" ) -# The system is only usable on SunOS. We provide our local copy of it so it's always available. -if(ENABLE_LIBZFS) - if(BINARY_LINK_TYPE STREQUAL "dlopen") - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LIBZFS=1) - else() - set(CMAKE_REQUIRED_LIBRARIES_BACKUP ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} zfs) - check_function_exists("libzfs_init" LIBZFS_FOUND) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_BACKUP}) - if(NOT LIBZFS_FOUND) - message(STATUS "Library: missing: LIBZFS") - else() - message(STATUS "Library: found LIBZFS") - target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LIBZFS=1) - target_link_libraries(libfastfetch PRIVATE zfs) - endif() - endif() -endif() if(ENABLE_THREADS) target_compile_definitions(libfastfetch PRIVATE FF_HAVE_THREADS=1) diff --git a/src/common/init.c b/src/common/init.c index fe7544245..ce0aa41a2 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -244,9 +244,6 @@ void ffListFeatures(void) #if FF_HAVE_ELF || __sun || (__FreeBSD__ && !__DragonFly__) || __OpenBSD__ || __NetBSD__ "libelf\n" #endif - #if FF_HAVE_LIBZFS - "libzfs\n" - #endif #if FF_HAVE_DIRECTX_HEADERS "Directx Headers\n" #endif diff --git a/src/detection/zpool/libzfs_simplified.h b/src/detection/zpool/libzfs_simplified.h index 7bd41cea1..49302c16d 100644 --- a/src/detection/zpool/libzfs_simplified.h +++ b/src/detection/zpool/libzfs_simplified.h @@ -32,7 +32,7 @@ // the correct value for a property at runtime. typedef int zpool_prop_t; typedef int zprop_source_t; -typedef bool boolean_t; +typedef int boolean_t; typedef struct libzfs_handle libzfs_handle_t; typedef struct zpool_handle zpool_handle_t; diff --git a/src/detection/zpool/zpool_linux.c b/src/detection/zpool/zpool.c similarity index 99% rename from src/detection/zpool/zpool_linux.c rename to src/detection/zpool/zpool.c index c74e0bb8c..074720595 100644 --- a/src/detection/zpool/zpool_linux.c +++ b/src/detection/zpool/zpool.c @@ -3,7 +3,6 @@ #include "util/kmod.h" #ifdef __sun -#define FF_DISABLE_DLOPEN #include #else #include "libzfs_simplified.h" diff --git a/src/detection/zpool/zpool_nosupport.c b/src/detection/zpool/zpool_nosupport.c deleted file mode 100644 index f7b71a7db..000000000 --- a/src/detection/zpool/zpool_nosupport.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "zpool.h" - -const char* ffDetectZpool(FF_MAYBE_UNUSED FFlist* result /* list of FFZpoolResult */) -{ - return "Not supported on this platform"; -}