Page MenuHomeFreeBSD

flua: Add an implementation of uname()
ClosedPublic

Authored by markj on Sep 29 2023, 1:09 PM.
Tags
None
Referenced Files
F108819605: D42017.diff
Tue, Jan 28, 7:30 AM
Unknown Object (File)
Mon, Jan 27, 5:44 AM
Unknown Object (File)
Tue, Jan 14, 7:02 AM
Unknown Object (File)
Tue, Jan 14, 7:02 AM
Unknown Object (File)
Tue, Jan 14, 6:49 AM
Unknown Object (File)
Dec 18 2024, 7:21 AM
Unknown Object (File)
Dec 11 2024, 4:10 AM
Unknown Object (File)
Dec 9 2024, 10:15 PM

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 Not Applicable
Unit
Tests Not Applicable

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.