shithub: gefs

Download patch

ref: 59b4c415b1a878a7c7f8a7725584489fca70cc61
parent: 1dc33dd936c0a90dc06dd3286698df8b4d770ad4
author: Ori Bernstein <ori@eigenstate.org>
date: Sun May 12 19:34:07 EDT 2024

fs: implement DMAPPEND files

--- a/TODO
+++ b/TODO
@@ -1,6 +1,8 @@
 *** commit blockers ***
 - atomics for all archs
 - docs
+- ORCLOSE
+- clunk fids on connection
 
 *** important bits ***
 - repair tools
--- a/fs.c
+++ b/fs.c
@@ -1819,7 +1819,7 @@
 		unlock(f);
 		error(Einuse);
 	}
-	if(m->mode & OTRUNC){
+	if((m->mode & OTRUNC) && !(f->dent->mode & DMAPPEND)){
 		wlock(f->dent);
 
 		if(waserror()){
@@ -2087,6 +2087,8 @@
 	p = m->data;
 	o = m->offset;
 	c = m->count;
+	if(f->dent->mode & DMAPPEND)
+		o = f->dent->length;
 	t = agetp(&f->mnt->root);
 	for(i = 0; i < nelem(kv)-1 && c != 0; i++){
 		assert(i == 0 || o%Blksz == 0);
@@ -2113,11 +2115,10 @@
 	kv[i].op = Owstat;
 	kv[i].k = f->dent->k;
 	kv[i].nk = f->dent->nk;
-	n = m->offset+w;
 	*p++ = 0;
-	if(n > f->dent->length){
+	if(o > f->dent->length){ 
 		sbuf[0] |= Owsize;
-		PACK64(p, n);
+		PACK64(p, o);
 		p += 8;
 		f->dent->length = m->offset+m->count;
 	}