nusb/cam: ctl message fixes
This commit is contained in:
parent
2da5e135dc
commit
657f0ed99a
2 changed files with 10 additions and 3 deletions
|
@ -202,6 +202,11 @@ strread(Req *req, char *str, int len)
|
|||
{
|
||||
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 @@ fsread(Req *req)
|
|||
}
|
||||
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 @@ err: respond(req, "the front fell off");
|
|||
werrstr("invalid argument");
|
||||
if(ctlwrite(c, s) < 0)
|
||||
responderror(req);
|
||||
else
|
||||
else{
|
||||
req->ofcall.count = req->ifcall.count;
|
||||
respond(req, nil);
|
||||
}
|
||||
free(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -507,7 +507,7 @@ ctlwrite(Cam *c, char *msg)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue