socsvn commit: r239110 - soc2012/oleksandr/udf-head/sys/fs/udf2
oleksandr at FreeBSD.org
oleksandr at FreeBSD.org
Sun Jul 8 10:55:26 UTC 2012
Author: oleksandr
Date: Sun Jul 8 10:55:22 2012
New Revision: 239110
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239110
Log:
Add some debug printf and comments and check permissions
Modified:
soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c
Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c
==============================================================================
--- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Sun Jul 8 09:55:00 2012 (r239109)
+++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Sun Jul 8 10:55:22 2012 (r239110)
@@ -252,7 +252,7 @@
error = uiomove(bp->b_data + on, n, uio);
brelse(bp);
- } while (error == 0 && uio->uio_resid > 0 && n != 0)
+ } while (error == 0 && uio->uio_resid > 0 && n != 0);
#if 0
/* note access time unless not requested */
if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) {
@@ -761,26 +761,48 @@
ump = dir_node->ump;
*vpp = NULL;
+ DPRINTF(LOOKUP, ("udf_cachedlookup callen\n"));
+
/* simplify/clarification flags */
nameiop = cnp->cn_nameiop;
islastcn = cnp->cn_flags & ISLASTCN;
mounted_ro = dvp->v_mount->mnt_flag & MNT_RDONLY;
+ /* check exec/dirread permissions first */
+ error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, curthread);
+ if (error)
+ return (error);
+
+ DPRINTF(LOOKUP, ("\taccess ok\n"));
+
/*
* If requesting a modify on the last path element on a read-only
- * filingsystem, reject lookup; XXX why is this repeated in every FS ?
+ * filingsystem, reject lookup.
*/
if (islastcn && mounted_ro && (nameiop == DELETE || nameiop == RENAME))
return (EROFS);
+ DPRINTF(LOOKUP, ("\tlooking up cnp->cn_nameptr '%s'\n", cnp->cn_nameptr));
+
+ /* look in the namei cache; return 0 on success!! */
+#if 0
+ error = cache_lookup(dvp, vpp, cnp);
+ if (error >= 0)
+ return error;
+
+ DPRINTF(LOOKUP, ("\tNOT found in cache\n"));
+#endif
/* get directory filesize */
if (dir_node->fe)
file_size = le64toh(dir_node->fe->inf_len);
else
file_size = le64toh(dir_node->efe->inf_len);
- /*
- *
+ /*
+ * If this is a LOOKUP and we've already partially searched through
+ * the directory, pick up where we left off and flag that the
+ * directory may need to be searched twice. For a full description,
+ * see /sys/fs/cd9660/cd9660_lookup.c:cd9660_lookup()
*/
if (nameiop != LOOKUP || dir_node->diroff == 0 || dir_node->diroff > file_size) {
offset = 0;
@@ -833,7 +855,11 @@
if (error)
goto exit;
+ /* Did we have a match? */
if (id) {
+ /*
+ * Remember where this entry was if it's the final component.
+ */
if ((cnp->cn_flags & ISLASTCN) && cnp->cn_nameiop == LOOKUP)
dir_node->diroff = offset;
if (numpasses == 2)
@@ -843,13 +869,16 @@
vn_vget_ino(dvp, id, cnp->cn_lkflags, &tdp);
}
else if (dir_node->hash_id == id) {
- /* through a glass darkly... */
- VREF(dvp);
+ VREF(dvp); /* we want ourself, ie "." */
+ /*
+ * When we lookup "." we still can be asked to lock it
+ * differently.
+ */
ltype = cnp->cn_lkflags & LK_TYPE_MASK;
if (ltype != VOP_ISLOCKED(dvp)) {
if (ltype == LK_EXCLUSIVE)
vn_lock(dvp, LK_UPGRADE | LK_RETRY);
- else
+ else /* if (ltype == LK_SHARED) */
vn_lock(dvp, LK_DOWNGRADE | LK_RETRY);
}
tdp = dvp;
@@ -860,16 +889,19 @@
if (!error) {
*vpp = tdp;
+ /* Put this entry in the cache */
if (cnp->cn_flags & MAKEENTRY)
cache_enter(dvp, *vpp, cnp);
}
}
else {
+ /* Name wasn't found on this pass. Do another pass? */
if (numpasses-- == 2) {
offset = 0;
goto lookuploop;
}
+ /* Enter name into cache as non-existant */
if (cnp->cn_flags & MAKEENTRY)
cache_enter(dvp, *vpp, cnp);
@@ -883,18 +915,10 @@
exit:
free(fid, M_UDFTEMP);
free(unix_name, M_UDFTEMP);
+
+ DPRINTFIF(LOOKUP, error, ("udf_cachedlookup returning error %d\n", error));
return (error);
-#if 0
- not sure if anything like this would be needed.
- if ((cnp->cn_namelen == 1) && (cnp->cn_nameptr[0] == '.')) {
- DPRINTF(LOOKUP, ("\tlookup '.'\n"));
- /* special case 1 '.' */
- vref(dvp);
- *vpp = dvp;
- /* done */
- }
-#endif
}
/* --------------------------------------------------------------------- */
More information about the svn-soc-all
mailing list