PERFORCE change 144941 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Wed Jul 9 12:49:12 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=144941
Change 144941 by trasz at trasz_traszkan on 2008/07/09 12:48:43
Properly handle the case when we are renaming one {file,directory}
over another.
Affected files ...
.. //depot/projects/soc2008/trasz_nfs4acl/sys/ufs/ufs/ufs_lookup.c#4 edit
Differences ...
==== //depot/projects/soc2008/trasz_nfs4acl/sys/ufs/ufs/ufs_lookup.c#4 (text+ko) ====
@@ -542,7 +542,13 @@
* regular file, or empty directory.
*/
if (nameiop == RENAME && (flags & ISLASTCN)) {
- if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)))
+ if (flags & WILLBEDIR)
+ error = VOP_GRANULAR(vdp, VWRITE, ACL_APPEND_DATA,
+ cred, cnp->cn_thread);
+ else
+ error = VOP_GRANULAR(vdp, VWRITE, ACL_WRITE_DATA,
+ cred, cnp->cn_thread);
+ if (error)
return (error);
/*
* Careful about locking second inode.
@@ -553,6 +559,27 @@
if ((error = VFS_VGET(vdp->v_mount, ino,
LK_EXCLUSIVE, &tdp)) != 0)
return (error);
+
+ /*
+ * The only purpose of this check is to return the correct
+ * error. Assume that we want to rename directory "a"
+ * to a file "b", and that we have no ACL_WRITE_DATA on
+ * a containing directory, but we _do_ have ACL_APPEND_DATA.
+ * In that case, the VOP_GRANULAR check above will return 0,
+ * and the operation will fail with ENOTDIR instead
+ * of EACCESS.
+ */
+ if (tdp->v_type == VDIR)
+ error = VOP_GRANULAR(vdp, VWRITE, ACL_APPEND_DATA,
+ cred, cnp->cn_thread);
+ else
+ error = VOP_GRANULAR(vdp, VWRITE, ACL_WRITE_DATA,
+ cred, cnp->cn_thread);
+ if (error) {
+ vput(tdp);
+ return (error);
+ }
+
*vpp = tdp;
cnp->cn_flags |= SAVENAME;
return (0);
More information about the p4-projects
mailing list