Page MenuHomeFreeBSD

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

Authored by bapt on Sep 12 2024, 2:20 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 29, 2:34 AM
Unknown Object (File)
Fri, Nov 22, 4:54 AM
Unknown Object (File)
Thu, Nov 21, 6:44 AM
Unknown Object (File)
Tue, Nov 19, 3:47 PM
Unknown Object (File)
Mon, Nov 18, 9:46 AM
Unknown Object (File)
Sun, Nov 17, 11:47 PM
Unknown Object (File)
Sun, Nov 17, 5:03 PM
Unknown Object (File)
Mon, Nov 11, 6:58 PM
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 Not Applicable
Unit
Tests Not Applicable

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
58–64

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.