Page MenuHomeFreeBSD

flua: Add an implementation of uname()
ClosedPublic

Authored by markj on Sep 29 2023, 1:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 17, 11:06 AM
Unknown Object (File)
Thu, Oct 9, 3:06 AM
Unknown Object (File)
Mon, Oct 6, 7:11 PM
Unknown Object (File)
Thu, Oct 2, 7:43 AM
Unknown Object (File)
Sep 5 2025, 8:33 AM
Unknown Object (File)
Sep 4 2025, 9:11 AM
Unknown Object (File)
Aug 7 2025, 8:08 PM
Unknown Object (File)
Jun 20 2025, 5:53 AM

Details

Summary

This implements the interface from luaposix:
http://luaposix.github.io/luaposix/modules/posix.sys.utsname.html

It's a bit nicer than using io.popen() or similar to run uname(1).

Diff Detail

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

Event Timeline

markj requested review of this revision.Sep 29 2023, 1:09 PM
libexec/flua/linit_flua.c
65

Why do we compile these modules (lfs, posix.*, etc.) into flua rather than having them be regular modules? This means that they are automatically imported into the global namespace. Though, that actually doesn't appear to work properly for posix.*:

markj@nuc> /usr/libexec/flua
Lua 5.4.6  Copyright (C) 1994-2023 Lua.org, PUC-Rio
> posix
nil
> posix.unistd
stdin:1: attempt to index a nil value (global 'posix')
stack traceback:
        stdin:1: in main chunk
        [C]: in ?
> _G['posix.unistd']
table: 0x3f7f7d213740

so you have to use require anyway.

Seems fine to me; we can move it out to a module with the rest of lposix later.

libexec/flua/linit_flua.c
65

lfs was initially compiled in because I needed it to be available in bootstrap flua for makesyscalls processing, and bootstrap flua doesn't support modules. The others I noted to bapt a little while ago should probably start moving into proper modules so that other non-flua things using base liblua could also use them (e.g., if we redo config(8) with lua, it'll almost certainly be its own C frontend that uses liblua to interpret config files and whatnot)

This revision is now accepted and ready to land.Sep 29 2023, 3:05 PM
libexec/flua/linit_flua.c
62

To provide an example for what I have in mind in the future, I'd for example create a freebsd.lib.uname and implement it in lua using posix.sys.utsname and freebsd.sys.sysctl. The latter is needed for some uname(1) flags that are useful, like uname -p.

65

Sorry for the maybe dumb question: why doesn't bootstrap flua support modules, assuming that we can compile said modules together with flua?

This revision was automatically updated to reflect the committed changes.