shithub: gefs

Download patch

ref: 14dfdb4a65fb65e1972a73103ec0618ba89b44ad
parent: c32c77ec90cb57b1a0cdfd3a94f5693475f160c7
author: Ori Bernstein <[email protected]>
date: Sat May 13 17:57:13 EDT 2023

fs: tweak the previous cleanup, fix a missed unlockfid.

--- a/fs.c
+++ b/fs.c
@@ -1460,11 +1460,14 @@
 	Xdir d;
 	int nm;
 
-	e = nil;
 	if(okname(m->name) == -1){
 		rerror(m, Ename);
 		return;
 	}
+	if(m->perm & (DMMOUNT|DMAUTH)){
+		rerror(m, Ebotch);
+		return;
+	}
 	if((f = getfid(m->conn, m->fid)) == nil){
 		rerror(m, Enofid);
 		return;
@@ -1471,17 +1474,12 @@
 	}
 	lock(f);
 	if(f->mode != -1){
-		e = Einuse;
-		goto Fiderr;
+		rerror(m, Einuse);
+		goto Out;
 	}
-	if(m->perm & (DMMOUNT|DMAUTH)){
-		e = Ebotch;
-		goto Fiderr;
-	}
 	de = f->dent;
 	if(walk1(f->mnt->root, f->qpath, m->name, &old, &oldlen) == 0){
-		e = Eexist;
-		goto Fiderr;
+		rerror(m, Eexist);
 	}
 
 	rlock(de);
@@ -1488,7 +1486,7 @@
 	if(fsaccess(f, de->mode, de->uid, de->gid, DMWRITE) == -1){
 		rerror(m, Eperm);
 		runlock(de);
-		goto Fiderr;
+		goto Out;
 	}
 
 	d.gid = de->gid;
@@ -1521,8 +1519,7 @@
 	mb[nm].op = Oinsert;
 	if(dir2kv(f->qpath, &d, &mb[nm], buf, sizeof(buf)) == -1){
 		rerror(m, Efs);
-		putfid(f);
-		return;
+		goto Out;
 	}
 	nm++;
 
@@ -1540,29 +1537,31 @@
 	}
 	if((e = upsert(f->mnt, mb, nm)) != nil){
 		rerror(m, e);
-		goto Fiderr;
+		goto Out;
 	}
 
 	de = getdent(f->qpath, &d);
 	if(de == nil){
 		rerror(m, Enomem);
-		goto Fiderr;
+		goto Out;
 	}
 	f->mode = mode2bits(m->mode);
 	f->pqpath = f->qpath;
 	f->qpath = d.qid.path;
 	f->dent = de;
+	unlock(f);
+	putfid(f);
 
 	r.type = Rcreate;
 	r.qid = d.qid;
 	r.iounit = f->iounit;
-Fiderr:
+	respond(m, &r);
+	return;
+
+Out:
 	unlock(f);
 	putfid(f);
-	if(e == nil)
-		respond(m, &r);
-	else
-		rerror(m, e);
+	return;
 }
 
 static char*