First commit

This commit is contained in:
PedroEdiaz
2025-10-01 12:41:12 -06:00
commit 5139653429
11 changed files with 319 additions and 0 deletions

23
libexec/shut.c Normal file
View File

@@ -0,0 +1,23 @@
#include "config.h"
void shut(char c)
{
log("Saving seed...");
{
char buf[512];
int input, output;
input = open("/dev/urandom", O_RDONLY);
output = open(SEEDFILE, O_WRONLY);
write(output, buf, read(input, buf, sizeof(buf)));
close(input);
close(output);
}
log("Running programs...");
runprgs((void *)shut_cmd, sizeof(shut_cmd) / sizeof(shut_cmd[0]));
reboot((c == 'r') ? RB_AUTOBOOT : RB_POWER_OFF);
}