shithub: riscv

Download patch

ref: 657f0ed99a23c2ee6872d890c8ca8ef97fed9ac9
parent: 2da5e135dc5d1d50ac2a760fe1bc693b6008087c
author: aiju <devnull@localhost>
date: Wed Mar 7 15:44:55 EST 2018

nusb/cam: ctl message fixes

--- a/sys/src/cmd/nusb/cam/cam.c
+++ b/sys/src/cmd/nusb/cam/cam.c
@@ -202,6 +202,11 @@
 {
 	ReadState *rs;
 	
+	if(req->fid->aux != nil){
+		free(((ReadState*)req->fid->aux)->buf);
+		free(req->fid->aux);
+		req->fid->aux = nil;
+	}
 	if(str == nil)
 		return;
 	rs = emallocz(sizeof(ReadState), 1);
@@ -223,7 +228,7 @@
 	}
 	f = req->fid->file;
 	c = f->aux;
-	if(req->fid->aux == nil)
+	if(req->fid->aux == nil || req->ifcall.offset == 0)
 		if(f == c->formatsfile)
 			strread(req, formatread(c), -1);
 		else if(f == c->ctlfile)
@@ -267,8 +272,10 @@
 	werrstr("invalid argument");
 	if(ctlwrite(c, s) < 0)
 		responderror(req);
-	else
+	else{
+		req->ofcall.count = req->ifcall.count;
 		respond(req, nil);
+	}
 	free(s);
 }
 
--- a/sys/src/cmd/nusb/cam/ctl.c
+++ b/sys/src/cmd/nusb/cam/ctl.c
@@ -507,7 +507,7 @@
 		p = findparam(f[1]);
 		if(p == nil)
 			return -1;
-		if((uint)uid >= nunit || unit[uid] == nil){
+		if(p->type != PARAMSPEC && ((uint)uid >= nunit || unit[uid] == nil)){
 			werrstr("no such unit");
 			return -1;
 		}