9p service framework
- C 93.1%
- Makefile 6.9%
| xrxs | ||
| mkfile | ||
| README.md | ||
xrxs
xrxs is a small library for building 9p filesystems; it can expose them as mounted filesystems or as service sockets
quickstart
have plan9port installed
copy/clone this repository and create a main.c file:
#include "xrxs/types.h"
#include "xrxs/fns.h"
enum FileType {
CTL = 1,
DATA
};
void xrxs_attach(Req* r) {
respond(r, nil);
}
void xrxs_read(Req* r) {
Aux* a = r->fid->file->aux;
switch (a->type) {
case DATA:
readstr(r, "some data\n");
respond(r, nil);
break;
default:
respond(r, nil);
}
}
void xrxs_write(Req* r) {
respond(r, nil);
}
int threadmaybackground(void) { return 1; }
void threadmain(int argc, char* argv[]) {
Srv* fs = xrxs_create(xrxs_read, xrxs_write, xrxs_attach);
xrxs_build(fs->tree->root, "ctl", nil, DMAPPEND | 0600, aux_create(CTL));
xrxs_build(fs->tree->root, "data", nil, 0400, aux_create(DATA));
xrxs_srv(fs, "svcname", "/home/nilix/n");
}
Adjust your mkfile and add any directoriess for your project organization with their own mkfiles.
mk and enjoy
API
pretty low key, just read types.h and fns.h; a lot of the functions are just string functions because this is C. if you have more questions 9 man 9p should answer most of them
LICENSE
MIT; use it however, just provide attribution