writerf(): write data to ramfile from serverside
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAmDS2TcACgkQO3+8IhRO Y5jkiQ/+O33mj9tUvzrQr/HJ+UxbTpY8pqc14PHiDiwfUViyEqETqGHQIKVLwUtb JdYbGvkV6vhOzKmHfJNs08LlCekJ+9dvjvxRf1Im2QE4AvfXnY7193V1qnmH3w+P irN5dgULIp/zgfaJhAF+9yhawDLRkzTuJ+/L295rchjHFedlp4ho/mRi23Nx3+iS VKTGkK8gxAyM+XDNOQWhTkTbTjIgd360Cku6xQPVIspjYfKgPcxbp6dCvFfIFNRr l8pu3eLNxe1koOQwHR14t04i4XZdQWrVmAGEX6n7bDzjUcxCnkojYfiAIBF/SrtI JqW8N0+ypNAfFbFmKLuBhGeN+GnecD5Yt+NCsoAnNbuSTZ+6AecXVZfQeyK+Ckos z103hob5+mn5INbJDzosrD1Lf2qdWeyKU7ZlqsruD1Ex5cG1D4FxQB2r+5ClozqI OcP4ITgmh0SAvBrnSDKeCkL6ynbWLRiUk4PXEcHj9a2i86myobPOrUp0m5+SUqZp dvfKwZi4fuNrwGZBD1jZsNWHLea5NxMl3NCxITJv0ApQNIk63olYETuEe/RkiuRW sdWtT8/QLWtI+mcFbzW6R8eSHJZrflqpZtmEW+Ejn2OkH2mZP2KLVRSYlAv19jMb 5f6c3UZk0A7x5jMOgBgCp2Za0VrN81EjT9lyAM06gUG1IeOH9z4= =b9z/ -----END PGP SIGNATURE-----
1 files changed,
16 insertions(+),
14 deletions(-)
jump to
M
xrxs.c
→
xrxs.c
@@ -84,13 +84,7 @@ void fscreate(Req* r) {
Ramfile* rf; File* f; - if ( - f = createfile( - r->fid->file, - r->ifcall.name, - nil, - r->ifcall.perm, - nil)) { + if (f = createfile(r->fid->file, r->ifcall.name, nil, r->ifcall.perm, nil)) { rf = emalloc9p(sizeof *rf); f->aux = rf; r->fid->file = f;@@ -125,6 +119,15 @@ free(rf);
} } +void writerf(Tree* t, char* path, char* data) { + Ramfile* rf; + File* f = walkfile(t->root, path); + rf = (Ramfile*)emalloc9p(sizeof *rf); + rf->data = data; + rf->ndata = slen(data); + f->aux = rf; +} + Srv fs = { .open = fsopen, .read = fsread,@@ -132,9 +135,7 @@ .write = fswrite,
.create = fscreate, }; -int threadmaybackground(void) { - return 1; -} +int threadmaybackground(void) { return 1; } void threadmain(int argc, char* argv[]) { Tree* tree;@@ -158,10 +159,11 @@ }
} } - /* create a single file called 'hello'. reading it calls fsread() */ - - fs.tree = alloctree(nil, nil, DMDIR|0777, fsdestroyfile); - fs.foreground = 1; + fs.tree = alloctree(nil, nil, DMDIR | 0777, fsdestroyfile); + tree = fs.tree; + createfile(tree->root, "carts", nil, 0444, nil); + writerf(tree, "carts", "uStrat\nkatbug\nSoulGrind\n"); + fs.foreground = 1; if (argc >= 3) { if (mtpt != nil && access(mtpt, AEXIST) < 0 && access(mtpt, AEXIST) < 0)