syscall
for node.js
Execute POSIX/Linux syscall
command from Node.js.
Usage, see syscall reference:
var syscall = syscall; // Print `Hello world` in console using kernel's `syscall` command.var buf = 'Hello world\n';; // Where, on x86_64 Linux:// 1 - `sys_write` system call// 1 - STDOUT file descriptor// buf - pointer to data in memory// buf.length - size of the memory block to print
See jskernel-posix for POSIX command implementation.
Reference
syscall
and syscall64
;;;
syscall
accepts up to 6 command arguments args
, which are treated as
follows depending on their type:
number
is put directly in the appropriate CPU register as is.string
gets converted to C'schar *
string and that pointer is put in CPU register.Buffer
pointer to the raw data in-memory is put in CPU register.
syscall
return a number
which is the result returned by the kernel,
numbers below -1 usually represent an error.
malloc
Returns a Buffer
object of size size
that is mapped to memory location
specified in addr
argument.
;
addr
and addr64
Return memory address of Buffer
's data contents.
;;
addr64
returns a tuple which represents 64-bit number, where first element contains the lower
32 bits and second element has the high 32 bits.
asm
[NOT IMPLEMENTED]
Execute assembly code, buffer
contains raw op-codes to run.
;
errno
Returns errno
variable.
;
Installation
npm i jskernel-sys
Compiles on Ubuntu 14.04 x86_64 running under Docker with Node.js 4.4.3, has not been tested on other machines.
Building addon:
node-gyp configure
node-gyp rebuild