mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 07:44:06 +01:00
Global: adds more FF_DEBUG
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#include "common/binary.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
@@ -108,6 +110,7 @@ static const char* dumpMachHeader(const FFMemoryMapping* mapping, off_t offset,
|
||||
if (is_64) {
|
||||
const struct mach_header_64* header = readData(mapping, sizeof(struct mach_header_64), offset);
|
||||
if (!header) {
|
||||
FF_DEBUG("Failed to read the 64-bit mach header at offset %lld", (long long) offset);
|
||||
return "read mach header failed";
|
||||
}
|
||||
|
||||
@@ -116,6 +119,7 @@ static const char* dumpMachHeader(const FFMemoryMapping* mapping, off_t offset,
|
||||
} else {
|
||||
const struct mach_header* header = readData(mapping, sizeof(struct mach_header), offset);
|
||||
if (!header) {
|
||||
FF_DEBUG("Failed to read the mach header at offset %lld", (long long) offset);
|
||||
return "read mach header failed";
|
||||
}
|
||||
|
||||
@@ -200,6 +204,7 @@ static const char* dumpMachHeader(const FFMemoryMapping* mapping, off_t offset,
|
||||
static const char* dumpFatHeader(const FFMemoryMapping* mapping, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata, uint32_t minLength) {
|
||||
const struct fat_header* headerRaw = readData(mapping, sizeof(struct fat_header), 0);
|
||||
if (!headerRaw) {
|
||||
FF_DEBUG("Failed to read the fat header");
|
||||
return "read fat header failed";
|
||||
}
|
||||
|
||||
@@ -251,6 +256,7 @@ static const char* dumpFatHeader(const FFMemoryMapping* mapping, bool (*cb)(cons
|
||||
return dumpMachHeader(mapping, machHeaderOffset, *magic == MH_MAGIC_64, cb, userdata, minLength);
|
||||
}
|
||||
}
|
||||
FF_DEBUG("No supported Mach-O slice was found in the fat binary");
|
||||
return "Unsupported fat header";
|
||||
}
|
||||
|
||||
@@ -265,11 +271,13 @@ static const char* dumpFatHeader(const FFMemoryMapping* mapping, bool (*cb)(cons
|
||||
const char* ffBinaryExtractStrings(const char* machoFile, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata, uint32_t minLength) {
|
||||
FF_AUTO_CLOSE_FD int fd = open(machoFile, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("open(\"%s\") failed: %s", machoFile, strerror(errno));
|
||||
return "File could not be opened";
|
||||
}
|
||||
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) != 0 || st.st_size <= 0) {
|
||||
FF_DEBUG("fstat(\"%s\") failed or the file is empty", machoFile);
|
||||
return "Failed to stat file";
|
||||
}
|
||||
|
||||
@@ -278,12 +286,14 @@ const char* ffBinaryExtractStrings(const char* machoFile, bool (*cb)(const char*
|
||||
.length = (size_t) st.st_size,
|
||||
};
|
||||
if (mapping.data == MAP_FAILED) {
|
||||
FF_DEBUG("mmap(\"%s\", %lld bytes) failed: %s", machoFile, (long long) st.st_size, strerror(errno));
|
||||
return "mmap failed";
|
||||
}
|
||||
|
||||
// Read the magic number to determine the type of binary
|
||||
const uint32_t* magic = readData(&mapping, sizeof(uint32_t), 0);
|
||||
if (!magic) {
|
||||
FF_DEBUG("Failed to read the magic number");
|
||||
return "read magic number failed";
|
||||
}
|
||||
|
||||
@@ -291,6 +301,7 @@ const char* ffBinaryExtractStrings(const char* machoFile, bool (*cb)(const char*
|
||||
// MH_CIGAM and MH_CIGAM_64 seem to be no longer used, as `swap_mach_header` is marked as deprecated.
|
||||
// However FAT_CIGAM and FAT_CIGAM_64 are still used (/usr/bin/vim).
|
||||
if (*magic != MH_MAGIC && *magic != MH_MAGIC_64 && *magic != FAT_CIGAM && *magic != FAT_CIGAM_64 && *magic != FAT_MAGIC && *magic != FAT_MAGIC_64) {
|
||||
FF_DEBUG("Unsupported magic number 0x%08x", (unsigned) *magic);
|
||||
return "Unsupported format or big endian mach-o file";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "common/binary.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#if defined(FF_HAVE_ELF) || defined(__sun) || (defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
|
||||
@@ -43,6 +44,7 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s
|
||||
FF_LIBRARY_LOAD_MESSAGE(libelf, "libelf" FF_LIBRARY_EXTENSION, 1);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libelf, elfData, elf_version)
|
||||
if (elfData.ffelf_version(EV_CURRENT) == EV_NONE) {
|
||||
FF_DEBUG("elf_version() failed");
|
||||
return "elf_version() failed";
|
||||
}
|
||||
|
||||
@@ -60,23 +62,27 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s
|
||||
}
|
||||
|
||||
if (elfData.ffelf_end == nullptr) {
|
||||
FF_DEBUG("load libelf failed");
|
||||
return "load libelf failed";
|
||||
}
|
||||
|
||||
// Open the ELF file
|
||||
FF_AUTO_CLOSE_FD int fd = open(elfFile, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("open(%s) failed: %s", elfFile, strerror(errno));
|
||||
return "open() failed";
|
||||
}
|
||||
|
||||
Elf* elf = elfData.ffelf_begin(fd, ELF_C_READ, nullptr);
|
||||
if (elf == nullptr) {
|
||||
FF_DEBUG("elf_begin() failed");
|
||||
return "elf_begin() failed";
|
||||
}
|
||||
|
||||
// Get the section header string table index
|
||||
size_t shstrndx = 0;
|
||||
if (elfData.ffelf_getshdrstrndx(elf, &shstrndx) < 0) {
|
||||
FF_DEBUG("elf_getshdrstrndx() failed");
|
||||
elfData.ffelf_end(elf);
|
||||
return "elf_getshdrstrndx() failed";
|
||||
}
|
||||
@@ -141,6 +147,7 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s
|
||||
*/
|
||||
const char* ffBinaryExtractStrings(const char* file, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata, uint32_t minLength) {
|
||||
FF_UNUSED(file, cb, userdata, minLength);
|
||||
FF_DEBUG("Fastfetch was built without libelf support");
|
||||
return "Fastfetch was built without libelf support";
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) {
|
||||
#endif
|
||||
#else
|
||||
FF_UNUSED(state);
|
||||
FF_DEBUG("TFO support is not available");
|
||||
return "TFO support is not available";
|
||||
#endif
|
||||
}
|
||||
@@ -593,6 +594,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
|
||||
}
|
||||
|
||||
if (chunked && !ffNetworkingDecodeChunked(buffer, &headerEnd)) {
|
||||
FF_DEBUG("Failed to decode chunked response");
|
||||
return "Failed to decode chunked response";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/processing.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
@@ -59,6 +60,7 @@ static inline int ffPipe2(int* fds, int flags) {
|
||||
const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFNativeFD stdinFd, FFProcessHandle* outHandle) {
|
||||
int pipes[2];
|
||||
if (ffPipe2(pipes, O_CLOEXEC) == -1) {
|
||||
FF_DEBUG("pipe() failed: %s", strerror(errno));
|
||||
return "pipe() failed";
|
||||
}
|
||||
|
||||
@@ -123,6 +125,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFNativeFD stdinF
|
||||
posix_spawn_file_actions_destroy(&file_actions);
|
||||
|
||||
if (ret != 0) {
|
||||
FF_DEBUG("posix_spawnp() failed: %s", strerror(ret));
|
||||
close(pipes[0]);
|
||||
close(pipes[1]);
|
||||
if (ret == ENOENT) {
|
||||
@@ -136,6 +139,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFNativeFD stdinF
|
||||
// https://github.com/termux/termux-packages/issues/25369
|
||||
childPid = fork();
|
||||
if (childPid == -1) {
|
||||
FF_DEBUG("fork() failed: %s", strerror(errno));
|
||||
close(pipes[0]);
|
||||
close(pipes[1]);
|
||||
return "fork() failed";
|
||||
@@ -177,6 +181,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) {
|
||||
struct pollfd pollfd = { childPipeFd, POLLIN, 0 };
|
||||
int pollret = poll(&pollfd, 1, timeout);
|
||||
if (pollret == 0) {
|
||||
FF_DEBUG("poll(&pollfd, 1, timeout) timeout (try increasing --processing-timeout)");
|
||||
kill(childPid, SIGTERM);
|
||||
waitpid(childPid, nullptr, 0);
|
||||
return "poll(&pollfd, 1, timeout) timeout (try increasing --processing-timeout)";
|
||||
@@ -199,6 +204,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) {
|
||||
return "child process exited abnormally";
|
||||
}
|
||||
if (WEXITSTATUS(stat_loc) == 127) {
|
||||
FF_DEBUG("command not found");
|
||||
return "command not found";
|
||||
}
|
||||
// We only handle 127 as an error. See `getTerminalVersionUrxvt` in `terminalshell.c`
|
||||
@@ -210,6 +216,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
FF_DEBUG("read(childPipeFd, str, FF_PIPE_BUFSIZ) failed: %s", strerror(errno));
|
||||
return "read(childPipeFd, str, FF_PIPE_BUFSIZ) failed";
|
||||
}
|
||||
|
||||
@@ -475,6 +482,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
|
||||
|
||||
const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, int32_t* tty) {
|
||||
if (pid <= 0) {
|
||||
FF_DEBUG("Invalid pid");
|
||||
return "Invalid pid";
|
||||
}
|
||||
|
||||
@@ -489,6 +497,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
char buf[PROC_FILE_BUFFSIZ];
|
||||
ssize_t nRead = ffReadFileData(procFilePath, sizeof(buf) - 1, buf);
|
||||
if (nRead <= 8) {
|
||||
FF_DEBUG("ffReadFileData(/proc/pid/stat, PROC_FILE_BUFFSIZ-1, buf) failed");
|
||||
return "ffReadFileData(/proc/pid/stat, PROC_FILE_BUFFSIZ-1, buf) failed";
|
||||
}
|
||||
buf[nRead] = '\0'; // pid (comm) state ppid pgrp session tty
|
||||
@@ -499,16 +508,19 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
// comm in `/proc/pid/stat` is not encoded, and may contain ' ', ')' or even `\n`
|
||||
const char* start = memchr(buf, '(', (size_t) nRead);
|
||||
if (!start) {
|
||||
FF_DEBUG("memchr(stat, '(') failed");
|
||||
return "memchr(stat, '(') failed";
|
||||
}
|
||||
start++;
|
||||
const char* end = memrchr(start, ')', (size_t) nRead - (size_t) (start - buf));
|
||||
if (!end) {
|
||||
FF_DEBUG("memrchr(stat, ')') failed");
|
||||
return "memrchr(stat, ')') failed";
|
||||
}
|
||||
ffStrbufSetNS(name, (uint32_t) (end - start), start);
|
||||
ffStrbufTrimRightSpace(name);
|
||||
if (name->chars[0] == '\0') {
|
||||
FF_DEBUG("process name is empty");
|
||||
return "process name is empty";
|
||||
}
|
||||
pState = end + 2; // skip ") "
|
||||
@@ -520,6 +532,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
{
|
||||
int ppid_, tty_;
|
||||
if (sscanf(pState + 2, "%d %*d %*d %d", &ppid_, &tty_) < 2) {
|
||||
FF_DEBUG("sscanf(stat) failed");
|
||||
return "sscanf(stat) failed";
|
||||
}
|
||||
|
||||
@@ -536,6 +549,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/comm", (int) pid);
|
||||
ssize_t nRead = ffReadFileBuffer(procFilePath, name);
|
||||
if (nRead <= 0) {
|
||||
FF_DEBUG("ffReadFileBuffer(/proc/pid/comm, name) failed");
|
||||
return "ffReadFileBuffer(/proc/pid/comm, name) failed";
|
||||
}
|
||||
ffStrbufTrimRightSpace(name);
|
||||
@@ -548,6 +562,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
size_t size = sizeof(proc);
|
||||
if (sysctl(
|
||||
(int[]) { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }, 4, &proc, &size, nullptr, 0)) {
|
||||
FF_DEBUG("sysctl(KERN_PROC_PID) failed: %s", strerror(errno));
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
}
|
||||
|
||||
@@ -574,6 +589,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
size_t size = sizeof(proc);
|
||||
if (sysctl(
|
||||
(int[]) { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }, 4, &proc, &size, nullptr, 0)) {
|
||||
FF_DEBUG("sysctl(KERN_PROC_PID) failed: %s", strerror(errno));
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
}
|
||||
|
||||
@@ -600,6 +616,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
size_t size = sizeof(proc);
|
||||
if (sysctl(
|
||||
(int[]) { CTL_KERN, KERN_PROC2, KERN_PROC_PID, pid, sizeof(proc), 1 }, 6, &proc, &size, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl(KERN_PROC_PID) failed: %s", strerror(errno));
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
}
|
||||
|
||||
@@ -625,6 +642,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
snprintf(path, sizeof(path), "/proc/%d/psinfo", (int) pid);
|
||||
psinfo_t proc;
|
||||
if (ffReadFileData(path, sizeof(proc), &proc) != sizeof(proc)) {
|
||||
FF_DEBUG("ffReadFileData(psinfo) failed");
|
||||
return "ffReadFileData(psinfo) failed";
|
||||
}
|
||||
|
||||
@@ -650,6 +668,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
*tty = (int) proc.p_tdev;
|
||||
}
|
||||
} else {
|
||||
FF_DEBUG("sysctl(KERN_PROC_PID) failed: %s", strerror(errno));
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
}
|
||||
|
||||
@@ -667,6 +686,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
|
||||
#else
|
||||
|
||||
FF_DEBUG("Unsupported platform");
|
||||
return "Unsupported platform";
|
||||
|
||||
#endif
|
||||
|
||||
@@ -360,6 +360,7 @@ static bool detectStatusFromProperty(uint64_t* status) {
|
||||
// back as it came and the caller decides what that is worth. The unit is milliseconds.
|
||||
static const char* getTimeRemaining(FFBinder* binder, uint32_t handle, int32_t transaction, int64_t* milliseconds) {
|
||||
if (transaction == FF_DEX_STATIC_INT_UNRESOLVED) {
|
||||
FF_DEBUG("computeBatteryTimeRemaining is unresolved in the jar (transaction %d)", (int) transaction);
|
||||
return "The battery stats service does not declare computeBatteryTimeRemaining";
|
||||
}
|
||||
|
||||
@@ -540,6 +541,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) {
|
||||
return error;
|
||||
}
|
||||
if (transaction == FF_DEX_STATIC_INT_UNRESOLVED) {
|
||||
FF_DEBUG("getProperty is unresolved in the jar (transaction %d)", (int) transaction);
|
||||
return "The battery service does not declare getProperty";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "battery.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
#include "common/apple/smc_temps.h"
|
||||
|
||||
@@ -9,6 +10,7 @@
|
||||
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) {
|
||||
FF_IOOBJECT_AUTO_RELEASE io_iterator_t iterator = IO_OBJECT_NULL;
|
||||
if (IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("AppleSmartBattery"), &iterator) != kIOReturnSuccess) {
|
||||
FF_DEBUG("IOServiceGetMatchingServices() failed");
|
||||
return "IOServiceGetMatchingServices() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/sysctl.h"
|
||||
#include "common/io.h"
|
||||
#include "battery.h"
|
||||
@@ -6,6 +7,8 @@
|
||||
#include <dev/acpica/acpiio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* results) {
|
||||
@@ -14,6 +17,7 @@ const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist*
|
||||
|
||||
int units = ffSysctlGetInt("hw.acpi.battery.units", -100);
|
||||
if (units < 0) {
|
||||
FF_DEBUG("sysctlbyname(\"hw.acpi.battery.units\") failed: %s", strerror(errno));
|
||||
return "sysctlbyname(\"hw.acpi.battery.units\") failed";
|
||||
}
|
||||
|
||||
@@ -23,6 +27,7 @@ const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist*
|
||||
|
||||
FF_AUTO_CLOSE_FD int acpifd = open("/dev/acpi", O_RDONLY | O_CLOEXEC);
|
||||
if (acpifd < 0) {
|
||||
FF_DEBUG("open(\"/dev/acpi\", O_RDONLY | O_CLOEXEC) failed: %s", strerror(errno));
|
||||
return "open(\"/dev/acpi\", O_RDONLY | O_CLOEXEC) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
#include "fastfetch.h"
|
||||
#include "battery.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <private/device/power_managment.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
const char* parseBattery(int dfd, const char* battId, FFlist* results) {
|
||||
FF_AUTO_CLOSE_FD int fd = openat(dfd, battId, O_RDWR);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("openat(%s) failed: %s", battId, strerror(errno));
|
||||
return "openat() failed";
|
||||
}
|
||||
|
||||
acpi_battery_info basic = {};
|
||||
if (ioctl(fd, GET_BATTERY_INFO, &basic, sizeof(basic)) != 0) {
|
||||
FF_DEBUG("ioctl(GET_BATTERY_INFO) failed");
|
||||
return "ioctl(GET_BATTERY_INFO) failed";
|
||||
}
|
||||
acpi_extended_battery_info extended = {};
|
||||
if (ioctl(fd, GET_EXTENDED_BATTERY_INFO, &extended, sizeof(extended)) != 0) {
|
||||
FF_DEBUG("ioctl(GET_EXTENDED_BATTERY_INFO) failed");
|
||||
return "ioctl(GET_EXTENDED_BATTERY_INFO) failed";
|
||||
}
|
||||
|
||||
@@ -56,6 +61,7 @@ const char* parseBattery(int dfd, const char* battId, FFlist* results) {
|
||||
const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* results) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/power/acpi_battery/");
|
||||
if (!dir) {
|
||||
FF_DEBUG("opendir(\"/dev/power/acpi_battery/\") failed: %s", strerror(errno));
|
||||
return "opendir(/dev/power/acpi_battery) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
// https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-power
|
||||
|
||||
@@ -176,6 +177,7 @@ static bool parseBattery(int dfd, const char* id, FFBatteryOptions* options, FFl
|
||||
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/power_supply/");
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("opendir(\"/sys/class/power_supply/\") failed: %s", strerror(errno));
|
||||
return "opendir(\"/sys/class/power_supply/\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "battery.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/FFstrbuf.h"
|
||||
#include "common/strutil.h"
|
||||
@@ -17,11 +18,13 @@
|
||||
const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* results) {
|
||||
FF_AUTO_CLOSE_FD int fd = open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("open(_PATH_SYSMON) failed: %s", strerror(errno));
|
||||
return "open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed";
|
||||
}
|
||||
|
||||
prop_dictionary_t root = nullptr;
|
||||
if (prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &root) < 0) {
|
||||
FF_DEBUG("prop_dictionary_recv_ioctl(ENVSYS_GETDICTIONARY) failed");
|
||||
return "prop_dictionary_recv_ioctl(ENVSYS_GETDICTIONARY) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "battery.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <machine/apmvar.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
@@ -10,12 +12,14 @@ const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist*
|
||||
FF_AUTO_CLOSE_FD int devfd = open("/dev/apm", O_RDONLY | O_CLOEXEC);
|
||||
|
||||
if (devfd < 0) {
|
||||
FF_DEBUG("open(\"/dev/apm\") failed: %s", strerror(errno));
|
||||
return "open(dev/apm, O_RDONLY | O_CLOEXEC) failed";
|
||||
}
|
||||
|
||||
struct apm_power_info info = {};
|
||||
|
||||
if (ioctl(devfd, APM_IOC_GETPOWER, &info) < 0) {
|
||||
FF_DEBUG("ioctl(APM_IOC_GETPOWER) failed: %s", strerror(errno));
|
||||
return "ioctl(APM_IOC_GETPOWER) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "battery.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <kstat.h>
|
||||
|
||||
@@ -50,6 +51,7 @@ const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist*
|
||||
// https://github.com/illumos/illumos-gate/blob/master/usr/src/cmd/powertop/common/battery.c
|
||||
[[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open();
|
||||
if (!kc) {
|
||||
FF_DEBUG("kstat_open() failed");
|
||||
return "kstat_open() failed";
|
||||
}
|
||||
|
||||
@@ -75,6 +77,7 @@ const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist*
|
||||
if (!getUint32(bif, "bif_last_cap", &lastCapacity) ||
|
||||
!getUint32(bst, "bst_rem_cap", &remainingCapacity) ||
|
||||
!getUint32(bst, "bst_state", &state)) {
|
||||
FF_DEBUG("kstat_data_lookup() failed for bif_last_cap, bst_rem_cap or bst_state");
|
||||
return "kstat_data_lookup() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "bios.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
@@ -10,11 +11,13 @@ const char* ffDetectBios(FFBiosResult* bios) {
|
||||
// For Intel
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t deviceRom = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/rom");
|
||||
if (!deviceRom) {
|
||||
FF_DEBUG("IODeviceTree:/rom not found");
|
||||
return "IODeviceTree:/rom not found";
|
||||
}
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFMutableDictionaryRef deviceRomProps = nullptr;
|
||||
if (IORegistryEntryCreateCFProperties(deviceRom, &deviceRomProps, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) {
|
||||
FF_DEBUG("IORegistryEntryCreateCFProperties(deviceRom) failed");
|
||||
return "IORegistryEntryCreateCFProperties(deviceRom) failed";
|
||||
}
|
||||
|
||||
@@ -28,6 +31,7 @@ const char* ffDetectBios(FFBiosResult* bios) {
|
||||
// For arm64
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t device = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/");
|
||||
if (!device) {
|
||||
FF_DEBUG("IODeviceTree:/ not found");
|
||||
return "IODeviceTree:/ not found";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "bluetooth.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#define L2CAP_SOCKET_CHECKED
|
||||
#include <bluetooth.h>
|
||||
@@ -31,6 +32,7 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF
|
||||
|
||||
// struct hostent* ent = bt_gethostent();
|
||||
if (bt_devenum((void*) enumDev, devices) < 0) {
|
||||
FF_DEBUG("bt_devenum() failed");
|
||||
return "bt_devenum() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "bluetooth.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/percent.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
@@ -304,11 +305,13 @@ static const char* detectBluetooth(FFBluetoothOptions* options, FFlist* devices,
|
||||
|
||||
DBusMessage* managedObjects = ffDBusGetMethodReply(&dbus, "org.bluez", "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", nullptr, nullptr);
|
||||
if (!managedObjects) {
|
||||
FF_DEBUG("Failed to call GetManagedObjects");
|
||||
return "Failed to call GetManagedObjects";
|
||||
}
|
||||
|
||||
DBusMessageIter rootIter;
|
||||
if (!dbus.lib->ffdbus_message_iter_init(managedObjects, &rootIter)) {
|
||||
FF_DEBUG("Failed to get root iterator of GetManagedObjects");
|
||||
dbus.lib->ffdbus_message_unref(managedObjects);
|
||||
return "Failed to get root iterator of GetManagedObjects";
|
||||
}
|
||||
@@ -351,6 +354,7 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF
|
||||
return detectBluetooth(options, devices, connectedCount);
|
||||
#else
|
||||
FF_UNUSED(options, devices);
|
||||
FF_DEBUG("Fastfetch was compiled without DBus support");
|
||||
return "Fastfetch was compiled without DBus support";
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "bluetoothradio.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#ifdef FF_HAVE_DBUS
|
||||
@@ -36,6 +37,7 @@ array [
|
||||
|
||||
static const char* detectBluetoothProperty(FFBluetoothRadioResult* device, FFDBusData* dbus, DBusMessageIter* iter) {
|
||||
if (dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_DICT_ENTRY) {
|
||||
FF_DEBUG("Expected dict entry");
|
||||
return "Expected dict entry";
|
||||
}
|
||||
|
||||
@@ -43,6 +45,7 @@ static const char* detectBluetoothProperty(FFBluetoothRadioResult* device, FFDBu
|
||||
dbus->lib->ffdbus_message_iter_recurse(iter, &dictIter);
|
||||
|
||||
if (dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_STRING) {
|
||||
FF_DEBUG("Expected dict entry key to be a string");
|
||||
return "Expected dict entry key to be a string";
|
||||
}
|
||||
|
||||
@@ -82,17 +85,20 @@ static const char* detectBluetoothRoot(FFBluetoothRadioResult* device, const cha
|
||||
|
||||
DBusMessage* properties = ffDBusGetMethodReply(dbus, "org.bluez", objPath, "org.freedesktop.DBus.Properties", "GetAll", "org.bluez.Adapter1", nullptr);
|
||||
if (!properties) {
|
||||
FF_DEBUG("Failed to call org.freedesktop.DBus.Properties.GetAll");
|
||||
return "Failed to call org.freedesktop.DBus.Properties.GetAll";
|
||||
}
|
||||
|
||||
DBusMessageIter rootIter;
|
||||
if (!dbus->lib->ffdbus_message_iter_init(properties, &rootIter)) {
|
||||
dbus->lib->ffdbus_message_unref(properties);
|
||||
FF_DEBUG("Failed to get root iterator of org.freedesktop.DBus.Properties.GetAll");
|
||||
return "Failed to get root iterator of org.freedesktop.DBus.Properties.GetAll";
|
||||
}
|
||||
|
||||
if (dbus->lib->ffdbus_message_iter_get_arg_type(&rootIter) != DBUS_TYPE_ARRAY) {
|
||||
dbus->lib->ffdbus_message_unref(properties);
|
||||
FF_DEBUG("Expected array");
|
||||
return "Expected array";
|
||||
}
|
||||
|
||||
@@ -110,6 +116,7 @@ static const char* detectBluetoothRoot(FFBluetoothRadioResult* device, const cha
|
||||
static const char* detectBluetooth(FFlist* devices) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/bluetooth");
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("opendir(\"/sys/class/bluetooth\") failed: %s", strerror(errno));
|
||||
return "Failed to open /sys/class/bluetooth";
|
||||
}
|
||||
|
||||
@@ -148,6 +155,7 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
|
||||
return detectBluetooth(devices);
|
||||
#else
|
||||
FF_UNUSED(devices)
|
||||
FF_DEBUG("Fastfetch was compiled without DBus support");
|
||||
return "Fastfetch was compiled without DBus support";
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "board.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
|
||||
const char* ffDetectBoard(FFBoardResult* result) {
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t service = IOServiceGetMatchingService(MACH_PORT_NULL, IOServiceMatching("IOPlatformExpertDevice"));
|
||||
if (!service) {
|
||||
FF_DEBUG("No IOPlatformExpertDevice found");
|
||||
return "No IOPlatformExpertDevice found";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "bootmgr.h"
|
||||
#include "common/io.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
@@ -8,15 +9,18 @@ static const char* detectSecureBoot(bool* result) {
|
||||
#if __aarch64__
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen");
|
||||
if (!entryDevice) {
|
||||
FF_DEBUG("IORegistryEntryFromPath(\"IODeviceTree:/chosen\") failed");
|
||||
return "IORegistryEntryFromPath() failed";
|
||||
}
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFTypeRef prop = IORegistryEntryCreateCFProperty(entryDevice, CFSTR("secure-boot"), kCFAllocatorDefault, kNilOptions);
|
||||
if (!prop) {
|
||||
FF_DEBUG("IORegistryEntryCreateCFProperty(\"secure-boot\") failed");
|
||||
return "IORegistryEntryCreateCFProperty() failed";
|
||||
}
|
||||
|
||||
if (CFGetTypeID(prop) != CFDataGetTypeID() || CFDataGetLength((CFDataRef) prop) == 0) {
|
||||
FF_DEBUG("Invalid secure-boot property");
|
||||
return "Invalid secure-boot property";
|
||||
}
|
||||
|
||||
@@ -24,15 +28,18 @@ static const char* detectSecureBoot(bool* result) {
|
||||
#else
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/options");
|
||||
if (!entryDevice) {
|
||||
FF_DEBUG("IORegistryEntryFromPath(\"IODeviceTree:/options\") failed");
|
||||
return "IORegistryEntryFromPath() failed";
|
||||
}
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFTypeRef prop = IORegistryEntryCreateCFProperty(entryDevice, CFSTR("94b73556-2197-4702-82a8-3e1337dafbfb:AppleSecureBootPolicy"), kCFAllocatorDefault, 0);
|
||||
if (!prop) {
|
||||
FF_DEBUG("IORegistryEntryCreateCFProperty(AppleSecureBootPolicy) failed");
|
||||
return "IORegistryEntryCreateCFProperty() failed";
|
||||
}
|
||||
|
||||
if (CFGetTypeID(prop) != CFDataGetTypeID() || CFDataGetLength((CFDataRef) prop) == 0) {
|
||||
FF_DEBUG("Invalid secure-boot property");
|
||||
return "Invalid secure-boot property";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "bootmgr.h"
|
||||
#include "efi_helper.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
@@ -22,6 +23,7 @@ typedef uint16_t efi_char;
|
||||
const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
FF_AUTO_CLOSE_FD int efifd = open("/dev/efi", O_RDWR | O_CLOEXEC);
|
||||
if (efifd < 0) {
|
||||
FF_DEBUG("open(\"/dev/efi\") failed: %s", strerror(errno));
|
||||
return "open(/dev/efi) failed";
|
||||
}
|
||||
|
||||
@@ -35,6 +37,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
ioc.name = (efi_char[]) { 'B', 'o', 'o', 't', 'C', 'u', 'r', 'r', 'e', 'n', 't', '\0' };
|
||||
ioc.namesize = sizeof("BootCurrent") * 2;
|
||||
if (ioctl(efifd, EFIIOC_VAR_GET, &ioc) < 0 || ioc.datasize != 2) {
|
||||
FF_DEBUG("ioctl(EFIIOC_VAR_GET, BootCurrent) failed");
|
||||
return "ioctl(EFIIOC_VAR_GET, BootCurrent) failed";
|
||||
}
|
||||
|
||||
@@ -46,6 +49,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
ioc.name = (efi_char[]) { 'B', 'o', 'o', 't', hex[0], hex[1], hex[2], hex[3], '\0' };
|
||||
ioc.namesize = sizeof("Boot####") * 2;
|
||||
if (ioctl(efifd, EFIIOC_VAR_GET, &ioc) < 0 || ioc.datasize == sizeof(buffer)) {
|
||||
FF_DEBUG("ioctl(EFIIOC_VAR_GET, Boot####) failed");
|
||||
return "ioctl(EFIIOC_VAR_GET, Boot####) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "bootmgr.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "efi_helper.h"
|
||||
|
||||
@@ -11,6 +12,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
alignas(uint16_t) uint8_t buffer[2048];
|
||||
|
||||
if (ffReadFileData(FF_EFIVARS_PATH_PREFIX "BootCurrent-" FF_EFI_GLOBAL_GUID, sizeof(buffer), buffer) != 6) {
|
||||
FF_DEBUG("Failed to read efivar: BootCurrent");
|
||||
return "Failed to read efivar: BootCurrent";
|
||||
}
|
||||
|
||||
@@ -20,6 +22,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
|
||||
ssize_t size = ffReadFileData((const char*) buffer, sizeof(buffer), buffer);
|
||||
if (size < 5 + (int) sizeof(FFEfiLoadOption) || size == (ssize_t) sizeof(buffer)) {
|
||||
FF_DEBUG("Failed to read efivar: Boot####");
|
||||
return "Failed to read efivar: Boot####";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "brightness.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/edidHelper.h"
|
||||
#include "common/time.h"
|
||||
|
||||
@@ -28,6 +29,7 @@ typedef CFTypeRef IOAVServiceRef;
|
||||
// Works for internal display
|
||||
static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* result) {
|
||||
if (DisplayServicesGetBrightness == nullptr) {
|
||||
FF_DEBUG("DisplayServices function DisplayServicesGetBrightness is not available");
|
||||
return "DisplayServices function DisplayServicesGetBrightness is not available";
|
||||
}
|
||||
|
||||
@@ -53,11 +55,13 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa
|
||||
// Works for Apple Silicon and USB-C adapter connection ( but not HTMI )
|
||||
static const char* detectWithDdcci([[maybe_unused]] const FFDisplayServerResult* displayServer, FFBrightnessOptions* options, FFlist* result) {
|
||||
if (!IOAVServiceCreate || !IOAVServiceReadI2C || !IOAVServiceWriteI2C) {
|
||||
FF_DEBUG("IOAVService is not available");
|
||||
return "IOAVService is not available";
|
||||
}
|
||||
|
||||
FF_IOOBJECT_AUTO_RELEASE io_iterator_t iterator = IO_OBJECT_NULL;
|
||||
if (IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("DCPAVServiceProxy"), &iterator) != kIOReturnSuccess) {
|
||||
FF_DEBUG("IOServiceGetMatchingServices() failed");
|
||||
return "IOServiceGetMatchingServices() failed";
|
||||
}
|
||||
|
||||
@@ -154,10 +158,12 @@ static IOOptionBits getSupportedTransactionType(void) {
|
||||
|
||||
static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, FFBrightnessOptions* options, FFlist* result) {
|
||||
if (!CGSServiceForDisplayNumber) {
|
||||
FF_DEBUG("CGSServiceForDisplayNumber is not available");
|
||||
return "CGSServiceForDisplayNumber is not available";
|
||||
}
|
||||
IOOptionBits transactionType = getSupportedTransactionType();
|
||||
if (transactionType == kIOI2CNoTransactionType) {
|
||||
FF_DEBUG("No supported IOI2C transaction type found");
|
||||
return "No supported IOI2C transaction type found";
|
||||
}
|
||||
|
||||
|
||||
@@ -206,8 +206,7 @@
|
||||
|
||||
FF_AUTO_CLOSE_FD int fd = open(path, O_RDWR | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
int error = errno;
|
||||
FF_DEBUG("Brightness DDC/CI: failed to open cached bus %d (errno=%d: %s)", device, error, strerror(error));
|
||||
FF_DEBUG("Brightness DDC/CI: failed to open cached bus %d (errno=%d: %s)", device, errno, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -281,6 +280,7 @@ static const char* detectWithBacklight(FFlist* result) {
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(backlightDirPath);
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("opendir(\"%s\") failed: %s", backlightDirPath, strerror(errno));
|
||||
return "Failed to open `/sys/class/backlight/`";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "brightness.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
@@ -15,6 +16,7 @@ const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FF
|
||||
|
||||
if (devfd < 0) {
|
||||
if (errno == EACCES && i == '0') {
|
||||
FF_DEBUG("open(%s) failed: %s", path, strerror(errno));
|
||||
return "Permission denied when opening tty device";
|
||||
}
|
||||
if (errno == ENOENT) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "btrfs.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
@@ -8,11 +9,13 @@ enum { uuidLen = (uint32_t) __builtin_strlen("00000000-0000-0000-0000-0000000000
|
||||
static const char* enumerateDevices(FFBtrfsResult* item, int dfd, FFstrbuf* buffer) {
|
||||
int subfd = openat(dfd, "devices", O_RDONLY | O_CLOEXEC | O_DIRECTORY);
|
||||
if (subfd < 0) {
|
||||
FF_DEBUG("openat(\"devices\") failed: %s", strerror(errno));
|
||||
return "openat(\"/sys/fs/btrfs/UUID/devices\") == -1";
|
||||
}
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = fdopendir(subfd);
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("fdopendir(\"devices\") failed: %s", strerror(errno));
|
||||
close(subfd);
|
||||
return "fdopendir(\"/sys/fs/btrfs/UUID/devices\") == nullptr";
|
||||
}
|
||||
@@ -42,11 +45,13 @@ static const char* enumerateDevices(FFBtrfsResult* item, int dfd, FFstrbuf* buff
|
||||
static const char* enumerateFeatures(FFBtrfsResult* item, int dfd) {
|
||||
int subfd = openat(dfd, "features", O_RDONLY | O_CLOEXEC | O_DIRECTORY);
|
||||
if (subfd < 0) {
|
||||
FF_DEBUG("openat(\"features\") failed: %s", strerror(errno));
|
||||
return "openat(\"/sys/fs/btrfs/UUID/features\") == -1";
|
||||
}
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = fdopendir(subfd);
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("fdopendir(\"features\") failed: %s", strerror(errno));
|
||||
return "fdopendir(\"/sys/fs/btrfs/UUID/features\") == nullptr";
|
||||
}
|
||||
|
||||
@@ -67,12 +72,14 @@ static const char* enumerateFeatures(FFBtrfsResult* item, int dfd) {
|
||||
static const char* detectAllocation(FFBtrfsResult* item, int dfd, FFstrbuf* buffer) {
|
||||
FF_AUTO_CLOSE_FD int subfd = openat(dfd, "allocation", O_RDONLY | O_CLOEXEC | O_PATH | O_DIRECTORY);
|
||||
if (subfd < 0) {
|
||||
FF_DEBUG("openat(\"allocation\") failed: %s", strerror(errno));
|
||||
return "openat(\"/sys/fs/btrfs/UUID/allocation\") == -1";
|
||||
}
|
||||
|
||||
if (ffReadFileBufferRelative(subfd, "global_rsv_size", buffer)) {
|
||||
item->globalReservationTotal = ffStrbufToUInt(buffer, 0);
|
||||
} else {
|
||||
FF_DEBUG("ffReadFileBuffer(\"global_rsv_size\") failed");
|
||||
return "ffReadFileBuffer(\"/sys/fs/btrfs/UUID/allocation/global_rsv_size\") == nullptr";
|
||||
}
|
||||
|
||||
@@ -124,6 +131,7 @@ static const char* detectAllocation(FFBtrfsResult* item, int dfd, FFstrbuf* buff
|
||||
const char* ffDetectBtrfs(FFlist* result) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/fs/btrfs/");
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("opendir(\"/sys/fs/btrfs\") failed: %s", strerror(errno));
|
||||
return "opendir(\"/sys/fs/btrfs\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "camera.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <camera/NdkCameraManager.h>
|
||||
#include <camera/NdkCameraMetadata.h>
|
||||
@@ -48,11 +49,13 @@ const char* ffDetectCamera(FFlist* result) {
|
||||
// API 24, so linking it unconditionally in CMakeLists.txt is fine on every supported device.
|
||||
ACameraManager* manager = ACameraManager_create();
|
||||
if (!manager) {
|
||||
FF_DEBUG("ACameraManager_create() failed");
|
||||
return "ACameraManager_create() failed";
|
||||
}
|
||||
|
||||
ACameraIdList* idList = nullptr;
|
||||
if (ACameraManager_getCameraIdList(manager, &idList) != ACAMERA_OK || !idList) {
|
||||
FF_DEBUG("ACameraManager_getCameraIdList() failed");
|
||||
ACameraManager_delete(manager);
|
||||
return "ACameraManager_getCameraIdList() failed";
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "camera.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if FF_HAVE_LINUX_VIDEODEV2
|
||||
@@ -26,6 +28,7 @@ const char* ffDetectCamera(FFlist* result) {
|
||||
if (errno == ENXIO) {
|
||||
continue;
|
||||
}
|
||||
FF_DEBUG("Failed to open /dev/videoN: %s", strerror(errno));
|
||||
return "Failed to open /dev/videoN";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "chassis.h"
|
||||
#include "common/debug.h"
|
||||
#include "detection/host/host.h"
|
||||
|
||||
const char* ffDetectChassis(FFChassisResult* result) {
|
||||
@@ -11,7 +12,9 @@ const char* ffDetectChassis(FFChassisResult* result) {
|
||||
.uuid = ffStrbufCreate(),
|
||||
.vendor = ffStrbufCreate(),
|
||||
};
|
||||
if (ffDetectHost(&host) != nullptr) {
|
||||
const char* hostError = ffDetectHost(&host);
|
||||
if (hostError != nullptr) {
|
||||
FF_DEBUG("ffDetectHost() failed: %s", hostError);
|
||||
return "Failed to detect host";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "codec.h"
|
||||
|
||||
#include "common/android/api.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/strutil.h"
|
||||
#include <media/NdkMediaCodec.h>
|
||||
|
||||
@@ -99,5 +100,6 @@ const char* ffDetectCodecNative(FFCodecOptions* options, FFlist* result /*list o
|
||||
// Reading the codec name is the only way to tell a hardware codec from a software one. Without
|
||||
// it there is nothing to report, and listing the codecs as if they were accelerated would be a
|
||||
// guess, so say why instead.
|
||||
FF_DEBUG("AMediaCodec_getName() requires Android 9 (API 28)");
|
||||
return "AMediaCodec_getName() requires Android 9 (API 28)";
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#if FF_HAVE_VA || FF_HAVE_VDPAU
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/library.h"
|
||||
#include "common/mallocHelper.h"
|
||||
#include "common/strutil.h"
|
||||
@@ -14,6 +15,7 @@
|
||||
#if FF_HAVE_VA
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <va/va.h>
|
||||
|
||||
typedef struct FFVAData {
|
||||
@@ -227,6 +229,7 @@ static const char* detectCodecByVaDrm(FFVAData* vaData, FFCodecOptions* options,
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/dev/dri/");
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("opendir(/dev/dri/) failed: %s", strerror(errno));
|
||||
return "opendir(/dev/dri/) failed";
|
||||
}
|
||||
int drifd = dirfd(dirp);
|
||||
@@ -268,11 +271,13 @@ static const char* detectCodecByVaX11(FFVAData* vaData, FFCodecOptions* options,
|
||||
|
||||
Display* x11Display = ffXOpenDisplay(nullptr);
|
||||
if (!x11Display) {
|
||||
FF_DEBUG("XOpenDisplay() failed");
|
||||
return "XOpenDisplay() failed";
|
||||
}
|
||||
|
||||
VADisplay display = ffvaGetDisplay(x11Display);
|
||||
if (!display) {
|
||||
FF_DEBUG("vaGetDisplay() failed");
|
||||
ffXCloseDisplay(x11Display);
|
||||
return "vaGetDisplay() failed";
|
||||
}
|
||||
@@ -380,14 +385,18 @@ static const char* detectCodecByVdpau(FFCodecOptions* options, FFlist* result) {
|
||||
|
||||
Display* x11Display = ffXOpenDisplay(nullptr);
|
||||
if (!x11Display) {
|
||||
FF_DEBUG("XOpenDisplay() failed");
|
||||
return "XOpenDisplay() failed";
|
||||
}
|
||||
|
||||
VdpDevice device = VDP_INVALID_HANDLE;
|
||||
VdpGetProcAddress* ffvdp_get_proc_address = nullptr;
|
||||
if (ffvdp_device_create_x11(x11Display, ffXDefaultScreen(x11Display), &device, &ffvdp_get_proc_address) != VDP_STATUS_OK ||
|
||||
VdpStatus ffvdp_device_create_x11_status = ffvdp_device_create_x11(x11Display, ffXDefaultScreen(x11Display), &device, &ffvdp_get_proc_address);
|
||||
if (ffvdp_device_create_x11_status != VDP_STATUS_OK ||
|
||||
device == VDP_INVALID_HANDLE ||
|
||||
ffvdp_get_proc_address == nullptr) {
|
||||
FF_DEBUG("vdp_device_create_x11() failed: status=%d, device=%p, getProcAddress=%p",
|
||||
ffvdp_device_create_x11_status, (void*) device, (void*) ffvdp_get_proc_address);
|
||||
ffXCloseDisplay(x11Display);
|
||||
return "vdp_device_create_x11() failed";
|
||||
}
|
||||
@@ -398,6 +407,7 @@ static const char* detectCodecByVdpau(FFCodecOptions* options, FFlist* result) {
|
||||
ffvdp_get_proc_address(device, VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES, (void**) &ffvdp_decoder_query_capabilities) != VDP_STATUS_OK ||
|
||||
ffvdp_device_destroy == nullptr ||
|
||||
ffvdp_decoder_query_capabilities == nullptr) {
|
||||
FF_DEBUG("vdp_device_create_x11() did not provide VDP_FUNC_ID_DEVICE_DESTROY / VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES");
|
||||
if (ffvdp_device_destroy) {
|
||||
ffvdp_device_destroy(device);
|
||||
}
|
||||
@@ -459,6 +469,7 @@ const char* ffDetectCodecNative(FFCodecOptions* options, FFlist* result /* list
|
||||
}
|
||||
#endif
|
||||
|
||||
FF_DEBUG("Neither libva nor libvdpau could initialize a display");
|
||||
return "Both libva and libvdpau fail to initialize";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/sysctl.h"
|
||||
#include "common/apple/smc_temps.h"
|
||||
#include "common/strutil.h"
|
||||
@@ -53,15 +54,18 @@ static const char* detectFrequency(FFCPUResult* cpu) {
|
||||
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IOServiceGetMatchingService(MACH_PORT_NULL, IOServiceNameMatching("pmgr"));
|
||||
if (!entryDevice) {
|
||||
FF_DEBUG("IOServiceGetMatchingService() failed");
|
||||
return "IOServiceGetMatchingService() failed";
|
||||
}
|
||||
|
||||
if (!IOObjectConformsTo(entryDevice, "AppleARMIODevice")) {
|
||||
FF_DEBUG("\"pmgr\" should conform to \"AppleARMIODevice\"");
|
||||
return "\"pmgr\" should conform to \"AppleARMIODevice\"";
|
||||
}
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFDataRef freqProperty = (CFDataRef) IORegistryEntryCreateCFProperty(entryDevice, CFSTR("voltage-states5-sram"), kCFAllocatorDefault, kNilOptions);
|
||||
if (!freqProperty || CFGetTypeID(freqProperty) != CFDataGetTypeID()) {
|
||||
FF_DEBUG("\"voltage-states5-sram\" in \"pmgr\" is not found");
|
||||
return "\"voltage-states5-sram\" in \"pmgr\" is not found";
|
||||
}
|
||||
|
||||
@@ -69,6 +73,7 @@ static const char* detectFrequency(FFCPUResult* cpu) {
|
||||
// voltage-states1-sram stores ecores'
|
||||
CFIndex propLength = CFDataGetLength(freqProperty);
|
||||
if (propLength == 0 || propLength % (CFIndex) (sizeof(uint32_t) * 2) != 0) {
|
||||
FF_DEBUG("Invalid \"voltage-states5-sram\" length");
|
||||
return "Invalid \"voltage-states5-sram\" length";
|
||||
}
|
||||
|
||||
@@ -106,6 +111,7 @@ static const char* detectFrequency(FFCPUResult* cpu) {
|
||||
static const char* detectCoreCount(FFCPUResult* cpu) {
|
||||
uint32_t nPerfLevels = (uint32_t) ffSysctlGetInt("hw.nperflevels", 0);
|
||||
if (nPerfLevels <= 0) {
|
||||
FF_DEBUG("sysctl(hw.nperflevels) failed");
|
||||
return "sysctl(hw.nperflevels) failed";
|
||||
}
|
||||
|
||||
@@ -124,7 +130,9 @@ static const char* detectCoreCount(FFCPUResult* cpu) {
|
||||
}
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
if (ffSysctlGetString("machdep.cpu.brand_string", &cpu->name) != nullptr) {
|
||||
const char* error = ffSysctlGetString("machdep.cpu.brand_string", &cpu->name);
|
||||
if (error != nullptr) {
|
||||
FF_DEBUG("sysctlbyname(machdep.cpu.brand_string) failed: %s", error);
|
||||
return "sysctlbyname(machdep.cpu.brand_string) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#include "cpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/sysctl.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#if __has_include(<sys/cpuset.h>)
|
||||
#include <sys/cpuset.h>
|
||||
@@ -13,6 +16,7 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
|
||||
if (options->tempSensor.length > 0) {
|
||||
temp = ffSysctlGetInt(options->tempSensor.chars, -999999);
|
||||
if (temp == -999999) {
|
||||
FF_DEBUG("sysctlbyname(%s) failed: %s", options->tempSensor.chars, strerror(errno));
|
||||
return "ffSysctlGetInt(options->tempSensor) failed";
|
||||
}
|
||||
} else {
|
||||
@@ -21,6 +25,7 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
|
||||
// Thermal zone temperature
|
||||
temp = ffSysctlGetInt("hw.acpi.thermal.tz0.temperature", -999999);
|
||||
if (temp == -999999) {
|
||||
FF_DEBUG("Neither sysctlbyname(dev.cpu.0.temperature) nor sysctlbyname(hw.acpi.thermal.tz0.temperature) is readable: %s", strerror(errno));
|
||||
return "ffSysctlGetInt(\"dev.cpu.0.temperature\" or \"hw.acpi.thermal.tz0.temperature\") failed";
|
||||
}
|
||||
}
|
||||
@@ -32,7 +37,9 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
|
||||
}
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
if (ffSysctlGetString("hw.model", &cpu->name) != nullptr) {
|
||||
const char* modelError = ffSysctlGetString("hw.model", &cpu->name);
|
||||
if (modelError != nullptr) {
|
||||
FF_DEBUG("sysctlbyname(hw.model) failed: %s", modelError);
|
||||
return "sysctlbyname(hw.model) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <OS.h>
|
||||
@@ -6,18 +7,23 @@
|
||||
|
||||
const char* ffDetectCPUImpl([[maybe_unused]] const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
system_info sysInfo;
|
||||
if (get_system_info(&sysInfo) != B_OK) {
|
||||
status_t status = get_system_info(&sysInfo);
|
||||
if (status != B_OK) {
|
||||
FF_DEBUG("get_system_info() failed: %d", (int) status);
|
||||
return "get_system_info() failed";
|
||||
}
|
||||
|
||||
uint32 topoNodeCount = 0;
|
||||
get_cpu_topology_info(nullptr, &topoNodeCount);
|
||||
if (topoNodeCount == 0) {
|
||||
FF_DEBUG("get_cpu_topology_info(nullptr) failed");
|
||||
return "get_cpu_topology_info(nullptr) failed";
|
||||
}
|
||||
|
||||
FF_AUTO_FREE cpu_topology_node_info* topology = malloc(sizeof(*topology) * topoNodeCount);
|
||||
if (get_cpu_topology_info(topology, &topoNodeCount) != B_OK) {
|
||||
status_t topoStatus = get_cpu_topology_info(topology, &topoNodeCount);
|
||||
if (topoStatus != B_OK) {
|
||||
FF_DEBUG("get_cpu_topology_info(topology) failed: %d", (int) topoStatus);
|
||||
return "get_cpu_topology_info(topology) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/processing.h"
|
||||
#include "common/properties.h"
|
||||
@@ -8,6 +9,7 @@
|
||||
|
||||
#include <sys/sysinfo.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
@@ -831,11 +833,13 @@ bool ffCPUQualcommSnapdragonToName(FFstrbuf* name, char* compatibles) {
|
||||
static const char* detectPhysicalCores(FFCPUResult* cpu) {
|
||||
int dfd = open("/sys/devices/system/cpu/", O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||
if (dfd < 0) {
|
||||
FF_DEBUG("open(/sys/devices/system/cpu/) failed: %s", strerror(errno));
|
||||
return "open(\"/sys/devices/system/cpu/\") failed";
|
||||
}
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = fdopendir(dfd);
|
||||
if (!dir) {
|
||||
FF_DEBUG("fdopendir(/sys/devices/system/cpu/) failed: %s", strerror(errno));
|
||||
close(dfd);
|
||||
return "fdopendir(dfd) failed";
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/sysctl.h"
|
||||
#include "common/io.h"
|
||||
|
||||
@@ -8,6 +9,8 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
static void freePropDict(prop_dictionary_t* pdict) {
|
||||
assert(pdict != nullptr);
|
||||
@@ -20,11 +23,13 @@ static void freePropDict(prop_dictionary_t* pdict) {
|
||||
static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
|
||||
FF_AUTO_CLOSE_FD int fd = open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed: %s", strerror(errno));
|
||||
return "open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed";
|
||||
}
|
||||
|
||||
[[gnu::cleanup(freePropDict)]] prop_dictionary_t root = nullptr;
|
||||
if (prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &root) < 0) {
|
||||
FF_DEBUG("prop_dictionary_recv_ioctl(ENVSYS_GETDICTIONARY) failed: %s", strerror(errno));
|
||||
return "prop_dictionary_recv_ioctl(ENVSYS_GETDICTIONARY) failed";
|
||||
}
|
||||
|
||||
@@ -33,6 +38,7 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
|
||||
if (options->tempSensor.length > 0) {
|
||||
array = prop_dictionary_get(root, options->tempSensor.chars);
|
||||
if (!array) {
|
||||
FF_DEBUG("No temp data found in specified sensor");
|
||||
return "No temp data found in specified sensor";
|
||||
}
|
||||
} else {
|
||||
@@ -47,21 +53,25 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
|
||||
array = prop_dictionary_get(root, "acpitz0"); // Thermal Zones
|
||||
}
|
||||
if (!array) {
|
||||
FF_DEBUG("No temp data found in root dictionary");
|
||||
return "No temp data found in root dictionary";
|
||||
}
|
||||
}
|
||||
|
||||
if (prop_array_count(array) != 2) {
|
||||
FF_DEBUG("Unexpected `xtemp0` data");
|
||||
return "Unexpected `xtemp0` data";
|
||||
}
|
||||
|
||||
prop_dictionary_t dict = prop_array_get(array, 0);
|
||||
if (prop_object_type(dict) != PROP_TYPE_DICTIONARY) {
|
||||
FF_DEBUG("Unexpected `xtemp0[0]`");
|
||||
return "Unexpected `xtemp0[0]`";
|
||||
}
|
||||
|
||||
int temp = 0; // in µK
|
||||
if (!prop_dictionary_get_int(dict, "cur-value", &temp)) {
|
||||
FF_DEBUG("Failed to get temperature");
|
||||
return "Failed to get temperature";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "cpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/sysctl.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/sensors.h>
|
||||
@@ -19,6 +21,7 @@ static const char* detectCPUTemp(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
if (errno == ENXIO) {
|
||||
continue;
|
||||
}
|
||||
FF_DEBUG("sysctl(sensordev) failed: %s", strerror(errno));
|
||||
return "sysctl(sensordev) failed";
|
||||
}
|
||||
|
||||
@@ -37,6 +40,7 @@ static const char* detectCPUTemp(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
size_t slen = sizeof(struct sensor);
|
||||
if (sysctl(mib, 5, &sensor, &slen, nullptr, 0) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
FF_DEBUG("sysctl(sensor) failed: %s", strerror(errno));
|
||||
return "sysctl(sensor) failed";
|
||||
}
|
||||
continue;
|
||||
@@ -50,11 +54,14 @@ static const char* detectCPUTemp(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
}
|
||||
}
|
||||
|
||||
FF_DEBUG("No sensor for CPU temp found");
|
||||
return "No sensor for CPU temp found";
|
||||
}
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
if (ffSysctlGetString(CTL_HW, HW_MODEL, &cpu->name)) {
|
||||
const char* error = ffSysctlGetString(CTL_HW, HW_MODEL, &cpu->name);
|
||||
if (error) {
|
||||
FF_DEBUG("sysctl(hw.model) failed: %s", error);
|
||||
return "sysctl(hw.model) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/processing.h"
|
||||
#include "common/strutil.h"
|
||||
#include <kstat.h>
|
||||
@@ -31,6 +32,7 @@ static const char* detectCPUTempByKstat(const FFCPUOptions* options, kstat_ctl_t
|
||||
}
|
||||
}
|
||||
|
||||
FF_DEBUG("Failed to find CPU temperature using kstat");
|
||||
return "Failed to find CPU temperature using kstat";
|
||||
}
|
||||
|
||||
@@ -50,6 +52,7 @@ static const char* detectCPUTempByIpmiTool(FFCPUResult* cpu) {
|
||||
}
|
||||
}
|
||||
|
||||
FF_DEBUG("ipmitool sdr list failed to find CPU temperature");
|
||||
return "ipmitool sdr list failed to find CPU temperature";
|
||||
}
|
||||
|
||||
@@ -101,15 +104,18 @@ static inline uint16_t countTypeId(kstat_ctl_t* kc, const char* type) {
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
[[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open();
|
||||
if (!kc) {
|
||||
FF_DEBUG("kstat_open() failed");
|
||||
return "kstat_open() failed";
|
||||
}
|
||||
|
||||
kstat_t* ks = kstat_lookup(kc, "cpu_info", -1, nullptr);
|
||||
if (!ks) {
|
||||
FF_DEBUG("kstat_lookup() failed");
|
||||
return "kstat_lookup() failed";
|
||||
}
|
||||
|
||||
if (kstat_read(kc, ks, nullptr) < 0) {
|
||||
FF_DEBUG("kstat_read() failed");
|
||||
return "kstat_read() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cpucache.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/sysctl.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
@@ -6,6 +7,7 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) {
|
||||
// https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_system_capabilities#3901385
|
||||
uint32_t nPerfLevels = (uint32_t) ffSysctlGetInt("hw.nperflevels", 0);
|
||||
if (nPerfLevels <= 0) {
|
||||
FF_DEBUG("sysctl(hw.nperflevels) failed");
|
||||
return "sysctl(hw.nperflevels) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
#include "cpucache.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result, FFstrbuf* buffer, FFstrbuf* added) {
|
||||
uint32_t baseLen = path->length;
|
||||
ffStrbufAppendS(path, "/level");
|
||||
if (!ffReadFileBuffer(path->chars, buffer)) {
|
||||
FF_DEBUG("Failed to read \"%s\"", path->chars);
|
||||
return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/level\") == nullptr";
|
||||
}
|
||||
|
||||
@@ -17,6 +22,7 @@ static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result,
|
||||
ffStrbufSubstrBefore(path, baseLen);
|
||||
ffStrbufAppendS(path, "/size");
|
||||
if (!ffReadFileBuffer(path->chars, buffer)) {
|
||||
FF_DEBUG("Failed to read \"%s\"", path->chars);
|
||||
return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/size\") == nullptr";
|
||||
}
|
||||
|
||||
@@ -28,6 +34,7 @@ static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result,
|
||||
ffStrbufSubstrBefore(path, baseLen);
|
||||
ffStrbufAppendS(path, "/type");
|
||||
if (!ffReadFileBuffer(path->chars, buffer)) {
|
||||
FF_DEBUG("Failed to read \"%s\"", path->chars);
|
||||
return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/type\") == nullptr";
|
||||
}
|
||||
ffStrbufTrimRightSpace(buffer);
|
||||
@@ -47,6 +54,7 @@ static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result,
|
||||
cacheType = FF_CPU_CACHE_TYPE_TRACE;
|
||||
break;
|
||||
default:
|
||||
FF_DEBUG("Unknown cache type \"%c\"", buffer->chars[0]);
|
||||
return "unknown cache type";
|
||||
}
|
||||
|
||||
@@ -62,6 +70,7 @@ static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result,
|
||||
ffStrbufClear(buffer);
|
||||
ffStrbufAppendC(buffer, '[');
|
||||
if (!ffAppendFileBuffer(path->chars, buffer)) {
|
||||
FF_DEBUG("Failed to read \"%s\"", path->chars);
|
||||
return "ffAppendFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/shared_cpu_list\") == nullptr";
|
||||
}
|
||||
ffStrbufTrimRightSpace(buffer);
|
||||
@@ -82,6 +91,7 @@ static const char* parseCpuCache(FFstrbuf* path, FFCPUCacheResult* result, FFstr
|
||||
uint32_t baseLen = path->length;
|
||||
FF_AUTO_CLOSE_DIR DIR* pathCacheDir = opendir(path->chars);
|
||||
if (!pathCacheDir) {
|
||||
FF_DEBUG("opendir(\"%s\") failed: %s", path->chars, strerror(errno));
|
||||
return "opendir(\"/sys/devices/system/cpu/cpuX/cache/\") == nullptr";
|
||||
}
|
||||
|
||||
@@ -108,6 +118,7 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) {
|
||||
uint32_t baseLen = path.length;
|
||||
FF_AUTO_CLOSE_DIR DIR* pathCpuDir = opendir(path.chars);
|
||||
if (!pathCpuDir) {
|
||||
FF_DEBUG("opendir(\"%s\") failed: %s", path.chars, strerror(errno));
|
||||
return "opendir(\"/sys/devices/system/cpu/\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/debug.h"
|
||||
#include "detection/cpuusage/cpuusage.h"
|
||||
|
||||
#include <mach/processor_info.h>
|
||||
@@ -11,9 +12,11 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
mach_msg_type_number_t numCpuInfo;
|
||||
|
||||
if (host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &numCPUs, &cpuInfo, &numCpuInfo) != KERN_SUCCESS) {
|
||||
FF_DEBUG("host_processor_info() failed");
|
||||
return "host_processor_info() failed";
|
||||
}
|
||||
if (numCPUs * CPU_STATE_MAX != numCpuInfo) {
|
||||
FF_DEBUG("Unexpected host_processor_info() result");
|
||||
return "Unexpected host_processor_info() result";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#include "detection/cpuusage/cpuusage.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/resource.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#if __OpenBSD__ || __NetBSD__
|
||||
#include <sys/sched.h>
|
||||
@@ -19,10 +22,12 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
int ctls[] = { CTL_KERN, KERN_CP_TIME };
|
||||
#endif
|
||||
if (sysctl(ctls, 2, nullptr, &neededLength, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl({CTL_KERN, KERN_CPTIME}, 2, nullptr) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, nullptr) failed";
|
||||
}
|
||||
#else
|
||||
if (sysctlbyname("kern.cp_times", nullptr, &neededLength, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctlbyname(kern.cp_times, nullptr) failed: %s", strerror(errno));
|
||||
return "sysctlbyname(kern.cp_times, nullptr) failed";
|
||||
}
|
||||
#endif
|
||||
@@ -34,10 +39,12 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
|
||||
#if __OpenBSD__ || __NetBSD__
|
||||
if (sysctl(ctls, 2, cpTimes, &neededLength, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl({CTL_KERN, KERN_CPTIME}, 2, cpTimes) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, nullptr) failed";
|
||||
}
|
||||
#else
|
||||
if (sysctlbyname("kern.cp_times", cpTimes, &neededLength, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctlbyname(kern.cp_times, cpTimes) failed: %s", strerror(errno));
|
||||
return "sysctlbyname(kern.cp_times, cpTime) failed";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "detection/cpuusage/cpuusage.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <OS.h>
|
||||
@@ -7,11 +8,13 @@
|
||||
const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
system_info sysInfo;
|
||||
if (get_system_info(&sysInfo) != B_OK) {
|
||||
FF_DEBUG("get_system_info() failed");
|
||||
return "get_system_info() failed";
|
||||
}
|
||||
|
||||
FF_AUTO_FREE cpu_info* cpuInfo = malloc(sizeof(*cpuInfo) * sysInfo.cpu_count);
|
||||
if (get_cpu_info(0, sysInfo.cpu_count, cpuInfo) != B_OK) {
|
||||
FF_DEBUG("get_cpu_info() failed");
|
||||
return "get_cpu_info() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "detection/cpuusage/cpuusage.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -9,6 +10,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
char buf[PROC_FILE_BUFFSIZ];
|
||||
ssize_t nRead = ffReadFileData("/proc/stat", ARRAY_SIZE(buf) - 1, buf);
|
||||
if (nRead < 0) {
|
||||
FF_DEBUG("Reading \"/proc/stat\" failed: %s", strerror(errno));
|
||||
#ifdef __ANDROID__
|
||||
return "Accessing \"/proc/stat\" is restricted on Android O+";
|
||||
#else
|
||||
@@ -20,6 +22,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
// Skip first line
|
||||
char* start = nullptr;
|
||||
if ((start = strchr(buf, '\n')) == nullptr) {
|
||||
FF_DEBUG("skip first line failed");
|
||||
return "skip first line failed";
|
||||
}
|
||||
++start;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/debug.h"
|
||||
#include "detection/cpuusage/cpuusage.h"
|
||||
|
||||
#include <kstat.h>
|
||||
@@ -14,6 +15,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) {
|
||||
const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
[[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open();
|
||||
if (!kc) {
|
||||
FF_DEBUG("kstat_open() failed");
|
||||
return "kstat_open() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "de.h"
|
||||
|
||||
#include "common/dbus.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/library.h"
|
||||
#include "common/parsing.h"
|
||||
@@ -43,12 +44,14 @@ static const char* getGnomeByDbus([[maybe_unused]] FFstrbuf* result) {
|
||||
#ifdef FF_HAVE_DBUS
|
||||
FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {};
|
||||
if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != nullptr) {
|
||||
FF_DEBUG("ffDBusLoadData() failed");
|
||||
return "ffDBusLoadData() failed";
|
||||
}
|
||||
|
||||
ffDBusGetPropertyString(&dbus, "org.gnome.Shell", "/org/gnome/Shell", "org.gnome.Shell", "ShellVersion", result);
|
||||
return nullptr;
|
||||
#else // FF_HAVE_DBUS
|
||||
FF_DEBUG("ffDBusLoadData() failed: dbus support not compiled in");
|
||||
return "ffDBusLoadData() failed: dbus support not compiled in";
|
||||
#endif // FF_HAVE_DBUS
|
||||
}
|
||||
@@ -103,6 +106,7 @@ static const char* getXfce4ByLib(FFstrbuf* result) {
|
||||
return nullptr;
|
||||
#else
|
||||
FF_UNUSED(result);
|
||||
FF_DEBUG("dlopen is disabled");
|
||||
return "dlopen is disabled";
|
||||
#endif
|
||||
}
|
||||
@@ -164,6 +168,7 @@ static const char* getTrinity(FFstrbuf* result, [[maybe_unused]] FFDEOptions* op
|
||||
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
|
||||
const char* error = ffFindExecutableInPath("tde-config", &path);
|
||||
if (error) {
|
||||
FF_DEBUG("Failed to find tde-config path");
|
||||
return "Failed to find tde-config path";
|
||||
}
|
||||
|
||||
@@ -180,6 +185,7 @@ static const char* getTrinity(FFstrbuf* result, [[maybe_unused]] FFDEOptions* op
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_DEBUG("All methods failed");
|
||||
return "All methods failed";
|
||||
}
|
||||
|
||||
@@ -197,6 +203,7 @@ static const char* getCosmic(FFstrbuf* result, [[maybe_unused]] FFDEOptions* opt
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_DEBUG("All methods failed");
|
||||
return "All methods failed";
|
||||
}
|
||||
|
||||
@@ -204,27 +211,32 @@ static const char* getEnlightenmentByDbus([[maybe_unused]] FFstrbuf* result) {
|
||||
#ifdef FF_HAVE_DBUS
|
||||
FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {};
|
||||
if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != nullptr) {
|
||||
FF_DEBUG("ffDBusLoadData() failed");
|
||||
return "ffDBusLoadData() failed";
|
||||
}
|
||||
|
||||
DBusMessage* reply = ffDBusGetMethodReply(&dbus, "org.enlightenment.wm.service", "/org/enlightenment/wm/RemoteObject", "org.enlightenment.wm.Core", "Version", nullptr, nullptr);
|
||||
if (!reply) {
|
||||
FF_DEBUG("ffDBusGetMethodReply() failed");
|
||||
return "ffDBusGetMethodReply() failed";
|
||||
}
|
||||
|
||||
DBusMessageIter rootIterator;
|
||||
if (!dbus.lib->ffdbus_message_iter_init(reply, &rootIterator)) {
|
||||
dbus.lib->ffdbus_message_unref(reply);
|
||||
FF_DEBUG("dbus_message_iter_init() failed");
|
||||
return "dbus_message_iter_init() failed";
|
||||
}
|
||||
if (!ffDBusGetString(&dbus, &rootIterator, result)) {
|
||||
dbus.lib->ffdbus_message_unref(reply);
|
||||
FF_DEBUG("ffDBusGetString() failed");
|
||||
return "ffDBusGetString() failed";
|
||||
}
|
||||
dbus.lib->ffdbus_message_unref(reply);
|
||||
|
||||
return nullptr;
|
||||
#else // FF_HAVE_DBUS
|
||||
FF_DEBUG("ffDBusLoadData() failed: dbus support not compiled in");
|
||||
return "ffDBusLoadData() failed: dbus support not compiled in";
|
||||
#endif // FF_HAVE_DBUS
|
||||
}
|
||||
@@ -241,6 +253,7 @@ static void getEnlightenment(FFstrbuf* result, [[maybe_unused]] FFDEOptions* opt
|
||||
}
|
||||
const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOptions* options) {
|
||||
if (!instance.config.general.detectVersion) {
|
||||
FF_DEBUG("Disabled by config");
|
||||
return "Disabled by config";
|
||||
}
|
||||
|
||||
@@ -270,6 +283,7 @@ const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOpti
|
||||
} else if (ffStrbufEqualS(deName, FF_DE_PRETTY_ENLIGHTENMENT)) {
|
||||
getEnlightenment(result, options);
|
||||
} else {
|
||||
FF_DEBUG("Unsupported DE");
|
||||
return "Unsupported DE";
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "disk.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/mallocHelper.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdalign.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -28,16 +30,19 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) {
|
||||
static struct gclass* cLabels;
|
||||
if (!cLabels) {
|
||||
if (geomTree.lg_ident) {
|
||||
FF_DEBUG("Previous geom_gettree() failed");
|
||||
return "Previous geom_gettree() failed";
|
||||
}
|
||||
|
||||
if (geom_gettree(&geomTree) < 0) {
|
||||
FF_DEBUG("geom_gettree() failed");
|
||||
geomTree.lg_ident = (void*) (intptr_t) -1;
|
||||
return "geom_gettree() failed";
|
||||
}
|
||||
|
||||
for (cLabels = geomTree.lg_class.lh_first; cLabels && !ffStrEquals(cLabels->lg_name, "LABEL"); cLabels = cLabels->lg_class.le_next);
|
||||
if (!cLabels) {
|
||||
FF_DEBUG("Class LABEL is not found");
|
||||
return "Class LABEL is not found";
|
||||
}
|
||||
}
|
||||
@@ -129,11 +134,13 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
|
||||
#ifndef __NetBSD__
|
||||
int size = getfsstat(nullptr, 0, MNT_WAIT);
|
||||
if (size <= 0) {
|
||||
FF_DEBUG("getfsstat(nullptr, 0, MNT_WAIT) failed: %s", strerror(errno));
|
||||
return "getfsstat(nullptr, 0, MNT_WAIT) failed";
|
||||
}
|
||||
#else
|
||||
int size = getvfsstat(nullptr, 0, ST_WAIT);
|
||||
if (size <= 0) {
|
||||
FF_DEBUG("getvfsstat(nullptr, 0, ST_WAIT) failed: %s", strerror(errno));
|
||||
return "getvfsstat(nullptr, 0, ST_WAIT) failed";
|
||||
}
|
||||
#endif
|
||||
@@ -141,10 +148,12 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
|
||||
FF_AUTO_FREE struct statfs* buf = malloc(sizeof(*buf) * (unsigned) size);
|
||||
#ifndef __NetBSD__
|
||||
if (getfsstat(buf, (int) (sizeof(*buf) * (unsigned) size), MNT_NOWAIT) <= 0) {
|
||||
FF_DEBUG("getfsstat(buf, size, MNT_NOWAIT) failed: %s", strerror(errno));
|
||||
return "getfsstat(buf, size, MNT_NOWAIT) failed";
|
||||
}
|
||||
#else
|
||||
if (getvfsstat(buf, sizeof(*buf) * (unsigned) size, ST_NOWAIT) <= 0) {
|
||||
FF_DEBUG("getvfsstat(buf, size, ST_NOWAIT) failed: %s", strerror(errno));
|
||||
return "getvfsstat(buf, size, ST_NOWAIT) failed";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "disk.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
@@ -285,6 +286,7 @@ static void detectStats(FFDisk* disk) {
|
||||
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
|
||||
FILE* mountsFile = setmntent("/proc/mounts", "r");
|
||||
if (mountsFile == nullptr) {
|
||||
FF_DEBUG("setmntent(\"/proc/mounts\", \"r\") failed: %s", strerror(errno));
|
||||
return "setmntent(\"/proc/mounts\", \"r\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "diskio.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
@@ -11,6 +12,7 @@
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
FF_IOOBJECT_AUTO_RELEASE io_iterator_t iterator = 0;
|
||||
if (IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching(kIOBlockStorageDriverClass), &iterator) != KERN_SUCCESS) {
|
||||
FF_DEBUG("IOServiceGetMatchingServices() failed");
|
||||
return "IOServiceGetMatchingServices() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#if __has_include(<libgeom.h>)
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#include <devstat.h>
|
||||
@@ -11,18 +12,24 @@
|
||||
#include <sys/disk.h>
|
||||
#include <libgeom.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
[[gnu::cleanup(geom_deletetree)]] struct gmesh geomTree = {};
|
||||
if (geom_gettree(&geomTree) < 0) {
|
||||
FF_DEBUG("geom_gettree() failed: %s", strerror(errno));
|
||||
return "geom_gettree() failed";
|
||||
}
|
||||
|
||||
if (geom_stats_open() < 0) {
|
||||
FF_DEBUG("geom_stats_open() failed: %s", strerror(errno));
|
||||
return "geom_stats_open() failed";
|
||||
}
|
||||
|
||||
void* snap = geom_stats_snapshot_get();
|
||||
if (!snap) {
|
||||
FF_DEBUG("geom_stats_snapshot_get() returned null");
|
||||
return "geom_stats_snapshot_get() failed";
|
||||
}
|
||||
|
||||
@@ -74,11 +81,15 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
|
||||
#else
|
||||
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <devstat.h>
|
||||
#include <memory.h>
|
||||
#include <errno.h>
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
if (checkversion() < 0) {
|
||||
FF_DEBUG("checkversion() failed: %s", strerror(errno));
|
||||
return "checkversion() failed";
|
||||
}
|
||||
|
||||
@@ -86,6 +97,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
.dinfo = (struct devinfo*) calloc(1, sizeof(struct devinfo)),
|
||||
};
|
||||
if (getdevs(&stats) < 0) {
|
||||
FF_DEBUG("getdevs() failed: %s", strerror(errno));
|
||||
return "getdevs() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "diskio.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/properties.h"
|
||||
#include "common/strutil.h"
|
||||
@@ -56,10 +57,12 @@ static const char* parseDiskIOCounters(int dfd, const char* devName, FFlist* res
|
||||
char sysBlockStat[PROC_FILE_BUFFSIZ];
|
||||
ssize_t fileSize = ffReadFileDataRelative(dfd, "stat", ARRAY_SIZE(sysBlockStat) - 1, sysBlockStat);
|
||||
if (fileSize <= 0) {
|
||||
FF_DEBUG("failed to read stat file");
|
||||
return "failed to read stat file";
|
||||
}
|
||||
sysBlockStat[fileSize] = '\0';
|
||||
if (sscanf(sysBlockStat, "%" PRIu64 "%*u%" PRIu64 "%*u%" PRIu64 "%*u%" PRIu64 "%*u", &nRead, §orRead, &nWritten, §orWritten) <= 0) {
|
||||
FF_DEBUG("invalid stat file format");
|
||||
return "invalid stat file format";
|
||||
}
|
||||
}
|
||||
@@ -78,6 +81,7 @@ static const char* parseDiskIOCounters(int dfd, const char* devName, FFlist* res
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
FF_AUTO_CLOSE_DIR DIR* sysBlockDirp = opendir("/sys/block/");
|
||||
if (sysBlockDirp == nullptr) {
|
||||
FF_DEBUG("opendir(\"/sys/block/\") failed: %s", strerror(errno));
|
||||
return "opendir(\"/sys/block/\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#include "diskio.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/iostat.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
@@ -10,6 +14,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
int mib[] = { CTL_HW, HW_IOSTATS, sizeof(struct io_sysctl) };
|
||||
size_t len;
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), nullptr, &len, nullptr, 0) < 0) {
|
||||
FF_DEBUG("sysctl({HW_IOSTATS}, nullptr) failed: %s", strerror(errno));
|
||||
return "sysctl({HW_IOSTATS}, nullptr) failed";
|
||||
}
|
||||
uint32_t nDrive = (uint32_t) (len / sizeof(struct io_sysctl));
|
||||
@@ -17,6 +22,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
FF_AUTO_FREE struct io_sysctl* stats = malloc(len);
|
||||
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, nullptr, 0) < 0) {
|
||||
FF_DEBUG("sysctl({HW_IOSTATS}, stats) failed: %s", strerror(errno));
|
||||
return "sysctl({HW_IOSTATS}, stats) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "diskio.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/strutil.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
@@ -9,6 +11,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
int mib[] = { CTL_HW, HW_DISKSTATS };
|
||||
size_t len;
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), nullptr, &len, nullptr, 0) < 0) {
|
||||
FF_DEBUG("sysctl({HW_DISKSTATS}, nullptr) failed: %s", strerror(errno));
|
||||
return "sysctl({HW_DISKSTATS}, nullptr) failed";
|
||||
}
|
||||
uint32_t nDrive = (uint32_t) (len / sizeof(struct diskstats));
|
||||
@@ -16,6 +19,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
FF_AUTO_FREE struct diskstats* stats = malloc(len);
|
||||
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, nullptr, 0) < 0) {
|
||||
FF_DEBUG("sysctl({HW_DISKSTATS}, stats) failed: %s", strerror(errno));
|
||||
return "sysctl({HW_DISKSTATS}, stats) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "diskio.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/strutil.h"
|
||||
#include <kstat.h>
|
||||
|
||||
@@ -12,6 +13,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) {
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
[[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open();
|
||||
if (!kc) {
|
||||
FF_DEBUG("kstat_open() failed");
|
||||
return "kstat_open() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "gamepad.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
@@ -65,6 +66,7 @@ static void detectGamepad(FFlist* devices, FFstrbuf* name, FFstrbuf* path) {
|
||||
const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/input/");
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("opendir(\"/sys/class/input/\") failed: %s", strerror(errno));
|
||||
return "opendir(\"/sys/class/input/\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "gpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
@@ -51,5 +52,6 @@ double ffGPUDetectTempFromTZ(void) {
|
||||
|
||||
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
FF_UNUSED(options, gpus);
|
||||
FF_DEBUG("No permission. Fallbacks to Vulkan, OpenCL or OpenGL instead");
|
||||
return "No permission. Fallbacks to Vulkan, OpenCL or OpenGL instead";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "gpu.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
#include "common/apple/smc_temps.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <IOKit/graphics/IOGraphicsLib.h>
|
||||
|
||||
@@ -58,21 +59,25 @@ static const char* detectFrequency(FFGPUResult* gpu) {
|
||||
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IOServiceGetMatchingService(MACH_PORT_NULL, IOServiceNameMatching("pmgr"));
|
||||
if (!entryDevice) {
|
||||
FF_DEBUG("IOServiceGetMatchingServices() failed");
|
||||
return "IOServiceGetMatchingServices() failed";
|
||||
}
|
||||
|
||||
if (!IOObjectConformsTo(entryDevice, "AppleARMIODevice")) {
|
||||
FF_DEBUG("\"pmgr\" should conform to \"AppleARMIODevice\"");
|
||||
return "\"pmgr\" should conform to \"AppleARMIODevice\"";
|
||||
}
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFDataRef freqProperty = (CFDataRef) IORegistryEntryCreateCFProperty(entryDevice, CFSTR("voltage-states9-sram"), kCFAllocatorDefault, kNilOptions);
|
||||
if (!freqProperty || CFGetTypeID(freqProperty) != CFDataGetTypeID()) {
|
||||
FF_DEBUG("\"voltage-states9-sram\" in \"pmgr\" is not found");
|
||||
return "\"voltage-states9-sram\" in \"pmgr\" is not found";
|
||||
}
|
||||
|
||||
// voltage-states9-sram stores supported <frequency / voltage> pairs of gpu from the lowest to the highest
|
||||
CFIndex propLength = CFDataGetLength(freqProperty);
|
||||
if (propLength == 0 || propLength % (CFIndex) (sizeof(uint32_t) * 2) != 0) {
|
||||
FF_DEBUG("Invalid \"voltage-states9-sram\" length");
|
||||
return "Invalid \"voltage-states9-sram\" length";
|
||||
}
|
||||
|
||||
@@ -101,6 +106,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
CFMutableDictionaryRef matches = IOServiceMatching(kIOAcceleratorClassName);
|
||||
CFDictionaryAddValue(matches, CFSTR("IOMatchCategory"), CFSTR(kIOAcceleratorClassName));
|
||||
if (IOServiceGetMatchingServices(MACH_PORT_NULL, matches, &iterator) != kIOReturnSuccess) {
|
||||
FF_DEBUG("IOServiceGetMatchingServices() failed");
|
||||
return "IOServiceGetMatchingServices() failed";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "gpu.h"
|
||||
#include "gpu_driver_specific.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/pciio.h>
|
||||
#include <fcntl.h>
|
||||
#if __has_include(<dev/pci/pcireg.h>)
|
||||
@@ -14,6 +16,7 @@
|
||||
static const char* detectByPci(const FFGPUOptions* options, FFlist* gpus) {
|
||||
FF_AUTO_CLOSE_FD int fd = open("/dev/pci", O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("open(\"/dev/pci\") failed: %s", strerror(errno));
|
||||
return "open(\"/dev/pci\", O_RDONLY | O_CLOEXEC, 0) failed";
|
||||
}
|
||||
|
||||
@@ -31,10 +34,12 @@ static const char* detectByPci(const FFGPUOptions* options, FFlist* gpus) {
|
||||
};
|
||||
|
||||
if (ioctl(fd, PCIOCGETCONF, &pcio) < 0) {
|
||||
FF_DEBUG("ioctl(PCIOCGETCONF) failed: %s", strerror(errno));
|
||||
return "ioctl(fd, PCIOCGETCONF, &pc) failed";
|
||||
}
|
||||
|
||||
if (pcio.status == PCI_GETCONF_ERROR) {
|
||||
FF_DEBUG("ioctl(fd, PCIOCGETCONF, &pc) returned error");
|
||||
return "ioctl(fd, PCIOCGETCONF, &pc) returned error";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
#include "gpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <private/drivers/poke.h>
|
||||
|
||||
const char* ffDetectGPUImpl([[maybe_unused]] const FFGPUOptions* options, FFlist* gpus) {
|
||||
FF_AUTO_CLOSE_FD int pokefd = open(POKE_DEVICE_FULLNAME, O_RDWR | O_CLOEXEC);
|
||||
if (pokefd < 0) {
|
||||
FF_DEBUG("open(%s) failed: %s", POKE_DEVICE_FULLNAME, strerror(errno));
|
||||
return "open(POKE_DEVICE_FULLNAME) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "detection/gpu/gpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/FFstrbuf.h"
|
||||
#include "common/strutil.h"
|
||||
@@ -57,6 +58,7 @@ static bool detectDriverFromSysfs(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf*
|
||||
sprintf(path, "/sys/class/drm/%s/device/drm", drmCardKey);
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(path);
|
||||
if (!dirp) {
|
||||
FF_DEBUG("opendir(%s) failed: %s", path, strerror(errno));
|
||||
return "Failed to open `/sys/class/drm/{drmCardKey}/device/drm`";
|
||||
}
|
||||
|
||||
@@ -68,6 +70,7 @@ static bool detectDriverFromSysfs(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf*
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
FF_DEBUG("Failed to find render device");
|
||||
return "Failed to find render device";
|
||||
}
|
||||
|
||||
@@ -214,6 +217,7 @@ static const char* drmDetectIntelSpecific(FFGPUResult* gpu, const char* drmKey,
|
||||
ffStrbufAppendS(buffer, drmKey);
|
||||
FF_AUTO_CLOSE_FD int fd = open(buffer->chars, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("open(%s) failed: %s", buffer->chars, strerror(errno));
|
||||
return "Failed to open drm device";
|
||||
}
|
||||
|
||||
@@ -222,6 +226,7 @@ static const char* drmDetectIntelSpecific(FFGPUResult* gpu, const char* drmKey,
|
||||
} else if (ffStrbufEqualS(&gpu->driver, "i915")) {
|
||||
return ffDrmDetectI915(gpu, fd);
|
||||
}
|
||||
FF_DEBUG("Unknown Intel GPU driver");
|
||||
return "Unknown Intel GPU driver";
|
||||
}
|
||||
|
||||
@@ -257,6 +262,7 @@ static const char* drmDetectNouveauSpecific(FFGPUResult* gpu, const char* drmKey
|
||||
ffStrbufAppendS(buffer, drmKey);
|
||||
FF_AUTO_CLOSE_FD int fd = open(buffer->chars, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("open(%s) failed: %s", buffer->chars, strerror(errno));
|
||||
return "Failed to open drm device";
|
||||
}
|
||||
|
||||
@@ -336,6 +342,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
uint32_t vendorId, deviceId, subVendorId, subDeviceId;
|
||||
uint8_t classId, subclassId;
|
||||
if (sscanf(buffer->chars + strlen("pci:"), "v%8" SCNx32 "d%8" SCNx32 "sv%8" SCNx32 "sd%8" SCNx32 "bc%2" SCNx8 "sc%2" SCNx8, &vendorId, &deviceId, &subVendorId, &subDeviceId, &classId, &subclassId) != 6) {
|
||||
FF_DEBUG("Failed to parse pci modalias");
|
||||
return "Failed to parse pci modalias";
|
||||
}
|
||||
|
||||
@@ -348,6 +355,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
if (drmKey) {
|
||||
ssize_t pathLength = readlink(deviceDir->chars, pciPath, ARRAY_SIZE(pciPath) - 1);
|
||||
if (pathLength <= 0) {
|
||||
FF_DEBUG("readlink(%s) failed: %s", deviceDir->chars, strerror(errno));
|
||||
return "Unable to get PCI device path";
|
||||
}
|
||||
pciPath[pathLength] = '\0';
|
||||
@@ -365,6 +373,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
|
||||
uint32_t pciDomain, pciBus, pciDevice, pciFunc;
|
||||
if (sscanf(pPciPath, "%" SCNx32 ":%" SCNx32 ":%" SCNx32 ".%" SCNx32, &pciDomain, &pciBus, &pciDevice, &pciFunc) != 4) {
|
||||
FF_DEBUG("Invalid PCI device path");
|
||||
return "Invalid PCI device path";
|
||||
}
|
||||
|
||||
@@ -517,6 +526,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
static const char* detectOf(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, const char* drmKey) {
|
||||
char compatible[256]; // vendor,model-name
|
||||
if (sscanf(buffer->chars + strlen("of:"), "NgpuT%*[^C]C%255[^C]", compatible) != 1) {
|
||||
FF_DEBUG("Failed to parse of modalias or not a GPU device");
|
||||
return "Failed to parse of modalias or not a GPU device";
|
||||
}
|
||||
|
||||
@@ -573,6 +583,7 @@ static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir(drmDir.chars);
|
||||
if (dir == nullptr) {
|
||||
FF_DEBUG("opendir(%s) failed: %s", drmDir.chars, strerror(errno));
|
||||
return "Failed to open `/sys/class/drm/`";
|
||||
}
|
||||
|
||||
@@ -612,6 +623,7 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) {
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDirPath);
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("opendir(%s) failed: %s", pciDirPath, strerror(errno));
|
||||
return "Failed to open `/sys/bus/pci/devices/`";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "gpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -37,6 +38,7 @@ const char* ffDetectGPUImpl([[maybe_unused]] const FFGPUOptions* options, FFlist
|
||||
if (errno == ENOENT) {
|
||||
break; // No more /dev/pciN devices
|
||||
}
|
||||
FF_DEBUG("open(\"%s\", O_RDONLY | O_CLOEXEC) failed: %s", pciDevPath, strerror(errno));
|
||||
return "open(\"/dev/pciN\", O_RDONLY | O_CLOEXEC) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "gpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
@@ -31,6 +34,7 @@ const char* detectByPci([[maybe_unused]] const FFGPUOptions* options, FFlist* gp
|
||||
char pciDevPath[] = "/dev/pci0";
|
||||
FF_AUTO_CLOSE_FD int pcifd = open(pciDevPath, O_RDONLY | O_CLOEXEC);
|
||||
if (pcifd < 0) {
|
||||
FF_DEBUG("open(\"%s\", O_RDONLY | O_CLOEXEC) failed: %s", pciDevPath, strerror(errno));
|
||||
return "open(\"/dev/pci0\", O_RDONLY | O_CLOEXEC) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "gpu.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#include <libdevinfo.h>
|
||||
@@ -46,6 +47,7 @@ static int walkDevTree(di_node_t node, [[maybe_unused]] di_minor_t minor, FFlist
|
||||
const char* ffDetectGPUImpl([[maybe_unused]] const FFGPUOptions* options, FFlist* gpus) {
|
||||
di_node_t rootNode = di_init("/", DINFOCPYALL);
|
||||
if (rootNode == DI_NODE_NIL) {
|
||||
FF_DEBUG("di_init() failed");
|
||||
return "di_init() failed";
|
||||
}
|
||||
di_walk_minor(rootNode, DDI_NT_DISPLAY, DI_WALK_CLDFIRST, gpus, (void*) walkDevTree);
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
#include "host.h"
|
||||
#include "common/sysctl.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
const char* getProductNameWithIokit(FFstrbuf* result) {
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/product");
|
||||
if (!registryEntry) {
|
||||
FF_DEBUG("IORegistryEntryFromPath(IODeviceTree:/product) failed");
|
||||
return "IOServiceGetMatchingService() failed";
|
||||
}
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFStringRef productName = IORegistryEntryCreateCFProperty(registryEntry, CFSTR("product-name"), kCFAllocatorDefault, kNilOptions);
|
||||
if (!productName) {
|
||||
FF_DEBUG("IORegistryEntryCreateCFProperty(product-name) failed");
|
||||
return "IORegistryEntryCreateCFProperty() failed";
|
||||
}
|
||||
|
||||
@@ -21,6 +24,7 @@ const char* getProductNameWithIokit(FFstrbuf* result) {
|
||||
const char* getOthersByIokit(FFHostResult* host) {
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t registryEntry = IOServiceGetMatchingService(MACH_PORT_NULL, IOServiceMatching("IOPlatformExpertDevice"));
|
||||
if (!registryEntry) {
|
||||
FF_DEBUG("IOServiceGetMatchingService(IOPlatformExpertDevice) failed");
|
||||
return "IOServiceGetMatchingService() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "icons.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/parsing.h"
|
||||
#include "detection/gtk_qt/gtk_qt.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
@@ -16,6 +17,7 @@ const char* ffDetectIcons(FFIconsResult* result) {
|
||||
const FFstrbuf* gtk4 = &ffDetectGTK4()->icons;
|
||||
|
||||
if (plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0) {
|
||||
FF_DEBUG("No icons could be found");
|
||||
return "No icons could be found";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "initsystem.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/strutil.h"
|
||||
#include "common/haiku/version.h"
|
||||
#include "common/io.h"
|
||||
@@ -11,6 +12,7 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) {
|
||||
// so we can't query be_roster for it.
|
||||
const char* path = "/boot/system/servers/launch_daemon";
|
||||
if (!ffPathExists(path, FF_PATHTYPE_FILE)) {
|
||||
FF_DEBUG("%s does not exist", path);
|
||||
return "launch_daemon is not found";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "keyboard.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
@@ -20,6 +21,7 @@ static void enumSet(IOHIDDeviceRef value, FFlist* results) {
|
||||
const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) {
|
||||
FF_CFTYPE_AUTO_RELEASE IOHIDManagerRef manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
|
||||
if (IOHIDManagerOpen(manager, kIOHIDOptionsTypeNone) != kIOReturnSuccess) {
|
||||
FF_DEBUG("IOHIDManagerOpen() failed");
|
||||
return "IOHIDManagerOpen() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "keyboard.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <usbhid.h>
|
||||
@@ -15,6 +17,7 @@
|
||||
static const char* detectByIoctl(FFlist* devices) {
|
||||
keyboard_info_t kbdInfo;
|
||||
if (ioctl(STDIN_FILENO, KDGKBINFO, &kbdInfo) != 0) {
|
||||
FF_DEBUG("ioctl(KDGKBINFO) failed: %s", strerror(errno));
|
||||
return "ioctl(KDGKBINFO) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extern "C" {
|
||||
#include "keyboard.h"
|
||||
#include "common/debug.h"
|
||||
}
|
||||
|
||||
#include <interface/Input.h>
|
||||
@@ -8,7 +9,9 @@ extern "C" {
|
||||
const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) {
|
||||
BList list;
|
||||
|
||||
if (get_input_devices(&list) != B_OK) {
|
||||
status_t status = get_input_devices(&list);
|
||||
if (status != B_OK) {
|
||||
FF_DEBUG("get_input_devices() failed: %d", (int) status);
|
||||
return "get_input_devices() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "keyboard.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
@@ -9,6 +10,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) {
|
||||
// This detects both wired and Bluetooth keyboards uniformly.
|
||||
FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate();
|
||||
if (!ffAppendFileBuffer("/proc/bus/input/devices", &content)) {
|
||||
FF_DEBUG("ffAppendFileBuffer(\"/proc/bus/input/devices\") failed");
|
||||
return "ffAppendFileBuffer(\"/proc/bus/input/devices\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "libc.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#include <features.h>
|
||||
@@ -17,6 +18,7 @@ const char* ffDetectLibc(FFLibcResult* result) {
|
||||
;
|
||||
return nullptr;
|
||||
#else
|
||||
FF_DEBUG("Unknown Android libc");
|
||||
return "Unknown Android libc";
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "lm.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/mallocHelper.h"
|
||||
#include "common/properties.h"
|
||||
@@ -9,6 +10,7 @@
|
||||
#include "common/dbus.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if __FreeBSD__
|
||||
@@ -30,6 +32,7 @@ static const char* getGdmVersion(FFstrbuf* version) {
|
||||
if (error || version->length == 0) {
|
||||
error = ffProcessAppendStdOut(version, (char* const[]) { "gdm", "--version", nullptr });
|
||||
if (error || version->length == 0) {
|
||||
FF_DEBUG("Failed to get GDM version");
|
||||
return "Failed to get GDM version";
|
||||
}
|
||||
}
|
||||
@@ -69,6 +72,7 @@ static const char* getSddmVersion(FFstrbuf* version) {
|
||||
|
||||
gzFile file = ffgzopen(FF_PATH_PKG_BASE "/share/man/man1/sddm.1.gz", "rb");
|
||||
if (file == Z_NULL) {
|
||||
FF_DEBUG("ffgzopen(\"/usr/share/man/man1/sddm.1.gz\", \"rb\") failed: %s", strerror(errno));
|
||||
return "ffgzopen(\"/usr/share/man/man1/sddm.1.gz\", \"rb\") failed";
|
||||
}
|
||||
|
||||
@@ -78,12 +82,14 @@ static const char* getSddmVersion(FFstrbuf* version) {
|
||||
ffgzclose(file);
|
||||
|
||||
if (size <= 0) {
|
||||
FF_DEBUG("ffgzread(file, version->chars, version->length) failed");
|
||||
return "ffgzread(file, version->chars, version->length) failed";
|
||||
}
|
||||
|
||||
version->length = (uint32_t) size;
|
||||
uint32_t index = ffStrbufFirstIndexS(version, ".TH ");
|
||||
if (index == version->length) {
|
||||
FF_DEBUG(".TH is not found");
|
||||
ffStrbufClear(version);
|
||||
return ".TH is not found";
|
||||
}
|
||||
@@ -137,6 +143,7 @@ static const char* detectBySystemdDbus(FFLMResult* result) {
|
||||
// and requires no $XDG_SESSION_ID being available
|
||||
FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {};
|
||||
if (ffDBusLoadData(DBUS_BUS_SYSTEM, &dbus) != nullptr) {
|
||||
FF_DEBUG("Failed to load system DBus");
|
||||
return "Failed to load system DBus";
|
||||
}
|
||||
|
||||
@@ -147,6 +154,7 @@ static const char* detectBySystemdDbus(FFLMResult* result) {
|
||||
"org.freedesktop.login1.Session",
|
||||
"Service",
|
||||
&result->service)) {
|
||||
FF_DEBUG("Failed to get systemd session Service property");
|
||||
return "Failed to get systemd session Service property";
|
||||
}
|
||||
|
||||
@@ -170,6 +178,7 @@ static const char* detectBySystemdPrivate(FFLMResult* result) {
|
||||
// This is actually buggy, and assumes current user is using DE
|
||||
// `sd_pid_get_session` can be a better option, but we need to find a pid to use
|
||||
if (!ffParsePropFile(path.chars, "DISPLAY=", &sessionId)) {
|
||||
FF_DEBUG("Failed to get $XDG_SESSION_ID");
|
||||
return "Failed to get $XDG_SESSION_ID";
|
||||
}
|
||||
}
|
||||
@@ -255,11 +264,13 @@ const char* detectByProcesses(FFLMResult* result) {
|
||||
size_t length = 0;
|
||||
|
||||
if (sysctl(request, ARRAY_SIZE(request), nullptr, &length, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, nullptr) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, nullptr) failed";
|
||||
}
|
||||
|
||||
FF_AUTO_FREE struct kinfo_proc* procs = (struct kinfo_proc*) malloc(length);
|
||||
if (sysctl(request, ARRAY_SIZE(request), procs, &length, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, procs) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, procs) failed";
|
||||
}
|
||||
|
||||
@@ -277,12 +288,14 @@ const char* detectByProcesses(FFLMResult* result) {
|
||||
size_t length = 0;
|
||||
|
||||
if (sysctl(request, ARRAY_SIZE(request), nullptr, &length, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, nullptr) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, nullptr) failed";
|
||||
}
|
||||
|
||||
FF_AUTO_FREE struct kinfo_proc* procs = (struct kinfo_proc*) malloc(length);
|
||||
request[5] = (int) (length / sizeof(struct kinfo_proc)); // count must be non-zero for data fetch
|
||||
if (sysctl(request, ARRAY_SIZE(request), procs, &length, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, procs) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, procs) failed";
|
||||
}
|
||||
|
||||
@@ -297,6 +310,7 @@ const char* detectByProcesses(FFLMResult* result) {
|
||||
#elif __sun
|
||||
FF_AUTO_CLOSE_DIR DIR* procdir = opendir("/proc");
|
||||
if (procdir == nullptr) {
|
||||
FF_DEBUG("opendir(\"/proc\") failed: %s", strerror(errno));
|
||||
return "opendir(\"/proc\") failed";
|
||||
}
|
||||
|
||||
@@ -331,6 +345,7 @@ const char* detectByProcesses(FFLMResult* result) {
|
||||
#elif __linux__ || __GNU__
|
||||
FF_AUTO_CLOSE_DIR DIR* procdir = opendir("/proc");
|
||||
if (procdir == nullptr) {
|
||||
FF_DEBUG("opendir(\"/proc\") failed: %s", strerror(errno));
|
||||
return "opendir(\"/proc\") failed";
|
||||
}
|
||||
|
||||
@@ -384,12 +399,14 @@ const char* detectByProcesses(FFLMResult* result) {
|
||||
|
||||
size_t size = 0;
|
||||
if (sysctl(request, ARRAY_SIZE(request), nullptr, &size, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl(KERN_PROC_UID, nullptr) failed: %s", strerror(errno));
|
||||
return "sysctl(KERN_PROC_UID, nullptr) failed";
|
||||
}
|
||||
|
||||
FF_AUTO_FREE struct kinfo_proc2* procs = malloc(size);
|
||||
|
||||
if (sysctl(request, ARRAY_SIZE(request), procs, &size, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl(KERN_PROC_UID, procs) failed: %s", strerror(errno));
|
||||
return "sysctl(KERN_PROC_UID, procs) failed";
|
||||
}
|
||||
|
||||
@@ -403,6 +420,7 @@ const char* detectByProcesses(FFLMResult* result) {
|
||||
#endif
|
||||
|
||||
if (result->service.length == 0) {
|
||||
FF_DEBUG("Failed to detect login manager by processes");
|
||||
return "Failed to detect login manager by processes";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "detection/loadavg/loadavg.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#if __FreeBSD__ || __OpenBSD__ || __NetBSD__
|
||||
@@ -14,6 +17,7 @@ const char* ffDetectLoadavg(double result[3]) {
|
||||
struct loadavg load;
|
||||
size_t size = sizeof(load);
|
||||
if (sysctl((int[]) { CTL_VM, VM_LOADAVG }, 2, &load, &size, nullptr, 0) < 0) {
|
||||
FF_DEBUG("sysctl({CTL_VM, VM_LOADAVG}) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_VM, VM_LOADAVG}) failed";
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "detection/loadavg/loadavg.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
const char* ffDetectLoadavg(double result[3]) {
|
||||
@@ -22,6 +25,7 @@ const char* ffDetectLoadavg(double result[3]) {
|
||||
// getloadavg requires higher ANDROID_API version
|
||||
struct sysinfo si;
|
||||
if (sysinfo(&si) < 0) {
|
||||
FF_DEBUG("both /proc/loadavg and sysinfo() failed: %s", strerror(errno));
|
||||
return "both /proc/loadavg and sysinfo() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "detection/locale/locale.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
@@ -18,5 +19,6 @@ const char* ffDetectLocale(FFstrbuf* result) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_DEBUG("LC_ALL, LANG and setlocale(LC_TIME, nullptr) are all empty");
|
||||
return "Failed to detect locale";
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) {
|
||||
|
||||
struct ifaddrs* ifAddrStruct = nullptr;
|
||||
if (getifaddrs(&ifAddrStruct) < 0) {
|
||||
FF_DEBUG("getifaddrs() failed");
|
||||
FF_DEBUG("getifaddrs() failed: %s", strerror(errno));
|
||||
return "getifaddrs(&ifAddrStruct) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -488,6 +488,8 @@ static const char* androidResolveCodes(FFMediaAndroidCodes* codes) {
|
||||
|| codes->getPackageName == FF_DEX_STATIC_INT_UNRESOLVED
|
||||
|| codes->getMetadata == FF_DEX_STATIC_INT_UNRESOLVED
|
||||
|| codes->getPlaybackState == FF_DEX_STATIC_INT_UNRESOLVED) {
|
||||
FF_DEBUG("Unresolved transaction codes: getSessions=%d, getPackageName=%d, getMetadata=%d, getPlaybackState=%d",
|
||||
(int) codes->getSessions, (int) codes->getPackageName, (int) codes->getMetadata, (int) codes->getPlaybackState);
|
||||
return "The session service does not declare every method this module calls";
|
||||
}
|
||||
return nullptr;
|
||||
@@ -637,6 +639,7 @@ static const char* androidReadMetadataEntry(FFMediaAndroidReader* reader, size_t
|
||||
static const char* androidReadMetadataBundle(FFMediaAndroidReader* reader, FFMediaResult* result, const FFBinderReply* reply, FFMediaAndroidCover* cover) {
|
||||
int32_t bundleLength = 0;
|
||||
if (!androidReadI32(reader, &bundleLength) || bundleLength <= 0) {
|
||||
FF_DEBUG("The metadata bundle length is %d, which cannot hold a bundle", (int) bundleLength);
|
||||
return "The metadata bundle is empty";
|
||||
}
|
||||
const size_t bundleEnd = reader->position + (size_t) bundleLength;
|
||||
@@ -646,10 +649,12 @@ static const char* androidReadMetadataBundle(FFMediaAndroidReader* reader, FFMed
|
||||
|
||||
int32_t magic = 0;
|
||||
if (!androidReadI32(reader, &magic) || (uint32_t) magic != FF_MEDIA_ANDROID_BUNDLE_MAGIC) {
|
||||
FF_DEBUG("The metadata magic is 0x%08x instead of 0x%08x", (unsigned) magic, FF_MEDIA_ANDROID_BUNDLE_MAGIC);
|
||||
return "The metadata is not a bundle";
|
||||
}
|
||||
int32_t count = 0;
|
||||
if (!androidReadI32(reader, &count)) {
|
||||
FF_DEBUG("The metadata bundle is truncated before its entry count");
|
||||
return "The metadata bundle has no entry count";
|
||||
}
|
||||
|
||||
@@ -951,6 +956,7 @@ static const char* androidDetectMediaSession(FFMediaResult* media, bool saveCove
|
||||
}
|
||||
|
||||
if (tokenCount == 0) {
|
||||
FF_DEBUG("The media_session service returned no session tokens");
|
||||
return "No active media session";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "memory.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <mach/mach.h>
|
||||
#include <sys/sysctl.h>
|
||||
@@ -11,10 +12,12 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
|
||||
#if FF_APPLE_MEMSIZE_USABLE
|
||||
if (sysctlbyname("hw.memsize_usable", &ram->bytesTotal, &length, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctlbyname(\"hw.memsize_usable\") failed: %s", strerror(errno));
|
||||
return "Failed to read hw.memsize_usable";
|
||||
}
|
||||
#else
|
||||
if (sysctl((int[]) { CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl(HW_MEMSIZE) failed: %s", strerror(errno));
|
||||
return "Failed to read hw.memsize";
|
||||
}
|
||||
#endif
|
||||
@@ -22,6 +25,7 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
|
||||
vm_statistics64_data_t vmstat;
|
||||
if (host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS) {
|
||||
FF_DEBUG("host_statistics64() failed");
|
||||
return "Failed to read host_statistics64";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#include "memory.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
size_t length = sizeof(ram->bytesTotal);
|
||||
if (sysctl((int[]) { CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, nullptr, 0)) {
|
||||
FF_DEBUG("sysctl(hw.physmem) failed: %s", strerror(errno));
|
||||
return "Failed to read hw.physmem";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#include "memory.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
system_info info;
|
||||
if (get_system_info(&info) != B_OK) {
|
||||
status_t status = get_system_info(&info);
|
||||
if (status != B_OK) {
|
||||
FF_DEBUG("get_system_info() failed: %d", (int) status);
|
||||
return "Error getting system info";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "memory.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
char buf[PROC_FILE_BUFFSIZ];
|
||||
ssize_t nRead = ffReadFileData("/proc/meminfo", ARRAY_SIZE(buf) - 1, buf);
|
||||
if (nRead < 0) {
|
||||
FF_DEBUG("ffReadFileData(\"/proc/meminfo\", ARRAY_SIZE(buf)-1, buf) failed: %s", strerror(errno));
|
||||
return "ffReadFileData(\"/proc/meminfo\", ARRAY_SIZE(buf)-1, buf)";
|
||||
}
|
||||
buf[nRead] = '\0';
|
||||
@@ -21,6 +23,7 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
if ((token = memmem(buf, (size_t) nRead, "MemTotal:", strlen("MemTotal:"))) != nullptr) {
|
||||
memTotal = (uint64_t) strtoull(token + strlen("MemTotal:"), nullptr, 10);
|
||||
} else {
|
||||
FF_DEBUG("MemTotal not found in /proc/meminfo");
|
||||
return "MemTotal not found in /proc/meminfo";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "memory.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
@@ -8,6 +11,7 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
struct uvmexp_sysctl buf;
|
||||
size_t length = sizeof(buf);
|
||||
if (sysctl((int[]) { CTL_VM, VM_UVMEXP2 }, 2, &buf, &length, nullptr, 0) < 0) {
|
||||
FF_DEBUG("sysctl(CTL_VM, VM_UVMEXP2) failed: %s", strerror(errno));
|
||||
return "sysctl(CTL_VM, VM_UVMEXP2) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "memory.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
@@ -8,6 +11,7 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
struct uvmexp buf;
|
||||
size_t length = sizeof(buf);
|
||||
if (sysctl((int[]) { CTL_VM, VM_UVMEXP }, 2, &buf, &length, nullptr, 0) < 0) {
|
||||
FF_DEBUG("sysctl(CTL_VM, VM_UVMEXP) failed: %s", strerror(errno));
|
||||
return "sysctl(CTL_VM, VM_UVMEXP) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "mouse.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
@@ -20,6 +21,7 @@ static void enumSet(IOHIDDeviceRef value, FFlist* results) {
|
||||
const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) {
|
||||
FF_CFTYPE_AUTO_RELEASE IOHIDManagerRef manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
|
||||
if (IOHIDManagerOpen(manager, kIOHIDOptionsTypeNone) != kIOReturnSuccess) {
|
||||
FF_DEBUG("IOHIDManagerOpen() failed");
|
||||
return "IOHIDManagerOpen() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extern "C" {
|
||||
#include "mouse.h"
|
||||
#include "common/debug.h"
|
||||
}
|
||||
|
||||
#include <interface/Input.h>
|
||||
@@ -8,7 +9,9 @@ extern "C" {
|
||||
const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) {
|
||||
BList list;
|
||||
|
||||
if (get_input_devices(&list) != B_OK) {
|
||||
status_t inputDevicesStatus = get_input_devices(&list);
|
||||
if (inputDevicesStatus != B_OK) {
|
||||
FF_DEBUG("get_input_devices() failed: status_t 0x%08x", (uint32_t) inputDevicesStatus);
|
||||
return "get_input_devices() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "mouse.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/input/");
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("opendir(\"/sys/class/input/\") failed: %s", strerror(errno));
|
||||
return "opendir(\"/sys/class/input/\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "netio.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/netif.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_mib.h>
|
||||
#include <sys/sysctl.h>
|
||||
@@ -12,6 +14,7 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
|
||||
size_t bufSize = 0;
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), nullptr, &bufSize, 0, 0) < 0) {
|
||||
FF_DEBUG("sysctl(mib, ARRAY_SIZE(mib), nullptr, &bufSize, 0, 0) failed: %s", strerror(errno));
|
||||
return "sysctl(mib, ARRAY_SIZE(mib), nullptr, &bufSize, 0, 0) failed";
|
||||
}
|
||||
|
||||
@@ -19,6 +22,7 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
|
||||
FF_AUTO_FREE struct ifmibdata* buf = (struct ifmibdata*) malloc(bufSize);
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), buf, &bufSize, 0, 0) < 0) {
|
||||
FF_DEBUG("sysctl(mib, ARRAY_SIZE(mib), buf, &bufSize, 0, 0) failed: %s", strerror(errno));
|
||||
return "sysctl(mib, ARRAY_SIZE(mib), buf, &bufSize, 0, 0) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "netio.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/netif.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
@@ -15,11 +17,13 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
|
||||
size_t bufSize = 0;
|
||||
if (sysctl((int[]) { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, (options->defaultRouteOnly ? (int) defaultRouteIfIndex : 0) }, 6, nullptr, &bufSize, 0, 0) < 0) {
|
||||
FF_DEBUG("sysctl({ CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, ifIndex }, 6, nullptr, &bufSize, 0, 0) failed: %s", strerror(errno));
|
||||
return "sysctl({ CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, ifIndex }, 6, nullptr, &bufSize, 0, 0) failed";
|
||||
}
|
||||
|
||||
FF_AUTO_FREE struct if_msghdr* buf = (struct if_msghdr*) malloc(bufSize);
|
||||
if (sysctl((int[]) { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, (options->defaultRouteOnly ? (int) defaultRouteIfIndex : 0) }, 6, buf, &bufSize, 0, 0) < 0) {
|
||||
FF_DEBUG("sysctl({ CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, ifIndex }, 6, buf, &bufSize, 0, 0) failed: %s", strerror(errno));
|
||||
return "sysctl({ CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, ifIndex }, 6, buf, &bufSize, 0, 0) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "netio.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/netif.h"
|
||||
#include "common/strutil.h"
|
||||
@@ -58,6 +59,7 @@ static void getData(FFstrbuf* buffer, const char* ifName, bool isDefaultRoute, i
|
||||
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/net");
|
||||
if (!dirp) {
|
||||
FF_DEBUG("opendir(\"/sys/class/net\") failed: %s", strerror(errno));
|
||||
return "opendir(\"/sys/class/net\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "netio.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/netif.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
@@ -14,6 +15,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) {
|
||||
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
[[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open();
|
||||
if (!kc) {
|
||||
FF_DEBUG("kstat_open() failed");
|
||||
return "kstat_open() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "opengl.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#define GL_SILENCE_DEPRECATION
|
||||
#include <OpenGL/gl.h>
|
||||
@@ -9,7 +10,9 @@
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, typeof(&glGetString) ffglGetString);
|
||||
|
||||
static const char* cglHandleContext(FFOpenGLResult* result, CGLContextObj context) {
|
||||
if (CGLSetCurrentContext(context) != kCGLNoError) {
|
||||
CGLError setContextError = CGLSetCurrentContext(context);
|
||||
if (setContextError != kCGLNoError) {
|
||||
FF_DEBUG("CGLSetCurrentContext() failed: CGLError %d", (int) setContextError);
|
||||
return "CGLSetCurrentContext() failed";
|
||||
}
|
||||
|
||||
@@ -25,7 +28,9 @@ static const char* cglHandleContext(FFOpenGLResult* result, CGLContextObj contex
|
||||
static const char* cglHandlePixelFormat(FFOpenGLResult* result, CGLPixelFormatObj pixelFormat) {
|
||||
CGLContextObj context;
|
||||
|
||||
if (CGLCreateContext(pixelFormat, nullptr, &context) != kCGLNoError) {
|
||||
CGLError createContextError = CGLCreateContext(pixelFormat, nullptr, &context);
|
||||
if (createContextError != kCGLNoError) {
|
||||
FF_DEBUG("CGLCreateContext() failed: CGLError %d", (int) createContextError);
|
||||
return "CGLCreateContext() failed";
|
||||
}
|
||||
|
||||
@@ -41,7 +46,9 @@ const char* cglDetectOpenGL(FFOpenGLResult* result) {
|
||||
};
|
||||
|
||||
GLint num;
|
||||
if (CGLChoosePixelFormat(attrs, &pixelFormat, &num) != kCGLNoError) {
|
||||
CGLError choosePixelFormatError = CGLChoosePixelFormat(attrs, &pixelFormat, &num);
|
||||
if (choosePixelFormatError != kCGLNoError) {
|
||||
FF_DEBUG("CGLChoosePixelFormat() failed: CGLError %d", (int) choosePixelFormatError);
|
||||
return "CGLChoosePixelFormat() failed";
|
||||
}
|
||||
|
||||
@@ -61,6 +68,7 @@ const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result) {
|
||||
return "fastfetch was compiled without egl support";
|
||||
#endif
|
||||
} else {
|
||||
FF_DEBUG("Unsupported OpenGL library requested: %d", (int) options->library);
|
||||
return "Unsupported OpenGL library";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
extern "C" {
|
||||
#include "opengl.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#if FF_HAVE_EGL
|
||||
const char* ffOpenGLDetectByEGL(FFOpenGLResult* result);
|
||||
@@ -16,6 +17,7 @@ static const char* oglDetectOpenGL(FFOpenGLResult* result) {
|
||||
BGLView glView(BRect(), "ff_ogl_view", B_FOLLOW_NONE, B_WILL_DRAW, BGL_RGB);
|
||||
auto ffglGetString = (decltype(&glGetString)) glView.GetGLProcAddress("glGetString");
|
||||
if (!ffglGetString) {
|
||||
FF_DEBUG("glView.GetGLProcAddress(glGetString) returned null");
|
||||
return "glView.GetGLProcAddress() failed";
|
||||
}
|
||||
ffOpenGLHandleResult(result, ffglGetString);
|
||||
@@ -33,6 +35,7 @@ const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result) {
|
||||
return "fastfetch was compiled without egl support";
|
||||
#endif
|
||||
} else {
|
||||
FF_DEBUG("Unsupported OpenGL library requested: %d", (int) options->library);
|
||||
return "Unsupported OpenGL library";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "opengl.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -50,6 +51,7 @@ typedef struct GLXData {
|
||||
|
||||
static const char* glxHandleContext(FFOpenGLResult* result, GLXData* data) {
|
||||
if (data->ffglXMakeCurrent(data->display, data->glxPixmap, data->context) != True) {
|
||||
FF_DEBUG("glXMakeCurrent() returned False");
|
||||
return "glXMakeCurrent returned False";
|
||||
}
|
||||
ffOpenGLHandleResult(result, data->ffglGetString);
|
||||
@@ -67,6 +69,7 @@ static const char* glxHandleContext(FFOpenGLResult* result, GLXData* data) {
|
||||
static const char* glxHandleGLXPixmap(FFOpenGLResult* result, GLXData* data) {
|
||||
data->context = data->ffglXCreateContext(data->display, data->visualInfo, nullptr, True);
|
||||
if (data->context == nullptr) {
|
||||
FF_DEBUG("glXCreateContext() returned nullptr");
|
||||
return "glXCreateContext returned nullptr";
|
||||
}
|
||||
|
||||
@@ -78,6 +81,7 @@ static const char* glxHandleGLXPixmap(FFOpenGLResult* result, GLXData* data) {
|
||||
static const char* glxHandlePixmap(FFOpenGLResult* result, GLXData* data) {
|
||||
data->glxPixmap = data->ffglXCreateGLXPixmap(data->display, data->visualInfo, data->pixmap);
|
||||
if (data->glxPixmap == None) {
|
||||
FF_DEBUG("glXCreateGLXPixmap() returned None");
|
||||
return "glXCreateGLXPixmap returned None";
|
||||
}
|
||||
|
||||
@@ -89,6 +93,7 @@ static const char* glxHandlePixmap(FFOpenGLResult* result, GLXData* data) {
|
||||
static const char* glxHandleVisualInfo(FFOpenGLResult* result, GLXData* data) {
|
||||
data->pixmap = data->ffXCreatePixmap(data->display, DefaultRootWindow(data->display), FF_OPENGL_BUFFER_WIDTH, FF_OPENGL_BUFFER_HEIGHT, (unsigned int) data->visualInfo->depth);
|
||||
if (data->pixmap == None) {
|
||||
FF_DEBUG("XCreatePixmap() returned None");
|
||||
return "XCreatePixmap returned None";
|
||||
}
|
||||
|
||||
@@ -100,6 +105,7 @@ static const char* glxHandleVisualInfo(FFOpenGLResult* result, GLXData* data) {
|
||||
static const char* glxHandleDisplay(FFOpenGLResult* result, GLXData* data) {
|
||||
data->visualInfo = data->ffglXChooseVisual(data->display, DefaultScreen(data->display), (int[]) { None });
|
||||
if (data->visualInfo == nullptr) {
|
||||
FF_DEBUG("glXChooseVisual() returned nullptr");
|
||||
return "glXChooseVisual returned nullptr";
|
||||
}
|
||||
|
||||
@@ -111,11 +117,13 @@ static const char* glxHandleDisplay(FFOpenGLResult* result, GLXData* data) {
|
||||
static const char* glxHandleData(FFOpenGLResult* result, GLXData* data) {
|
||||
data->ffglGetString = (typeof(data->ffglGetString)) data->ffglXGetProcAddress((const GLubyte*) "glGetString");
|
||||
if (data->ffglGetString == nullptr) {
|
||||
FF_DEBUG("glXGetProcAddress(glGetString) returned nullptr");
|
||||
return "glXGetProcAddress(glGetString) returned nullptr";
|
||||
}
|
||||
|
||||
data->display = data->ffXOpenDisplay(nullptr);
|
||||
if (data->display == nullptr) {
|
||||
FF_DEBUG("XOpenDisplay() returned nullptr");
|
||||
return "XOpenDisplay returned nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "physicaldisk.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/IOBSD.h>
|
||||
@@ -25,11 +26,13 @@ static const char* detectSsdTemp(io_service_t entryPhysical, double* temp) {
|
||||
[[gnu::cleanup(wrapIoDestroyPlugInInterface)]] IOCFPlugInInterface** pluginInf = nullptr;
|
||||
int32_t score;
|
||||
if (IOCreatePlugInInterfaceForService(entryPhysical, kIONVMeSMARTUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInf, &score) != kIOReturnSuccess) {
|
||||
FF_DEBUG("IOCreatePlugInInterfaceForService(kIONVMeSMARTUserClientTypeID) failed");
|
||||
return "IOCreatePlugInInterfaceForService() failed";
|
||||
}
|
||||
|
||||
IONVMeSMARTInterface** smartInf = nullptr;
|
||||
if ((*pluginInf)->QueryInterface(pluginInf, CFUUIDGetUUIDBytes(kIONVMeSMARTInterfaceID), (LPVOID) &smartInf) != kIOReturnSuccess) {
|
||||
FF_DEBUG("QueryInterface(kIONVMeSMARTInterfaceID) failed");
|
||||
return "QueryInterface() failed";
|
||||
}
|
||||
|
||||
@@ -44,6 +47,7 @@ static const char* detectSsdTemp(io_service_t entryPhysical, double* temp) {
|
||||
(*pluginInf)->Release(smartInf);
|
||||
return error;
|
||||
#else
|
||||
FF_DEBUG("SSD temperature detection needs macOS 10.15 or newer");
|
||||
return "No support for old MacOS version";
|
||||
#endif
|
||||
}
|
||||
@@ -51,6 +55,7 @@ static const char* detectSsdTemp(io_service_t entryPhysical, double* temp) {
|
||||
const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) {
|
||||
FF_IOOBJECT_AUTO_RELEASE io_iterator_t iterator = 0;
|
||||
if (IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching(kIOBlockStorageDriverClass), &iterator) != KERN_SUCCESS) {
|
||||
FF_DEBUG("IOServiceGetMatchingServices(kIOBlockStorageDriverClass) failed");
|
||||
return "IOServiceGetMatchingServices() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#if __has_include(<libgeom.h>)
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#include <devstat.h>
|
||||
@@ -14,10 +15,12 @@
|
||||
const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) {
|
||||
struct gmesh geomTree;
|
||||
if (geom_gettree(&geomTree) < 0) {
|
||||
FF_DEBUG("geom_gettree() failed");
|
||||
return "geom_gettree() failed";
|
||||
}
|
||||
|
||||
if (geom_stats_open() < 0) {
|
||||
FF_DEBUG("geom_stats_open() failed");
|
||||
return "geom_stats_open() failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "physicaldisk.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
@@ -11,6 +12,7 @@
|
||||
static const char* searchRawDeviceFile(FFstrbuf* path, const char* diskType, FFlist* result, FFPhysicalDiskOptions* options) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir(path->chars);
|
||||
if (!dir) {
|
||||
FF_DEBUG("opendir(\"%s\") failed: %s", path->chars, strerror(errno));
|
||||
return "detectDiskType: opendir() failed";
|
||||
}
|
||||
uint32_t baseLen = path->length;
|
||||
@@ -83,6 +85,7 @@ static const char* searchRawDeviceFile(FFstrbuf* path, const char* diskType, FFl
|
||||
const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/disk");
|
||||
if (!dir) {
|
||||
FF_DEBUG("opendir(\"/dev/disk\") failed: %s", strerror(errno));
|
||||
return "opendir(/dev/disk) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "physicaldisk.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/properties.h"
|
||||
#include "common/strutil.h"
|
||||
@@ -178,6 +179,7 @@ static void parsePhysicalDisk(int dfd, const char* devName, FFPhysicalDiskOption
|
||||
const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) {
|
||||
FF_AUTO_CLOSE_DIR DIR* sysBlockDirp = opendir("/sys/block/");
|
||||
if (sysBlockDirp == nullptr) {
|
||||
FF_DEBUG("opendir(\"/sys/block/\") failed: %s", strerror(errno));
|
||||
return "opendir(\"/sys/block/\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "physicaldisk.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/strutil.h"
|
||||
#include "sys/scsi/generic/inquiry.h"
|
||||
|
||||
@@ -98,6 +99,7 @@ static int walkDevTree(di_node_t node, di_minor_t minor, struct FFWalkTreeBundle
|
||||
const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) {
|
||||
di_node_t rootNode = di_init("/", DINFOCPYALL);
|
||||
if (rootNode == DI_NODE_NIL) {
|
||||
FF_DEBUG("di_init() failed");
|
||||
return "di_init() failed";
|
||||
}
|
||||
di_walk_minor(rootNode, DDI_NT_BLOCK, DI_WALK_CLDFIRST, &(struct FFWalkTreeBundle) { options, result }, (void*) walkDevTree);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "physicalmemory.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/endian.h"
|
||||
#include "common/smbios.h"
|
||||
|
||||
@@ -68,11 +69,13 @@ static_assert(offsetof(FFSmbiosMemoryDevice, RcdRevisionNumber) == 0x62,
|
||||
const char* ffDetectPhysicalMemory(FFPhysicalMemoryOptions* options, FFlist* result) {
|
||||
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
|
||||
if (!smbiosTable) {
|
||||
FF_DEBUG("Failed to get SMBIOS data");
|
||||
return "Failed to get SMBIOS data";
|
||||
}
|
||||
|
||||
const FFSmbiosMemoryDevice* data = (const FFSmbiosMemoryDevice*) (*smbiosTable)[FF_SMBIOS_TYPE_MEMORY_DEVICE];
|
||||
if (!data) {
|
||||
FF_DEBUG("Memory device is not found in SMBIOS data");
|
||||
return "Memory device is not found in SMBIOS data";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "poweradapter.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/io.h"
|
||||
#include "common/strutil.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
static void parsePowerAdapter(int dfd, const char* id, FFlist* results) {
|
||||
FF_STRBUF_AUTO_DESTROY tmpBuffer = ffStrbufCreate();
|
||||
@@ -72,6 +74,7 @@ static void parsePowerAdapter(int dfd, const char* id, FFlist* results) {
|
||||
const char* ffDetectPowerAdapter(FFlist* results) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/power_supply/");
|
||||
if (dirp == nullptr) {
|
||||
FF_DEBUG("opendir(\"/sys/class/power_supply/\") failed: %s", strerror(errno));
|
||||
return "opendir(\"/sys/class/power_supply/\") == nullptr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include "processes.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#import <libproc.h>
|
||||
|
||||
@@ -9,6 +13,7 @@ const char* ffDetectProcesses(const FFProcessesOptions* options, FFProcessesResu
|
||||
size_t length;
|
||||
|
||||
if (sysctl(request, ARRAY_SIZE(request), nullptr, &length, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl({CTL_KERN, KERN_PROC, KERN_PROC_ALL, nullptr}) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_ALL, nullptr}) failed";
|
||||
}
|
||||
|
||||
@@ -17,6 +22,7 @@ const char* ffDetectProcesses(const FFProcessesOptions* options, FFProcessesResu
|
||||
FF_AUTO_FREE struct kinfo_proc* processes = malloc(length);
|
||||
|
||||
if (sysctl(request, ARRAY_SIZE(request), processes, &length, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl({CTL_KERN, KERN_PROC, KERN_PROC_ALL, processes}) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_ALL, processes}) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "processes.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/user.h>
|
||||
@@ -9,6 +12,7 @@ const char* ffDetectProcesses(const FFProcessesOptions* options, FFProcessesResu
|
||||
int request[] = { CTL_KERN, KERN_PROC, KERN_PROC_PROC };
|
||||
size_t length;
|
||||
if (sysctl(request, ARRAY_SIZE(request), nullptr, &length, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl({CTL_KERN, KERN_PROC, KERN_PROC_PROC}) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_PROC}) failed";
|
||||
}
|
||||
|
||||
@@ -16,6 +20,7 @@ const char* ffDetectProcesses(const FFProcessesOptions* options, FFProcessesResu
|
||||
length += length / 8 + sizeof(struct kinfo_proc);
|
||||
FF_AUTO_FREE struct kinfo_proc* procs = malloc(length);
|
||||
if (sysctl(request, ARRAY_SIZE(request), procs, &length, nullptr, 0) != 0) {
|
||||
FF_DEBUG("sysctl({CTL_KERN, KERN_PROC, KERN_PROC_PROC}) failed: %s", strerror(errno));
|
||||
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_PROC}) failed";
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user