System programming library; libjs — libc in JavaScript.
npm install libjs libsys
This library uses libsys
to execute system calls from JavaScript.
It expects your environment has libsys
global object, in Node.js you can shim libsys
as follows:
require('libsys/shim');
- Synchronous system calls
- Files — Standard file operations, which operate on most of the Linux/Unix file descriptors.
read
— read from a file descriptor.write
— write to a file descriptor.open
— open a file.close
— close a file descriptor.access
— check user can access a file.chmod
— change file attributes.fchmod
— change file attributes.chown
— change file owner.fchown
— change file owner.lchown
— change file owner.truncate
— erase file contents.ftruncate
— erase file contents.lseek
— change cursor position.rename
— rename a file.fsync
— flush file to disk.fdatasync
— flush file to disk.
- Stats — Fetches and returns statistics about a file.
- Directories
mkdir
— creat a directory.mkdirat
— create a directory relative to another directory.rmdir
— remove a directory.getcwd
— fetch current working directory.getdents64
— scan through directory entries.readdir
— fetch all folder entries.readdirList
— fetch all folder entries.
- Links
- Time
- Networking
socket
— create a socket file descriptor.connect
— initiate a connection on a socket.bind
— assign an address to a socket.listen
— listen for new connections on a socket.accept
— accept a connection on a socket.accept4
— accept a connection on a socket.shutdown
— shut down all or part of a full-duplex connection.send
— write data to a socket file descriptor.sendto
— write data to a socket file descriptor.recv
— read data from socket file descriptor.recvfrom
— read data from socket file descriptor.setsockopt
— get and set options on a socket.
- Process
- Events
fcntl
— manipulate file descriptor.epoll_create
— create an epoll file descriptor.epoll_create1
— create an epoll file descriptor.epoll_wait
— fetch epoll events.epoll_ctl
— control interface for an epoll file descriptor.inotify_init
inotify_init1
inotify_add_watch
inotify_rm_watch
kqueue
kevent
EV_SET
- Memory
- Files — Standard file operations, which operate on most of the Linux/Unix file descriptors.
- Asynchronous system calls
- Files:
readAsync
,writeAsync
,openAsync
,closeAsync
,accessAsync
,chmodAsync
,fchmodAsync
,chownAsync
,fchownAsync
,lchownAsync
,truncateAsync
,ftruncateAsync
,lseekAsync
,renameAsync
,fsyncAsync
,fdatasyncAsync
- Stats:
statAsync
,lstatAsync
, andfstatAsync
- Directories:
mkdirAsync
,mkdiratAsync
,rmdirAsync
,getcwdAsync
,getdents64Async
, andreaddirListAsync
- Links:
symlinkAsync
,unlinkAsync
,readlinkAsync
, andlinkAsync
- Time:
utimeAsync
andutimesAsync
- Networking:
socketAsync
,connectAsync
,bindAsync
,listenAsync
,acceptAsync
,accept4Async
,shutdownAsync
,sendAsync
andsendtoAsync
, - Process:
getpidAsync
,getppidAsync
,getuidAsync
,geteuidAsync
,getgidAsync
, andgetegidAsync
,
- Files:
- Structs
epoll_event
andIepoll_event
in_addr
andIin_addr
inotify_event
andIinotify_event
ipc_perm
andIipc_perm
ipv4
andIipv4
linux_dirent64
andIlinux_dirent64
shmid_ds
andIshmid_ds
sigaction
andIsigaction
sockaddr
andIsockaddr
sockaddr_in
andIsockaddr_in
statStruct
andIstatStruct
timespec
andItimespec
timeval
andItimeval
timevalarr
andItimevalarr
utimbuf
andIutimbuf
keventStruct
andIkeventStruct
kevent64_sStruct
andIkevent64_sStruct
- Sockets
flip
,htons32
,hton16
,htons
,Ip
,Ipv4
, andIpv6
,
- Constants
Unlicense — public domain.