]> git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfs_search.c
xnu-792.6.70.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 proc *p);
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 = suser(kauth_cred_get(), 0)))
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, p)) {
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, p)) {
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 proc *theProcPtr)
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 struct vfs_context my_context;
550
551 myResult = 0; /* default to "no access" */
552 my_context.vc_proc = theProcPtr;
553 my_context.vc_ucred = kauth_cred_get();
554
555 if (!proc_suser(theProcPtr)) {
556 myResult = 1; /* allow access */
557 goto ExitThisRoutine; /* root always has access */
558 }
559
560 hfsmp = VCBTOHFS( theVCBPtr );
561 isHFSPlus = ( theVCBPtr->vcbSigWord == kHFSPlusSigWord );
562 if ( isHFSPlus )
563 myNodeID = theKeyPtr->hfsPlus.parentID;
564 else
565 myNodeID = theKeyPtr->hfs.parentID;
566
567 while ( myNodeID >= kRootDirID ) {
568 cnode_t * cp;
569
570 /* now go get catalog data for this directory */
571 myErr = hfs_vget(hfsmp, myNodeID, &vp, 0);
572 if ( myErr ) {
573 goto ExitThisRoutine; /* no access */
574 }
575
576 cp = VTOC(vp);
577 finfop = (struct FndrDirInfo *)&cp->c_attr.ca_finderinfo[0];
578
579 if ( searchBits & SRCHFS_SKIPPACKAGES ) {
580 if ( (SWAP_BE16(finfop->frFlags) & kHasBundle)
581 || (cp->c_desc.cd_nameptr != NULL
582 && is_package_name(cp->c_desc.cd_nameptr, cp->c_desc.cd_namelen)) ) {
583 myResult = 0;
584 goto ExitThisRoutine;
585 }
586 }
587
588 if ( searchBits & SRCHFS_SKIPINAPPROPRIATE ) {
589 if ( cp->c_parentcnid == kRootDirID && cp->c_desc.cd_nameptr != NULL &&
590 is_inappropriate_name(cp->c_desc.cd_nameptr, cp->c_desc.cd_namelen) ) {
591 myResult = 0;
592 goto ExitThisRoutine;
593 }
594 }
595
596 if ( (searchBits & SRCHFS_SKIPINVISIBLE) &&
597 (SWAP_BE16(finfop->frFlags) & kIsInvisible) ) {
598 myResult = 0;
599 goto ExitThisRoutine;
600 }
601
602 myNodeID = cp->c_parentcnid; /* move up the hierarchy */
603 hfs_unlock(VTOC(vp));
604 if (vp->v_type == VDIR) {
605 myErr = vnode_authorize(vp, NULL, (KAUTH_VNODE_SEARCH | KAUTH_VNODE_LIST_DIRECTORY), &my_context);
606 } else {
607 myErr = vnode_authorize(vp, NULL, (KAUTH_VNODE_SEARCH), &my_context);
608 }
609 vnode_put(vp);
610 vp = NULL;
611 if ( myErr ) {
612 goto ExitThisRoutine; /* no access */
613 }
614 }
615 myResult = 1; /* allow access */
616
617 ExitThisRoutine:
618 if ( vp != NULL ) {
619 hfs_unlock(VTOC(vp));
620 vnode_put(vp);
621 }
622 return ( myResult );
623
624 }
625
626 static int
627 CheckCriteria( ExtendedVCB *vcb,
628 u_long searchBits,
629 struct attrlist *attrList,
630 CatalogRecord *rec,
631 CatalogKey *key,
632 searchinfospec_t *searchInfo1,
633 searchinfospec_t *searchInfo2,
634 Boolean lookForDup )
635 {
636 Boolean matched, atleastone;
637 Boolean isHFSPlus;
638 attrgroup_t searchAttributes;
639 struct cat_attr c_attr;
640 struct cat_fork datafork;
641 struct cat_fork rsrcfork;
642
643 bzero(&c_attr, sizeof(c_attr));
644 isHFSPlus = (vcb->vcbSigWord == kHFSPlusSigWord);
645
646 switch (rec->recordType) {
647 case kHFSFolderRecord:
648 case kHFSPlusFolderRecord:
649 if ( (searchBits & SRCHFS_MATCHDIRS) == 0 ) { /* If we are NOT searching folders */
650 matched = false;
651 goto TestDone;
652 }
653 break;
654
655 case kHFSFileRecord:
656 if ( (searchBits & SRCHFS_MATCHFILES) == 0 ) { /* If we are NOT searching files */
657 matched = false;
658 goto TestDone;
659 }
660 break;
661
662 case kHFSPlusFileRecord:
663 /* Check if hardlink links should be skipped. */
664 if (searchBits & SRCHFS_SKIPLINKS) {
665 cnid_t parid = key->hfsPlus.parentID;
666 HFSPlusCatalogFile *filep = (HFSPlusCatalogFile *)rec;
667
668 if ((SWAP_BE32(filep->userInfo.fdType) == kHardLinkFileType) &&
669 (SWAP_BE32(filep->userInfo.fdCreator) == kHFSPlusCreator)) {
670 return (false); /* skip over link records */
671 } else if ((parid == VCBTOHFS(vcb)->hfs_privdir_desc.cd_cnid) &&
672 (filep->bsdInfo.special.linkCount == 0)) {
673 return (false); /* skip over unlinked files */
674 }
675 } else if (key->hfsPlus.parentID == VCBTOHFS(vcb)->hfs_privdir_desc.cd_cnid) {
676 return (false); /* skip over private files */
677 }
678
679 if ( (searchBits & SRCHFS_MATCHFILES) == 0 ) { /* If we are NOT searching files */
680 matched = false;
681 goto TestDone;
682 }
683 break;
684
685 default: /* Never match a thread record or any other type. */
686 return( false ); /* Not a file or folder record, so can't search it */
687 }
688
689 matched = true; /* Assume we got a match */
690 atleastone = false; /* Dont insert unless we match at least one criteria */
691
692 /* First, attempt to match the name -- either partial or complete */
693 if ( attrList->commonattr & ATTR_CMN_NAME ) {
694 if (isHFSPlus) {
695 /* Check for partial/full HFS Plus name match */
696
697 if ( searchBits & SRCHFS_MATCHPARTIALNAMES ) {
698 matched = ComparePartialUnicodeName(key->hfsPlus.nodeName.unicode,
699 key->hfsPlus.nodeName.length,
700 (UniChar*)searchInfo1->name,
701 searchInfo1->nameLength );
702 } else /* full HFS Plus name match */ {
703 matched = (FastUnicodeCompare(key->hfsPlus.nodeName.unicode,
704 key->hfsPlus.nodeName.length,
705 (UniChar*)searchInfo1->name,
706 searchInfo1->nameLength ) == 0);
707 }
708 } else {
709 /* Check for partial/full HFS name match */
710
711 if ( searchBits & SRCHFS_MATCHPARTIALNAMES )
712 matched = ComparePartialPascalName(key->hfs.nodeName, (u_char*)searchInfo1->name);
713 else /* full HFS name match */
714 matched = (FastRelString(key->hfs.nodeName, (u_char*)searchInfo1->name) == 0);
715 }
716
717 #if 1 // Installer workaround (2940423)
718 if ( lookForDup ) {
719 HFSCatalogNodeID parentID;
720 if (isHFSPlus)
721 parentID = key->hfsPlus.parentID;
722 else
723 parentID = key->hfs.parentID;
724
725 if ( matched && parentID == kRootDirID &&
726 IsTargetName( searchInfo1, isHFSPlus ) )
727 matched = false;
728 }
729 #endif // Installer workaround
730
731 if ( matched == false || (searchBits & ~SRCHFS_MATCHPARTIALNAMES) == 0 )
732 goto TestDone; /* no match, or nothing more to compare */
733
734 atleastone = true;
735 }
736
737 /* Convert catalog record into cat_attr format. */
738 cat_convertattr(VCBTOHFS(vcb), rec, &c_attr, &datafork, &rsrcfork);
739
740 if (searchBits & SRCHFS_SKIPINVISIBLE) {
741 int flags;
742
743 switch (rec->recordType) {
744 case kHFSFolderRecord:
745 case kHFSPlusFolderRecord: {
746 struct FndrDirInfo *finder_info;
747
748 finder_info = (struct FndrDirInfo *)&c_attr.ca_finderinfo[0];
749 flags = SWAP_BE16(finder_info->frFlags);
750 break;
751 }
752
753 case kHFSFileRecord:
754 case kHFSPlusFileRecord: {
755 struct FndrFileInfo *finder_info;
756
757 finder_info = (struct FndrFileInfo *)&c_attr.ca_finderinfo[0];
758 flags = SWAP_BE16(finder_info->fdFlags);
759 break;
760 }
761
762 default: {
763 flags = kIsInvisible;
764 break;
765 }
766 }
767
768 if (flags & kIsInvisible) {
769 matched = false;
770 goto TestDone;
771 }
772 }
773
774
775
776 /* Now that we have a record worth searching, see if it matches the search attributes */
777 if (rec->recordType == kHFSFileRecord ||
778 rec->recordType == kHFSPlusFileRecord) {
779 if ((attrList->fileattr & ~ATTR_FILE_VALIDMASK) != 0) { /* attr we do know about */
780 matched = false;
781 goto TestDone;
782 }
783 else if ((attrList->fileattr & ATTR_FILE_VALIDMASK) != 0) {
784 searchAttributes = attrList->fileattr;
785
786 /* File logical length (data fork) */
787 if ( searchAttributes & ATTR_FILE_DATALENGTH ) {
788 matched = CompareWideRange(
789 datafork.cf_size,
790 searchInfo1->f.dataLogicalLength,
791 searchInfo2->f.dataLogicalLength);
792 if (matched == false) goto TestDone;
793 atleastone = true;
794 }
795
796 /* File physical length (data fork) */
797 if ( searchAttributes & ATTR_FILE_DATAALLOCSIZE ) {
798 matched = CompareWideRange(
799 (u_int64_t)datafork.cf_blocks * (u_int64_t)vcb->blockSize,
800 searchInfo1->f.dataPhysicalLength,
801 searchInfo2->f.dataPhysicalLength);
802 if (matched == false) goto TestDone;
803 atleastone = true;
804 }
805
806 /* File logical length (resource fork) */
807 if ( searchAttributes & ATTR_FILE_RSRCLENGTH ) {
808 matched = CompareWideRange(
809 rsrcfork.cf_size,
810 searchInfo1->f.resourceLogicalLength,
811 searchInfo2->f.resourceLogicalLength);
812 if (matched == false) goto TestDone;
813 atleastone = true;
814 }
815
816 /* File physical length (resource fork) */
817 if ( searchAttributes & ATTR_FILE_RSRCALLOCSIZE ) {
818 matched = CompareWideRange(
819 (u_int64_t)rsrcfork.cf_blocks * (u_int64_t)vcb->blockSize,
820 searchInfo1->f.resourcePhysicalLength,
821 searchInfo2->f.resourcePhysicalLength);
822 if (matched == false) goto TestDone;
823 atleastone = true;
824 }
825 }
826 else {
827 atleastone = true; /* to match SRCHFS_MATCHFILES */
828 }
829 }
830 /*
831 * Check the directory attributes
832 */
833 else if (rec->recordType == kHFSFolderRecord ||
834 rec->recordType == kHFSPlusFolderRecord) {
835 if ((attrList->dirattr & ~ATTR_DIR_VALIDMASK) != 0) { /* attr we do know about */
836 matched = false;
837 goto TestDone;
838 }
839 else if ((attrList->dirattr & ATTR_DIR_VALIDMASK) != 0) {
840 searchAttributes = attrList->dirattr;
841
842 /* Directory valence */
843 if ( searchAttributes & ATTR_DIR_ENTRYCOUNT ) {
844 matched = CompareRange(c_attr.ca_entries,
845 searchInfo1->d.numFiles,
846 searchInfo2->d.numFiles );
847 if (matched == false) goto TestDone;
848 atleastone = true;
849 }
850 }
851 else {
852 atleastone = true; /* to match SRCHFS_MATCHDIRS */
853 }
854 }
855
856 /*
857 * Check the common attributes
858 */
859 searchAttributes = attrList->commonattr;
860 if ( (searchAttributes & ATTR_CMN_VALIDMASK) != 0 ) {
861 /* node ID */
862 if ( searchAttributes & ATTR_CMN_OBJID ) {
863 matched = CompareRange(c_attr.ca_fileid,
864 searchInfo1->nodeID,
865 searchInfo2->nodeID );
866 if (matched == false) goto TestDone;
867 atleastone = true;
868 }
869
870 /* Parent ID */
871 if ( searchAttributes & ATTR_CMN_PAROBJID ) {
872 HFSCatalogNodeID parentID;
873
874 if (isHFSPlus)
875 parentID = key->hfsPlus.parentID;
876 else
877 parentID = key->hfs.parentID;
878
879 matched = CompareRange(parentID, searchInfo1->parentDirID,
880 searchInfo2->parentDirID );
881 if (matched == false) goto TestDone;
882 atleastone = true;
883 }
884
885 /* Finder Info & Extended Finder Info where extFinderInfo is last 32 bytes */
886 if ( searchAttributes & ATTR_CMN_FNDRINFO ) {
887 UInt32 *thisValue;
888 thisValue = (UInt32 *) &c_attr.ca_finderinfo;
889
890 /*
891 * Note: ioFlFndrInfo and ioDrUsrWds have the same offset in search info, so
892 * no need to test the object type here.
893 */
894 matched = CompareMasked(thisValue,
895 (UInt32 *)&searchInfo1->finderInfo,
896 (UInt32 *) &searchInfo2->finderInfo, 8);
897 if (matched == false) goto TestDone;
898 atleastone = true;
899 }
900
901 /* Create date */
902 if ( searchAttributes & ATTR_CMN_CRTIME ) {
903 matched = CompareRange(c_attr.ca_itime,
904 searchInfo1->creationDate.tv_sec,
905 searchInfo2->creationDate.tv_sec);
906 if (matched == false) goto TestDone;
907 atleastone = true;
908 }
909
910 /* Mod date */
911 if ( searchAttributes & ATTR_CMN_MODTIME ) {
912 matched = CompareRange(c_attr.ca_mtime,
913 searchInfo1->modificationDate.tv_sec,
914 searchInfo2->modificationDate.tv_sec);
915 if (matched == false) goto TestDone;
916 atleastone = true;
917 }
918
919 /* Change Time */
920 if ( searchAttributes & ATTR_CMN_CHGTIME ) {
921 matched = CompareRange(c_attr.ca_ctime,
922 searchInfo1->changeDate.tv_sec,
923 searchInfo2->changeDate.tv_sec);
924 if (matched == false) goto TestDone;
925 atleastone = true;
926 }
927
928 /* Access date */
929 if ( searchAttributes & ATTR_CMN_ACCTIME ) {
930 matched = CompareRange(c_attr.ca_atime,
931 searchInfo1->accessDate.tv_sec,
932 searchInfo2->accessDate.tv_sec);
933 if (matched == false) goto TestDone;
934 atleastone = true;
935 }
936
937 /* Backup date */
938 if ( searchAttributes & ATTR_CMN_BKUPTIME ) {
939 matched = CompareRange(c_attr.ca_btime,
940 searchInfo1->lastBackupDate.tv_sec,
941 searchInfo2->lastBackupDate.tv_sec);
942 if (matched == false) goto TestDone;
943 atleastone = true;
944 }
945
946 /* User ID */
947 if ( searchAttributes & ATTR_CMN_OWNERID ) {
948 matched = CompareRange(c_attr.ca_uid,
949 searchInfo1->uid, searchInfo2->uid);
950 if (matched == false) goto TestDone;
951 atleastone = true;
952 }
953
954 /* Group ID */
955 if ( searchAttributes & ATTR_CMN_GRPID ) {
956 matched = CompareRange(c_attr.ca_gid,
957 searchInfo1->gid, searchInfo2->gid);
958 if (matched == false) goto TestDone;
959 atleastone = true;
960 }
961
962 /* mode */
963 if ( searchAttributes & ATTR_CMN_ACCESSMASK ) {
964 matched = CompareRange((uint32_t)c_attr.ca_mode,
965 (uint32_t)searchInfo1->mask,
966 (uint32_t)searchInfo2->mask);
967 if (matched == false) goto TestDone;
968 atleastone = true;
969 }
970 }
971
972 /* If we got here w/o matching any, then set to false */
973 if (! atleastone)
974 matched = false;
975
976 TestDone:
977 /*
978 * Finally, determine whether we need to negate the sense of the match
979 * (i.e. find all objects that DON'T match).
980 */
981 if ( searchBits & SRCHFS_NEGATEPARAMS )
982 matched = !matched;
983
984 return( matched );
985 }
986
987
988 /*
989 * Adds another record to the packed array for output
990 */
991 static int
992 InsertMatch(struct hfsmount *hfsmp, uio_t a_uio, CatalogRecord *rec,
993 CatalogKey *key, struct attrlist *returnAttrList,
994 void *attributesBuffer, void *variableBuffer, u_long * nummatches)
995 {
996 int err;
997 void *rovingAttributesBuffer;
998 void *rovingVariableBuffer;
999 u_long packedBufferSize;
1000 u_long privateDir = hfsmp->hfs_privdir_desc.cd_cnid;
1001 struct attrblock attrblk;
1002 struct cat_desc c_desc;
1003 struct cat_attr c_attr;
1004 struct cat_fork datafork;
1005 struct cat_fork rsrcfork;
1006
1007 bzero(&c_desc, sizeof(c_desc));
1008 bzero(&c_attr, sizeof(c_attr));
1009 rovingAttributesBuffer = (char*)attributesBuffer + sizeof(u_long); /* Reserve space for length field */
1010 rovingVariableBuffer = variableBuffer;
1011
1012 /* Convert catalog record into cat_attr format. */
1013 cat_convertattr(hfsmp, rec, &c_attr, &datafork, &rsrcfork);
1014
1015 /* hide our private meta data directory */
1016 if ((privateDir != 0) && (c_attr.ca_fileid == privateDir)) {
1017 err = 0;
1018 goto exit;
1019 }
1020
1021 /* Hide the private journal files */
1022 if (hfsmp->jnl &&
1023 ((c_attr.ca_fileid == hfsmp->hfs_jnlfileid) ||
1024 (c_attr.ca_fileid == hfsmp->hfs_jnlinfoblkid))) {
1025 err = 0;
1026 goto exit;
1027 }
1028
1029 if (returnAttrList->commonattr & ATTR_CMN_NAME) {
1030 cat_convertkey(hfsmp, key, rec, &c_desc);
1031 } else {
1032 c_desc.cd_cnid = c_attr.ca_fileid;
1033 if (hfsmp->hfs_flags & HFS_STANDARD)
1034 c_desc.cd_parentcnid = key->hfs.parentID;
1035 else
1036 c_desc.cd_parentcnid = key->hfsPlus.parentID;
1037 }
1038
1039 attrblk.ab_attrlist = returnAttrList;
1040 attrblk.ab_attrbufpp = &rovingAttributesBuffer;
1041 attrblk.ab_varbufpp = &rovingVariableBuffer;
1042 attrblk.ab_flags = 0;
1043 attrblk.ab_blocksize = 0;
1044
1045 hfs_packattrblk(&attrblk, hfsmp, NULL, &c_desc, &c_attr, &datafork, &rsrcfork, current_proc());
1046
1047 packedBufferSize = (char*)rovingVariableBuffer - (char*)attributesBuffer;
1048
1049 if ( packedBufferSize > uio_resid(a_uio) )
1050 return( errSearchBufferFull );
1051
1052 (* nummatches)++;
1053
1054 *((u_long *)attributesBuffer) = packedBufferSize; /* Store length of fixed + var block */
1055
1056 err = uiomove( (caddr_t)attributesBuffer, packedBufferSize, a_uio ); /* XXX should be packedBufferSize */
1057 exit:
1058 cat_releasedesc(&c_desc);
1059
1060 return( err );
1061 }
1062
1063
1064 static int
1065 UnpackSearchAttributeBlock( struct hfsmount *hfsmp, struct attrlist *alist, searchinfospec_t *searchInfo, void *attributeBuffer )
1066 {
1067 attrgroup_t a;
1068 u_long bufferSize;
1069 boolean_t is_64_bit;
1070
1071 DBG_ASSERT(searchInfo != NULL);
1072
1073 is_64_bit = proc_is64bit(current_proc());
1074
1075 bufferSize = *((uint32_t *)attributeBuffer);
1076 if (bufferSize == 0)
1077 return (EINVAL); /* XXX -DJB is a buffer size of zero ever valid for searchfs? */
1078
1079 ++((uint32_t *)attributeBuffer); /* advance past the size */
1080
1081 /*
1082 * UnPack common attributes
1083 */
1084 a = alist->commonattr;
1085 if ( a != 0 ) {
1086 if ( a & ATTR_CMN_NAME ) {
1087 char *s;
1088 u_int32_t len;
1089
1090 s = (char*) attributeBuffer + ((attrreference_t *) attributeBuffer)->attr_dataoffset;
1091 len = ((attrreference_t *) attributeBuffer)->attr_length;
1092
1093 if (len > sizeof(searchInfo->name))
1094 return (EINVAL);
1095
1096 if (hfsmp->hfs_flags & HFS_STANDARD) {
1097 /* Convert name to pascal string to match HFS B-Tree names */
1098
1099 if (len > 0) {
1100 if (utf8_to_hfs(HFSTOVCB(hfsmp), len-1, s, (u_char*)searchInfo->name) != 0)
1101 return (EINVAL);
1102
1103 searchInfo->nameLength = searchInfo->name[0];
1104 } else {
1105 searchInfo->name[0] = searchInfo->nameLength = 0;
1106 }
1107 ++((attrreference_t *)attributeBuffer);
1108 } else {
1109 size_t ucslen;
1110 /* Convert name to Unicode to match HFS Plus B-Tree names */
1111
1112 if (len > 0) {
1113 if (utf8_decodestr(s, len-1, (UniChar*)searchInfo->name, &ucslen,
1114 sizeof(searchInfo->name), ':', UTF_DECOMPOSED))
1115 return (EINVAL);
1116
1117 searchInfo->nameLength = ucslen / sizeof(UniChar);
1118 } else {
1119 searchInfo->nameLength = 0;
1120 }
1121 ++((attrreference_t *)attributeBuffer);
1122 }
1123 }
1124 if ( a & ATTR_CMN_OBJID ) {
1125 searchInfo->nodeID = ((fsobj_id_t *) attributeBuffer)->fid_objno; /* ignore fid_generation */
1126 ++((fsobj_id_t *)attributeBuffer);
1127 }
1128 if ( a & ATTR_CMN_PAROBJID ) {
1129 searchInfo->parentDirID = ((fsobj_id_t *) attributeBuffer)->fid_objno; /* ignore fid_generation */
1130 ++((fsobj_id_t *)attributeBuffer);
1131 }
1132 if ( a & ATTR_CMN_CRTIME ) {
1133 if (is_64_bit) {
1134 struct user_timespec tmp;
1135 tmp = *((struct user_timespec *)attributeBuffer);
1136 searchInfo->creationDate.tv_sec = (time_t)tmp.tv_sec;
1137 searchInfo->creationDate.tv_nsec = tmp.tv_nsec;
1138 ++((struct user_timespec *)attributeBuffer);
1139 }
1140 else {
1141 searchInfo->creationDate = *((struct timespec *)attributeBuffer);
1142 ++((struct timespec *)attributeBuffer);
1143 }
1144 }
1145 if ( a & ATTR_CMN_MODTIME ) {
1146 if (is_64_bit) {
1147 struct user_timespec tmp;
1148 tmp = *((struct user_timespec *)attributeBuffer);
1149 searchInfo->modificationDate.tv_sec = (time_t)tmp.tv_sec;
1150 searchInfo->modificationDate.tv_nsec = tmp.tv_nsec;
1151 ++((struct user_timespec *)attributeBuffer);
1152 }
1153 else {
1154 searchInfo->modificationDate = *((struct timespec *)attributeBuffer);
1155 ++((struct timespec *)attributeBuffer);
1156 }
1157 }
1158 if ( a & ATTR_CMN_CHGTIME ) {
1159 if (is_64_bit) {
1160 struct user_timespec tmp;
1161 tmp = *((struct user_timespec *)attributeBuffer);
1162 searchInfo->changeDate.tv_sec = (time_t)tmp.tv_sec;
1163 searchInfo->changeDate.tv_nsec = tmp.tv_nsec;
1164 ++((struct user_timespec *)attributeBuffer);
1165 }
1166 else {
1167 searchInfo->changeDate = *((struct timespec *)attributeBuffer);
1168 ++((struct timespec *)attributeBuffer);
1169 }
1170 }
1171 if ( a & ATTR_CMN_ACCTIME ) {
1172 if (is_64_bit) {
1173 struct user_timespec tmp;
1174 tmp = *((struct user_timespec *)attributeBuffer);
1175 searchInfo->accessDate.tv_sec = (time_t)tmp.tv_sec;
1176 searchInfo->accessDate.tv_nsec = tmp.tv_nsec;
1177 ++((struct user_timespec *)attributeBuffer);
1178 }
1179 else {
1180 searchInfo->accessDate = *((struct timespec *)attributeBuffer);
1181 ++((struct timespec *)attributeBuffer);
1182 }
1183 }
1184 if ( a & ATTR_CMN_BKUPTIME ) {
1185 if (is_64_bit) {
1186 struct user_timespec tmp;
1187 tmp = *((struct user_timespec *)attributeBuffer);
1188 searchInfo->lastBackupDate.tv_sec = (time_t)tmp.tv_sec;
1189 searchInfo->lastBackupDate.tv_nsec = tmp.tv_nsec;
1190 ++((struct user_timespec *)attributeBuffer);
1191 }
1192 else {
1193 searchInfo->lastBackupDate = *((struct timespec *)attributeBuffer);
1194 ++((struct timespec *)attributeBuffer);
1195 }
1196 }
1197 if ( a & ATTR_CMN_FNDRINFO ) {
1198 bcopy( attributeBuffer, searchInfo->finderInfo, sizeof(searchInfo->finderInfo) );
1199 (uint8_t *)attributeBuffer += 32;
1200 }
1201 if ( a & ATTR_CMN_OWNERID ) {
1202 searchInfo->uid = *((uid_t *)attributeBuffer);
1203 ++((uid_t *)attributeBuffer);
1204 }
1205 if ( a & ATTR_CMN_GRPID ) {
1206 searchInfo->gid = *((gid_t *)attributeBuffer);
1207 ++((gid_t *)attributeBuffer);
1208 }
1209 if ( a & ATTR_CMN_ACCESSMASK ) {
1210 searchInfo->mask = *((mode_t *)attributeBuffer);
1211 ++((mode_t *)attributeBuffer);
1212 }
1213 }
1214
1215 a = alist->dirattr;
1216 if ( a != 0 ) {
1217 if ( a & ATTR_DIR_ENTRYCOUNT ) {
1218 searchInfo->d.numFiles = *((u_int32_t *)attributeBuffer);
1219 ++((u_int32_t *)attributeBuffer);
1220 }
1221 }
1222
1223 a = alist->fileattr;
1224 if ( a != 0 ) {
1225 if ( a & ATTR_FILE_DATALENGTH ) {
1226 searchInfo->f.dataLogicalLength = *((off_t *)attributeBuffer);
1227 ++((off_t *)attributeBuffer);
1228 }
1229 if ( a & ATTR_FILE_DATAALLOCSIZE ) {
1230 searchInfo->f.dataPhysicalLength = *((off_t *)attributeBuffer);
1231 ++((off_t *)attributeBuffer);
1232 }
1233 if ( a & ATTR_FILE_RSRCLENGTH ) {
1234 searchInfo->f.resourceLogicalLength = *((off_t *)attributeBuffer);
1235 ++((off_t *)attributeBuffer);
1236 }
1237 if ( a & ATTR_FILE_RSRCALLOCSIZE ) {
1238 searchInfo->f.resourcePhysicalLength = *((off_t *)attributeBuffer);
1239 ++((off_t *)attributeBuffer);
1240 }
1241 }
1242
1243 return (0);
1244 }
1245
1246
1247 #if 1 // Installer workaround (2940423)
1248 /* this routine was added as part of the work around where some installers would fail */
1249 /* because they incorrectly assumed search results were in some kind of order. */
1250 /* This routine is used to indentify the problematic target. At this point we */
1251 /* only know of one. This routine could be modified for more (I hope not). */
1252 static Boolean IsTargetName( searchinfospec_t * searchInfoPtr, Boolean isHFSPlus )
1253 {
1254 if ( searchInfoPtr->name == NULL )
1255 return( false );
1256
1257 if (isHFSPlus) {
1258 HFSUniStr255 myName = {
1259 7, /* number of unicode characters */
1260 {
1261 'L','i','b','r','a','r','y'
1262 }
1263 };
1264 if ( FastUnicodeCompare( myName.unicode, myName.length,
1265 (UniChar*)searchInfoPtr->name,
1266 searchInfoPtr->nameLength ) == 0 ) {
1267 return( true );
1268 }
1269
1270 } else {
1271 u_char myName[32] = {
1272 0x07,'L','i','b','r','a','r','y'
1273 };
1274 if ( FastRelString(myName, (u_char*)searchInfoPtr->name) == 0 ) {
1275 return( true );
1276 }
1277 }
1278 return( false );
1279
1280 } /* IsTargetName */
1281 #endif // Installer workaround
1282