}
result = cat_lookupbykey(hfsmp, keyp, 0, 0, outdescp, attrp, forkp, NULL);
+ if (!result && outdescp) {
+ cnid_t dcnid = outdescp->cd_cnid;
+ /*
+ * Just for sanity's sake, let's make sure that
+ * the key in the thread matches the key in the record.
+ */
+ if (cnid != dcnid) {
+ printf("Requested cnid (%d / 0x%08lx) != dcnid (%d / 0x%08lx)\n", cnid, cnid, dcnid, dcnid);
+ result = ENOENT;
+ }
+ }
+
exit:
FREE(recp, M_TEMP);
FREE(iterator, M_TEMP);
return (ENOENT);
fileID = GetEmbeddedFileID(descp->cd_nameptr, descp->cd_namelen, &prefixlen);
- if (fileID < kHFSFirstUserCatalogNodeID)
+
+ if (fileID < (cnid_t)kHFSFirstUserCatalogNodeID)
+ return (ENOENT);
+
+ if(fileID == hfsmp->hfs_privdir_desc.cd_cnid ||
+ fileID == hfsmp->hfs_jnlfileid ||
+ fileID == hfsmp->hfs_jnlinfoblkid) {
return (ENOENT);
+ }
result = cat_idlookup(hfsmp, fileID, outdescp, attrp, forkp);
if (result)
result = BTIterateRecords(fcb, op, iterator,
(IterateCallBackProcPtr)cat_packdirentry, &state);
+ /* If readdir is called for NFS and BTIterateRecords reaches the end of the
+ * Catalog BTree, call cat_packdirentry() with dummy values to copy previous
+ * direntry stored in state to the user buffer.
+ */
+ if (state.cbs_extended && (result == fsBTRecordNotFoundErr)) {
+ CatalogKey ckp;
+ CatalogRecord crp;
+
+ bzero(&ckp, sizeof(ckp));
+ bzero(&crp, sizeof(crp));
+
+ result = cat_packdirentry(&ckp, &crp, &state);
+ }
+
/* Note that state.cbs_index is still valid on errors */
*items = state.cbs_index - index;
index = state.cbs_index;