Skip to content

Commit 7611d67

Browse files
authored
Merge pull request fastfetch-cli#1931 from CarterLi/dev
Add GNU/Hurd support
2 parents f2f9b10 + bfb93cd commit 7611d67

File tree

26 files changed

+244
-76
lines changed

26 files changed

+244
-76
lines changed

CMakeLists.txt

Lines changed: 107 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
3232
set(SunOS TRUE CACHE BOOL "..." FORCE)
3333
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku")
3434
set(Haiku TRUE CACHE BOOL "..." FORCE)
35+
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
36+
set(GNU TRUE CACHE BOOL "..." FORCE)
3537
elseif(NOT APPLE AND NOT WIN32)
3638
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
3739
endif()
@@ -56,30 +58,30 @@ include(CheckIncludeFile)
5658

5759
include(CMakeDependentOption)
5860

59-
cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS OR Haiku" OFF)
60-
cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD" OFF)
61-
cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
62-
cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
63-
cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
64-
cmake_dependent_option(ENABLE_DRM_AMDGPU "Enable libdrm_amdgpu" ON "LINUX OR FreeBSD" OFF)
65-
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
66-
cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
67-
cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR Haiku" OFF)
68-
cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
69-
cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR FreeBSD OR APPLE OR OpenBSD OR NetBSD OR SunOS" OFF)
70-
cmake_dependent_option(ENABLE_RPM "Enable rpm" ON "LINUX" OFF)
71-
cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR APPLE OR WIN32 OR SunOS OR Haiku" OFF)
72-
cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR APPLE OR SunOS" OFF)
61+
cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS OR Haiku OR GNU" OFF)
62+
cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR GNU" OFF)
63+
cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR GNU" OFF)
64+
cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR GNU" OFF)
65+
cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR GNU" OFF)
66+
cmake_dependent_option(ENABLE_DRM_AMDGPU "Enable libdrm_amdgpu" ON "LINUX OR FreeBSD OR GNU" OFF)
67+
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR GNU" OFF)
68+
cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR GNU" OFF)
69+
cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR Haiku OR GNU" OFF)
70+
cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR GNU" OFF)
71+
cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR FreeBSD OR APPLE OR OpenBSD OR NetBSD OR SunOS OR GNU" OFF)
72+
cmake_dependent_option(ENABLE_RPM "Enable rpm" ON "LINUX OR GNU" OFF)
73+
cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR APPLE OR WIN32 OR SunOS OR Haiku OR GNU" OFF)
74+
cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR APPLE OR SunOS OR GNU" OFF)
7375
cmake_dependent_option(ENABLE_CHAFA "Enable chafa" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF)
7476
cmake_dependent_option(ENABLE_ZLIB "Enable zlib" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF)
75-
cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR WIN32 OR SunOS OR Haiku" OFF)
76-
cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS" OFF)
77-
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS OR Haiku" OFF)
77+
cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR WIN32 OR SunOS OR Haiku OR GNU" OFF)
78+
cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR GNU" OFF)
79+
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS OR Haiku OR GNU" OFF)
7880
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
79-
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX" OFF)
81+
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR GNU" OFF)
8082
cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
8183
cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF)
82-
cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly OR Haiku" OFF)
84+
cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly OR Haiku OR GNU" OFF)
8385
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
8486
cmake_dependent_option(ENABLE_LIBZFS "Enable libzfs" ON "LINUX OR FreeBSD OR SunOS" OFF)
8587
cmake_dependent_option(ENABLE_PCIACCESS "Enable libpciaccess" ON "NetBSD OR OpenBSD" OFF)
@@ -1192,6 +1194,84 @@ elseif(Haiku)
11921194
src/util/binary_linux.c
11931195
src/util/haiku/version.cpp
11941196
)
1197+
elseif(GNU)
1198+
list(APPEND LIBFASTFETCH_SRC
1199+
src/common/dbus.c
1200+
src/common/io/io_unix.c
1201+
src/common/netif/netif_gnu.c
1202+
src/common/networking/networking_linux.c
1203+
src/common/processing_linux.c
1204+
src/detection/battery/battery_nosupport.c
1205+
src/detection/bios/bios_nosupport.c
1206+
src/detection/board/board_nosupport.c
1207+
src/detection/bootmgr/bootmgr_nosupport.c
1208+
src/detection/brightness/brightness_nosupport.c
1209+
src/detection/btrfs/btrfs_nosupport.c
1210+
src/detection/chassis/chassis_nosupport.c
1211+
src/detection/cpu/cpu_linux.c
1212+
src/detection/cpucache/cpucache_nosupport.c
1213+
src/detection/cpuusage/cpuusage_linux.c
1214+
src/detection/cursor/cursor_linux.c
1215+
src/detection/bluetooth/bluetooth_linux.c
1216+
src/detection/bluetoothradio/bluetoothradio_linux.c
1217+
src/detection/disk/disk_linux.c
1218+
src/detection/dns/dns_linux.c
1219+
src/detection/physicaldisk/physicaldisk_nosupport.c
1220+
src/detection/physicalmemory/physicalmemory_nosupport.c
1221+
src/detection/diskio/diskio_nosupport.c
1222+
src/detection/displayserver/linux/displayserver_linux.c
1223+
src/detection/displayserver/linux/drm.c
1224+
src/detection/displayserver/linux/wayland/wayland.c
1225+
src/detection/displayserver/linux/wayland/global-output.c
1226+
src/detection/displayserver/linux/wayland/zwlr-output.c
1227+
src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-protocol.c
1228+
src/detection/displayserver/linux/wmde.c
1229+
src/detection/displayserver/linux/xcb.c
1230+
src/detection/displayserver/linux/xlib.c
1231+
src/detection/font/font_linux.c
1232+
src/detection/gpu/gpu_nosupport.c
1233+
src/detection/gpu/gpu_pci.c
1234+
src/detection/gtk_qt/gtk.c
1235+
src/detection/host/host_nosupport.c
1236+
src/detection/icons/icons_linux.c
1237+
src/detection/initsystem/initsystem_linux.c
1238+
src/detection/keyboard/keyboard_nosupport.c
1239+
src/detection/libc/libc_linux.c
1240+
src/detection/lm/lm_linux.c
1241+
src/detection/loadavg/loadavg_linux.c
1242+
src/detection/locale/locale_linux.c
1243+
src/detection/localip/localip_linux.c
1244+
src/detection/gamepad/gamepad_nosupport.c
1245+
src/detection/media/media_linux.c
1246+
src/detection/memory/memory_linux.c
1247+
src/detection/mouse/mouse_nosupport.c
1248+
src/detection/netio/netio_nosupport.c
1249+
src/detection/opengl/opengl_linux.c
1250+
src/detection/os/os_linux.c
1251+
src/detection/packages/packages_linux.c
1252+
src/detection/packages/packages_nix.c
1253+
src/detection/poweradapter/poweradapter_nosupport.c
1254+
src/detection/processes/processes_linux.c
1255+
src/detection/gtk_qt/qt.c
1256+
src/detection/sound/sound_linux.c
1257+
src/detection/swap/swap_linux.c
1258+
src/detection/terminalfont/terminalfont_linux.c
1259+
src/detection/terminalshell/terminalshell_linux.c
1260+
src/detection/terminalsize/terminalsize_linux.c
1261+
src/detection/theme/theme_linux.c
1262+
src/detection/tpm/tpm_nosupport.c
1263+
src/detection/uptime/uptime_linux.c
1264+
src/detection/users/users_linux.c
1265+
src/detection/wallpaper/wallpaper_linux.c
1266+
src/detection/wifi/wifi_nosupport.c
1267+
src/detection/wm/wm_linux.c
1268+
src/detection/de/de_linux.c
1269+
src/detection/wmtheme/wmtheme_linux.c
1270+
src/detection/camera/camera_nosupport.c
1271+
src/detection/zpool/zpool_nosupport.c
1272+
src/util/platform/FFPlatform_unix.c
1273+
src/util/binary_linux.c
1274+
)
11951275
endif()
11961276

11971277
if(ENABLE_DIRECTX_HEADERS)
@@ -1315,6 +1395,10 @@ elseif(NetBSD)
13151395
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/usr/X11R7/lib -Wl,-rpath,/usr/pkg/lib") # ditto
13161396
elseif(Haiku)
13171397
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE)
1398+
elseif(GNU)
1399+
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE)
1400+
# On Hurd PATH_MAX is not defined. Set an arbitrary limit as workaround.
1401+
target_compile_definitions(libfastfetch PUBLIC PATH_MAX=4096)
13181402
endif()
13191403

13201404
if(FreeBSD OR OpenBSD OR NetBSD)
@@ -1639,6 +1723,10 @@ elseif(SunOS)
16391723
PRIVATE "nvpair"
16401724
PRIVATE "devinfo"
16411725
)
1726+
elseif(GNU)
1727+
target_link_libraries(libfastfetch
1728+
PRIVATE "m"
1729+
)
16421730
elseif(ANDROID)
16431731
CHECK_LIBRARY_EXISTS(-l:libandroid-wordexp.a wordexp "" HAVE_LIBANDROID_WORDEXP_STATIC)
16441732
if(HAVE_LIBANDROID_WORDEXP_STATIC)

src/common/netif/netif_gnu.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "netif.h"
2+
#include "common/io/io.h"
3+
4+
#include <net/if.h>
5+
#include <stdio.h>
6+
7+
#define FF_STR_INDIR(x) #x
8+
#define FF_STR(x) FF_STR_INDIR(x)
9+
10+
bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result)
11+
{
12+
FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/route", "r");
13+
14+
if (!netRoute) return false;
15+
16+
// skip first line
17+
FF_UNUSED(fscanf(netRoute, "%*[^\n]\n"));
18+
unsigned long long destination; //, gateway, flags, refCount, use, metric, mask, mtu, ...
19+
while (fscanf(netRoute, "%" FF_STR(IF_NAMESIZE) "s%llx%*[^\n]", result->ifName, &destination) == 2)
20+
{
21+
if (destination != 0) continue;
22+
result->ifIndex = if_nametoindex(result->ifName);
23+
// TODO: Get the preferred source address
24+
return true;
25+
}
26+
result->ifName[0] = '0';
27+
return false;
28+
}
29+
30+
bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result)
31+
{
32+
// TODO: AF_INET6
33+
FF_UNUSED(result);
34+
return false;
35+
}

src/common/networking/networking_linux.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state)
2222

2323
if (!state->tfo)
2424
{
25-
#ifdef __linux__
25+
#if __linux__ || __GNU__
2626
// Linux doesn't support sendto() on unconnected sockets
2727
FF_DEBUG("TCP Fast Open disabled, skipping");
2828
return "TCP Fast Open disabled";
@@ -34,7 +34,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state)
3434

3535
#ifndef __APPLE__ // On macOS, TCP_FASTOPEN doesn't seem to be needed
3636
// Set TCP Fast Open
37-
#ifdef __linux__
37+
#if __linux__ || __GNU__
3838
int flag = 5; // the queue length of pending packets
3939
#else
4040
int flag = 1; // enable TCP Fast Open
@@ -50,7 +50,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state)
5050
FF_DEBUG("Failed to set TCP_FASTOPEN option: %s", strerror(errno));
5151
return "setsockopt(TCP_FASTOPEN) failed";
5252
} else {
53-
#ifdef __linux__
53+
#if __linux__ || __GNU__
5454
FF_DEBUG("Successfully set TCP_FASTOPEN option, queue length: %d", flag);
5555
#elif defined(__APPLE__)
5656
FF_DEBUG("Successfully set TCP_FASTOPEN_FORCE_ENABLE option");

src/common/processing_linux.c

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
234234
assert(processName->length > 0);
235235
ffStrbufClear(exe);
236236

237-
#ifdef __linux__
237+
#if defined(__linux__) || defined(__GNU__)
238238

239239
char filePath[64];
240240
snprintf(filePath, sizeof(filePath), "/proc/%d/cmdline", (int)pid);
@@ -436,33 +436,54 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
436436
if (pid <= 0)
437437
return "Invalid pid";
438438

439-
#ifdef __linux__
439+
#if defined(__linux__) || defined(__GNU__)
440440

441441
char procFilePath[64];
442-
if (ppid)
442+
#if __linux__
443+
if (ppid || tty)
444+
#endif
443445
{
444446
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/stat", (int)pid);
445447
char buf[PROC_FILE_BUFFSIZ];
446448
ssize_t nRead = ffReadFileData(procFilePath, sizeof(buf) - 1, buf);
447449
if(nRead <= 8)
448450
return "ffReadFileData(/proc/pid/stat, PROC_FILE_BUFFSIZ-1, buf) failed";
449-
buf[nRead] = '\0';
451+
buf[nRead] = '\0'; // pid (comm) state ppid pgrp session tty
450452

451-
*ppid = 0;
452-
static_assert(sizeof(*ppid) == sizeof(int), "");
453+
const char* pState = NULL;
453454

454-
ffStrbufEnsureFixedLengthFree(name, 255);
455-
int tty_;
456-
if(
457-
sscanf(buf, "%*s (%255[^)]) %*c %d %*d %*d %d", name->chars, ppid, &tty_) < 2 || //stat (comm) state ppid pgrp session tty
458-
name->chars[0] == '\0'
459-
)
460-
return "sscanf(stat) failed";
455+
{
456+
// comm in `/proc/pid/stat` is not encoded, and may contain ' ', ')' or even `\n`
457+
const char* start = memchr(buf, '(', (size_t) nRead);
458+
if (!start)
459+
return "memchr(stat, '(') failed";
460+
start++;
461+
const char* end = memrchr(start, ')', (size_t) nRead - (size_t) (start - buf));
462+
if (!end)
463+
return "memrchr(stat, ')') failed";
464+
ffStrbufSetNS(name, (uint32_t) (end - start), start);
465+
ffStrbufTrimRightSpace(name);
466+
pState = end + 2; // skip ") "
467+
}
461468

462-
ffStrbufRecalculateLength(name);
463-
if (tty)
464-
*tty = tty_ & 0xFF;
469+
#if !__linux__
470+
if (ppid || tty)
471+
#endif
472+
{
473+
int ppid_, tty_;
474+
if(
475+
sscanf(pState + 2, "%d %*d %*d %d", &ppid_, &tty_) < 2 ||
476+
name->chars[0] == '\0'
477+
)
478+
return "sscanf(stat) failed";
479+
480+
if (ppid)
481+
*ppid = (pid_t) ppid_;
482+
if (tty)
483+
*tty = tty_ & 0xFF;
484+
}
465485
}
486+
#if __linux__
466487
else
467488
{
468489
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/comm", (int)pid);
@@ -471,6 +492,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
471492
return "ffReadFileBuffer(/proc/pid/comm, name) failed";
472493
ffStrbufTrimRightSpace(name);
473494
}
495+
#endif
474496

475497
#elif defined(__APPLE__)
476498

src/detection/cpu/cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ inline static void ffCPUDetectByCpuid(FFCPUResult* cpu)
9797

9898
#else
9999

100-
inline static void ffCPUDetectByCpuid(FFCPUResult* cpu)
100+
inline static void ffCPUDetectByCpuid(FF_MAYBE_UNUSED FFCPUResult* cpu)
101101
{
102102
// Unsupported platform
103103
}

src/detection/cpuusage/cpuusage.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const char* ffGetCpuUsageResult(FFCPUUsageOptions* options, FFlist* result)
5454
ffTimeSleep(options->waitTime);
5555
goto retry;
5656
}
57+
return "CPU time did not increase. Try increasing wait time.";
5758
}
5859
}
5960

src/detection/diskio/diskio_linux.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ static const char* parseDiskIOCounters(int dfd, const char* devName, FFlist* res
2323
ffStrbufAppendC(&name, ' ');
2424
}
2525

26-
if (ffAppendFileBufferRelative(devfd, "model", &name))
27-
ffStrbufTrimRightSpace(&name);
26+
ffAppendFileBufferRelative(devfd, "model", &name);
27+
ffStrbufTrimRightSpace(&name);
2828

2929
if (name.length == 0)
3030
ffStrbufSetS(&name, devName);

src/detection/displayserver/linux/wayland/wayland.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
static bool waylandDetectWM(int fd, FFDisplayServerResult* result)
2828
{
29-
#if __linux__ || (__FreeBSD__ && !__DragonFly__)
29+
#if __linux__ || __GNU__ || (__FreeBSD__ && !__DragonFly__)
3030

31-
#if __linux
31+
#if __linux__ || __GNU__
3232
struct ucred ucred = {};
3333
socklen_t len = sizeof(ucred);
3434
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1 || ucred.pid <= 0)

src/detection/displayserver/linux/wmde.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result)
351351
break;
352352
}
353353
}
354-
#elif __linux__
354+
#elif __linux__ || __GNU__
355355
FF_AUTO_CLOSE_DIR DIR* procdir = opendir("/proc");
356356
if(procdir == NULL)
357357
return "opendir(\"/proc\") failed";

src/detection/initsystem/initsystem_linux.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const char* ffDetectInitSystem(FFInitSystemResult* result)
4848

4949
if (instance.config.general.detectVersion)
5050
{
51-
#if __linux__ && !__ANDROID__
51+
#if (defined(__linux__) && !defined(__ANDROID__)) || defined(__GNU__)
5252
if (ffStrbufEqualS(&result->name, "systemd"))
5353
{
5454
ffBinaryExtractStrings(result->exe.chars, extractSystemdVersion, &result->version, (uint32_t) strlen("systemd 0.0 running in x"));
@@ -84,6 +84,20 @@ const char* ffDetectInitSystem(FFInitSystemResult* result)
8484
ffStrbufSubstrAfterLastC(&result->version, ' ');
8585
}
8686
}
87+
else if (ffStrbufEqualS(&result->name, "guile"))
88+
{
89+
// TODO: guile is actually shepherd
90+
if (ffProcessAppendStdOut(&result->version, (char* const[]) {
91+
ffStrbufEndsWithS(&result->exe, "/guile") ? result->exe.chars : "guile",
92+
"--version",
93+
NULL,
94+
}) == NULL && result->version.length)
95+
{
96+
// guile (GNU Guile) 3.0.9
97+
ffStrbufSubstrBeforeFirstC(&result->version, '\n');
98+
ffStrbufSubstrAfterLastC(&result->version, ' ');
99+
}
100+
}
87101
#elif __APPLE__
88102
if (ffStrbufEqualS(&result->name, "launchd"))
89103
{

0 commit comments

Comments
 (0)