ohmu
·
2026-10-15
1#include "initsystem.h"
2#include "common/debug.h"
3#include "common/strutil.h"
4#include "common/haiku/version.h"
5#include "common/io.h"
6
7#include <OS.h>
8#include <unistd.h>
9
10const char* ffDetectInitSystem(FFInitSystemResult* result) {
11 // Since it runs first, registrar does not know about it,
12 // so we can't query be_roster for it.
13 const char* path = "/boot/system/servers/launch_daemon";
14 if (!ffPathExists(path, FF_PATHTYPE_FILE)) {
15 FF_DEBUG("%s does not exist", path);
16 return "launch_daemon is not found";
17 }
18
19 ffStrbufSetStatic(&result->exe, path);
20 ffStrbufSetStatic(&result->name, "launch_daemon");
21 result->pid = 0;
22
23 team_info teamInfo;
24 int32 cookie = 0;
25 while (get_next_team_info(&cookie, &teamInfo) == B_OK) {
26 if (ffStrEquals(teamInfo.args, path)) {
27 result->pid = (uint32_t) teamInfo.team;
28 break;
29 }
30 }
31
32 if (instance.config.general.detectVersion) {
33 ffGetFileVersion(path, &result->version);
34 }
35
36 return nullptr;
37}