Code Monkey home page Code Monkey logo

ljsyscall's Introduction

Unix system calls for LuaJIT

Build Status

What? An FFI implementation of the Linux, NetBSD, FreeBSD and OSX kernel ABIs for LuaJIT. This means you will be able to program all the functionality the Unix kernel provides to userspace directly in Lua. You can view it as a high level language equivalent of the Busybox project in a way, although the functionality it provides is somewhat different, and the interface very different.

Why? First it provides a comprehensive set of system call APIs for programming sockets, files and so on, including the more obscure things (eg file change notifications). Second it provides higher level interfaces such as network interface configuration, so your application can control its entire runtime interface including IP addresses routing and so on. Third it provides tools for added security, such as support for Linux namespaces (containers), system call filtering (seccomp type 2), capabilities and so on, all with a script language interface that is much simpler to use than the C interface. As it is Lua based it can easily be embedded in another language; in the future ports to other scripting languages are planned. It also serves as a way of learning how the operating system interfaces work in a more forgiving environment than C.

There is support for the NetBSD rump kernel under other operating systems and natively without an operating system under Xen.

This code is beta. Interfaces will change in future. The code is riddled with TODOs. On the other hand it does work, and the changes at this stage will be smaller than in the past.

Introductory talks

The video of my FOSDEM 2013 talk here, and the video of my Lua Workshop 2013 talk is here.

Install

A Docker hub automated build (currently only for Linux) is available via docker pull justincormack/ljsyscall. You can run the test suite with docker run justincormack/ljsyscall test/test.lua, use in a scripted way eg docker run justincormack/ljsyscall -e "print(require('syscall').nl.interfaces())" or get an interactive session with docker -it run justincormack/ljsyscall.

The stable release is now available in the luarocks repository, so you should be able to run luarocks install ljsyscall. There will be a ljsyscall-rump rock soon, but I need to fix the install for the rump libraries.

For simple uses, you just need to put the .lua files somewhere that LuaJIT will find them, eg typically in /usr/local/share/lua/5.1/. Keep the directory structure there is. You can safely remove files from architectures and operating systems you do not use.

You can also install the head version using luarocks: luarocks install rockspec/ljsyscall-scm-1.rockspec .

It is also available as a package in buildroot, a build system for embedded systems, and in [pkgsrc](http://www.pkgsrc.org] the portable packaging system for many systems. It is now packaged for Alpine Linux, in the testing repository.

If you are using Lua rather than LuaJIT you need to install luaffi first; this is largely working now, but there will be more support for standard Lua coming soon.

There is more information in the INSTALL file.

Requirements

Requirements: Needs LuaJIT 2.0.2 or later.

The code now runs again with luaffi under standard Lua 5.2 (and probably 5.1, untested). Because the function calls in luaffi use dynasm they are not fully portable, so I will be adding support for Lua C interface function calls as well shortly. This is not yet integrated into the test suite so there may be regressions and issues still.

On Linux ARM (soft or hard float), ARM64, x86, AMD64, and PPC32 and MIPS32 (o32 ABI) architectures are supported; this is the complete set of architectures that upstream LuaJIT supports. In addition ppc64le is supported using the LuaJIT port for PPC64. For full testing (as root) a recent kernel is recommended, eg Linux 3.5 or Ubuntu 12.04 is fine, as we use many recent features such as network namespaces to test thoroughly; tests should be skipped if unsupported, raise an issue if not. Other architectures will require a LuaJIT port or the in-progress pure Lua port.

Android (ARM tested so far) currently passes all the non root tests now; some tests are be skipped as the kernel does not ship with some functionality (aio, mq). Generally much functionality is available even though it is not in Bionic libc.

For the NetBSD support all platforms should work in principle; more test targets will be added soon, currently tests being run on x86 and amd64, an ARM test target will be added. The port currently targets NetBSD 6 and 7.

FreeBSD support is currently for FreeBSD 9 and 10, and only tested on amd64 and i386. Other architectures should work, but are currently untested.

OpenBSD support is tested under 5.4 and 5.5, on amd64. Other architectures should work, but are currently untested. Versions before 5.4 should be easy to add support for, as the ABI does not have significant differences.

OSX support is currently tested only on amd64, and on a recent release (currently testing on Mountain Lion). It should work on other recent releases, and should work on ARM, ie iOS, although some tweaks might be necessary. As I do not have a suitable test machine for OSX support, testing is intermittent and there may be regressions.

There is currently no Windows support, although in principle Cygwin or Windows Services for Unix could be supported. If you want to do similar things using the Windows native APIs you should try TINN.

For the (optional) rump kernel functionality, the easiest way at present to install it is usually using the buildrump.sh project, which is now included as a git submodule. The rump kernel is a way of running parts of the NetBSD kernel in userspace as libraries. At the moment support is partially implemented, planning to add more soon, in particular to be able to script the backend "hypervisor" part. There are some additional examples in examples/rump which is a port of the tests in buildrump. The rump kernel runs on many elf/Posix OS and architectures, currently tested on Linux x86, x64, ppc, arm and NetBSD x86, x64, FreeBSD 10 (with gcc). It does not currently run on OSX or Windows.

Examples and documentation

Apart from the tests, there are now some examples at in the examples directory; more to come.

There will be proper documentation before the 1.0 release, apologies for it not being available sooner. I understand how important it is and it is planned shortly.

Projects using ljsyscall

This project is being used in a variety of places, such as for testing the Linux compatibility code in NetBSD, among other things. If your project is not listed here please let me know or send a pull request.

  • ljlinenoise a Lua implementation of the linenoise (readline) library.
  • nodish a lightweight Lua equivalent to Node.js.
  • lua-mmapfile a simple Lua interface to mmap.
  • buildroot has an ljsyscall package.
  • luatz uses ljsyscall when available
  • Snabb switch a high performance networking toolkit.
  • Spook started out as an fs events based test runner similar to Rubys guard but grew into an event toolkit of sorts.

Testing

The test script is fairly comprehensive. Tested on ARM, amd64, x86, PowerPC. I run long test runs as LuaJIT makes random choices in code generation so single runs do not necessarily show errors. Also tested with Valgrind to pick up memory errors, although there are some issues with some of the system calls, which are being gradually resolved (I use Valgrind SVN).

Some tests need to be run as root, and will not be run otherwise. You cannot test a lot of system calls otherwise. Under Linux the testing is now done in isolated containers so should not affect the host system, although on old kernels reboot in a container could reboot the host.

The test script is a copy of luaunit. I have made some modifications to allow tests to be skipped, which are not really general enough to push upstream, although I would like a nicer solution.

I have added initial coverage tests (now needs fixing), and a C test to check constants and structures. The C test is useful for picking up errors but needs a comprehensive set of headers which eg is not available on most ARM machines so it can be difficult to run. I am putting together a set of hardware to run comprehensive tests on to make this less of an issue.

There is now Travis CI support, although this will only test on one architecture (x64, glibc) at present. You can see the test results here. If you fork the code you should be able to run these tests by setting up your own Travis account, and they will also be run for pull requests.

I have used the LuaJIT reflect library for checking struct offsets.

There are buildbot tests for a wider variety of architectures, as Travis is limited to Linux/Ubuntu. Currently building on Linux ARM, PowerPC, x64 and x86, NetBSD x86 and x64, FreeBSD x64, OpenBSD x64; more targets to come soon. The buildbot dashboard is now up.

What is implemented?

This project is in beta! Much stuff is still missing, this is a work in progress! The majority of syscalls are now there, let me know if you need some that are not.

As well as syscalls, there are interfaces to features such as proc, termios and netlink. These are still work in progress, and are being split into separate modules.

Work on the Linux netlink API is progressing. You can now do print(S.get_interfaces()) to get something much like ifconfig returns, and all the raw data is there as Lua tables. You can then modify these, and add IP addresses, similarly for routes. There is also a raw netlink interface, and you can create new interfaces. There is a lot more functionality that netlink needs to provide, but this is now mostly a matter of configuration. The API needs more work still. Netlink documentation is pretty bad. Useful resources: blog post

There is also a lot of the ioctl, getsockopt and fcntl interfaces to implement, which are very miscellaneous. Mostly you just need some constants and typecasting, but helper functions are probably useful. These are being improved so they understand the underlying types and functionality, making them less error prone.

The aim is to provide nice to use, Lua friendly interfaces where possible, but more work needs to be done, as have really started with the raw interfaces, but adding functionality through metatypes. Where possible the aim is to provide cross platform interfaces for higher level functionality that are as close as possible at least in a duck-typing sort of way.

Note on libc

Under Linux, there are several alternative C libraries as well as the standard Glibc, such as Musl libc, uClibc, Dietlibc and Bionic, which is the C library used on Android. These are not ABI compatible, so in order to allow use of any of them, we just call system calls directly on Linux, bypassing libc completely.

Under NetBSD it is much simpler, the only thing we need to be careful of is versioned system calls in libc, where we directly call a specific version as the plain name will always refer to the old version for compatibility. FreeBSD and OpenBSD do a more transparent versioning, so the syscall names stay the same.

API

This will be documented properly soon, once it stabilises.

All functions return two or more values, the return value, or true if there is not one other than success, then an error value. This makes it easy to write things like assert(fd:close()). The error type can be converted to a string message, or you can retrieve the errno, or test against a symbolic error name. Some functions then return additional return values, such as pipe() that returns the two file descriptors for the pipe. A few functions return a Lua iterator, such as epoll_wait().

File descriptors are returned as a type not an integer. This is because they are garbage collected by default, ie if they go out of scope the file is closed. You can get the file descriptor using the fileno field. To disable the garbage collection you can call fd:nogc(), in which case you need to close the descriptors by hand. They also have methods for operations that take an fd, like close, fsync, read. You can use this type where an fd is required, or a numeric fd, or a string like "stderr".

String conversions are not done automatically, you get a buffer back, you have to force a conversion. This is because interning strings is expensive if you do not need it. However if you do not supply a buffer for the return value, you will get a string in general as more useful.

Many functions that return structs return metatypes exposing additional methods, so you get the raw values eg st_size and a Lua number as size, and possibly some extra helpful methods. As these are (ffi) metamethods they have no overhead, so more can be added to make the interfaces easier to use.

Where there are variable length arrays, these are bundled together into a structure that has an array and a count, so you do not need to keep passing around the size. These provide iterators, which helps hide the fact that they are 0-based.

Constants should all be available, eg c.SEEK.SET etc, note they are namespaced into Lua tables rather than underscore seperated like in C. The constant tables will also let you combine flags where appropriate and you can use lower case, so c.O["rdonly, create"] is the same as the bitwise or of c.O.RDONLY and c.O.CREAT. When you call a function, you can just pass the string, as fd = S.open("file", "rdonly, creat") which makes things much more concise.

You do not generally need to use the numbered versions of functions, eg dup can do dup2 or dup3 by adding more arguments (not fully consistent yet).

Types are key, as these encapsulate a lot of functionality, and easy to use constructors and helpful methods. For example you can create the in_addr type with addr = t.in_addr("127.0.0.1") or addr = t.in_addr("loopback").

The test cases are good examples until there is better documentation!

A very few functions have arguments in a different order to make optional ones easier. This is a bit confusing sometimes, so check the examples or source code.

There is now an expreimental luafilesystem interface available, use lfs = require "syscall.lfs". It would be nice to be API compatible with other projects, especially Luaposix, luasocket, nixio. Unfortunately none of these seem to have good test suites, and there interfaces are problematic for some functions, so this has been put on hold, although basic luasocket support is planned fairly soon.

Performance

If you want the highest performance, allocate and pass your own buffers, as obviously allocation is expensive. It is now fine to use the string flags for functions, as these are memoized. Check the output of luajit -jv to see what is going on and let me know if there are any issues that need fixes for NYI functions. You should be able to get native C like performance.

There is an example epoll script that you can test with Apachebench in the examples directory. On my machine apachebench uses more CPU time than the script so the results are a bit low.

Porting

If you wish to port to an unsupported platform, please get in touch for help. All contributions welcomed.

Porting to different Linux processor architectures is a matter of filling in the constants and types that differ. The ctest tests will flag issues with these, although many platforms are also missing headers which makes it more complex. If you can provide qemu target information that would be helpful as the platform can be added to the test suite, or easily available hardware. We currently support all the platforms that LuaJIT does, so new platforms will require Lua support or new LuJIT ports.

Porting to different OSs is a fair amount of work, but can generally be done gradually. There is a lot of code sharing with the BSD operating systems so porting to new ones is just a matter of finding the differences; DragonflyBSD is the main one left to support. Solaris support would be nice to have, but it differs more than the BSDs. The first thing to do is check the base shared types, and work out if there are issues with large file support if it is a 32 bit platform. There is a fair amount of shared code that should just work once the types and constants are defined.

If you want to port this to a different language, then get in touch, as I have some ideas and plans along this route, though I am trying to get a good fairly stable interface in Lua first. Pypy and Ruby ought to be suitable targets as they have an ffi; I also intend to do a classic Lua port using the C API. I intend to use reflection to generate more generic data for the ports, and rework how files are included. The first thing to do is just prototype some basic functions to see what is needed. Get in touch if you are interested in a port!

Issues

There will no doubt be bugs and missing features, please report them if you find them. Also API design issues. You can use the github issue tracker to report issues.

License

All the ljsyscall code is under the MIT license. The ABI definitions are considered to be non copyrighted or CC0 if you need an official disclaimer. See LICENSE file for further details.

ljsyscall's People

Contributors

agladysh avatar alexandergall avatar anttikantee avatar aperezdc avatar bdowning avatar daurnimator avatar fperrad avatar geoffleyland avatar gut avatar hishamhm avatar jdesgats avatar johnae avatar jonringer avatar justincormack avatar lipp avatar lukego avatar qsn avatar sileht avatar tcoram avatar vavrusa avatar wingo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ljsyscall's Issues

Failed build on head

sudo luarocks install ljsyscall-scm-1.rockspec
[sudo] password for wakefield:
Using ljsyscall-scm-1.rockspec... switching to 'build' mode
Cloning into 'ljsyscall'...
remote: Counting objects: 6831, done.
remote: Compressing objects: 100% (2737/2737), done.
remote: Total 6831 (delta 4138), reused 6754 (delta 4089)
Receiving objects: 100% (6831/6831), 3.24 MiB | 123 KiB/s, done.
Resolving deltas: 100% (4138/4138), done.
stat: cannot stat `syscall/bsd/constants.lua': No such file or directory

Error: Failed copying syscall/bsd/constants.lua

Commenting out the entire bsd section in the rockspec seems to work. Should bsd -> netbsd?

raw sockets issues

Raw socket support is very messy, needs better metatables. (see some notes in code and tests).

It is also not receiving packets in the test in netbsd/rump so there are some issues.

Should also add a receive test, although for BSD probably makes more sense to receive via bpf interface.

mips support

At the moment I only have a softfloat (openwrt) mips box, which I don't think can run luajit at all, so supporting mips is not going to happen in the short term, although I may be able to add untested support. Hoping there will be a luajit mips softfloat issue. If anyone has online access to mips hardware let me know.

posix message queues

syscalls are:
mq_open, mq_close, mq_getattr, mq_notify, mq_receive, mq_send, mq_unlink, mq_timedrecieve, mq_timedsend -- note glibc wraps these (in -lrt) and changes them a bit see man (7) mq_overview.

add globals test to tests

find syscall syscall.lua -name '*.lua' | xargs -n1 luajit -bl | egrep 'GGET|GSET|^--' | egrep -v "; \"$(luajit -e 'for k in pairs(_G) do print(k) end')\""

more formats for mode

should be able to use "0600" and "rwxrwxrwx" or similar.

(0600 is octal so messy with no native lua support)

inconsistency of sockaddr_un

This is a Lua table of sockaddr and a length. This is because it is variable length and impossible to interpret without length.

We could make them all consistent. Could also wrap all in an ffi struct with length

musl 32 bit tests

I have not tested on x86 with Musl and may need some fixes due to saner handling of 64 bit fileops versus glibc.

Documentation

Needs documentation! It is all a bit fluid now, but settling down so may be a good time to start...

generic __new function

this function is duplicated in many places in types, and could be just one function

__new = function(tp, tab) -- TODO this function is duplicated in many places
local ifreq = ffi.new(tp)
if tab then for k, v in pairs(tab) do ifreq[k] = v end end
return ifreq
end,

remove default numeric initialisers

Unfortunately types may vary and differ in layout, so numeric array initialisers are dangerous. Fix them to use standard order or tables by name only.

ppc support

Powerpc support should be ok, other than huge numbers of constants and types are very different. Need to reinstall by old ppc box.

missing Linux system calls

This list is probably out of date and needs cross checking, but many of the following are missing. Some are obsolete.

timer_create, timer_getoverrun, clock_adjtime,
sigqueue,
init_module, delete_module, query_module, get_kernel_syms
iopl, ioperm,
futex, set_robust_list, get_robust_list,
getrusage, ptrace,
setfsuid, setfsgid,
recvmmsg,
mq_open, mq_close, mq_getattr, mq_notify, mq_receive, mq_send, mq_unlink, mq_timedrecieve, mq_timedsend -- note glibc wraps these (in -lrt)
quotactl, ioprio_set, ioprio_get
bdflush, kexec_load
mbind, get_mpolicy, set_mpolicy
sysfs, mincore, remap_file_pages, set_tid_address
add_key, request_key, keyctl (see libkeyutils wrappers)
migrate_pages, move_pages
perf_event_open -- see http://web.eecs.utk.edu/~vweaver1/projects/perf-events/programming.html
set_thread_area, get_thread_area, exit_group, tgkill
open_by_handle_at, name_by_handle_at
fanotify
process_vm_readv, process_vm_writev
...

note we will probably implement the posix ipc not sysv, as functionality slightly better.
sys v ipc: msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop, semtimedop, shmat, shmctl, shmdt, shmget

probably not useful: brk, uselib, socketcall, idle, ipc, modify_ldt, personality, sigreturn, sigaltstack, lookup_dcookie

from man(3)
clock_getcpuclockid
getdomainname (from uname)
ftok
shm_open and other posix functions (use /dev/shm)
uuid
sysconf

Failed test: test_netlink:test_get_interfaces

Under Linux,

$ uname -a
Linux ********* 3.2.0-25-generic #40-Ubuntu SMP Wed May 23 20:33:05 UTC 2012 i686 i686 i386 GNU/Linux

Luajit-2.0.0-beta10 (from git today) and ljsyscall from git today, I get this:

Failed tests:
-------------
>>> test_netlink:test_get_interfaces failed
test.lua:697: expected: 6, actual: 0
stack traceback:
    ./luaunit.lua:454: in function <./luaunit.lua:453>
    [C]: in function 'error'
    ./luaunit.lua:214: in function 'assert_equal'
    test.lua:697: in function 'test_get_interfaces'
    [string "test_netlink:test_get_interfaces()"]:1: in main chunk
    [C]: in function 'xpcall'
    ./luaunit.lua:458: in function 'runTestMethod'
    ./luaunit.lua:479: in function 'runTestMethodName'
    ./luaunit.lua:508: in function 'runTestClassByName'
    ./luaunit.lua:542: in function 'run'
    test.lua:1108: in main chunk
    [C]: ?
Success : 98% - 84 / 85

miscellaneous list of things to work on

Misc list of ideas, no particular order. See also notes in code. These should be split out into separate issues

  1. non blocking netlink functions ie return EAGAIN but can resume.
  2. futex support. Needs some assembly support.
  3. Other atomic ops eg CAS - see https://lwn.net/Articles/509102/
  4. try using llvm to parse headers to get syscall numbers, or a C program. Generate headers by arch.
  5. evented coroutine example
  6. iterators eg for reading large files? (cat)
  7. ping support
  8. dhcp client
  9. misc shell commands eg touch
  10. syslog? Not sure. Might do remote protocol.
  11. selinux
  12. seccomp
  13. insmod, lsmod, depmod
  14. decide on netlink interface, still experimenting
  15. netlink missing functionality and tests
  16. use netlink instead of bridge ioctls for create, destroy.
  17. sysctl wrapper (trivial write to /proc/sys)
  18. cgroups
  19. replace more of the man(3) stuff with native syscalls. More transparent.
  20. Standard lua support, eventually. Might start with luasocket support for netlink, but there is a lot of work to do.
  21. make more modular, started with netlink and arch specific but needs more.
  22. udev (uses netlink)
  23. netlink listen for events - started, needs more work
  24. fix fs specific mount ops so can round-trip mounts
  25. fix aio
  26. automate ctest.lua to do full compile and run
  27. short form for dellink(name)
  28. use S.if_nametoindex to convert interface names to numbers in nl where number not.
  29. performance counters
  30. define a bitshift function that works correctly with unsigned output.
  31. garbage collect mmap?

test device numbers / Linux dev_t issues

ctest should test device numbers.

Also I believe that Linux maybe should have the extended 32 bit device numbers as per osx/how they used to be, Musl may be incorrect.

make a way of not creating metatypes

Maybe look at putting all the metatypes in a module so you can monkeypatch it to modify them before loading.

So the metatype module returns a table that addtype uses to create types.

ie it has meth/mt in it, which are already tables.

Obviously this means that most of types goes to metatypes.

iovec helper

If you get partial reads and writes on an iovec you need to increment them. So we need to modify the iovecs type to allow this easily, ideally letting you just do iovec + offset just using metamethods.

Too many locals in syscall.lua

When I merge master into my termios support branch, I run into the lovely and very annoying "main function has more than 200 local variables" Lua limitation. It looks like the lowest-hanging fruit would be to simply directly assign typedefs to S.whatever_t instead of using local whatever_t. They could still be exported out the S.t table for compatibility, of course.

Opinions?

pseudo 1 based arrays

ctype __newindex tables and non-string lookups in ctype __index tables are not optimised now. We use these to convert some arrays to apparently 1-based. Maybe something else is better.

I think I will just allocate an extra element in arrays and pass the offset by one version to the system call, much cleaner.

be32 type?

Can we sanely create a generic network byte order type link __be32 in the Linux headers?
Also __le32 (currently named le32, may need renaming.)

test_raw_udp_root

This should not have a require in it! use helper functions to abstract this. Also endian issues exposed.

Please alias standard globals to allow sandboxing

Please alias all "standard" globals (i.e. require, assert, error, string, table etc.) at the top of each file. This common Lua coding idiom will allow ljsyscall to be used inside sandboxed environments, where _G is replaced by something else.

See #57 for some hints on how to list such globals.

cacheing scheme for constants

Should probably devise a better caching scheme. Often we want to iterate or reverse lookup the base constants eg to display error messages. So maybe the cache should be in a different table.

64 bit file ops on 32 bit

This is largely resolved (64 bit ops always used, see code for open, creat plus other functions), but have not looked at fcntl64 or statfs, which may need changes still as there is a 64 bit flock structure which is not defined yet.

wrapping in structs

define cpu_set_t as a struct which is wrong. Can define a struct for lua eg lua_cpu_set_t (or make it anon) which wraps a cpu_set_t but we should allow correct type to be given.

modularity

The code is getting bigger, and is only partially modular.

For many applications that does not matter as it is not huge at all. It will grow a little, but pretty much all the syscalls are in now.

There are a lot more functions and types that appear in other interfaces, such as ioctl, netlink etc, that are not used directly by syscalls. I think I will move these so they are only pulled in when you pull the relevant code, so types, constants are defined eg when you pull in eg the netlink code.

This means util should probably be split, and ioctl.

modules:

netlink which would pull in syscall.nl.types syscall.nl.constants etc
bridge (moved from util.bridge) which pulls in syscall.bridge.ioctl syscall.bridge.constants

In theory all of ioctl can move to these modules, although there will be a core for defining _IOW etc.

Other modules: tuntap, fuse etc

Tests should be split too.

This will leave a fixed size core syscall part which will stop growing. This could be further broken down.

ctest not on vm

Should be able to run rump ctest under eg Linux.

Requires that rump be provided as git submodule, plus can test against headers there.

Also might be sane to split netbsd code into rump and non rump eg mmap not defined. Doesnt matter for this though, as headers complete for rump.

allow octal modes in S_I[], mknod improvements

S_I[] is used eg in mknod. It should allow octal modes as well as the type of dev, so you can do S.mknod(dev, "chr, 0666", dev)

Device should also be allowed to be {2, 2} as well just t.device(t, t)

size of dev_t

In Linux dev_t seems to be 32 bit, despite glibc having 64 bits. And only 16 bits used in syscall, according to Musl, although that may change.

memcached example

Example of connecting to memcached, as need to do this anyway.

(also Redis, protocol is a little different).

easier flag manipulation

it would be nice to toggle flags more easily. We added C.IFF(flags, "up") but would be good to do C.IFF(flags, "~up") or C.IFF(flags, "-up")

Possibly other things to, eg test. Problem is they are not a particular type.

len for types

could add __len on metatypes, either returns sizeof, or it works out the size if VLA, usually possible form data.

Potentially removes much of need for s table of sizes. EDIT: Actually seem to use sizes table quite a bit, main point is to avoid passing lengths

mkswap

Need mkswap code in order to test swapon (and to be useful)

remove TODOs in code

These are things that came up as working, and need cleaning up, turning into proper issues or fixing.

checking using strace

Need to test we are getting what we think, eg it turns out signal calls sigaction in glibc, so we are not getting the syscall wrapper (indeed, we should just provide signal as a utility I suspect).

type naming issues

Have modified some of the type names in the cdefs, should fix. eg __le32 is le32. Should probably make a namespace for them eg __lj__le32? So do not collide with other cdefs.

support for running under PUC Lua

Currently requires LuaJIT, but it should be possible to also support vanilla Lua, although there is a fair amount of work. It used to work with Luaffi, and I think the best idea is to take the ffi structure code from there, but produce a traditional C binding to the system calls, so no dynasm is needed, for the widest compatibility.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.