Skip to content

Commit

Permalink
Display the command and kernel being run on init
Browse files Browse the repository at this point in the history
I want to boot the kernel in quiet mode so need a way to tell the user what is
being tested.
  • Loading branch information
haesbaert committed Nov 12, 2024
1 parent 3c0abac commit 137f95d
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <sys/reboot.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/utsname.h>
#include <sys/wait.h>

static void
Expand All @@ -27,11 +28,31 @@ powerdown(void)
}
}

static void
display_banner(char *argv[])
{
struct utsname uts;
char **pp;

if (uname(&uts) == -1)
warn("uname");
else {
putchar('`');
for (pp = argv; *pp != 0; pp++) {
if (pp != argv)
putchar(' ');
printf("%s", *pp);
}
putchar('`');
printf(" on %s %s\n", uts.release, uts.machine);
}
}

int
main(int argc, char *argv[])
{
pid_t pid;
int status;
pid_t pid;
int status;

/*
* Cut the kernel some slack until it is in a good shape, I see TSC
Expand All @@ -55,7 +76,6 @@ main(int argc, char *argv[])

/* child */
if (pid == 0) {

if (mkdir("/proc", 0666) != 0)
err(1, "mkdir /proc");
if (mkdir("/sys", 0666) != 0)
Expand All @@ -76,6 +96,8 @@ main(int argc, char *argv[])
}
}

display_banner(argv);

return (execv(argv[0], argv));
}

Expand Down

0 comments on commit 137f95d

Please sign in to comment.