Skip to content

Commit

Permalink
Parse /kboot.conf
Browse files Browse the repository at this point in the history
If there's a kboot.conf, prase it after the command line args are
parsed. It's not always easy to get all the right command line args
depending on the environment. Allow an escape hatch. While we can't do
everything one might like in this file, we can do enough.

Sponsored by:		Netflix
  • Loading branch information
bsdimp committed Mar 14, 2023
1 parent bc33c99 commit 7f3c360
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions stand/kboot/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,31 @@ has_acpi(void)
return rsdp != 0;
}

static void
parse_file(const char *fn)
{
struct stat st;
int fd = -1;
char *env = NULL;

if (stat(fn, &st) != 0)
return;
fd = open(fn, O_RDONLY);
if (fd == -1)
return;
env = malloc(st.st_size + 1);
if (env == NULL)
goto out;
if (read(fd, env, st.st_size) != st.st_size)
goto out;
env[st.st_size] = '\0';
boot_parse_cmdline(env);
out:
free(env);
close(fd);
}


int
main(int argc, const char **argv)
{
Expand All @@ -221,6 +246,8 @@ main(int argc, const char **argv)
/* Parse the command line args -- ignoring for now the console selection */
parse_args(argc, argv);

parse_file("host:/kboot.conf");

/*
* Set up console.
*/
Expand Down

0 comments on commit 7f3c360

Please sign in to comment.