InitSystem (Haiku): add support

This commit is contained in:
François Revol 2025-02-15 04:26:10 +01:00 committed by Carter Li
parent 349fdd47e4
commit 1c858ae835
2 changed files with 53 additions and 1 deletions

View File

@ -1148,7 +1148,7 @@ elseif(Haiku)
src/detection/gtk_qt/gtk.c
src/detection/host/host_windows.c
src/detection/icons/icons_nosupport.c
src/detection/initsystem/initsystem_linux.c
src/detection/initsystem/initsystem_haiku.cpp
src/detection/keyboard/keyboard_nosupport.c
src/detection/libc/libc_nosupport.c
src/detection/lm/lm_nosupport.c

View File

@ -0,0 +1,52 @@
extern "C" {
#include "initsystem.h"
#include "common/processing.h"
#include "util/binary.h"
#include "util/stringUtils.h"
};
#include <AppFileInfo.h>
#include <File.h>
#include <libgen.h>
#include <OS.h>
#include <Path.h>
#include <unistd.h>
const char* ffDetectInitSystem(FFInitSystemResult* result)
{
team_info teamInfo;
int32 cookie = 0;
// Since it runs first, registrar does not know about it,
// so we can't query be_roster for it.
BPath path("/boot/system/servers/launch_daemon");
if (path.InitCheck() != B_OK)
return NULL;
ffStrbufSetS(&result->exe, path.Path());
ffStrbufSetStatic(&result->name, "launch_daemon");
while (get_next_team_info(&cookie, &teamInfo) == B_OK)
{
if (strcmp(teamInfo.args, path.Path()) == 0)
{
result->pid = (int)teamInfo.team;
break;
}
}
BFile f(path.Path(), B_READ_ONLY);
if (f.InitCheck() != B_OK)
return NULL;
BAppFileInfo fileInfo(&f);
if (f.InitCheck() != B_OK)
return NULL;
version_info version;
if (fileInfo.GetVersionInfo(&version, B_SYSTEM_VERSION_KIND) != B_OK)
return NULL;
ffStrbufSetF(&result->version, "%d.%d.%d", (int)version.major, (int)version.middle, (int)version.minor);
return NULL;
}