[6764] in Athena Bugs

home help back first fref pref prev next nref lref last post

kernel: sys/vfs_vnode.c:vn_rename()

daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Tue Jan 1 21:27:15 1991

To: bugs@ATHENA.MIT.EDU
Date: Tue, 01 Jan 91 21:27:03 EST
From: John Carr <jfc@ATHENA.MIT.EDU>


vn_rename() contains this code

	error = lookuppn(&fpn, NO_FOLLOW, &fdvp, &fvp);
	if (error)
		goto out;
	/*        
	 * make sure there is an entry
	 */
	if (fvp == (struct vnode *)0) {
		/*
		 * If parent vnode does not allow search, return
		 * access error.
		 */
		if (error = VOP_ACCESS(fdvp, VEXEC, u.u_cred) == 0)
			error = ENOENT;
		goto out;
	}

There are 3 problems with this code.

	1. If lookuppn() sets fvp to NULL, then it returns a non-zero
	error status, so the test of fvp is redundant.

	2. If fvp is 0, ENOENT would be the correct error return always;
	there is no need for the VOP_ACCESS call.

	3. The test

		if (error = VOP_ACCESS(fdvp, VEXEC, u.u_cred) == 0)

	is missing a set of parentheses.  It parses 

		if (error = (VOP_ACCESS(fdvp, VEXEC, u.u_cred) == 0))

	but what is meant is

		if ((error = VOP_ACCESS(fdvp, VEXEC, u.u_cred)) == 0)


I think the entire block of code beginning

	if (fvp == (struct vnode *)0) {

should be deleted.  probe thinks the VOP_ACCESS call should be deleted
and ENOENT always returned (this is what 4.3 tahoe does).  Maybe we
should ask Berkeley if the test for fvp == 0 is really needed.


home help back first fref pref prev next nref lref last post