mirror of
https://github.com/opnsense/src.git
synced 2026-06-06 23:32:52 -04:00
We haven't used this since commitbe67ea40c5in 2021 so stop carrying it forward. Also remove support for setting the list in syscalls.conf via the capenabled variable. This was last used by cloudabi (removed in 2021 by commitcf0ee8738e).
89 lines
2.5 KiB
Lua
Executable file
89 lines
2.5 KiB
Lua
Executable file
#!/usr/libexec/flua
|
|
--
|
|
-- SPDX-License-Identifier: BSD-2-Clause
|
|
--
|
|
-- Copyright (c) 2024 Tyler Baxter <agge@FreeBSD.org>
|
|
-- Copyright (c) 2023 Warner Losh <imp@bsdimp.com>
|
|
-- Copyright (c) 2019 Kyle Evans <kevans@FreeBSD.org>
|
|
--
|
|
|
|
-- Setup to be a module, or ran as its own script.
|
|
local syscall_mk = {}
|
|
local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script.
|
|
if script then
|
|
-- Add library root to the package path.
|
|
local path = arg[0]:gsub("/[^/]+.lua$", "")
|
|
package.path = package.path .. ";" .. path .. "/../?.lua"
|
|
end
|
|
|
|
local FreeBSDSyscall = require("core.freebsd-syscall")
|
|
local generator = require("tools.generator")
|
|
|
|
-- File has not been decided yet; config will decide file. Default defined as
|
|
-- /dev/null.
|
|
syscall_mk.file = "/dev/null"
|
|
|
|
-- Libc has all the STD, NOSTD and SYSMUX system calls in it, as well as
|
|
-- replaced system calls dating back to FreeBSD 7. We are lucky that the
|
|
-- system call filename is just the base symbol name for it.
|
|
function syscall_mk.generate(tbl, config, fh)
|
|
-- Grab the master system calls table.
|
|
local s = tbl.syscalls
|
|
-- Bookkeeping for keeping track of when we're at the last system
|
|
-- call (no backslash).
|
|
local size = #s
|
|
local idx = 0
|
|
|
|
-- Bind the generator to the parameter file.
|
|
local gen = generator:new({}, fh)
|
|
|
|
-- Write the generated preamble.
|
|
gen:preamble("FreeBSD system call object files.", "#")
|
|
|
|
gen:write("MIASM = \\\n") -- preamble
|
|
for _, v in pairs(s) do
|
|
local c = v:compatLevel()
|
|
idx = idx + 1
|
|
if v:native() and not v.type.NODEF then
|
|
if idx >= size then
|
|
-- At last system call, no backslash.
|
|
gen:write(string.format("\t%s.o\n", v:symbol()))
|
|
else
|
|
-- Normal behavior.
|
|
gen:write(string.format("\t%s.o \\\n", v:symbol()))
|
|
end
|
|
-- Handle compat (everything >= FREEBSD3):
|
|
elseif c >= 7 and not v.type.NODEF then
|
|
if idx >= size then
|
|
-- At last system call, no backslash.
|
|
gen:write(string.format("\t%s.o\n", v:symbol()))
|
|
else
|
|
-- Normal behavior.
|
|
gen:write(string.format("\t%s.o \\\n", v:symbol()))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- Entry of script:
|
|
if script then
|
|
local config = require("config")
|
|
|
|
if #arg < 1 or #arg > 2 then
|
|
error("usage: " .. arg[0] .. " syscall.master")
|
|
end
|
|
|
|
local sysfile, configfile = arg[1], arg[2]
|
|
|
|
config.merge(configfile)
|
|
config.mergeCompat()
|
|
|
|
-- The parsed syscall table.
|
|
local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
|
|
|
|
syscall_mk.file = config.sysmk -- change file here
|
|
syscall_mk.generate(tbl, config, syscall_mk.file)
|
|
end
|
|
|
|
-- Return the module.
|
|
return syscall_mk
|