[BACK]Return to lua.4 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / man / man4

File: [cvs.NetBSD.org] / src / share / man / man4 / lua.4 (download)

Revision 1.5, Sat Jul 26 20:04:05 2014 UTC (9 years, 8 months ago) by wiz
Branch: MAIN
CVS Tags: tls-maxphys-base, tls-earlyentropy-base, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-10-base, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, HEAD
Branch point for: tls-maxphys
Changes since 1.4: +6 -6 lines

Sort sections.

.\" $NetBSD: lua.4,v 1.5 2014/07/26 20:04:05 wiz Exp $
.\"
.\" Copyright (c) 2013 Marc Balmer <marc@msys.ch>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd July 25, 2014
.Dt LUA 4
.Os
.Sh NAME
.Nm lua
.Nd control in-kernel Lua states
.Sh SYNOPSIS
.Cd "lua*"
.Pp
.In sys/types.h
.In sys/lua.h
.Sh DESCRIPTION
The
.Nm
device allows to create, control, and delete Lua states in the kernel
through an
.Xr ioctl 2
interface.
Moreover,
.Nm
can be used to load Lua scripts into a Lua state and to assign modules to an
existing state, i.e. perform the equivalent of the Lua command
.Em require .
.Nm
is also used to retrieve information about currently active Lua states.
.Sh LUA MODULES
Lua modules are used to provide functionality to Lua scripts not available
in the language itself, e.g. to access core kernel functionality like
printing text on the console.
Unlike in user space Lua, where Lua modules are files in the filesystem,
modules must be provided to
.Nm
in the form of loadable kernel modules that register their
functionality with
.Nm .
Modules are loaded using the
.Ic require
Lua command; whether this command
is available or not is controlled by a
.Xr sysctl 8
variable.
.Nm
by default tries to load a kernel module named
.Em luafoo.kmod
when it encounters the Lua command
.Em require 'foo' .
.Sh SYSCTL VARIABLES
The operation of
.Nm
can be controlled by means of the following
.Xr sysctl 8
variables:
.Bl -tag -width XXXX
.It Dv kern.lua.autoload
When set to 1,
.Nm
tries to autoload kernel modules.
.Pp
The default value is 1.
.It Dv kern.lua.bytecode
When set to 1, loading of Lua bytecode is allowed.
.Pp
The default value is 0.
.It Dv kern.lua.maxcount
When set to a value > 0,
.Nm
limits the number of instructions executed
to this number.
.Pp
The default value is 0.
.It Dv kern.lua.require
When set to 1, enables the
.Em require
command in Lua.
.Pp
The default value is 1.
.It Dv kern.lua.verbose
When set to a value > 0, verbosity is increased.
.Pp
The default value is 0.
.El
.Sh IOCTL INTERFACE
The following structures and constants are defined in the
.In sys/lua.h
header file:
.Pp
.Bl -tag -width XXXX -compact
.It Dv LUAINFO(struct lua_info)
Returns information about the
.Nm
states in the
.Fa lua_info
structure:
.Bd -literal
#define MAX_LUA_NAME		16
#define MAX_LUA_DESC		64

struct lua_state_info {
	char	name[MAX_LUA_NAME];
	char	desc[MAX_LUA_DESC];
	bool	user;
};

struct lua_info {
	int num_states;		/* total number of Lua states */
	struct lua_state_info *states;
};
.Ed
.Pp
.It Dv LUACREATE(struct lua_create)
Create a new named Lua state with name and description in the
.Fa lua_create
structure:
.Bd -literal
struct lua_create {
	char	name[MAX_LUA_NAME];
	char	desc[MAX_LUA_DESC];
};
.Ed
.Pp
.It Dv LUADESTROY(struct lua_create)
Destroy a named Lua state.
.Pp
.It Dv LUAREQUIRE(struct lua_require)
Perform the equivalent of the Lua command
.Em require
in a named state.
The name of the state and of the module name is passed in the
.Fa lua_require
structure:
.Bd -literal
#define LUA_MAX_MODNAME		32

struct lua_require {
	char	state[MAX_LUA_NAME];
	char	module[LUA_MAX_MODNAME];
};
.Ed
.Pp
.It Dv LUALOAD(struct lua_load)
Load Lua code from the filesystem into a named Lua state.
The name of the state and the path to the Lua code are passed in the
.Fa lua_load
structure:
.Bd -literal
struct lua_load {
	char	state[MAX_LUA_NAME];
	char	path[MAXPATHLEN];
};
.Ed
.Pp
The path element of the
.Fa lua_load
structure must contain at least one
.Sq /
character.
.Pp
.El
.Sh FILES
.Bl -tag -width "/dev/lua" -compact
.It /dev/lua
Lua device file.
.El
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr luactl 8
.Sh HISTORY
The
.Nm
device first appeared in
.Nx 7.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm
driver was written by
.An Marc Balmer Aq Mt mbalmer@NetBSD.org .
.Sh CAVEATS
The
.Nm
device is experimental.
Incompatible changes might be made in the future.