]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfs_search.c
xnu-3248.60.10.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_search.c
index 53ea092f40a1ad4af3d33aa0bd82c59f45071286..45cd1a22d053961bdcfe21a89b66bfe0034af251 100644 (file)
@@ -324,7 +324,7 @@ hfs_vnop_search(ap)
                (void) hfs_fsync(vcb->catalogRefNum, MNT_WAIT, 0, p);
                if (hfsmp->jnl) {
                    hfs_systemfile_unlock(hfsmp, lockflags);
-                   hfs_journal_flush(hfsmp, FALSE);
+                   hfs_flush(hfsmp, HFS_FLUSH_JOURNAL);
                    lockflags = hfs_systemfile_lock(hfsmp, SFL_CATALOG, HFS_SHARED_LOCK);
                }
 
@@ -332,6 +332,7 @@ hfs_vnop_search(ap)
                bzero((caddr_t)myCatPositionPtr, sizeof(*myCatPositionPtr));
                err = BTScanInitialize(catalogFCB, 0, 0, 0, kCatSearchBufferSize, &myBTScanState);
                if (err) {
+                       hfs_systemfile_unlock(hfsmp, lockflags);
                        goto ExitThisRoutine;
                }
        } else {
@@ -678,7 +679,6 @@ CheckCriteria(      ExtendedVCB *vcb,
        struct cat_attr c_attr;
        struct cat_fork datafork;
        struct cat_fork rsrcfork;
-       struct hfsmount *hfsmp = (struct hfsmount*)vcb;
        int force_case_sensitivity = proc_is_forcing_hfs_case_sensitivity(vfs_context_proc(ctx));
        
        bzero(&c_attr, sizeof(c_attr));
@@ -750,19 +750,29 @@ CheckCriteria(    ExtendedVCB *vcb,
                if (isHFSPlus) {
                        int case_sensitive = 0;
 
-                       if (hfsmp->hfs_flags & HFS_CASE_SENSITIVE) {
-                               case_sensitive = 1;
-                       } else if (force_case_sensitivity) {
+                       /*
+                        * Longstanding default behavior here is to use a non-case-sensitive 
+                        * search, even on case-sensitive filesystems. 
+                        * 
+                        * We only force case sensitivity if the controlling process has explicitly
+                        * asked for it in the proc flags, and only if they are not doing
+                        * a partial name match.  Consider that if you are doing a partial
+                        * name match ("all files that begin with 'image'"), the likelihood is 
+                        * high that you would want to see all matches, even those that do not
+                        * explicitly match the case.
+                        */
+                       if (force_case_sensitivity) {
                                case_sensitive = 1;
                        }
 
                        /* Check for partial/full HFS Plus name match */
 
                        if ( searchBits & SRCHFS_MATCHPARTIALNAMES ) {
+                               /* always use a case-INSENSITIVE search here */
                                matched = ComparePartialUnicodeName(key->hfsPlus.nodeName.unicode,
                                                                    key->hfsPlus.nodeName.length,
                                                                    (UniChar*)searchInfo1->name,
-                                                                   searchInfo1->nameLength, case_sensitive);
+                                                                   searchInfo1->nameLength, 0);
                        } 
                        else {
                                /* Full name match.  Are we HFSX (case sensitive) or HFS+ ? */