code: plan9front

Download patch

ref: 16369de87d69df0b8e0f29a183b412d40111e543
parent: f3ee0648020f1c566920b26d33be65665a2c179c
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Jun 9 10:40:40 EDT 2024

gefs: correctly set duid/dgid on Tcreate

we were updating the dir that the fid pointed
to, but not updating the parent uid/gid.

--- a/sys/src/cmd/gefs/fs.c
+++ b/sys/src/cmd/gefs/fs.c
@@ -1604,6 +1604,7 @@
 fscreate(Fmsg *m)
 {
 	char *p, *e, buf[Kvmax], upkbuf[Keymax], upvbuf[Inlmax];
+	int nm, duid, dgid;
 	Dent *de;
 	vlong oldlen;
 	Qid old;
@@ -1611,7 +1612,6 @@
 	Msg mb[2];
 	Fid *f;
 	Xdir d;
-	int nm;
 
 	if((e = okname(m->name)) != nil){
 		rerror(m, e);
@@ -1648,8 +1648,8 @@
 		runlock(de);
 		goto Out;
 	}
-
-	d.gid = de->gid;
+	duid = de->uid;
+	dgid = de->gid;
 	runlock(de);
 
 	nm = 0;
@@ -1674,7 +1674,7 @@
 	d.mtime = d.atime;
 	d.length = 0;
 	d.uid = f->uid;
-	d.gid = de->gid;
+	d.gid = dgid;
 	d.muid = f->uid;
 
 	mb[nm].op = Oinsert;
@@ -1701,6 +1701,8 @@
 	f->pqpath = f->qpath;
 	f->qpath = d.qid.path;
 	f->dent = de;
+	f->duid = duid;
+	f->dgid = dgid;
 	if(m->mode & ORCLOSE)
 		f->rclose = emalloc(sizeof(Amsg), 1);