code: mafs

Download patch

ref: 96858dcc4406b23673d5f032018b423e625c9ec6
parent: f026afa15041406a242835cf583b4729217826b7
author: 9ferno <gophone2015@gmail.com>
date: Fri Jan 13 01:52:27 EST 2023

using srv.walk as it is a more convenient wrapper

--- a/9p.c
+++ b/9p.c
@@ -76,7 +76,7 @@
 }
 
 static char*
-fswalk1(Fid *fid, char *name, Qid *qid)
+fswalk1(Fid *fid, char *name, void*)
 {
 	Aux *aux;
 	Dentry *d, *chd, *p;
@@ -83,6 +83,7 @@
 	Iobuf *dbuf, *cbuf, *pbuf;
 	u64 chreli, blkno;
 	s8 v;
+	Qid qid;
 
 	if(shuttingdown)
 		return nil;
@@ -106,7 +107,7 @@
 			pbuf = egetmetachk(aux->pdblkno, Breadonly, Tdentry, aux->pqpath);
 
 			p = pbuf->d;
-			*qid = (Qid){p->path, p->version, (p->mode&DMDIR) ? QTDIR : QTFILE};
+			qid = (Qid){p->path, p->version, (p->mode&DMDIR) ? QTDIR : QTFILE};
 			if(aux != nil){
 				aux->dblkno = pbuf->blkno; /* preli in aux will be wrong, issue? */
 				aux->pdblkno = p->pdblkno;
@@ -114,7 +115,7 @@
 				aux->preli = p->preli;
 			}
 			putbuf(pbuf, 0);
-			fid->qid = *qid;
+			fid->qid = qid;
 			poperror();
 			return nil;
 		}
@@ -151,7 +152,7 @@
 	if((chd->mode&DMDIR) && canaccess(aux->uid, chd, DMEXEC) == 0)
 		error(errstring[Eperm]);
 
-	*qid = (Qid){chd->path, chd->version, (chd->mode&DMDIR) ? QTDIR : QTFILE};
+	qid = (Qid){chd->path, chd->version, (chd->mode&DMDIR) ? QTDIR : QTFILE};
 	if(aux != nil){
 		aux->dblkno = blkno;
 		aux->pdblkno = chd->pdblkno;/* or, aux->dblkno */
@@ -162,13 +163,13 @@
 	putbuf(cbuf, 0);
 	poperror();
 	putbuf(dbuf, 0);
-	fid->qid = *qid;
+	fid->qid = qid;
 	poperror();
 	return nil;
 }
 
 static char*
-fsclone(Fid *oldfid, Fid *newfid)
+fsclone(Fid *oldfid, Fid *newfid, void*)
 {
 	Aux *o;
 
@@ -182,6 +183,12 @@
 }
 
 static void
+fswalk(Req *r)
+{
+	walkandclone(r, fswalk1, fsclone, nil);
+}
+
+static void
 fsdestroyfid(Fid *fid)
 {
 	Tlock *t;
@@ -1326,6 +1333,12 @@
 	put(&buf, fsremove, r);
 }
 
+void
+mfswalk(Req *r)
+{
+	put(&buf, fswalk, r);
+}
+
 /* multi process server */
 Srv mpsrv = {
 	.auth = fsauth,
@@ -1333,9 +1346,6 @@
 	.destroyfid = fsdestroyfid,
 	.msize = Iounit,
 
-	.walk1 = fswalk1,
-	.clone = fsclone,
-
 	.open = mfsopen,
 	.create = mfscreate,
 	.read = mfsread,
@@ -1342,6 +1352,7 @@
 	.write = mfswrite,
 	.stat = mfsstat,
 	.wstat = mfswstat,
+	.walk = mfswalk,
 	.remove = mfsremove,
 
 	.start = fsstart,
@@ -1355,9 +1366,6 @@
 	.destroyfid = fsdestroyfid,
 	.msize = Iounit,
 
-	.walk1 = fswalk1,
-	.clone = fsclone,
-
 	.open = fsopen,
 	.create = fscreate,
 	.read = fsread,
@@ -1364,6 +1372,7 @@
 	.write = fswrite,
 	.stat = fsstat,
 	.wstat = fswstat,
+	.walk = fswalk,
 	.remove = fsremove,
 
 	.end = fsend,