SCCS-vsn: sys/kern/kern_descrip.c 7.25
case F_RDLCK:
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
case F_RDLCK:
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
case F_WRLCK:
if ((fp->f_flag & FWRITE) == 0)
return (EBADF);
return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
case F_WRLCK:
if ((fp->f_flag & FWRITE) == 0)
return (EBADF);
return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
case F_UNLCK:
return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
case F_UNLCK:
* a flag in the unlock to free ONLY locks obeying POSIX
* semantics, and not to free BSD-style file locks.
*/
* a flag in the unlock to free ONLY locks obeying POSIX
* semantics, and not to free BSD-style file locks.
*/
- if (fp->f_type == DTYPE_VNODE) {
+ if ((p->p_flag & SADVLCK) && fp->f_type == DTYPE_VNODE) {
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
return (0);
if (fp->f_count < 0)
panic("closef: count < 0");
return (0);
if (fp->f_count < 0)
panic("closef: count < 0");
- if (fp->f_type == DTYPE_VNODE)
+ if ((fp->f_flag & FHASLOCK) && fp->f_type == DTYPE_VNODE) {
+ lf.l_whence = SEEK_SET;
+ lf.l_start = 0;
+ lf.l_len = 0;
+ lf.l_type = F_UNLCK;
+ vp = (struct vnode *)fp->f_data;
(void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK);
(void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK);
error = (*fp->f_ops->fo_close)(fp, p);
crfree(fp->f_cred);
fp->f_count = 0;
error = (*fp->f_ops->fo_close)(fp, p);
crfree(fp->f_cred);
fp->f_count = 0;
lf.l_len = 0;
if (uap->how & LOCK_UN) {
lf.l_type = F_UNLCK;
lf.l_len = 0;
if (uap->how & LOCK_UN) {
lf.l_type = F_UNLCK;
+ fp->f_flag &= ~FHASLOCK;
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK));
}
if (uap->how & LOCK_EX)
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK));
}
if (uap->how & LOCK_EX)
lf.l_type = F_RDLCK;
else
return (EBADF);
lf.l_type = F_RDLCK;
else
return (EBADF);
+ fp->f_flag |= FHASLOCK;
if (uap->how & LOCK_NB)
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, F_FLOCK));
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, F_FLOCK|F_WAIT));
if (uap->how & LOCK_NB)
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, F_FLOCK));
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, F_FLOCK|F_WAIT));