commit e8a244ca5cba8f49d5db04892bfbcd86836c93ad
parent e9e6e9eca34c7526ace17e4be64fb5efa8522cc0
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Sun, 29 Aug 2021 19:29:40 +0000
did something , i dunno
Diffstat:
M | fs.c | | | 34 | +++++++++++++++++++++++----------- |
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/fs.c b/fs.c
@@ -15,6 +15,7 @@ File *cons, *consctl, *ctl, *menu, *new, *text;
Object *newobj;
Reqqueue *rq;
+void arrayopen(Req *);
void arrayread(Req *);
void arraywrite(Req *);
void consread(Req *);
@@ -30,6 +31,7 @@ void fs_open(Req *);
void fs_read(Req *);
void fs_write(Req *);
void imageclose(Fid *);
+void newopen(Req *);
void newread(Req *);
void textread(Req *);
void textwrite(Req *);
@@ -53,7 +55,7 @@ initfs(char *srvname)
srv.tree = alloctree("richterm", "richterm", DMDIR|0555, nil);
fsroot = srv.tree->root;
new = createfile(fsroot, "new", "richterm", 0444,
- fauxalloc(nil, nil, nil, newread, nil, nil));
+ fauxalloc(nil, nil, newopen, newread, nil, nil));
ctl = createfile(fsroot, "ctl", "richterm", DMAPPEND|0666,
fauxalloc(nil, nil, nil, ctlread, ctlwrite, nil));
text = createfile(fsroot, "text", "richterm", 0444,
@@ -179,16 +181,10 @@ fs_destroyfid(Fid *fid)
void
fs_open(Req *r)
{
- if (r->fid->omode && OTRUNC) {
-// if ((r->fid->file->aux != nil) && (((Faux *)r->fid->file->aux)->data != nil))
-// ((Faux *)r->fid->file->aux)->data->count = 0;
- }
- if (r->fid->file == new) {
- newobj = objectcreate();
- mkobjectftree(newobj, fsroot);
- objinsertbeforelast(newobj);
- }
- respond(r, nil);
+ Faux *aux;
+ aux = r->fid->file->aux;
+ if ((aux != nil) && (aux->open != nil)) aux->open(r);
+ else respond(r, nil);
}
void
@@ -229,6 +225,13 @@ delayedread(Req *r)
}
void
+arrayopen(Req *r)
+{
+
+ respond(r, nil);
+}
+
+void
arrayread(Req *r)
{
Array *data;
@@ -409,6 +412,15 @@ ctlwrite(Req *r)
}
void
+newopen(Req *r)
+{
+ newobj = objectcreate();
+ mkobjectftree(newobj, fsroot);
+ objinsertbeforelast(newobj);
+ respond(r, nil);
+}
+
+void
newread(Req *r)
{
readstr(r, newobj->id);