File: kdump

package info (click to toggle)
lua-ljsyscall 0.12-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,732 kB
  • sloc: ansic: 434; sh: 59; makefile: 3
file content (23 lines) | stat: -rwxr-xr-x 637 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env luajit

local function assert(cond, err, ...)
  if cond == nil then error(tostring(err)) end -- annoyingly, assert does not call tostring!
  if type(cond) == "function" then return cond, err, ... end
  if cond == true then return ... end
  return cond, ...
end

local kfile = arg[1] or "ktrace.out"

local S = require "syscall"
local N = require "syscall.netbsd.init"

local fd = assert(S.open(kfile, "rdonly"))
local buf = S.t.buffer(32768)
local n = assert(fd:read(buf, 32768))
for _, ktr in N.util.kdump(buf, n) do
  if ktr.version ~= 2 then error "currently only v2 supported" end
  print(ktr)
end
assert(fd:close())