lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Am 16.08.11 16:13, schrieb Steve Litt:
> On Tuesday, August 16, 2011 07:31:34 AM Marc Balmer wrote:
>> I just got it working.  Here is a a transcript of a session.  The
>> commandline prompt is 'amd64 #', console output is prefixed with
>> console:
>> First, lets load the lua(4) module...
>> amd64# modload lua
>> console: lua0: Lua 5.1.4  Copyright (C) 1994-2008, PUC-Rio
>> Now create a Lua state...
>> amd64# luactl create s1
>> console: lua0: state s1 created
>> Now try to execute the Lua code 'print("Hello, kernel world")' from
>> file ./test.lua in state s1...
>> amd64# luactl load s1 ./test.lua
>> console: lua0: loading ./test.lua into state s1
>> console: lua0: error executing Lua code
>> console: lua0: [string "test.lua"]:1: attempt to call global
>> 'print' (a nil value)
>> Of course!  Newly created states are empty, they have no functions.
>>  So lets provide state s1 with the print function, it is in a Lua
>> module I called luaempty. First load the module, then let s1 use
>> it...
>> amd64# modload luaempty
>> console: registered lua module luaempty
>> amd64# luactl require s1 luaempty
>> console: lua0: requiring module luaempty to state s1
>> Now we retry loading (and executing) ./test.lua...
>> amd64# luactl load s1 ./test.lua
>> console: Hello, kernel world
> Hi Marc,
> I was unable to do this in Linux. Is that surprising? I'm more 
> familiar with OpenBSD than NetBSD. Do you think this would work with 
> OpenBSD?

It is no surprise that this does not work on Linux.  It is not made for
Linux, but for NetBSD.  I will not work on OpenBSD, since they do not
have the modules like NetBSD does.  So even if you take the source code,
you won't get it running on OpenBSD.

> What's the purpose of what you did here? It sounds very interesting 
> but I don't understand the context. What are some of the things you 
> can do with this?

Rapid development of in-kernel software (prototyping), changing the
behaviour of kernel code, providing configuration data to kernel
subsystem, experiments and tinkering with the kernel in general.  Call
it a kernel experimenters/developers toolkit ;)

I can not tell much about real applications, since I only today got the
mechanism working... So it will take some more time to create e.g. some
standard bindings etc.

> Thanks
> SteveT