tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: struct file at VFS level (round 1.5)



On Tue, May 03, 2016 at 12:20:41PM +0000, Emmanuel Dreyfus wrote:
> Well, I need you to explain me what happens in sys_flock() then.
> Is it a bug?
>                 error = VOP_ADVLOCK(vp, fp, F_UNLCK, &lf, F_FLOCK);
> 
> fp is struct file. Same thing happens in open_setfp() and closef()

sys_flock() is for BSD flock(2) advisory file locking.  There is no
mandatory BSD file locking.

The Linux mandatory-locking.txt that you cited clearly states that it
applies to fcntl(2)/lockf(2) locking.

If you look into lf_advlock() you notice:

	if (lock->lf_flags & F_POSIX) {
		KASSERT(curproc == (struct proc *)ap->a_id);
	}
	lock->lf_id = ap->a_id;

I.e. for POSIX/fcntl(2) locking it the owner must be curproc.

Are you looking for sys_lockf?  That doesn't exist because
libc/gen/lockf.c is a thin wrapper around fcntl(2).

--chris


Home | Main Index | Thread Index | Old Index