kernel: devdup: fix dup(n, 0)
A successful dup(n, 0) must not return -1L
This commit is contained in:
@ -64,13 +64,17 @@ static Chan*
|
|||||||
dupcreate(Chan* c, char* name, unsigned long omode, unsigned long perm)
|
dupcreate(Chan* c, char* name, unsigned long omode, unsigned long perm)
|
||||||
{
|
{
|
||||||
FdPair in, out;
|
FdPair in, out;
|
||||||
|
int d;
|
||||||
|
|
||||||
if((omode|OCEXEC) == ~0 && c->qid.path == 0){
|
if((omode|OCEXEC) == ~0 && c->qid.path == 0){
|
||||||
in.aslong = perm;
|
in.aslong = perm;
|
||||||
out.aslong = 0;
|
out.aslong = ~0;
|
||||||
out.fd[1] = sysdup(in.fd[0], in.fd[1]);
|
d = sysdup(in.fd[0], in.fd[1]);
|
||||||
|
if(d >= 0){
|
||||||
|
out.fd[1] = d;
|
||||||
errorl(nil, ~out.aslong);
|
errorl(nil, ~out.aslong);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
error(Eperm);
|
error(Eperm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user