mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-31 10:02:49 +01:00
Start work on GNU
This commit is contained in:
@@ -234,7 +234,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
|
||||
assert(processName->length > 0);
|
||||
ffStrbufClear(exe);
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) || defined(__GNU__)
|
||||
|
||||
char filePath[64];
|
||||
snprintf(filePath, sizeof(filePath), "/proc/%d/cmdline", (int)pid);
|
||||
@@ -436,7 +436,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
if (pid <= 0)
|
||||
return "Invalid pid";
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) || defined(__GNU__)
|
||||
|
||||
char procFilePath[64];
|
||||
if (ppid)
|
||||
@@ -465,11 +465,30 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef __GNU__
|
||||
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/comm", (int)pid);
|
||||
ssize_t nRead = ffReadFileBuffer(procFilePath, name);
|
||||
if(nRead <= 0)
|
||||
return "ffReadFileBuffer(/proc/pid/comm, name) failed";
|
||||
ffStrbufTrimRightSpace(name);
|
||||
#else
|
||||
// No /proc/1/comm on Hurd so read /proc/1/stat again
|
||||
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/stat", (int)pid);
|
||||
char buf[PROC_FILE_BUFFSIZ];
|
||||
ssize_t nRead = ffReadFileData(procFilePath, sizeof(buf) - 1, buf);
|
||||
if(nRead <= 8)
|
||||
return "ffReadFileData(/proc/pid/stat, PROC_FILE_BUFFSIZ-1, buf) failed";
|
||||
buf[nRead] = '\0';
|
||||
|
||||
ffStrbufEnsureFixedLengthFree(name, 255);
|
||||
if(
|
||||
sscanf(buf, "%*s (%255[^)]) %*c %*d %*d %*d %*d", name->chars) == 0 || //stat (comm) state ppid pgrp session tty
|
||||
name->chars[0] == '\0'
|
||||
)
|
||||
return "sscanf(stat) failed";
|
||||
|
||||
ffStrbufRecalculateLength(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
@@ -19,7 +19,7 @@ const char* ffDetectLoadavg(double result[3])
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __GNU__
|
||||
// getloadavg requires higher ANDROID_API version
|
||||
struct sysinfo si;
|
||||
if (sysinfo(&si) < 0)
|
||||
@@ -27,5 +27,6 @@ const char* ffDetectLoadavg(double result[3])
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
result[i] = (double) si.loads[i] / (1 << SI_LOAD_SHIFT);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) || defined(__HAIKU__)
|
||||
#include <net/if_media.h>
|
||||
#include <net/if_dl.h>
|
||||
#elif defined(__GNU__)
|
||||
#else
|
||||
#include <netpacket/packet.h>
|
||||
#endif
|
||||
@@ -69,12 +70,14 @@ static const FFLocalIpNIFlag niFlagOptions[] = {
|
||||
#ifdef IFF_NOTRAILERS
|
||||
FF_LOCALIP_NIFLAG(NOTRAILERS),
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
#if defined( __linux__) || defined (__GNU__)
|
||||
FF_LOCALIP_NIFLAG(MASTER),
|
||||
FF_LOCALIP_NIFLAG(SLAVE),
|
||||
FF_LOCALIP_NIFLAG(PORTSEL),
|
||||
FF_LOCALIP_NIFLAG(AUTOMEDIA),
|
||||
FF_LOCALIP_NIFLAG(DYNAMIC),
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
FF_LOCALIP_NIFLAG(LOWER_UP),
|
||||
FF_LOCALIP_NIFLAG(DORMANT),
|
||||
FF_LOCALIP_NIFLAG(ECHO),
|
||||
@@ -562,6 +565,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
FF_DEBUG("No MAC address available for interface %s", adapter->mac->ifa_name);
|
||||
}
|
||||
}
|
||||
#elif defined(__GNU__)
|
||||
#else
|
||||
(void) adapter;
|
||||
#endif
|
||||
|
||||
@@ -26,13 +26,13 @@ const char* ffDetectUptime(FFUptimeResult* result)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __GNU__
|
||||
struct timespec uptime;
|
||||
if (clock_gettime(CLOCK_BOOTTIME, &uptime) != 0)
|
||||
return "clock_gettime(CLOCK_BOOTTIME) failed";
|
||||
|
||||
result->uptime = (uint64_t) uptime.tv_sec * 1000 + (uint64_t) uptime.tv_nsec / 1000000;
|
||||
result->bootTime = ffTimeGetNow() - result->uptime;
|
||||
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
#define FF_SYSNAME "NetBSD"
|
||||
#elif defined(__HAIKU__)
|
||||
#define FF_SYSNAME "Haiku"
|
||||
#elif defined(__GNU__)
|
||||
#define FF_SYSNAME "GNU"
|
||||
#else
|
||||
#define FF_SYSNAME "Unknown"
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@ typedef struct FFOptionsGeneral
|
||||
bool detectVersion;
|
||||
|
||||
// Module options that cannot be put in module option structure
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(__GNU__)
|
||||
FFstrbuf playerName;
|
||||
FFDsForceDrmType dsForceDrm;
|
||||
#elif defined(_WIN32)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
static void getExePath(FFPlatform* platform)
|
||||
{
|
||||
char exePath[PATH_MAX + 1];
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) || defined (__GNU__)
|
||||
ssize_t exePathLen = readlink("/proc/self/exe", exePath, sizeof(exePath) - 1);
|
||||
if (exePathLen >= 0)
|
||||
exePath[exePathLen] = '\0';
|
||||
|
||||
Reference in New Issue
Block a user