Page MenuHomeFreeBSD

flua: add freebsd.kenv, kenv(2) bindings
ClosedPublic

Authored by bapt on Sep 12 2024, 2:20 PM.
Tags
None
Referenced Files
F102068403: D46654.diff
Thu, Nov 7, 5:37 AM
F102067910: D46654.diff
Thu, Nov 7, 5:29 AM
Unknown Object (File)
Sat, Oct 26, 4:19 AM
Unknown Object (File)
Thu, Oct 24, 7:50 AM
Unknown Object (File)
Wed, Oct 23, 8:28 AM
Unknown Object (File)
Wed, Oct 23, 3:42 AM
Unknown Object (File)
Tue, Oct 22, 1:46 PM
Unknown Object (File)
Mon, Oct 21, 9:14 AM
Subscribers

Details

Summary

Add bindings for kenv(2) right now only get() has been created
it allows do dump into a key/value table the kernel environement if
no argument is passed, or it returns the value associated to the
provided key.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 59457
Build 56344: arc lint + arc unit

Event Timeline

bapt requested review of this revision.Sep 12 2024, 2:20 PM
bapt created this revision.

I like this interface. Should we need to share code between userland and the loader that needs to access this interface, I think it can be trivially implemented in lua using the loader's loader.getenv for both variations. I don't think it's required that we implement that today, though.

libexec/flua/libfreebsd/kenv/freebsd.kenv.3lua
57–63

Return the
.Fa value
associated to the
.Fa key ,
if it exists, or
.Va nil
otherwise.

rephrase the manpage using @imp suggestion

bapt marked an inline comment as done.Sep 12 2024, 2:51 PM
libexec/flua/libfreebsd/kenv/kenv.c
50

Line after declarations for readability

87

Declaration needs to move up

91

IMO we should maintain the error interface here; that is, we return nil and a message at a minimum to be more assert-friendly

bapt marked an inline comment as done.

Address @kevans comments

bapt marked 2 inline comments as done.

meh

bapt marked 2 inline comments as not done.Sep 12 2024, 3:35 PM
lwhsu added inline comments.
libexec/flua/libfreebsd/kenv/kenv.c
16

s/REGENTS/AUTHOR/ ?

libexec/flua/libfreebsd/kenv/kenv.c
7

Consider dropping all this boilerplate

25

C

bapt marked 4 inline comments as done.Sep 13 2024, 5:06 AM
This revision is now accepted and ready to land.Sep 13 2024, 8:14 PM
kevans added inline comments.
libexec/flua/libfreebsd/kenv/kenv.c
75

It just occurred to me that all of these lua_pushnil in error paths should technically be luaL_pushfail in flua/5.4. That's an alias for lua_pushnil still in 5.4, so I don't insist on fixing this now / we can clean it up later in a larger cleanup pass.

This revision was automatically updated to reflect the committed changes.