Skip to content

Commit af754f6

Browse files
committed
InitSystem (Haiku): add support
1 parent 5a665ff commit af754f6

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ elseif(Haiku)
11481148
src/detection/gtk_qt/gtk.c
11491149
src/detection/host/host_windows.c
11501150
src/detection/icons/icons_nosupport.c
1151-
src/detection/initsystem/initsystem_linux.c
1151+
src/detection/initsystem/initsystem_haiku.cpp
11521152
src/detection/keyboard/keyboard_nosupport.c
11531153
src/detection/libc/libc_nosupport.c
11541154
src/detection/lm/lm_nosupport.c
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
extern "C" {
2+
#include "initsystem.h"
3+
#include "common/processing.h"
4+
#include "util/binary.h"
5+
#include "util/stringUtils.h"
6+
};
7+
8+
#include <AppFileInfo.h>
9+
#include <File.h>
10+
#include <libgen.h>
11+
#include <OS.h>
12+
#include <Path.h>
13+
#include <unistd.h>
14+
15+
const char* ffDetectInitSystem(FFInitSystemResult* result)
16+
{
17+
team_info teamInfo;
18+
int32 cookie = 0;
19+
20+
// Since it runs first, registrar does not know about it,
21+
// so we can't query be_roster for it.
22+
BPath path("/boot/system/servers/launch_daemon");
23+
if (path.InitCheck() != B_OK)
24+
return NULL;
25+
26+
ffStrbufSetS(&result->exe, path.Path());
27+
ffStrbufSetStatic(&result->name, "launch_daemon");
28+
29+
while (get_next_team_info(&cookie, &teamInfo) == B_OK)
30+
{
31+
if (strcmp(teamInfo.args, path.Path()) == 0)
32+
{
33+
result->pid = (int)teamInfo.team;
34+
break;
35+
}
36+
}
37+
38+
BFile f(path.Path(), B_READ_ONLY);
39+
if (f.InitCheck() != B_OK)
40+
return NULL;
41+
BAppFileInfo fileInfo(&f);
42+
if (f.InitCheck() != B_OK)
43+
return NULL;
44+
45+
version_info version;
46+
if (fileInfo.GetVersionInfo(&version, B_SYSTEM_VERSION_KIND) != B_OK)
47+
return NULL;
48+
49+
ffStrbufSetF(&result->version, "%d.%d.%d", (int)version.major, (int)version.middle, (int)version.minor);
50+
51+
return NULL;
52+
}

0 commit comments

Comments
 (0)