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)
Feb 10 2024, 3:21 PM
Unknown Object (File)
Feb 5 2024, 3:37 PM
Unknown Object (File)
Jan 26 2024, 2:33 PM
Unknown Object (File)
Jan 13 2024, 1:19 AM
Unknown Object (File)
Dec 23 2023, 1:20 AM
Unknown Object (File)
Dec 20 2023, 8:08 PM
Unknown Object (File)
Dec 5 2023, 6:34 AM
Unknown Object (File)
Oct 29 2023, 5:01 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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 40128
Build 37017: arc lint + arc unit

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