]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfscommon/Catalog/CatalogUtilities.c
xnu-1228.7.58.tar.gz
[apple/xnu.git] / bsd / hfs / hfscommon / Catalog / CatalogUtilities.c
index 85cdddbf8a6ed5ea24163ebe8a9e90f38f3bb6a5..1e24463f14e3afd05e9b643cedba347e3b91a17c 100644 (file)
@@ -1,16 +1,19 @@
 /*
- * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002, 2004-2005 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  * This file contains Original Code and/or Modifications of Original Code
  * as defined in and that are subject to the Apple Public Source License
  * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ * 
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
  * 
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
@@ -20,7 +23,7 @@
  * Please see the License for the specific language governing rights and
  * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 #include <sys/param.h>
 #include <sys/utfconv.h>
@@ -43,7 +46,7 @@
 
 OSErr
 LocateCatalogNode(const ExtendedVCB *volume, HFSCatalogNodeID folderID, const CatalogName *name,
-                                       UInt32 hint, CatalogKey *keyPtr, CatalogRecord *dataPtr, UInt32 *newHint)
+                                       u_int32_t hint, CatalogKey *keyPtr, CatalogRecord *dataPtr, u_int32_t *newHint)
 {
        OSErr                           result;
        CatalogName             *nodeName = NULL;       /* To ward off uninitialized use warnings from compiler */
@@ -87,17 +90,19 @@ LocateCatalogNode(const ExtendedVCB *volume, HFSCatalogNodeID folderID, const Ca
 //
 
 OSErr
-LocateCatalogNodeByKey(const ExtendedVCB *volume, UInt32 hint, CatalogKey *keyPtr,
-                                               CatalogRecord *dataPtr, UInt32 *newHint)
+LocateCatalogNodeByKey(const ExtendedVCB *volume, u_int32_t hint, CatalogKey *keyPtr,
+                                               CatalogRecord *dataPtr, u_int32_t *newHint)
 {
        OSErr                           result;
        CatalogName             *nodeName = NULL;
        HFSCatalogNodeID        threadParentID;
-       UInt16 tempSize;
+       u_int16_t tempSize;
        FSBufferDescriptor       btRecord;
-       BTreeIterator            searchIterator = {0};
+       BTreeIterator            searchIterator
        FCB                     *fcb;
 
+       bzero(&searchIterator, sizeof(searchIterator));
+
        fcb = GetFileControlBlock(volume->catalogRefNum);
 
        btRecord.bufferAddress = dataPtr;
@@ -158,11 +163,11 @@ LocateCatalogNodeByKey(const ExtendedVCB *volume, UInt32 hint, CatalogKey *keyPt
 
 OSErr
 LocateCatalogRecord(const ExtendedVCB *volume, HFSCatalogNodeID folderID, const CatalogName *name,
-                                       UInt32 hint, CatalogKey *keyPtr, CatalogRecord *dataPtr, UInt32 *newHint)
+                                       u_int32_t hint, CatalogKey *keyPtr, CatalogRecord *dataPtr, u_int32_t *newHint)
 {
        OSErr                   result;
        CatalogKey              tempKey;        // 518 bytes
-       UInt16                  tempSize;
+       u_int16_t               tempSize;
 
        BuildCatalogKey(folderID, name, (volume->vcbSigWord == kHFSPlusSigWord), &tempKey);
 
@@ -214,15 +219,15 @@ BuildCatalogKey(HFSCatalogNodeID parentID, const CatalogName *cName, Boolean isH
 }
 
 OSErr
-BuildCatalogKeyUTF8(ExtendedVCB *volume, HFSCatalogNodeID parentID, const char *name, UInt32 nameLength,
-                   CatalogKey *key, UInt32 *textEncoding)
+BuildCatalogKeyUTF8(ExtendedVCB *volume, HFSCatalogNodeID parentID, const unsigned char *name, u_int32_t nameLength,
+                   CatalogKey *key, u_int32_t *textEncoding)
 {
        OSErr err = 0;
 
     if ( name == NULL)
         nameLength = 0;
     else if (nameLength == kUndefinedStrLen)
-        nameLength = strlen(name);
+        nameLength = strlen((const char *)name);
 
        if ( volume->vcbSigWord == kHFSPlusSigWord ) {
                size_t unicodeBytes = 0;
@@ -294,10 +299,10 @@ FlushCatalog(ExtendedVCB *volume)
                
                if ( 0 /*fcb->fcbFlags & fcbModifiedMask*/ )
                {
-                       VCB_LOCK(volume);
-                       volume->vcbFlags |= 0xFF00;             // Mark the VCB dirty
+                       HFS_MOUNT_LOCK(volume, TRUE);
+                       MarkVCBDirty(volume);   // Mark the VCB dirty
                        volume->vcbLsMod = GetTimeUTC();        // update last modified date
-                       VCB_UNLOCK(volume);
+                       HFS_MOUNT_UNLOCK(volume, TRUE);
 
                //      result = FlushVolumeControlBlock(volume);
                }
@@ -332,7 +337,7 @@ UpdateCatalogName(ConstStr31Param srcName, Str31 destName)
 void
 CopyCatalogName(const CatalogName *srcName, CatalogName *dstName, Boolean isHFSPLus)
 {
-       UInt32  length;
+       u_int32_t       length;
        
        if ( srcName == NULL )
        {
@@ -344,7 +349,7 @@ CopyCatalogName(const CatalogName *srcName, CatalogName *dstName, Boolean isHFSP
        if (isHFSPLus)
                length = sizeof(UniChar) * (srcName->ustr.length + 1);
        else
-               length = sizeof(UInt8) + srcName->pstr[0];
+               length = sizeof(u_int8_t) + srcName->pstr[0];
 
        if ( length > 1 )
                BlockMoveData(srcName, dstName, length);