Page MenuHomeFreeBSD

kenv: allow listing of static kernel environments
ClosedPublic

Authored by kevans on Jun 20 2021, 8:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 12:12 AM
Unknown Object (File)
Oct 16 2024, 9:22 PM
Unknown Object (File)
Oct 16 2024, 6:59 PM
Unknown Object (File)
Oct 5 2024, 8:38 PM
Unknown Object (File)
Oct 4 2024, 7:27 PM
Unknown Object (File)
Oct 3 2024, 9:07 AM
Unknown Object (File)
Oct 2 2024, 5:26 PM
Unknown Object (File)
Oct 2 2024, 3:12 PM
Subscribers

Details

Summary

The early environment is typically cleared, so these new options
need the PRESERVE_EARLY_KENV kernel config(8) option. These environments
are reported as missing by kenv(1) if the option is not present in the
running kernel.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Dump seems overloaded here. It was confusing before and this compounds the confusion.

bin/kenv/kenv.1
54

Dump is a terrible word. Does this mean discard or list? I'd suggest replacing the ambiguous term with whichever this is.

kevans retitled this revision from kenv: allow dumping of static kernel environments to kenv: allow listing of static kernel environments.Jun 21 2021, 3:19 AM
kevans edited the summary of this revision. (Show Details)
sys/kern/kern_environment.c
182

I think it might be a bit clearer to rewrite this as a switch on the what. I think it's then more obvious that your MPASS is really an '_assert_unreachable()'. Looking at this even further though, I think I'd really like to just split out this early section into a helper function:

static int
kenv_dump(char **envp, int what, char *value, int len)
{
   char *senv;

   senv = **envp;
   ....
}

And then in sys_kenv() you add this to the start of the switch statement below:

    switch (uap->what) {
    case KENV_DUMP:
        return (kenv_dump(kenvp, uap->what, uap->value, uap->len));
    case KENV_DUMP_LOADER:
    case KENV_DUMP_STATIC:
#ifdef PRESERVE_EARLY_KENV
        return (kenv_dump(uap->what == KENV_DUMP_LOADER ? &md_envp : &kern_envp,
            uap->what, uap->value, uap->len);
#else
        return (ENOENT);
#endif
`
kevans marked an inline comment as done.
kevans edited the summary of this revision. (Show Details)

Address commentary from jhb

This revision is now accepted and ready to land.Jun 27 2021, 6:40 AM