[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Enabling lua in binfmt on Debian
- From: Walter Cruz <walter.php@...>
- Date: Fri, 21 Oct 2005 11:00:48 -0300
Do you know the filesystem binfmt_misc on Linux?
>From here: http://www.tat.physik.uni-tuebingen.de/~rguenth/linux/binfmt_misc.html
we got a definition
"Binfmt_misc provides the ability to register additional binary formats
to the Kernel without compiling an additional module/kernel. Therefore
binfmt_misc needs to know magic numbers at the beginning
or the filename extension of the binary."
With it, is possible to make this(suppose that you have a simple hello world in Lua..):
MCid299a:~$ luac -o hello hello.lua
MCid299a:~$ chmod +x hello
This is what I make just now :)
And now, the little HOWTO.
I'm assuming Debian, I don't know how another distros implements the
configuration on binfmt (althoug I guess that is similar...)
I'm on Debian Unstable.
1- Create a file in /usr/share/binfmts called 'lua', with the contens below:
This assumes that you're using Lua5, cause in Lua 5, the magic word
'LuaP' is showed after the the 1st byte (the offset) in the bytecoded
Lua file (just for the sake of curiosity, try to edit a lua bytecode in
a editor!). is that magic word that binfmt uses to determine if a file
is a lua bytecod or not.
2 - Run the commands:
update-binfmts -- import lua
update-binfmts -- enable lua
The first command install the lua script on /var/lib/binfmts
The second enables the binfmt to Lua
3- That's all!
You can do that to see if worked:
MCid299a:/proc/sys/fs/binfmt_misc# cat lua
And now, you can create a Lua script (or compile one that you have), chmod it (+x) and run it.
I hope you like.