X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/143cc14e17b26a90f1f4060725df7ea635161581..b4c24cb9d3df001f2892dc4ed451bc769ff28a9f:/bsd/hfs/hfs_search.c diff --git a/bsd/hfs/hfs_search.c b/bsd/hfs/hfs_search.c index 0c7638fbe..84aecbb01 100644 --- a/bsd/hfs/hfs_search.c +++ b/bsd/hfs/hfs_search.c @@ -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 {