EMILUA(3em)
π NAME π
Emilua (3em) β the Lua execution engine. Yep, thatβs EMILUA(3em) for you, bestie. β¨
π¦ SYNOPSIS π¦
local libc_service = require "libc_service"
This is the handle to the slave endβs initialization data. When the handle is used in some function, itβs consumed and can no longer be used in different calls. The resources associated with the handle will be sent to the process created by the function that consumes this handle.
You cannot configure properties from this handle after a call that consumes it (e.g. spawn_vm()). If some setting is desired, it must be prepared before the call that consumes this object. No cap.
π§ METAMETHODS π§
__newindex()
Assigns a Lua chunk (the source code as a string) to run on the slave end when the libc function (identified by the key) is attempted. The Lua function will be called with the proxified libc function as the first argument (before the arguments that were passed to the attempted libc function call). If no Lua function is assigned and the libc function is called, the proxified libc function will be called directly.
The Lua function has access to the same API that is available to init.script(3em). However errexit will be false by default. Lowkey important, bestie.
Okay, diagram time β hereβs the whole vibe, verbatim:
+--------------------+
| |
| Process |
| |
+-+------------------+
| ^
| calls libc | receives result
| function |
v |
+------------------+-+
| |
| Lua chunk filter |
| |
+---+----------------+
| ^
v |
+---------------+----+ +-----------+
| +--->| |
| Proxified function | | Real libc |
| |<---+ |
+---+----------------+ +-----------+
| ^
v |
+---------------+-----+
| |
| libc_service.master |
| |
+---------------------+
Whether the proxified function forwards the request to the real libc depends on libc_service.master's reply. If the Lua chunk never calls the proxified function, then the proxified function never even runs. That part is fr fr.
π AVAILABLE LUA FILTERS π
This section lists the Lua filters you can implement to run when an interposed libc function is called. Iconic list, ngl.
open
open(real_open: function, path: string, flags: integer[, mode: integer]) β integer[, integer]
Returns:
- The value for
open()βs return. - Optional: The value for
errno.
openat
openat(real_openat: function, dirfd: integer, path: string, flags: integer, mode: integer, resolve: string[]) β integer[, integer]
mode will be 0 on unused.
resolve will be translated to whatever the current system uses under the hood (e.g. openat2() on Linux). Unsupported values wonβt be silently ignored. If some flag is unsupported, the function will return with an error. It may contain:
"beneath"β Path resolution must not cross thefddirectory."in_root"β Treat the directory referred to bydirfdas the root directory while resolvingpathname. Absolute symbolic links are interpreted relative todirfd."no_magiclinks"β Disallow all magic-link resolution during path resolution."no_symlinks"β Disallow resolution of symbolic links during path resolution."no_xdev"β Disallow traversal of mount points during path resolution (including all bind mounts)."cached"β Make the open operation fail unless all path components are already present in the kernelβs lookup cache.
Returns:
- The value for
openat()βs return. - Optional: The value for
errno.
unlink
unlink(real_unlink: function, path: string) β integer[, integer]
Returns:
- The value for
unlink()βs return. - Optional: The value for
errno.
rename
rename(real_rename: function, path1: string, path2: string) β integer[, integer]
Returns:
- The value for
rename()βs return. - Optional: The value for
errno.
stat
stat(real_stat: function, path: string) β integer|table[, integer]
Returns:
- The value for
stat()βs return. Or Lua table on success (return0). - Optional: The value for
errno.
lstat
lstat(real_lstat: function, path: string) β integer|table[, integer]
Returns:
- The value for
lstat()βs return. Or Lua table on success (return0). - Optional: The value for
errno.
access
access(real_access: function, path: string, amode: integer) β integer[, integer]
Returns:
- The value for
access()βs return. - Optional: The value for
errno.
eaccess
eaccess(real_eaccess: function, path: string, amode: integer) β integer[, integer]
Returns:
- The value for
eaccess()βs return. - Optional: The value for
errno.
mkdir
mkdir(real_mkdir: function, path: string, mode: integer) β integer[, integer]
Returns:
- The value for
mkdir()βs return. - Optional: The value for
errno.
rmdir
rmdir(real_rmdir: function, path: string) β integer[, integer]
Returns:
- The value for
rmdir()βs return. - Optional: The value for
errno.
connect_unix
connect_unix(real_connect: function, fd: integer, path: string) β integer[, integer]
Returns:
- The value for
connect()βs return. - Optional: The value for
errno.
connect_inet
connect_inet(real_connect: function, fd: integer, ipv4_addr: integer[], port: integer) β integer[, integer]
Returns:
- The value for
connect()βs return. - Optional: The value for
errno.
connect_inet6
connect_inet6(real_connect: function, fd: integer, ipv6_addr: integer[], port: integer, scope_id: integer) β integer[, integer]
Returns:
- The value for
connect()βs return. - Optional: The value for
errno.
bind_unix
bind_unix(real_bind: function, fd: integer, path: string) β integer[, integer]
Returns:
- The value for
bind()βs return. - Optional: The value for
errno.
bind_inet
bind_inet(real_bind: function, fd: integer, ipv4_addr: integer[], port: integer) β integer[, integer]
Returns:
- The value for
bind()βs return. - Optional: The value for
errno.
bind_inet6
bind_inet6(real_bind: function, fd: integer, ipv6_addr: integer[], port: integer, scope_id: integer) β integer[, integer]
Returns:
- The value for
bind()βs return. - Optional: The value for
errno.
getaddrinfo
getaddrinfo(real_getaddrinfo: function, node: string, service: string,
protocol: tcp"|"udp"|nil) β ..."
To indicate failure, this function should return one of strings below or some equivalent integer code:
"again""badflags""fail""family""memory""noname""service""socktype""system"
If "system" is returned, another integer value for errno should follow.
To indicate success without any resolved address, the function should return just nil.
To indicate success with a resolved address, the function should return the following values:
nilβ Itβs here just to disambiguate against other cases.ip_addr: integer[]β On IPv6 addresses, it should include an extra integer at the end for the scope ID.port: integerβ The port.
Cute sign-off time π«Ά: this page is source/version Emilua 0.12.1-nixpkgs1, dated 1980-01-01. Bye bestie, go interpose some libc calls π
π
π¦ where this page comes from
- nixos 26.05: emilua 0.12.1
- nixpkgs unstable: emilua 0.12.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms