diff --git a/CMakeLists.txt b/CMakeLists.txt index 781888f4f..ea929c28d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,9 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") set(OpenBSD TRUE CACHE BOOL "..." FORCE) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "NetBSD") set(NetBSD TRUE CACHE BOOL "..." FORCE) +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly") + set(FreeBSD TRUE CACHE BOOL "..." FORCE) + set(DragonFly TRUE CACHE BOOL "..." FORCE) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS") set(SunOS TRUE CACHE BOOL "..." FORCE) elseif(NOT APPLE AND NOT WIN32) @@ -74,7 +77,7 @@ cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR OpenBSD OR NetBSD OR SunOS" OFF) 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" OFF) +cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly" 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" OFF) cmake_dependent_option(ENABLE_PCIACCESS "Enable libpciaccess" ON "NetBSD OR OpenBSD OR SunOS" OFF) @@ -1139,6 +1142,8 @@ elseif(APPLE) elseif(OpenBSD) target_compile_definitions(libfastfetch PUBLIC _XOPEN_SOURCE=700 _FILE_OFFSET_BITS=64 _BSD_SOURCE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/usr/X11R6/lib") # detect x11 lib path automatically +elseif(DragonFly) + target_compile_definitions(libfastfetch PUBLIC __FreeBSD__) elseif(SunOS) target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64 __EXTENSIONS__ _POSIX_C_SOURCE) elseif(NetBSD) @@ -1418,8 +1423,12 @@ elseif(FreeBSD) target_link_libraries(libfastfetch PRIVATE "m" PRIVATE "usbhid" - PRIVATE "geom" ) + if(NOT DragonFly) + target_link_libraries(libfastfetch + PRIVATE "geom" + ) + endif() elseif(OpenBSD) target_link_libraries(libfastfetch PRIVATE "m" diff --git a/src/common/init.c b/src/common/init.c index 96117c66e..8f8dfea24 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -245,7 +245,7 @@ void ffListFeatures(void) #if FF_HAVE_DDCUTIL "libddcutil\n" #endif - #if FF_HAVE_ELF || __sun || __FreeBSD__ || __OpenBSD__ || __NetBSD__ + #if FF_HAVE_ELF || __sun || (__FreeBSD__ && !__DragonFly__) || __OpenBSD__ || __NetBSD__ "libelf\n" #endif #if FF_HAVE_LIBZFS diff --git a/src/common/netif/netif_bsd.c b/src/common/netif/netif_bsd.c index b01ef2040..ee084e011 100644 --- a/src/common/netif/netif_bsd.c +++ b/src/common/netif/netif_bsd.c @@ -91,7 +91,7 @@ bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex) if (rtmsg.hdr.rtm_seq == 1 && rtmsg.hdr.rtm_pid == pid) { struct sockaddr_dl* sdl = (struct sockaddr_dl *)get_rt_address(&rtmsg.hdr, RTA_IFP); - if (sdl) + if (sdl && sdl->sdl_len) { assert(sdl->sdl_nlen <= IF_NAMESIZE); memcpy(iface, sdl->sdl_data, sdl->sdl_nlen); diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 718879999..fb5db6260 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -367,6 +367,13 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i #elif defined(__FreeBSD__) + #ifdef __DragonFly__ + #define ki_comm kp_comm + #define ki_ppid kp_ppid + #define ki_tdev kp_tdev + #define ki_flag kp_flags + #endif + struct kinfo_proc proc; size_t size = sizeof(proc); if(sysctl( diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index 228d6aa36..2997070cd 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -70,14 +70,26 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r ffStrbufTrimRight(&battery->status, ','); } + #ifdef ACPIIO_BATT_GET_BIX battio.unit = i; if (ioctl(acpifd, ACPIIO_BATT_GET_BIX, &battio) >= 0) { ffStrbufAppendS(&battery->manufacturer, battio.bix.oeminfo); ffStrbufAppendS(&battery->modelName, battio.bix.model); ffStrbufAppendS(&battery->technology, battio.bix.type); + ffStrbufAppendS(&battery->serial, battio.bix.serial); battery->cycleCount = battio.bix.cycles; } + #elif defined(ACPIIO_BATT_GET_BIF) + battio.unit = i; + if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) >= 0) + { + ffStrbufAppendS(&battery->manufacturer, battio.bif.oeminfo); + ffStrbufAppendS(&battery->modelName, battio.bif.model); + ffStrbufAppendS(&battery->technology, battio.bif.type); + ffStrbufAppendS(&battery->serial, battio.bif.serial); + } + #endif } return NULL; } diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index 9fa19e311..957314f10 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -15,6 +15,7 @@ #endif #ifdef __FreeBSD__ +#if __has_include() #include static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) @@ -51,6 +52,12 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) return NULL; } +#else +static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) +{ + return "Fastfetch was compiled without libgeom support"; +} +#endif static void detectFsInfo(struct statfs* fs, FFDisk* disk) { @@ -134,7 +141,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) if(!ffDiskMatchMountpoint(options, fs->f_mntonname)) continue; } - else if(!ffStrStartsWith(fs->f_mntfromname, "/dev/") && !ffStrEquals(fs->f_fstypename, "zfs")) + else if(!ffStrEquals(fs->f_mntonname, "/") && !ffStrStartsWith(fs->f_mntfromname, "/dev/") && !ffStrEquals(fs->f_fstypename, "zfs")) continue; #ifdef __FreeBSD__ @@ -168,10 +175,11 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) #ifdef __OpenBSD__ #define st_birthtimespec __st_birthtim #endif - + #ifndef __DragonFly__ struct stat st; if(stat(fs->f_mntonname, &st) == 0 && st.st_birthtimespec.tv_sec > 0) disk->createTime = (uint64_t)((st.st_birthtimespec.tv_sec * 1000) + (st.st_birthtimespec.tv_nsec / 1000000)); + #endif } return NULL; diff --git a/src/detection/diskio/diskio_bsd.c b/src/detection/diskio/diskio_bsd.c index 08ecb47cf..42d2ab920 100644 --- a/src/detection/diskio/diskio_bsd.c +++ b/src/detection/diskio/diskio_bsd.c @@ -1,4 +1,7 @@ #include "diskio.h" + +#if __has_include() + #include "util/stringUtils.h" #include @@ -58,3 +61,9 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) return NULL; } +#else +const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) +{ + return "Fastfetch was compiled without libgeom support"; +} +#endif diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 5502da78a..aa1f0eafd 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -257,6 +257,10 @@ static const char* getFromProcesses(FFDisplayServerResult* result) uint32_t userId = getuid(); #if __FreeBSD__ + #ifdef __DragonFly__ + #define ki_comm kp_comm + #endif + int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_UID, (int) userId}; size_t length = 0; diff --git a/src/detection/gamepad/gamepad_bsd.c b/src/detection/gamepad/gamepad_bsd.c index a84f4f42c..fa68b46fc 100644 --- a/src/detection/gamepad/gamepad_bsd.c +++ b/src/detection/gamepad/gamepad_bsd.c @@ -4,7 +4,12 @@ #include #include #include -#include + +#if __has_include() +#include // FreeBSD +#else +#include // DragonFly +#endif #define MAX_UHID_JOYS 64 diff --git a/src/detection/gpu/gpu_bsd.c b/src/detection/gpu/gpu_bsd.c index b64935df4..49218e13f 100644 --- a/src/detection/gpu/gpu_bsd.c +++ b/src/detection/gpu/gpu_bsd.c @@ -2,12 +2,14 @@ #include "common/io/io.h" #include "common/properties.h" -#include "util/mallocHelper.h" -#include "util/stringUtils.h" -#include #include #include +#if __has_include() + #include // FreeBSD +#else + #include // DragonFly +#endif const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { diff --git a/src/detection/gpu/gpu_pci.c b/src/detection/gpu/gpu_pci.c index 52dabb49c..2de51a2ca 100644 --- a/src/detection/gpu/gpu_pci.c +++ b/src/detection/gpu/gpu_pci.c @@ -4,6 +4,9 @@ #include #ifdef __FreeBSD__ #include + #ifndef _PATH_LOCALBASE + #define _PATH_LOCALBASE "/usr/local" + #endif #endif #if FF_HAVE_EMBEDDED_PCIIDS diff --git a/src/detection/keyboard/keyboard_bsd.c b/src/detection/keyboard/keyboard_bsd.c index 4f424ba70..31dc3aa24 100644 --- a/src/detection/keyboard/keyboard_bsd.c +++ b/src/detection/keyboard/keyboard_bsd.c @@ -4,7 +4,12 @@ #include #include #include -#include + +#if __has_include() + #include // FreeBSD +#else + #include // DragonFly +#endif #define MAX_UHID_JOYS 64 diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index 87d4acb2f..00e64b990 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -39,7 +39,7 @@ static const FFLocalIpNIFlag niFlagOptions[] = { { IFF_PROMISC, "PROMISC" }, { IFF_ALLMULTI, "ALLMULTI" }, { IFF_MULTICAST, "MULTICAST" }, -#if defined(__linux__) || defined(__APPLE__) || defined(__sun) +#ifdef IFF_NOTRAILERS { IFF_NOTRAILERS, "NOTRAILERS" }, #endif #ifdef __linux__ @@ -59,10 +59,10 @@ static const FFLocalIpNIFlag niFlagOptions[] = { { IFF_LINK1, "LINK1" }, { IFF_LINK2, "LINK2" }, #endif -#if defined(__FreeBSD__) || defined(__APPLE__) +#ifdef IFF_ALTPHYS { IFF_ALTPHYS, "ALTPHYS" }, #endif -#ifdef __FreeBSD__ +#ifdef IFF_CANTCONFIG { IFF_CANTCONFIG, "CANTCONFIG" }, #endif // sentinel diff --git a/src/detection/mouse/mouse_bsd.c b/src/detection/mouse/mouse_bsd.c index 6018d1893..cb99a47cf 100644 --- a/src/detection/mouse/mouse_bsd.c +++ b/src/detection/mouse/mouse_bsd.c @@ -4,7 +4,12 @@ #include #include #include -#include + +#if __has_include() +#include // FreeBSD +#else +#include // DragonFly +#endif #define MAX_UHID_JOYS 64 diff --git a/src/detection/physicaldisk/physicaldisk_bsd.c b/src/detection/physicaldisk/physicaldisk_bsd.c index 99dbaf9cc..42918ff95 100644 --- a/src/detection/physicaldisk/physicaldisk_bsd.c +++ b/src/detection/physicaldisk/physicaldisk_bsd.c @@ -1,4 +1,7 @@ #include "physicaldisk.h" + +#if __has_include() + #include "util/stringUtils.h" #include @@ -92,3 +95,9 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) return NULL; } +#else +const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) +{ + return "Fastfetch was compiled without libgeom support"; +} +#endif diff --git a/src/detection/sound/sound_bsd.c b/src/detection/sound/sound_bsd.c index 3053c14d5..4a30c5ae7 100644 --- a/src/detection/sound/sound_bsd.c +++ b/src/detection/sound/sound_bsd.c @@ -10,6 +10,9 @@ const char* ffDetectSound(FFlist* devices) char path[] = "/dev/mixer0"; int defaultDev = ffSysctlGetInt("hw.snd.default_unit", -1); + if (defaultDev == -1) + return "sysctl(hw.snd.default_unit) failed"; + for (int idev = 0; idev <= 9; ++idev) { path[strlen("/dev/mixer")] = (char) ('0' + idev); diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index f2d322b79..b8f6e1159 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -8,6 +8,9 @@ #include #ifdef __FreeBSD__ #include + #ifndef _PATH_LOCALBASE + #define _PATH_LOCALBASE "/usr/local" + #endif #elif __OpenBSD__ #define _PATH_LOCALBASE "/usr/local" #elif __NetBSD__ diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index a6bcd261a..9e3f88e1b 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -530,7 +530,7 @@ void ffInitLocalIpOptions(FFLocalIpOptions* options) ffOptionInitModuleArg(&options->moduleArgs, "󰩟"); options->showType = FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_PREFIX_LEN_BIT - #if !__ANDROID__ /*Permission denied*/ && !__OpenBSD__ /*Report invalid argument for some reason*/ + #if !__ANDROID__ /*Permission denied*/ && !__OpenBSD__ /*Report invalid argument for some reason*/ && !__DragonFly__ /*Doesn't work*/ | FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT #endif ; diff --git a/src/util/binary_linux.c b/src/util/binary_linux.c index 1d520ca3b..3b6ccca35 100644 --- a/src/util/binary_linux.c +++ b/src/util/binary_linux.c @@ -1,6 +1,6 @@ #include "binary.h" -#if defined(FF_HAVE_ELF) || defined(__sun) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) +#if defined(FF_HAVE_ELF) || defined(__sun) || (defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(__OpenBSD__) || defined(__NetBSD__) #include "common/io/io.h" #include "common/library.h"