meta: replace systemd and ldd with herdd and nsd

This commit is contained in:
2026-03-23 18:15:38 +00:00
parent d4d3ab13f4
commit bf5052fd3d
12 changed files with 105 additions and 34 deletions

View File

@@ -0,0 +1,10 @@
file(GLOB sources *.c)
add_executable(herdd ${sources})
target_link_libraries(herdd libc libc-runtime libmango libpthread)
sysroot_add_program(
NAME herdd
BIN_DIR /usr/bin)
bsp_add_program(
NAME herdd
BIN_DIR /usr/bin)

43
services/herdd/main.c Normal file
View File

@@ -0,0 +1,43 @@
#include <errno.h>
#include <mango/log.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
static void *thread_func(void *arg)
{
kern_logf("started thread with arg %p", arg);
errno = 100;
return (void *)0xdeadbeef;
}
int main(int argc, const char *argv[], const char *envp[])
{
kern_logf("herdd");
kern_logf("args:");
for (int i = 0; i < argc; i++) {
kern_logf("[%d]: %s", i, argv[i]);
}
kern_logf("env:");
for (int i = 0; envp[i]; i++) {
kern_logf("[%d]: %s", i, envp[i]);
}
kern_logf("self = %p", pthread_self());
errno = 200;
pthread_t thread;
pthread_create(&thread, NULL, thread_func, (void *)0xdeafcafe);
kern_logf("started thread %p", thread);
void *ret = NULL;
pthread_join(thread, &ret);
kern_logf("thread returned %p", ret);
kern_logf("errno...");
kern_logf("%u", errno);
kern_logf("...errno");
return 0;
}

View File

14
services/herdd/runlevel.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef RUNLEVEL_H_
#define RUNLEVEL_H_
#include <stddef.h>
#define RUNLEVEL_DESCRIPTION_MAX 64
struct runlevel {
char rl_description[RUNLEVEL_DESCRIPTION_MAX];
char **rl_requires;
size_t rl_requires_count;
};
#endif

0
services/herdd/service.c Normal file
View File

17
services/herdd/service.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef SERVICE_H_
#define SERVICE_H_
#define SVC_DESCRIPTION_MAX 64
enum service_role {
SVC_ROLE_NONE = 0x00u,
SVC_ROLE_NAMESPACE_PROVIDER = 0x01u,
};
struct service {
char s_description[SVC_DESCRIPTION_MAX];
enum service_role s_roles;
char *s_exec;
};
#endif

View File

@@ -1,10 +0,0 @@
file(GLOB sources *.c)
add_executable(ldd ${sources})
target_link_libraries(ldd libc-core libc-runtime libmango)
sysroot_add_program(
NAME ldd
BIN_DIR /usr/bin)
bsp_add_program(
NAME ldd
BIN_DIR /usr/bin)

View File

@@ -0,0 +1,15 @@
file(GLOB sources *.c)
rosetta_add_service(
NAME nsd
SOURCES ${sources}
CFG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/nsd.service)
target_link_libraries(nsd libc libc-runtime)
sysroot_add_service(
NAME nsd
BIN_DIR /usr/bin
SVC_DIR /etc/herdd/services)
bsp_add_service(
NAME nsd
BIN_DIR /usr/bin
SVC_DIR /etc/herdd/services)

6
services/nsd/nsd.service Normal file
View File

@@ -0,0 +1,6 @@
[Unit]
Description=Namespace Service
[Service]
Exec=/usr/bin/nsd
Role=NamespaceProvider