SCCS-vsn: sys/kern/kern_descrip.c 5.26
SCCS-vsn: sys/kern/kern_exec.c 4.4
SCCS-vsn: sys/kern/kern_exit.c 4.4
SCCS-vsn: sys/kern/kern_fork.c 4.3
-/* kern_descrip.c 5.25 83/06/12 */
+/* kern_descrip.c 5.26 83/06/14 */
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/param.h"
#include "../h/systm.h"
if (u.u_ofile[uap->j]) {
if (u.u_pofile[uap->j] & UF_MAPPED)
munmapfd(uap->j);
if (u.u_ofile[uap->j]) {
if (u.u_pofile[uap->j] & UF_MAPPED)
munmapfd(uap->j);
- closef(u.u_ofile[uap->j], u.u_pofile[uap->j]);
+ closef(u.u_ofile[uap->j]);
- /* u.u_ofile[uap->j] = 0; */
- /* u.u_pofile[uap->j] = 0; */
}
dupit(uap->j, fp, u.u_pofile[uap->i]);
}
}
dupit(uap->j, fp, u.u_pofile[uap->i]);
}
-dupit(fd, fp, lockflags)
int fd;
register struct file *fp;
int fd;
register struct file *fp;
- register int lockflags;
- u.u_pofile[fd] = lockflags;
+ u.u_pofile[fd] = flags;
-/* THIS DOESN'T BELONG HERE */
- if (lockflags&UF_SHLOCK)
- ((struct inode *)fp->f_data)->i_shlockc++;
- if (lockflags&UF_EXLOCK)
- ((struct inode *)fp->f_data)->i_exlockc++;
-/* END DOESN'T BELONG */
pf = (u_char *)&u.u_pofile[uap->i];
if (*pf & UF_MAPPED)
munmapfd(uap->i);
pf = (u_char *)&u.u_pofile[uap->i];
if (*pf & UF_MAPPED)
munmapfd(uap->i);
- if (*pf & (UF_SHLOCK|UF_EXLOCK))
- unlockf(fp, pf);
closef(fp);
/* WHAT IF u.u_error ? */
u.u_ofile[uap->i] = NULL;
closef(fp);
/* WHAT IF u.u_error ? */
u.u_ofile[uap->i] = NULL;
/*NOTREACHED*/
}
if (u.u_error == 0)
/*NOTREACHED*/
}
if (u.u_error == 0)
- u.u_error = copyout(&ub, uap->sb, sizeof (ub));
+ u.u_error = copyout((caddr_t)&ub, (caddr_t)uap->sb,
+ sizeof (ub));
int how;
} *uap = (struct a *)u.u_ap;
register struct file *fp;
int how;
} *uap = (struct a *)u.u_ap;
register struct file *fp;
- register u_char *pf;
- int cmd;
fp = getf(uap->fd);
if (fp == NULL)
return;
fp = getf(uap->fd);
if (fp == NULL)
return;
- cmd = uap->how;
- pf = (u_char *)&u.u_pofile[uap->fd];
- if (cmd & LOCK_UN) {
- unlockf(fp, pf);
+ if (fp->f_type != DTYPE_INODE) {
+ u.u_error = EOPNOTSUPP;
- /*
- * No reason to write lock a file we've already
- * write locked, similarly with a read lock.
- */
- if ((*pf & UF_EXLOCK) && (cmd & LOCK_EX) ||
- (*pf & UF_SHLOCK) && (cmd & LOCK_SH))
+ if (uap->how & LOCK_UN) {
+ ino_unlock(fp, FSHLOCK|FEXLOCK);
- switch (fp->f_type) {
-
- case DTYPE_INODE:
- u.u_error = ino_lock((struct inode *)fp->f_data, pf, cmd);
- break;
-
- case DTYPE_SOCKET:
- u.u_error = soo_lock((struct socket *)fp->f_data, pf, cmd);
- break;
-
- default:
- panic("lockf");
-}
-
-unlockf(fp, pf)
- register struct file *fp;
- register u_char *pf;
-{
-
- if ((*pf & (UF_SHLOCK|UF_EXLOCK)) == 0)
+ /* avoid work... */
+ if ((fp->f_flag & FEXLOCK) && (uap->how & LOCK_EX) ||
+ (fp->f_flag & FSHLOCK) && (uap->how & LOCK_SH))
- switch (fp->f_type) {
-
- case DTYPE_INODE:
- ino_unlock((struct inode *)fp->f_data, *pf);
- break;
-
- case DTYPE_SOCKET:
- soo_unlock((struct socket *)fp->f_data, *pf);
- break;
-
- default:
- panic("unlockf");
- }
- *pf &= ~(UF_SHLOCK|UF_EXLOCK);
+ u.u_error = ino_lock(fp, uap->how);
-/* kern_exec.c 4.3 83/06/12 */
+/* kern_exec.c 4.4 83/06/14 */
#include "../machine/reg.h"
#include "../machine/pte.h"
#include "../machine/reg.h"
#include "../machine/pte.h"
#endif
for (i=0; i<NOFILE; i++) {
if (u.u_pofile[i]&UF_EXCLOSE) {
#endif
for (i=0; i<NOFILE; i++) {
if (u.u_pofile[i]&UF_EXCLOSE) {
- closef(u.u_ofile[i], u.u_pofile[i]);
u.u_ofile[i] = NULL;
u.u_pofile[i] = 0;
}
u.u_ofile[i] = NULL;
u.u_pofile[i] = 0;
}
-/* kern_exit.c 4.3 83/06/02 */
+/* kern_exit.c 4.4 83/06/14 */
#include "../machine/reg.h"
#include "../machine/psl.h"
#include "../machine/reg.h"
#include "../machine/psl.h"
u.u_ofile[i] = NULL;
po = u.u_pofile[i];
u.u_pofile[i] = 0;
u.u_ofile[i] = NULL;
po = u.u_pofile[i];
u.u_pofile[i] = 0;
}
ilock(u.u_cdir);
iput(u.u_cdir);
}
ilock(u.u_cdir);
iput(u.u_cdir);
-/* kern_fork.c 4.2 83/06/02 */
+/* kern_fork.c 4.3 83/06/14 */
#include "../machine/reg.h"
#include "../machine/pte.h"
#include "../machine/reg.h"
#include "../machine/pte.h"
if (fp == NULL)
continue;
fp->f_count++;
if (fp == NULL)
continue;
fp->f_count++;
- if (u.u_pofile[n]&UF_SHLOCK)
- ((struct inode *)fp->f_data)->i_shlockc++;
- if (u.u_pofile[n]&UF_EXLOCK)
- ((struct inode *)fp->f_data)->i_exlockc++;
}
u.u_cdir->i_count++;
if (u.u_rdir)
}
u.u_cdir->i_count++;
if (u.u_rdir)