try to use cp only for curproc[cpu()]

This commit is contained in:
rsc 2007-08-09 17:32:40 +00:00
parent 22330658ff
commit 9583b476bf
4 changed files with 37 additions and 36 deletions

View file

@ -22,11 +22,11 @@ argfd(int argno, int *pfd, struct file **pf)
{
int fd;
struct file *f;
struct proc *p = curproc[cpu()];
struct proc *cp = curproc[cpu()];
if(argint(argno, &fd) < 0)
return -1;
if(fd < 0 || fd >= NOFILE || (f=p->ofile[fd]) == 0)
if(fd < 0 || fd >= NOFILE || (f=cp->ofile[fd]) == 0)
return -1;
if(pfd)
*pfd = fd;
@ -41,10 +41,11 @@ static int
fdalloc(struct file *f)
{
int fd;
struct proc *p = curproc[cpu()];
struct proc *cp = curproc[cpu()];
for(fd = 0; fd < NOFILE; fd++){
if(p->ofile[fd] == 0){
p->ofile[fd] = f;
if(cp->ofile[fd] == 0){
cp->ofile[fd] = f;
return fd;
}
}
@ -57,7 +58,7 @@ sys_pipe(void)
int *fd;
struct file *rf = 0, *wf = 0;
int fd0, fd1;
struct proc *p = curproc[cpu()];
struct proc *cp = curproc[cpu()];
if(argptr(0, (void*)&fd, 2*sizeof fd[0]) < 0)
return -1;
@ -66,7 +67,7 @@ sys_pipe(void)
fd0 = -1;
if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
if(fd0 >= 0)
p->ofile[fd0] = 0;
cp->ofile[fd0] = 0;
fileclose(rf);
fileclose(wf);
return -1;
@ -241,7 +242,7 @@ sys_mkdir(void)
int
sys_chdir(void)
{
struct proc *p = curproc[cpu()];
struct proc *cp = curproc[cpu()];
struct inode *ip;
char *path;
@ -261,9 +262,9 @@ sys_chdir(void)
return -1;
}
idecref(p->cwd);
p->cwd = ip;
iunlock(p->cwd);
idecref(cp->cwd);
cp->cwd = ip;
iunlock(cp->cwd);
return 0;
}