ref: 68a4565cabee2e272740b375bcd02565823021e5
parent: e5d9d3c049b93a6bb948aa81398b0f841f771704
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Sun Mar 10 17:13:57 EDT 2024
ext4srv: support ORCLOSE
--- a/sys/src/cmd/ext4srv/ext4srv.c
+++ b/sys/src/cmd/ext4srv/ext4srv.c
@@ -24,6 +24,7 @@
ext4_dir *dir;
};
int type;
+ bool rclose;
};
enum {
@@ -60,6 +61,7 @@
case OREAD:
p = AREAD;
break;
+ case ORCLOSE:
case OWRITE:
p = AWRITE;
break;
@@ -225,6 +227,7 @@
responderror(r);
return;
}
+ a->rclose = (r->ifcall.mode & ORCLOSE) != 0;
break;
Nomem:
@@ -721,12 +724,13 @@
a = oldfid->aux;
- if((c = calloc(1, sizeof(*c))) == nil)
+ if((c = malloc(sizeof(*c))) == nil)
return "memory";
memmove(c, a, sizeof(*c));
c->path = estrdup9p(a->path);
c->file = nil;
c->dir = nil;
+ c->rclose = false;
incref(c->p);
newfid->aux = c;
@@ -750,6 +754,8 @@
}else if(a->type == Afile && a->file != nil){
ext4_fclose(a->file);
free(a->file);
+ if(a->rclose)
+ ext4_fremove(&a->p->mp, a->path);
}
if(decref(a->p) < 1)