shithub: mq

Download patch

ref: c76e7422f948b4302839f0b189a126fd3b29393d
parent: f3e647cd3055f1e1686e5f3957d40649ad5bea1f
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Jan 4 01:14:20 EST 2024

mqstat: fix stat without open

--- a/mq.c
+++ b/mq.c
@@ -236,7 +236,10 @@
 void
 mqstat(Req *r)
 {
-	switch(QTYPE(r->fid->qid.path)){
+	vlong p;
+
+	p = r->fid->qid.path;
+	switch(QTYPE(p)){
 	case Qroot:
 		r->d.uid = estrdup9p("glenda");
 		r->d.gid = estrdup9p("glenda");
@@ -247,7 +250,9 @@
 		r->d.mode = 0755;
 		break;
 	default:
-		qstat(&r->d, ((Aux*)r->fid->aux)->q);
+		incref(queues[QIDX(p)]);
+		qstat(&r->d, queues[QIDX(p)]);
+		decref(queues[QIDX(p)]);
 	}
 	respond(r, nil);
 }