]> git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfs_search.c
xnu-792.24.17.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_search.c
1 /*
2 * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 *
22 * @(#)hfs_search.c
23 */
24
25 #include <sys/param.h>
26 #include <sys/systm.h>
27 #include <sys/kernel.h>
28 #include <sys/file.h>
29 #include <sys/proc.h>
30 #include <sys/conf.h>
31 #include <mach/machine/vm_types.h>
32 #include <sys/vnode.h>
33 #include <sys/malloc.h>
34 #include <sys/signalvar.h>
35 #include <sys/attr.h>
36 #include <sys/utfconv.h>
37 #include <sys/kauth.h>
38 #include <sys/vnode_internal.h>
39
40 #include "hfs.h"
41 #include "hfs_dbg.h"
42 #include "hfs_catalog.h"
43 #include "hfs_attrlist.h"
44 #include "hfs_endian.h"
45
46 #include "hfscommon/headers/FileMgrInternal.h"
47 #include "hfscommon/headers/HFSUnicodeWrappers.h"
48 #include "hfscommon/headers/BTreesPrivate.h"
49 #include "hfscommon/headers/BTreeScanner.h"
50 #include "hfscommon/headers/CatalogPrivate.h"
51
52 /* Search criterea. */
53 struct directoryInfoSpec
54 {
55 u_int32_t numFiles;
56 };
57
58 struct fileInfoSpec
59 {
60 off_t dataLogicalLength;
61 off_t dataPhysicalLength;
62 off_t resourceLogicalLength;
63 off_t resourcePhysicalLength;
64 };
65
66 struct searchinfospec
67 {
68 u_char name[kHFSPlusMaxFileNameBytes];
69 u_long nameLength;
70 char attributes; // see IM:Files 2-100
71 u_long nodeID;
72 u_long parentDirID;
73 struct timespec creationDate;
74 struct timespec modificationDate;
75 struct timespec changeDate;
76 struct timespec accessDate;
77 struct timespec lastBackupDate;
78 uint8_t finderInfo[32];
79 uid_t uid;
80 gid_t gid;
81 mode_t mask;
82 struct fileInfoSpec f;
83 struct directoryInfoSpec d;
84 };
85 typedef struct searchinfospec searchinfospec_t;
86
87 static void ResolveHardlink(ExtendedVCB *vcb, HFSPlusCatalogFile *recp);
88
89
90 static int UnpackSearchAttributeBlock(struct hfsmount *hfsmp, struct attrlist *alist,
91 searchinfospec_t *searchInfo, void *attributeBuffer);
92
93 static int CheckCriteria( ExtendedVCB *vcb,
94 u_long searchBits,
95 struct attrlist *attrList,
96 CatalogRecord *rec,
97 CatalogKey *key,
98 searchinfospec_t *searchInfo1,
99 searchinfospec_t *searchInfo2,
100 Boolean lookForDup );
101
102 static int CheckAccess(ExtendedVCB *vcb, u_long searchBits, CatalogKey *key, struct vfs_context *ctx);
103
104 static int InsertMatch(struct hfsmount *hfsmp, uio_t a_uio, CatalogRecord *rec,
105 CatalogKey *key, struct attrlist *returnAttrList,
106 void *attributesBuffer, void *variableBuffer,
107 u_long * nummatches );
108
109 static Boolean CompareRange(u_long val, u_long low, u_long high);
110 static Boolean CompareWideRange(u_int64_t val, u_int64_t low, u_int64_t high);
111
112 static Boolean CompareRange( u_long val, u_long low, u_long high )
113 {
114 return( (val >= low) && (val <= high) );
115 }
116
117 static Boolean CompareWideRange( u_int64_t val, u_int64_t low, u_int64_t high )
118 {
119 return( (val >= low) && (val <= high) );
120 }
121 //#define CompareRange(val, low, high) ((val >= low) && (val <= high))
122
123 #if 1 // Installer workaround (2940423)
124 static Boolean IsTargetName( searchinfospec_t * searchInfoPtr, Boolean isHFSPlus );
125 #endif // Installer workaround
126
127 __private_extern__ int hfs_vnop_search(struct vnop_searchfs_args *ap);
128
129
130 /************************************************************************/
131 /* Entry for searchfs() */
132 /************************************************************************/
133
134 #define errSearchBufferFull 101 /* Internal search errors */
135 /*
136 #
137 #% searchfs vp L L L
138 #
139 vnop_searchfs {
140 IN struct vnode *vp;
141 IN off_t length;
142 IN int flags;
143 IN kauth_cred_t cred;
144 IN struct proc *p;
145 };
146 */
147
148 __private_extern__
149 int
150 hfs_vnop_search(ap)
151 struct vnop_searchfs_args *ap; /*
152 struct vnodeop_desc *a_desc;
153 struct vnode *a_vp;
154 void *a_searchparams1;
155 void *a_searchparams2;
156 struct attrlist *a_searchattrs;
157 u_long a_maxmatches;
158 struct timeval *a_timelimit;
159 struct attrlist *a_returnattrs;
160 u_long *a_nummatches;
161 u_long a_scriptcode;
162 u_long a_options;
163 struct uio *a_uio;
164 struct searchstate *a_searchstate;
165 vfs_context_t a_context;
166 */
167 {
168 ExtendedVCB *vcb = VTOVCB(ap->a_vp);
169 struct hfsmount *hfsmp;
170 FCB * catalogFCB;
171 searchinfospec_t searchInfo1;
172 searchinfospec_t searchInfo2;
173 void *attributesBuffer;
174 void *variableBuffer;
175 u_long fixedBlockSize;
176 u_long eachReturnBufferSize;
177 struct proc *p = proc_self();
178 int err = E_NONE;
179 int isHFSPlus;
180 int timerExpired = false;
181 int doQuickExit = false;
182 CatalogKey * myCurrentKeyPtr;
183 CatalogRecord * myCurrentDataPtr;
184 CatPosition * myCatPositionPtr;
185 BTScanState myBTScanState;
186 user_addr_t user_start = 0;
187 user_size_t user_len = 0;
188 int32_t searchTime;
189 int lockflags;
190
191 /* XXX Parameter check a_searchattrs? */
192
193 *(ap->a_nummatches) = 0;
194
195 if (ap->a_options & ~SRCHFS_VALIDOPTIONSMASK)
196 return (EINVAL);
197
198 /* SRCHFS_SKIPLINKS requires root access.
199 * This option cannot be used with either
200 * the ATTR_CMN_NAME or ATTR_CMN_PAROBJID
201 * attributes.
202 */
203 if (ap->a_options & SRCHFS_SKIPLINKS) {
204 attrgroup_t attrs;
205
206 attrs = ap->a_searchattrs->commonattr | ap->a_returnattrs->commonattr;
207 if (attrs & (ATTR_CMN_NAME | ATTR_CMN_PAROBJID))
208 return (EINVAL);
209 if ((err = vfs_context_suser(ap->a_context)))
210 return (err);
211 }
212
213 if (uio_resid(ap->a_uio) <= 0)
214 return (EINVAL);
215
216 isHFSPlus = (vcb->vcbSigWord == kHFSPlusSigWord);
217 hfsmp = VTOHFS(ap->a_vp);
218
219 searchTime = kMaxMicroSecsInKernel;
220 if (ap->a_timelimit->tv_sec == 0 &&
221 ap->a_timelimit->tv_usec > 0 &&
222 ap->a_timelimit->tv_usec < kMaxMicroSecsInKernel) {
223 searchTime = ap->a_timelimit->tv_usec;
224 }
225
226 /* UnPack the search boundries, searchInfo1, searchInfo2 */
227 err = UnpackSearchAttributeBlock(hfsmp, ap->a_searchattrs,
228 &searchInfo1, ap->a_searchparams1);
229 if (err) return err;
230 err = UnpackSearchAttributeBlock(hfsmp, ap->a_searchattrs,
231 &searchInfo2, ap->a_searchparams2);
232 if (err) return err;
233
234 fixedBlockSize = sizeof(uint32_t) + hfs_attrblksize(ap->a_returnattrs); /* uint32_t for length word */
235
236 eachReturnBufferSize = fixedBlockSize;
237
238 if ( ap->a_returnattrs->commonattr & ATTR_CMN_NAME ) /* XXX should be more robust! */
239 eachReturnBufferSize += kHFSPlusMaxFileNameBytes + 1;
240
241 MALLOC( attributesBuffer, void *, eachReturnBufferSize, M_TEMP, M_WAITOK );
242 variableBuffer = (void*)((char*) attributesBuffer + fixedBlockSize);
243
244 // XXXdbg - have to lock the user's buffer so we don't fault
245 // while holding the shared catalog file lock. see the comment
246 // in hfs_readdir() for more details.
247 //
248 if (hfsmp->jnl && uio_isuserspace(ap->a_uio)) {
249 user_start = uio_curriovbase(ap->a_uio);
250 user_len = uio_curriovlen(ap->a_uio);
251
252 if ((err = vslock(user_start, user_len)) != 0) {
253 user_start = 0;
254 goto ExitThisRoutine;
255 }
256 }
257
258 lockflags = hfs_systemfile_lock(hfsmp, SFL_CATALOG, HFS_SHARED_LOCK);
259
260 catalogFCB = GetFileControlBlock(vcb->catalogRefNum);
261 myCurrentKeyPtr = NULL;
262 myCurrentDataPtr = NULL;
263 myCatPositionPtr = (CatPosition *)ap->a_searchstate;
264
265 if (ap->a_options & SRCHFS_START) {
266 /* Starting a new search. */
267 /* Make sure the on-disk Catalog file is current */
268 (void) hfs_fsync(vcb->catalogRefNum, MNT_WAIT, 0, p);
269 if (hfsmp->jnl) {
270 hfs_systemfile_unlock(hfsmp, lockflags);
271 journal_flush(hfsmp->jnl);
272 lockflags = hfs_systemfile_lock(hfsmp, SFL_CATALOG, HFS_SHARED_LOCK);
273 }
274
275 ap->a_options &= ~SRCHFS_START;
276 bzero( (caddr_t)myCatPositionPtr, sizeof( *myCatPositionPtr ) );
277 err = BTScanInitialize(catalogFCB, 0, 0, 0, kCatSearchBufferSize, &myBTScanState);
278
279 #if 1 // Installer workaround (2940423)
280 // hack to get around installer problems when the installer expects search results
281 // to be in key order. At this point the problem appears to be limited to
282 // searches for "Library". The idea here is to go get the "Library" at root
283 // and return it first to the caller then continue the search as normal with
284 // the exception of taking care not to return a duplicate hit (see CheckCriteria)
285 if ( err == E_NONE &&
286 (ap->a_searchattrs->commonattr & ATTR_CMN_NAME) != 0 &&
287 IsTargetName( &searchInfo1, isHFSPlus ) )
288 {
289 CatalogRecord rec;
290 BTreeIterator iterator;
291 FSBufferDescriptor btrec;
292 CatalogKey * keyp;
293 UInt16 reclen;
294 OSErr result;
295
296 bzero( (caddr_t)&iterator, sizeof( iterator ) );
297 keyp = (CatalogKey *) &iterator.key;
298 (void) BuildCatalogKeyUTF8(vcb, kRootDirID, "Library", kUndefinedStrLen, keyp, NULL);
299
300 btrec.bufferAddress = &rec;
301 btrec.itemCount = 1;
302 btrec.itemSize = sizeof( rec );
303
304 result = BTSearchRecord( catalogFCB, &iterator, &btrec, &reclen, &iterator );
305 if ( result == E_NONE ) {
306 // need to unlock since CheckAccess assumes no lock held
307 hfs_systemfile_unlock(hfsmp, lockflags);
308 if (CheckCriteria(vcb, ap->a_options, ap->a_searchattrs, &rec,
309 keyp, &searchInfo1, &searchInfo2, false) &&
310 CheckAccess(vcb, ap->a_options, keyp, ap->a_context)) {
311
312 result = InsertMatch(hfsmp, ap->a_uio, &rec,
313 keyp, ap->a_returnattrs,
314 attributesBuffer, variableBuffer,
315 ap->a_nummatches);
316 if (result == E_NONE && *(ap->a_nummatches) >= ap->a_maxmatches)
317 doQuickExit = true;
318 }
319 lockflags = hfs_systemfile_lock(hfsmp, SFL_CATALOG, HFS_SHARED_LOCK);
320 }
321 }
322 #endif // Installer workaround
323 } else {
324 /* Resuming a search. */
325 err = BTScanInitialize(catalogFCB, myCatPositionPtr->nextNode,
326 myCatPositionPtr->nextRecord,
327 myCatPositionPtr->recordsFound,
328 kCatSearchBufferSize,
329 &myBTScanState);
330 /* Make sure Catalog hasn't changed. */
331 if (err == 0
332 && myCatPositionPtr->writeCount != myBTScanState.btcb->writeCount) {
333 myCatPositionPtr->writeCount = myBTScanState.btcb->writeCount;
334 err = EBUSY; /* catChangedErr */
335 }
336 }
337 hfs_systemfile_unlock(hfsmp, lockflags);
338
339 if (err)
340 goto ExitThisRoutine;
341 #if 1 // Installer workaround (2940423)
342 if ( doQuickExit )
343 goto QuickExit;
344 #endif // Installer workaround
345
346 /*
347 * Check all the catalog btree records...
348 * return the attributes for matching items
349 */
350 for (;;) {
351 struct timeval myCurrentTime;
352 struct timeval myElapsedTime;
353
354 err = BTScanNextRecord(&myBTScanState, timerExpired,
355 (void **)&myCurrentKeyPtr, (void **)&myCurrentDataPtr,
356 NULL);
357 if (err)
358 break;
359
360 /* Resolve any hardlinks */
361 if (isHFSPlus && (ap->a_options & SRCHFS_SKIPLINKS) == 0) {
362 lockflags = hfs_systemfile_lock(hfsmp, SFL_CATALOG, HFS_SHARED_LOCK);
363 ResolveHardlink(vcb, (HFSPlusCatalogFile *) myCurrentDataPtr);
364 hfs_systemfile_unlock(hfsmp, lockflags);
365 }
366 if (CheckCriteria( vcb, ap->a_options, ap->a_searchattrs, myCurrentDataPtr,
367 myCurrentKeyPtr, &searchInfo1, &searchInfo2, true )
368 && CheckAccess(vcb, ap->a_options, myCurrentKeyPtr, ap->a_context)) {
369 err = InsertMatch(hfsmp, ap->a_uio, myCurrentDataPtr,
370 myCurrentKeyPtr, ap->a_returnattrs,
371 attributesBuffer, variableBuffer, ap->a_nummatches);
372 if (err) {
373 /*
374 * The last match didn't fit so come back
375 * to this record on the next trip.
376 */
377 --myBTScanState.recordsFound;
378 --myBTScanState.recordNum;
379 break;
380 }
381
382 if (*(ap->a_nummatches) >= ap->a_maxmatches)
383 break;
384 }
385
386 /*
387 * Check our elapsed time and bail if we've hit the max.
388 * The idea here is to throttle the amount of time we
389 * spend in the kernel.
390 */
391 microuptime(&myCurrentTime);
392 timersub(&myCurrentTime, &myBTScanState.startTime, &myElapsedTime);
393 /* Note: assumes kMaxMicroSecsInKernel is less than 1,000,000 */
394 if (myElapsedTime.tv_sec > 0
395 || myElapsedTime.tv_usec >= searchTime) {
396 timerExpired = true;
397 }
398 }
399
400 QuickExit:
401 /* Update catalog position */
402 myCatPositionPtr->writeCount = myBTScanState.btcb->writeCount;
403
404 BTScanTerminate(&myBTScanState, &myCatPositionPtr->nextNode,
405 &myCatPositionPtr->nextRecord,
406 &myCatPositionPtr->recordsFound);
407
408 if ( err == E_NONE ) {
409 err = EAGAIN; /* signal to the user to call searchfs again */
410 } else if ( err == errSearchBufferFull ) {
411 if ( *(ap->a_nummatches) > 0 )
412 err = EAGAIN;
413 else
414 err = ENOBUFS;
415 } else if ( err == btNotFound ) {
416 err = E_NONE; /* the entire disk has been searched */
417 } else if ( err == fsBTTimeOutErr ) {
418 err = EAGAIN;
419 }
420
421 ExitThisRoutine:
422 FREE( attributesBuffer, M_TEMP );
423
424 if (hfsmp->jnl && user_start) {
425 vsunlock(user_start, user_len, TRUE);
426 }
427
428 return (MacToVFSError(err));
429 }
430
431
432 static void
433 ResolveHardlink(ExtendedVCB *vcb, HFSPlusCatalogFile *recp)
434 {
435 if ((recp->recordType == kHFSPlusFileRecord)
436 && (SWAP_BE32(recp->userInfo.fdType) == kHardLinkFileType)
437 && (SWAP_BE32(recp->userInfo.fdCreator) == kHFSPlusCreator)
438 && ((to_bsd_time(recp->createDate) == vcb->vcbCrDate) ||
439 (to_bsd_time(recp->createDate) == VCBTOHFS(vcb)->hfs_metadata_createdate))) {
440 cnid_t saved_cnid;
441
442 /* Export link's cnid (a unique value) instead of inode's cnid */
443 saved_cnid = recp->fileID;
444 (void) resolvelink(VCBTOHFS(vcb), recp->bsdInfo.special.iNodeNum, recp);
445 recp->fileID = saved_cnid;
446 }
447 }
448
449
450 static Boolean
451 CompareMasked(const UInt32 *thisValue, const UInt32 *compareData,
452 const UInt32 *compareMask, UInt32 count)
453 {
454 Boolean matched;
455 UInt32 i;
456
457 matched = true; /* Assume it will all match */
458
459 for (i=0; i<count; i++) {
460 if (((*thisValue++ ^ *compareData++) & *compareMask++) != 0) {
461 matched = false;
462 break;
463 }
464 }
465
466 return matched;
467 }
468
469
470 static Boolean
471 ComparePartialUnicodeName (register ConstUniCharArrayPtr str, register ItemCount s_len,
472 register ConstUniCharArrayPtr find, register ItemCount f_len )
473 {
474 if (f_len == 0 || s_len == 0)
475 return FALSE;
476
477 do {
478 if (s_len-- < f_len)
479 return FALSE;
480 } while (FastUnicodeCompare(str++, f_len, find, f_len) != 0);
481
482 return TRUE;
483 }
484
485
486 static Boolean
487 ComparePartialPascalName ( register ConstStr31Param str, register ConstStr31Param find )
488 {
489 register u_char s_len = str[0];
490 register u_char f_len = find[0];
491 register u_char *tsp;
492 Str31 tmpstr;
493
494 if (f_len == 0 || s_len == 0)
495 return FALSE;
496
497 bcopy(str, tmpstr, s_len + 1);
498 tsp = &tmpstr[0];
499
500 while (s_len-- >= f_len) {
501 *tsp = f_len;
502
503 if (FastRelString(tsp++, find) == 0)
504 return TRUE;
505 }
506
507 return FALSE;
508 }
509
510
511 //
512 // Determine if a name is "inappropriate" where the definition
513 // of "inappropriate" is up to higher level execs. Currently
514 // that's limited to /System.
515 //
516 static int
517 is_inappropriate_name(char *name, int len)
518 {
519 const char *bad_names[] = { "System" };
520 int bad_len[] = { 6 };
521 int i;
522
523 for(i=0; i < (int) (sizeof(bad_names) / sizeof(bad_names[0])); i++) {
524 if (len == bad_len[i] && strcmp(name, bad_names[i]) == 0) {
525 return 1;
526 }
527 }
528
529 // if we get here, no name matched
530 return 0;
531 }
532
533
534
535 /*
536 * Check to see if caller has access rights to this item
537 */
538
539 static int
540 CheckAccess(ExtendedVCB *theVCBPtr, u_long searchBits, CatalogKey *theKeyPtr, struct vfs_context *ctx)
541 {
542 Boolean isHFSPlus;
543 int myErr;
544 int myResult;
545 HFSCatalogNodeID myNodeID;
546 hfsmount_t * hfsmp;
547 struct FndrDirInfo *finfop;
548 struct vnode * vp = NULL;
549
550 myResult = 0; /* default to "no access" */
551
552 if (!vfs_context_suser(ctx)) {
553 myResult = 1; /* allow access */
554 goto ExitThisRoutine; /* root always has access */
555 }
556
557 hfsmp = VCBTOHFS( theVCBPtr );
558 isHFSPlus = ( theVCBPtr->vcbSigWord == kHFSPlusSigWord );
559 if ( isHFSPlus )
560 myNodeID = theKeyPtr->hfsPlus.parentID;
561 else
562 myNodeID = theKeyPtr->hfs.parentID;
563
564 while ( myNodeID >= kRootDirID ) {
565 cnode_t * cp;
566
567 /* now go get catalog data for this directory */
568 myErr = hfs_vget(hfsmp, myNodeID, &vp, 0);
569 if ( myErr ) {
570 goto ExitThisRoutine; /* no access */
571 }
572
573 cp = VTOC(vp);
574 finfop = (struct FndrDirInfo *)&cp->c_attr.ca_finderinfo[0];
575
576 if ( searchBits & SRCHFS_SKIPPACKAGES ) {
577 if ( (SWAP_BE16(finfop->frFlags) & kHasBundle)
578 || (cp->c_desc.cd_nameptr != NULL
579 && is_package_name(cp->c_desc.cd_nameptr, cp->c_desc.cd_namelen)) ) {
580 myResult = 0;
581 goto ExitThisRoutine;
582 }
583 }
584
585 if ( searchBits & SRCHFS_SKIPINAPPROPRIATE ) {
586 if ( cp->c_parentcnid == kRootDirID && cp->c_desc.cd_nameptr != NULL &&
587 is_inappropriate_name(cp->c_desc.cd_nameptr, cp->c_desc.cd_namelen) ) {
588 myResult = 0;
589 goto ExitThisRoutine;
590 }
591 }
592
593 if ( (searchBits & SRCHFS_SKIPINVISIBLE) &&
594 (SWAP_BE16(finfop->frFlags) & kIsInvisible) ) {
595 myResult = 0;
596 goto ExitThisRoutine;
597 }
598
599 myNodeID = cp->c_parentcnid; /* move up the hierarchy */
600 hfs_unlock(VTOC(vp));
601 if (vp->v_type == VDIR) {
602 myErr = vnode_authorize(vp, NULL, (KAUTH_VNODE_SEARCH | KAUTH_VNODE_LIST_DIRECTORY), ctx);
603 } else {
604 myErr = vnode_authorize(vp, NULL, (KAUTH_VNODE_SEARCH), ctx);
605 }
606 vnode_put(vp);
607 vp = NULL;
608 if ( myErr ) {
609 goto ExitThisRoutine; /* no access */
610 }
611 }
612 myResult = 1; /* allow access */
613
614 ExitThisRoutine:
615 if ( vp != NULL ) {
616 hfs_unlock(VTOC(vp));
617 vnode_put(vp);
618 }
619 return ( myResult );
620
621 }
622
623 static int
624 CheckCriteria( ExtendedVCB *vcb,
625 u_long searchBits,
626 struct attrlist *attrList,
627 CatalogRecord *rec,
628 CatalogKey *key,
629 searchinfospec_t *searchInfo1,
630 searchinfospec_t *searchInfo2,
631 Boolean lookForDup )
632 {
633 Boolean matched, atleastone;
634 Boolean isHFSPlus;
635 attrgroup_t searchAttributes;
636 struct cat_attr c_attr;
637 struct cat_fork datafork;
638 struct cat_fork rsrcfork;
639
640 bzero(&c_attr, sizeof(c_attr));
641 isHFSPlus = (vcb->vcbSigWord == kHFSPlusSigWord);
642
643 switch (rec->recordType) {
644 case kHFSFolderRecord:
645 case kHFSPlusFolderRecord:
646 if ( (searchBits & SRCHFS_MATCHDIRS) == 0 ) { /* If we are NOT searching folders */
647 matched = false;
648 goto TestDone;
649 }
650 break;
651
652 case kHFSFileRecord:
653 if ( (searchBits & SRCHFS_MATCHFILES) == 0 ) { /* If we are NOT searching files */
654 matched = false;
655 goto TestDone;
656 }
657 break;
658
659 case kHFSPlusFileRecord:
660 /* Check if hardlink links should be skipped. */
661 if (searchBits & SRCHFS_SKIPLINKS) {
662 cnid_t parid = key->hfsPlus.parentID;
663 HFSPlusCatalogFile *filep = (HFSPlusCatalogFile *)rec;
664
665 if ((SWAP_BE32(filep->userInfo.fdType) == kHardLinkFileType) &&
666 (SWAP_BE32(filep->userInfo.fdCreator) == kHFSPlusCreator)) {
667 return (false); /* skip over link records */
668 } else if ((parid == VCBTOHFS(vcb)->hfs_privdir_desc.cd_cnid) &&
669 (filep->bsdInfo.special.linkCount == 0)) {
670 return (false); /* skip over unlinked files */
671 }
672 } else if (key->hfsPlus.parentID == VCBTOHFS(vcb)->hfs_privdir_desc.cd_cnid) {
673 return (false); /* skip over private files */
674 }
675
676 if ( (searchBits & SRCHFS_MATCHFILES) == 0 ) { /* If we are NOT searching files */
677 matched = false;
678 goto TestDone;
679 }
680 break;
681
682 default: /* Never match a thread record or any other type. */
683 return( false ); /* Not a file or folder record, so can't search it */
684 }
685
686 matched = true; /* Assume we got a match */
687 atleastone = false; /* Dont insert unless we match at least one criteria */
688
689 /* First, attempt to match the name -- either partial or complete */
690 if ( attrList->commonattr & ATTR_CMN_NAME ) {
691 if (isHFSPlus) {
692 /* Check for partial/full HFS Plus name match */
693
694 if ( searchBits & SRCHFS_MATCHPARTIALNAMES ) {
695 matched = ComparePartialUnicodeName(key->hfsPlus.nodeName.unicode,
696 key->hfsPlus.nodeName.length,
697 (UniChar*)searchInfo1->name,
698 searchInfo1->nameLength );
699 } else /* full HFS Plus name match */ {
700 matched = (FastUnicodeCompare(key->hfsPlus.nodeName.unicode,
701 key->hfsPlus.nodeName.length,
702 (UniChar*)searchInfo1->name,
703 searchInfo1->nameLength ) == 0);
704 }
705 } else {
706 /* Check for partial/full HFS name match */
707
708 if ( searchBits & SRCHFS_MATCHPARTIALNAMES )
709 matched = ComparePartialPascalName(key->hfs.nodeName, (u_char*)searchInfo1->name);
710 else /* full HFS name match */
711 matched = (FastRelString(key->hfs.nodeName, (u_char*)searchInfo1->name) == 0);
712 }
713
714 #if 1 // Installer workaround (2940423)
715 if ( lookForDup ) {
716 HFSCatalogNodeID parentID;
717 if (isHFSPlus)
718 parentID = key->hfsPlus.parentID;
719 else
720 parentID = key->hfs.parentID;
721
722 if ( matched && parentID == kRootDirID &&
723 IsTargetName( searchInfo1, isHFSPlus ) )
724 matched = false;
725 }
726 #endif // Installer workaround
727
728 if ( matched == false || (searchBits & ~SRCHFS_MATCHPARTIALNAMES) == 0 )
729 goto TestDone; /* no match, or nothing more to compare */
730
731 atleastone = true;
732 }
733
734 /* Convert catalog record into cat_attr format. */
735 cat_convertattr(VCBTOHFS(vcb), rec, &c_attr, &datafork, &rsrcfork);
736
737 if (searchBits & SRCHFS_SKIPINVISIBLE) {
738 int flags;
739
740 switch (rec->recordType) {
741 case kHFSFolderRecord:
742 case kHFSPlusFolderRecord: {
743 struct FndrDirInfo *finder_info;
744
745 finder_info = (struct FndrDirInfo *)&c_attr.ca_finderinfo[0];
746 flags = SWAP_BE16(finder_info->frFlags);
747 break;
748 }
749
750 case kHFSFileRecord:
751 case kHFSPlusFileRecord: {
752 struct FndrFileInfo *finder_info;
753
754 finder_info = (struct FndrFileInfo *)&c_attr.ca_finderinfo[0];
755 flags = SWAP_BE16(finder_info->fdFlags);
756 break;
757 }
758
759 default: {
760 flags = kIsInvisible;
761 break;
762 }
763 }
764
765 if (flags & kIsInvisible) {
766 matched = false;
767 goto TestDone;
768 }
769 }
770
771
772
773 /* Now that we have a record worth searching, see if it matches the search attributes */
774 if (rec->recordType == kHFSFileRecord ||
775 rec->recordType == kHFSPlusFileRecord) {
776 if ((attrList->fileattr & ~ATTR_FILE_VALIDMASK) != 0) { /* attr we do know about */
777 matched = false;
778 goto TestDone;
779 }
780 else if ((attrList->fileattr & ATTR_FILE_VALIDMASK) != 0) {
781 searchAttributes = attrList->fileattr;
782
783 /* File logical length (data fork) */
784 if ( searchAttributes & ATTR_FILE_DATALENGTH ) {
785 matched = CompareWideRange(
786 datafork.cf_size,
787 searchInfo1->f.dataLogicalLength,
788 searchInfo2->f.dataLogicalLength);
789 if (matched == false) goto TestDone;
790 atleastone = true;
791 }
792
793 /* File physical length (data fork) */
794 if ( searchAttributes & ATTR_FILE_DATAALLOCSIZE ) {
795 matched = CompareWideRange(
796 (u_int64_t)datafork.cf_blocks * (u_int64_t)vcb->blockSize,
797 searchInfo1->f.dataPhysicalLength,
798 searchInfo2->f.dataPhysicalLength);
799 if (matched == false) goto TestDone;
800 atleastone = true;
801 }
802
803 /* File logical length (resource fork) */
804 if ( searchAttributes & ATTR_FILE_RSRCLENGTH ) {
805 matched = CompareWideRange(
806 rsrcfork.cf_size,
807 searchInfo1->f.resourceLogicalLength,
808 searchInfo2->f.resourceLogicalLength);
809 if (matched == false) goto TestDone;
810 atleastone = true;
811 }
812
813 /* File physical length (resource fork) */
814 if ( searchAttributes & ATTR_FILE_RSRCALLOCSIZE ) {
815 matched = CompareWideRange(
816 (u_int64_t)rsrcfork.cf_blocks * (u_int64_t)vcb->blockSize,
817 searchInfo1->f.resourcePhysicalLength,
818 searchInfo2->f.resourcePhysicalLength);
819 if (matched == false) goto TestDone;
820 atleastone = true;
821 }
822 }
823 else {
824 atleastone = true; /* to match SRCHFS_MATCHFILES */
825 }
826 }
827 /*
828 * Check the directory attributes
829 */
830 else if (rec->recordType == kHFSFolderRecord ||
831 rec->recordType == kHFSPlusFolderRecord) {
832 if ((attrList->dirattr & ~ATTR_DIR_VALIDMASK) != 0) { /* attr we do know about */
833 matched = false;
834 goto TestDone;
835 }
836 else if ((attrList->dirattr & ATTR_DIR_VALIDMASK) != 0) {
837 searchAttributes = attrList->dirattr;
838
839 /* Directory valence */
840 if ( searchAttributes & ATTR_DIR_ENTRYCOUNT ) {
841 matched = CompareRange(c_attr.ca_entries,
842 searchInfo1->d.numFiles,
843 searchInfo2->d.numFiles );
844 if (matched == false) goto TestDone;
845 atleastone = true;
846 }
847 }
848 else {
849 atleastone = true; /* to match SRCHFS_MATCHDIRS */
850 }
851 }
852
853 /*
854 * Check the common attributes
855 */
856 searchAttributes = attrList->commonattr;
857 if ( (searchAttributes & ATTR_CMN_VALIDMASK) != 0 ) {
858 /* node ID */
859 if ( searchAttributes & ATTR_CMN_OBJID ) {
860 matched = CompareRange(c_attr.ca_fileid,
861 searchInfo1->nodeID,
862 searchInfo2->nodeID );
863 if (matched == false) goto TestDone;
864 atleastone = true;
865 }
866
867 /* Parent ID */
868 if ( searchAttributes & ATTR_CMN_PAROBJID ) {
869 HFSCatalogNodeID parentID;
870
871 if (isHFSPlus)
872 parentID = key->hfsPlus.parentID;
873 else
874 parentID = key->hfs.parentID;
875
876 matched = CompareRange(parentID, searchInfo1->parentDirID,
877 searchInfo2->parentDirID );
878 if (matched == false) goto TestDone;
879 atleastone = true;
880 }
881
882 /* Finder Info & Extended Finder Info where extFinderInfo is last 32 bytes */
883 if ( searchAttributes & ATTR_CMN_FNDRINFO ) {
884 UInt32 *thisValue;
885 thisValue = (UInt32 *) &c_attr.ca_finderinfo;
886
887 /*
888 * Note: ioFlFndrInfo and ioDrUsrWds have the same offset in search info, so
889 * no need to test the object type here.
890 */
891 matched = CompareMasked(thisValue,
892 (UInt32 *)&searchInfo1->finderInfo,
893 (UInt32 *) &searchInfo2->finderInfo, 8);
894 if (matched == false) goto TestDone;
895 atleastone = true;
896 }
897
898 /* Create date */
899 if ( searchAttributes & ATTR_CMN_CRTIME ) {
900 matched = CompareRange(c_attr.ca_itime,
901 searchInfo1->creationDate.tv_sec,
902 searchInfo2->creationDate.tv_sec);
903 if (matched == false) goto TestDone;
904 atleastone = true;
905 }
906
907 /* Mod date */
908 if ( searchAttributes & ATTR_CMN_MODTIME ) {
909 matched = CompareRange(c_attr.ca_mtime,
910 searchInfo1->modificationDate.tv_sec,
911 searchInfo2->modificationDate.tv_sec);
912 if (matched == false) goto TestDone;
913 atleastone = true;
914 }
915
916 /* Change Time */
917 if ( searchAttributes & ATTR_CMN_CHGTIME ) {
918 matched = CompareRange(c_attr.ca_ctime,
919 searchInfo1->changeDate.tv_sec,
920 searchInfo2->changeDate.tv_sec);
921 if (matched == false) goto TestDone;
922 atleastone = true;
923 }
924
925 /* Access date */
926 if ( searchAttributes & ATTR_CMN_ACCTIME ) {
927 matched = CompareRange(c_attr.ca_atime,
928 searchInfo1->accessDate.tv_sec,
929 searchInfo2->accessDate.tv_sec);
930 if (matched == false) goto TestDone;
931 atleastone = true;
932 }
933
934 /* Backup date */
935 if ( searchAttributes & ATTR_CMN_BKUPTIME ) {
936 matched = CompareRange(c_attr.ca_btime,
937 searchInfo1->lastBackupDate.tv_sec,
938 searchInfo2->lastBackupDate.tv_sec);
939 if (matched == false) goto TestDone;
940 atleastone = true;
941 }
942
943 /* User ID */
944 if ( searchAttributes & ATTR_CMN_OWNERID ) {
945 matched = CompareRange(c_attr.ca_uid,
946 searchInfo1->uid, searchInfo2->uid);
947 if (matched == false) goto TestDone;
948 atleastone = true;
949 }
950
951 /* Group ID */
952 if ( searchAttributes & ATTR_CMN_GRPID ) {
953 matched = CompareRange(c_attr.ca_gid,
954 searchInfo1->gid, searchInfo2->gid);
955 if (matched == false) goto TestDone;
956 atleastone = true;
957 }
958
959 /* mode */
960 if ( searchAttributes & ATTR_CMN_ACCESSMASK ) {
961 matched = CompareRange((uint32_t)c_attr.ca_mode,
962 (uint32_t)searchInfo1->mask,
963 (uint32_t)searchInfo2->mask);
964 if (matched == false) goto TestDone;
965 atleastone = true;
966 }
967 }
968
969 /* If we got here w/o matching any, then set to false */
970 if (! atleastone)
971 matched = false;
972
973 TestDone:
974 /*
975 * Finally, determine whether we need to negate the sense of the match
976 * (i.e. find all objects that DON'T match).
977 */
978 if ( searchBits & SRCHFS_NEGATEPARAMS )
979 matched = !matched;
980
981 return( matched );
982 }
983
984
985 /*
986 * Adds another record to the packed array for output
987 */
988 static int
989 InsertMatch(struct hfsmount *hfsmp, uio_t a_uio, CatalogRecord *rec,
990 CatalogKey *key, struct attrlist *returnAttrList,
991 void *attributesBuffer, void *variableBuffer, u_long * nummatches)
992 {
993 int err;
994 void *rovingAttributesBuffer;
995 void *rovingVariableBuffer;
996 u_long packedBufferSize;
997 u_long privateDir = hfsmp->hfs_privdir_desc.cd_cnid;
998 struct attrblock attrblk;
999 struct cat_desc c_desc;
1000 struct cat_attr c_attr;
1001 struct cat_fork datafork;
1002 struct cat_fork rsrcfork;
1003
1004 bzero(&c_desc, sizeof(c_desc));
1005 bzero(&c_attr, sizeof(c_attr));
1006 rovingAttributesBuffer = (char*)attributesBuffer + sizeof(u_long); /* Reserve space for length field */
1007 rovingVariableBuffer = variableBuffer;
1008
1009 /* Convert catalog record into cat_attr format. */
1010 cat_convertattr(hfsmp, rec, &c_attr, &datafork, &rsrcfork);
1011
1012 /* hide our private meta data directory */
1013 if ((privateDir != 0) && (c_attr.ca_fileid == privateDir)) {
1014 err = 0;
1015 goto exit;
1016 }
1017
1018 /* Hide the private journal files */
1019 if (hfsmp->jnl &&
1020 ((c_attr.ca_fileid == hfsmp->hfs_jnlfileid) ||
1021 (c_attr.ca_fileid == hfsmp->hfs_jnlinfoblkid))) {
1022 err = 0;
1023 goto exit;
1024 }
1025
1026 if (returnAttrList->commonattr & ATTR_CMN_NAME) {
1027 cat_convertkey(hfsmp, key, rec, &c_desc);
1028 } else {
1029 c_desc.cd_cnid = c_attr.ca_fileid;
1030 if (hfsmp->hfs_flags & HFS_STANDARD)
1031 c_desc.cd_parentcnid = key->hfs.parentID;
1032 else
1033 c_desc.cd_parentcnid = key->hfsPlus.parentID;
1034 }
1035
1036 attrblk.ab_attrlist = returnAttrList;
1037 attrblk.ab_attrbufpp = &rovingAttributesBuffer;
1038 attrblk.ab_varbufpp = &rovingVariableBuffer;
1039 attrblk.ab_flags = 0;
1040 attrblk.ab_blocksize = 0;
1041
1042 hfs_packattrblk(&attrblk, hfsmp, NULL, &c_desc, &c_attr, &datafork, &rsrcfork, current_proc());
1043
1044 packedBufferSize = (char*)rovingVariableBuffer - (char*)attributesBuffer;
1045
1046 if ( packedBufferSize > uio_resid(a_uio) )
1047 return( errSearchBufferFull );
1048
1049 (* nummatches)++;
1050
1051 *((u_long *)attributesBuffer) = packedBufferSize; /* Store length of fixed + var block */
1052
1053 err = uiomove( (caddr_t)attributesBuffer, packedBufferSize, a_uio ); /* XXX should be packedBufferSize */
1054 exit:
1055 cat_releasedesc(&c_desc);
1056
1057 return( err );
1058 }
1059
1060
1061 static int
1062 UnpackSearchAttributeBlock( struct hfsmount *hfsmp, struct attrlist *alist, searchinfospec_t *searchInfo, void *attributeBuffer )
1063 {
1064 attrgroup_t a;
1065 u_long bufferSize;
1066 boolean_t is_64_bit;
1067
1068 DBG_ASSERT(searchInfo != NULL);
1069
1070 is_64_bit = proc_is64bit(current_proc());
1071
1072 bufferSize = *((uint32_t *)attributeBuffer);
1073 if (bufferSize == 0)
1074 return (EINVAL); /* XXX -DJB is a buffer size of zero ever valid for searchfs? */
1075
1076 ++((uint32_t *)attributeBuffer); /* advance past the size */
1077
1078 /*
1079 * UnPack common attributes
1080 */
1081 a = alist->commonattr;
1082 if ( a != 0 ) {
1083 if ( a & ATTR_CMN_NAME ) {
1084 char *s;
1085 u_int32_t len;
1086
1087 s = (char*) attributeBuffer + ((attrreference_t *) attributeBuffer)->attr_dataoffset;
1088 len = ((attrreference_t *) attributeBuffer)->attr_length;
1089
1090 if (len > sizeof(searchInfo->name))
1091 return (EINVAL);
1092
1093 if (hfsmp->hfs_flags & HFS_STANDARD) {
1094 /* Convert name to pascal string to match HFS B-Tree names */
1095
1096 if (len > 0) {
1097 if (utf8_to_hfs(HFSTOVCB(hfsmp), len-1, s, (u_char*)searchInfo->name) != 0)
1098 return (EINVAL);
1099
1100 searchInfo->nameLength = searchInfo->name[0];
1101 } else {
1102 searchInfo->name[0] = searchInfo->nameLength = 0;
1103 }
1104 ++((attrreference_t *)attributeBuffer);
1105 } else {
1106 size_t ucslen;
1107 /* Convert name to Unicode to match HFS Plus B-Tree names */
1108
1109 if (len > 0) {
1110 if (utf8_decodestr(s, len-1, (UniChar*)searchInfo->name, &ucslen,
1111 sizeof(searchInfo->name), ':', UTF_DECOMPOSED))
1112 return (EINVAL);
1113
1114 searchInfo->nameLength = ucslen / sizeof(UniChar);
1115 } else {
1116 searchInfo->nameLength = 0;
1117 }
1118 ++((attrreference_t *)attributeBuffer);
1119 }
1120 }
1121 if ( a & ATTR_CMN_OBJID ) {
1122 searchInfo->nodeID = ((fsobj_id_t *) attributeBuffer)->fid_objno; /* ignore fid_generation */
1123 ++((fsobj_id_t *)attributeBuffer);
1124 }
1125 if ( a & ATTR_CMN_PAROBJID ) {
1126 searchInfo->parentDirID = ((fsobj_id_t *) attributeBuffer)->fid_objno; /* ignore fid_generation */
1127 ++((fsobj_id_t *)attributeBuffer);
1128 }
1129 if ( a & ATTR_CMN_CRTIME ) {
1130 if (is_64_bit) {
1131 struct user_timespec tmp;
1132 tmp = *((struct user_timespec *)attributeBuffer);
1133 searchInfo->creationDate.tv_sec = (time_t)tmp.tv_sec;
1134 searchInfo->creationDate.tv_nsec = tmp.tv_nsec;
1135 ++((struct user_timespec *)attributeBuffer);
1136 }
1137 else {
1138 searchInfo->creationDate = *((struct timespec *)attributeBuffer);
1139 ++((struct timespec *)attributeBuffer);
1140 }
1141 }
1142 if ( a & ATTR_CMN_MODTIME ) {
1143 if (is_64_bit) {
1144 struct user_timespec tmp;
1145 tmp = *((struct user_timespec *)attributeBuffer);
1146 searchInfo->modificationDate.tv_sec = (time_t)tmp.tv_sec;
1147 searchInfo->modificationDate.tv_nsec = tmp.tv_nsec;
1148 ++((struct user_timespec *)attributeBuffer);
1149 }
1150 else {
1151 searchInfo->modificationDate = *((struct timespec *)attributeBuffer);
1152 ++((struct timespec *)attributeBuffer);
1153 }
1154 }
1155 if ( a & ATTR_CMN_CHGTIME ) {
1156 if (is_64_bit) {
1157 struct user_timespec tmp;
1158 tmp = *((struct user_timespec *)attributeBuffer);
1159 searchInfo->changeDate.tv_sec = (time_t)tmp.tv_sec;
1160 searchInfo->changeDate.tv_nsec = tmp.tv_nsec;
1161 ++((struct user_timespec *)attributeBuffer);
1162 }
1163 else {
1164 searchInfo->changeDate = *((struct timespec *)attributeBuffer);
1165 ++((struct timespec *)attributeBuffer);
1166 }
1167 }
1168 if ( a & ATTR_CMN_ACCTIME ) {
1169 if (is_64_bit) {
1170 struct user_timespec tmp;
1171 tmp = *((struct user_timespec *)attributeBuffer);
1172 searchInfo->accessDate.tv_sec = (time_t)tmp.tv_sec;
1173 searchInfo->accessDate.tv_nsec = tmp.tv_nsec;
1174 ++((struct user_timespec *)attributeBuffer);
1175 }
1176 else {
1177 searchInfo->accessDate = *((struct timespec *)attributeBuffer);
1178 ++((struct timespec *)attributeBuffer);
1179 }
1180 }
1181 if ( a & ATTR_CMN_BKUPTIME ) {
1182 if (is_64_bit) {
1183 struct user_timespec tmp;
1184 tmp = *((struct user_timespec *)attributeBuffer);
1185 searchInfo->lastBackupDate.tv_sec = (time_t)tmp.tv_sec;
1186 searchInfo->lastBackupDate.tv_nsec = tmp.tv_nsec;
1187 ++((struct user_timespec *)attributeBuffer);
1188 }
1189 else {
1190 searchInfo->lastBackupDate = *((struct timespec *)attributeBuffer);
1191 ++((struct timespec *)attributeBuffer);
1192 }
1193 }
1194 if ( a & ATTR_CMN_FNDRINFO ) {
1195 bcopy( attributeBuffer, searchInfo->finderInfo, sizeof(searchInfo->finderInfo) );
1196 (uint8_t *)attributeBuffer += 32;
1197 }
1198 if ( a & ATTR_CMN_OWNERID ) {
1199 searchInfo->uid = *((uid_t *)attributeBuffer);
1200 ++((uid_t *)attributeBuffer);
1201 }
1202 if ( a & ATTR_CMN_GRPID ) {
1203 searchInfo->gid = *((gid_t *)attributeBuffer);
1204 ++((gid_t *)attributeBuffer);
1205 }
1206 if ( a & ATTR_CMN_ACCESSMASK ) {
1207 searchInfo->mask = *((mode_t *)attributeBuffer);
1208 ++((mode_t *)attributeBuffer);
1209 }
1210 }
1211
1212 a = alist->dirattr;
1213 if ( a != 0 ) {
1214 if ( a & ATTR_DIR_ENTRYCOUNT ) {
1215 searchInfo->d.numFiles = *((u_int32_t *)attributeBuffer);
1216 ++((u_int32_t *)attributeBuffer);
1217 }
1218 }
1219
1220 a = alist->fileattr;
1221 if ( a != 0 ) {
1222 if ( a & ATTR_FILE_DATALENGTH ) {
1223 searchInfo->f.dataLogicalLength = *((off_t *)attributeBuffer);
1224 ++((off_t *)attributeBuffer);
1225 }
1226 if ( a & ATTR_FILE_DATAALLOCSIZE ) {
1227 searchInfo->f.dataPhysicalLength = *((off_t *)attributeBuffer);
1228 ++((off_t *)attributeBuffer);
1229 }
1230 if ( a & ATTR_FILE_RSRCLENGTH ) {
1231 searchInfo->f.resourceLogicalLength = *((off_t *)attributeBuffer);
1232 ++((off_t *)attributeBuffer);
1233 }
1234 if ( a & ATTR_FILE_RSRCALLOCSIZE ) {
1235 searchInfo->f.resourcePhysicalLength = *((off_t *)attributeBuffer);
1236 ++((off_t *)attributeBuffer);
1237 }
1238 }
1239
1240 return (0);
1241 }
1242
1243
1244 #if 1 // Installer workaround (2940423)
1245 /* this routine was added as part of the work around where some installers would fail */
1246 /* because they incorrectly assumed search results were in some kind of order. */
1247 /* This routine is used to indentify the problematic target. At this point we */
1248 /* only know of one. This routine could be modified for more (I hope not). */
1249 static Boolean IsTargetName( searchinfospec_t * searchInfoPtr, Boolean isHFSPlus )
1250 {
1251 if ( searchInfoPtr->name == NULL )
1252 return( false );
1253
1254 if (isHFSPlus) {
1255 HFSUniStr255 myName = {
1256 7, /* number of unicode characters */
1257 {
1258 'L','i','b','r','a','r','y'
1259 }
1260 };
1261 if ( FastUnicodeCompare( myName.unicode, myName.length,
1262 (UniChar*)searchInfoPtr->name,
1263 searchInfoPtr->nameLength ) == 0 ) {
1264 return( true );
1265 }
1266
1267 } else {
1268 u_char myName[32] = {
1269 0x07,'L','i','b','r','a','r','y'
1270 };
1271 if ( FastRelString(myName, (u_char*)searchInfoPtr->name) == 0 ) {
1272 return( true );
1273 }
1274 }
1275 return( false );
1276
1277 } /* IsTargetName */
1278 #endif // Installer workaround
1279