richterm

"terminal emulator" with support for text fonts and images for plan9
git clone git://nsmpr.xyz/richterm.git
Log | Files | Refs | README

commit 5f469ad212074b8940be46db4c93898e083c99ec
parent 67bc1dd121eb560de38d2e96f7ac8443bcec983a
Author: glenda <glenda@9front.local>
Date:   Wed, 21 Jul 2021 20:24:34 +0000

fs.c: populate fs_write()

Diffstat:
Mfs.c | 23++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/fs.c b/fs.c @@ -27,7 +27,28 @@ fs_read(Req *r) void fs_write(Req *r) { - respond(r, nil); + char *buf; + long n, m; + File *f; + Faux *aux; + f = r->fid->file; + aux = f->aux; + if (f == new) { + respond(r, "not allowed"); + } else if (aux != nil) { + /* TODO: this is not exactly finished */ + n = r->ifcall.offset + r->ifcall.count; + m = (r->ifcall.offset > aux->data->n) ? aux->data->n : r->ifcall.offset; + buf = mallocz(n, 1); + memcpy(buf, aux->data->p, m); + memcpy(buf + r->ifcall.offset, r->ifcall.data, r->ifcall.count); + free(aux->data->p); + aux->data->p = buf; + aux->data->n = n; + r->ofcall.count = r->ifcall.count; + respond(r, nil); + return; + } else respond(r, "fs_write: f->aux is nil"); } Fsctl *