]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfs_search.c
xnu-344.12.2.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_search.c
index 0c7638fbe86a4f05fdec7b2cf8d7e8e9b16da248..84aecbb016dd7c3090fc5a70172f15509f47fe63 100644 (file)
@@ -193,6 +193,8 @@ hfs_search( ap )
        CatalogRecord * myCurrentDataPtr;
        CatPosition * myCatPositionPtr;
        BTScanState myBTScanState;
+       void *user_start = NULL;
+       int   user_len;
 
        /* XXX Parameter check a_searchattrs? */
 
@@ -223,6 +225,20 @@ hfs_search( ap )
        MALLOC( attributesBuffer, void *, eachReturnBufferSize, M_TEMP, M_WAITOK );
        variableBuffer = (void*)((char*) attributesBuffer + fixedBlockSize);
 
+       // XXXdbg - have to lock the user's buffer so we don't fault
+       // while holding the shared catalog file lock.  see the comment
+       // in hfs_readdir() for more details.
+       //
+       if (VTOHFS(ap->a_vp)->jnl && ap->a_uio->uio_segflg == UIO_USERSPACE) {
+               user_start = ap->a_uio->uio_iov->iov_base;
+               user_len   = ap->a_uio->uio_iov->iov_len;
+
+               if ((err = vslock(user_start, user_len)) != 0) {
+                       user_start = NULL;
+                       goto ExitThisRoutine;
+               }
+       }
+
        /* Lock catalog b-tree */
        err = hfs_metafilelocking(VTOHFS(ap->a_vp), kHFSCatalogFileID, LK_SHARED, p);
        if (err)
@@ -383,6 +399,10 @@ QuickExit:
 ExitThisRoutine:
         FREE( attributesBuffer, M_TEMP );
 
+       if (VTOHFS(ap->a_vp)->jnl && user_start) {
+               vsunlock(user_start, user_len, TRUE);
+       }
+
        return (MacToVFSError(err));
 }
 
@@ -858,6 +878,14 @@ InsertMatch( struct vnode *root_vp, struct uio *a_uio, CatalogRecord *rec,
                goto exit;
        }
 
+       /* Hide the private journal files */
+       if (VTOHFS(root_vp)->jnl &&
+           ((c_attr.ca_fileid == VTOHFS(root_vp)->hfs_jnlfileid) ||
+            (c_attr.ca_fileid == VTOHFS(root_vp)->hfs_jnlinfoblkid))) {
+               err = 0;
+               goto exit;
+       }
+
        if (returnAttrList->commonattr & ATTR_CMN_NAME) {
                cat_convertkey(VTOHFS(root_vp), key, rec, &c_desc);
        } else {