-/* kern_descrip.c 5.15 82/10/22 */
+/* kern_descrip.c 5.23 83/01/17 */
#include "../h/param.h"
#include "../h/systm.h"
return;
adtype.dt_type = 0; /* XXX */
adtype.dt_protocol = 0; /* XXX */
- if (copyout((caddr_t)&adtype, (caddr_t)uap->dtypeb,
- sizeof (struct dtype)) < 0) {
- u.u_error = EFAULT;
+ u.u_error = copyout((caddr_t)&adtype, (caddr_t)uap->dtypeb,
+ sizeof (struct dtype));
+ if (u.u_error)
return;
- }
}
getdopt()
j = ufalloc();
if (j < 0)
return;
- dupit(j, fp, u.u_pofile[uap->i] & (RDLOCK|WRLOCK));
+ dupit(j, fp, u.u_pofile[uap->i] & (UF_SHLOCK|UF_EXLOCK));
}
dup2()
if (uap->i == uap->j)
return;
if (u.u_ofile[uap->j]) {
+ if (u.u_pofile[uap->j] & UF_MAPPED)
+ munmapfd(uap->j);
closef(u.u_ofile[uap->j], 0, u.u_pofile[uap->j]);
if (u.u_error)
return;
/* u.u_ofile[uap->j] = 0; */
/* u.u_pofile[uap->j] = 0; */
}
- dupit(uap->j, fp, u.u_pofile[uap->i] & (RDLOCK|WRLOCK));
+ dupit(uap->j, fp, u.u_pofile[uap->i] & (UF_SHLOCK|UF_EXLOCK));
}
dupit(fd, fp, lockflags)
u.u_ofile[fd] = fp;
u.u_pofile[fd] = lockflags;
fp->f_count++;
- if (lockflags&RDLOCK)
- fp->f_inode->i_rdlockc++;
- if (lockflags&WRLOCK)
- fp->f_inode->i_wrlockc++;
+ if (lockflags&UF_SHLOCK)
+ fp->f_inode->i_shlockc++;
+ if (lockflags&UF_EXLOCK)
+ fp->f_inode->i_exlockc++;
}
close()
fp = getf(uap->i);
if (fp == 0)
return;
+ if (u.u_pofile[uap->i] & UF_MAPPED)
+ munmapfd(uap->i);
closef(fp, 0, u.u_pofile[uap->i]);
/* WHAT IF u.u_error ? */
u.u_ofile[uap->i] = NULL;
fp = getf(uap->d);
if (fp == 0)
return;
- if (copyin((caddr_t)uap->dtypeb, (caddr_t)&adtype,
- sizeof (struct dtype)) < 0) {
- u.u_error = EFAULT;
+ u.u_error = copyin((caddr_t)uap->dtypeb, (caddr_t)&adtype,
+ sizeof (struct dtype));
+ if (u.u_error)
return;
- }
/* DO WRAP */
}
label_t lqsave;
obits[0] = obits[1] = obits[2] = 0;
- if (uap->nd >= NOFILE) {
- u.u_error = EINVAL;
- goto done;
- }
+ if (uap->nd > NOFILE)
+ uap->nd = NOFILE; /* forgiving, if slightly wrong */
#define getbits(name, x) \
if (uap->name) { \
- if (copyin((caddr_t)uap->name, (caddr_t)&ibits[x], \
- sizeof (ibits[x]))) { \
- u.u_error = EFAULT; \
+ u.u_error = copyin((caddr_t)uap->name, (caddr_t)&ibits[x], \
+ sizeof (ibits[x])); \
+ if (u.u_error) \
goto done; \
- } \
} else \
ibits[x] = 0;
getbits(in, 0);
#undef getbits
if (uap->tv) {
- if (copyin((caddr_t)uap->tv, (caddr_t)&atv, sizeof (atv))) {
- u.u_error = EFAULT;
+ u.u_error = copyin((caddr_t)uap->tv, (caddr_t)&atv,
+ sizeof (atv));
+ if (u.u_error)
goto done;
- }
if (itimerfix(&atv)) {
u.u_error = EINVAL;
goto done;
done:
#define putbits(name, x) \
if (uap->name) { \
- if (copyout((caddr_t)obits[x], (caddr_t)uap->name, \
- sizeof (obits[x]))) \
- u.u_error = EFAULT; \
+ int error = copyout((caddr_t)&obits[x], (caddr_t)uap->name, \
+ sizeof (obits[x])); \
+ if (error) \
+ u.u_error = error; \
}
putbits(in, 0);
putbits(ou, 1);
register struct proc *p;
int coll;
{
- int s;
if (coll) {
nselcoll++;
wakeup((caddr_t)&selwait);
}
if (p) {
+ int s = spl6();
if (p->p_wchan == (caddr_t)&selwait)
setrun(p);
- else {
- s = spl6();
- if (p->p_flag & SSEL)
- p->p_flag &= ~SSEL;
- splx(s);
- }
+ else if (p->p_flag & SSEL)
+ p->p_flag &= ~SSEL;
+ splx(s);
}
}
ip = fp->f_inode;
dev = (dev_t)ip->i_rdev;
mode = ip->i_mode & IFMT;
- flags &= RDLOCK|WRLOCK; /* conservative */
+ flags &= UF_SHLOCK|UF_EXLOCK; /* conservative */
if (flags)
funlocki(ip, flags);
ilock(ip);