Subject: Re: access(2) error returns: ETXTBSY vs. read-only
To: Ignatios Souvatzis <ignatios@cs.uni-bonn.de>
From: Jaromir Dolecek <dolecek@ics.muni.cz>
List: tech-kern
Date: 06/16/1999 17:58:10
Ignatios Souvatzis wrote:
> As far as I can tell, this is caused by these lines in
> vfs_syscalls.c::sys_access()
> 
> 1543               if ((flags & VWRITE) == 0 || (error = vn_writechk(vp)) == 0)
> 1544                       error = VOP_ACCESS(vp, flags, cred, p);
> 
> Therefore, I'm wondering if reversing the tests like this:
> 
> 1543               if ((flags & VWRITE) == 0 ||
> 1544                   (error = VOP_ACCESS(vp, flags, cred, p)) == 0)
> 1545                       error = vn_writechk(vp);
> 

Your code mistakely doesn't call VOP_ACCESS() when (flags & VWRITE) ==
0).

The code shoould be IMHO like:
	error = VOP_ACCESS(vp, flags, cred, p);
	if (!error && (flags & VWRITE))
		error = vn_writechk(vp);

Jaromir