Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | /* * Copyright (c) 2000-2005 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. 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 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* File: FilesInternal.h Contains: IPI for File Manager (HFS Plus) Version: HFS Plus 1.0 Copyright: © 1996-2001 by Apple Computer, Inc., all rights reserved. */ #ifndef __FILEMGRINTERNAL__ #define __FILEMGRINTERNAL__ #include <sys/appleapiopts.h> #ifdef KERNEL #ifdef __APPLE_API_PRIVATE #include <sys/param.h> #include <sys/vnode.h> #include "../../hfs.h" #include "../../hfs_macos_defs.h" #include "../../hfs_format.h" #include "../../hfs_cnode.h" #ifdef __cplusplus extern "C" { #endif /* CatalogNodeID is used to track catalog objects */ typedef u_int32_t HFSCatalogNodeID; /* internal error codes*/ #if TARGET_API_MACOS_X #define ERR_BASE -32767 #else #define ERR_BASE 0 #endif enum { /* FXM errors*/ fxRangeErr = ERR_BASE + 16, /* file position beyond mapped range*/ fxOvFlErr = ERR_BASE + 17, /* extents file overflow*/ /* Unicode errors*/ uniTooLongErr = ERR_BASE + 24, /* Unicode string too long to convert to Str31*/ uniBufferTooSmallErr = ERR_BASE + 25, /* Unicode output buffer too small*/ uniNotMappableErr = ERR_BASE + 26, /* Unicode string can't be mapped to given script*/ /* BTree Manager errors*/ btNotFound = ERR_BASE + 32, /* record not found*/ btExists = ERR_BASE + 33, /* record already exists*/ btNoSpaceAvail = ERR_BASE + 34, /* no available space*/ btNoFit = ERR_BASE + 35, /* record doesn't fit in node */ btBadNode = ERR_BASE + 36, /* bad node detected*/ btBadHdr = ERR_BASE + 37, /* bad BTree header record detected*/ dsBadRotate = ERR_BASE + 64, /* bad BTree rotate*/ /* Catalog Manager errors*/ cmNotFound = ERR_BASE + 48, /* CNode not found*/ cmExists = ERR_BASE + 49, /* CNode already exists*/ cmNotEmpty = ERR_BASE + 50, /* directory CNode not empty (valence = 0)*/ cmRootCN = ERR_BASE + 51, /* invalid reference to root CNode*/ cmBadNews = ERR_BASE + 52, /* detected bad catalog structure*/ cmFThdDirErr = ERR_BASE + 53, /* thread belongs to a directory not a file*/ cmFThdGone = ERR_BASE + 54, /* file thread doesn't exist*/ cmParentNotFound = ERR_BASE + 55, /* CNode for parent ID does not exist*/ /* TFS internal errors*/ fsDSIntErr = -127 /* Internal file system error*/ }; /* internal flags*/ enum { kEFAllMask = 0x01, /* allocate all requested bytes or none */ kEFContigMask = 0x02, /* force contiguous allocation */ kEFReserveMask = 0x04, /* keep block reserve */ kEFDeferMask = 0x08, /* defer file block allocations */ kEFNoClumpMask = 0x10, /* don't round up to clump size */ kEFMetadataMask = 0x20, /* metadata allocation */ kTFTrunExtBit = 0, /* truncate to the extent containing new PEOF*/ kTFTrunExtMask = 1 }; enum { kUndefinedStrLen = 0, /* Unknown string length */ kNoHint = 0, /* FileIDs variables*/ kNumExtentsToCache = 4 /* just guessing for ExchangeFiles*/ }; /* Universal Extent Key */ union ExtentKey { HFSExtentKey hfs; HFSPlusExtentKey hfsPlus; }; typedef union ExtentKey ExtentKey; /* Universal extent descriptor */ union ExtentDescriptor { HFSExtentDescriptor hfs; HFSPlusExtentDescriptor hfsPlus; }; typedef union ExtentDescriptor ExtentDescriptor; /* Universal extent record */ union ExtentRecord { HFSExtentRecord hfs; HFSPlusExtentRecord hfsPlus; }; typedef union ExtentRecord ExtentRecord; enum { CMMaxCName = kHFSMaxFileNameChars }; /* Universal catalog name*/ union CatalogName { Str31 pstr; HFSUniStr255 ustr; }; typedef union CatalogName CatalogName; /* * MacOS accessor routines */ #define GetFileControlBlock(fref) VTOF((fref)) #define GetFileRefNumFromFCB(fcb) FTOV((fcb)) /* Test for error and return if error occurred*/ EXTERN_API_C( void ) ReturnIfError (OSErr result); #define ReturnIfError(result) do { if ( (result) != noErr ) return (result); } while(0) /* Exit function on error*/ EXTERN_API_C( void ) ExitOnError (OSErr result); #define ExitOnError( result ) do { if ( ( result ) != noErr ) goto ErrorExit; } while(0) /* Catalog Manager Routines (IPI)*/ EXTERN_API_C( OSErr ) ExchangeFileIDs (ExtendedVCB * volume, ConstUTF8Param srcName, ConstUTF8Param destName, HFSCatalogNodeID srcID, HFSCatalogNodeID destID, u_int32_t srcHint, u_int32_t destHint ); /* BTree Manager Routines*/ typedef CALLBACK_API_C( int32_t , KeyCompareProcPtr )(void *a, void *b); EXTERN_API_C( OSErr ) ReplaceBTreeRecord (FileReference refNum, const void * key, u_int32_t hint, void * newData, u_int16_t dataSize, u_int32_t * newHint); /* Prototypes for exported routines in VolumeAllocation.c*/ /* * Flags for BlockAllocate() and BlockDeallocate() */ /* Force contiguous block allocation and to force minBlocks to actually be allocated */ #define HFS_ALLOC_FORCECONTIG 0x1 /* Can use metadata zone blocks */ #define HFS_ALLOC_METAZONE 0x2 /* Skip checking and updating of free blocks during allocation and deallocation */ #define HFS_ALLOC_SKIPFREEBLKS 0x4 EXTERN_API_C( OSErr ) BlockAllocate (ExtendedVCB * vcb, u_int32_t startingBlock, u_int32_t minBlocks, u_int32_t maxBlocks, u_int32_t flags, u_int32_t * startBlock, u_int32_t * actualBlocks); EXTERN_API_C( OSErr ) BlockDeallocate (ExtendedVCB * vcb, u_int32_t firstBlock, u_int32_t numBlocks, u_int32_t flags); EXTERN_API_C ( void ) invalidate_free_extent_cache (ExtendedVCB * vcb); EXTERN_API_C( OSErr ) BlockMarkAllocated(ExtendedVCB *vcb, u_int32_t startingBlock, u_int32_t numBlocks); EXTERN_API_C( OSErr ) BlockMarkFree( ExtendedVCB *vcb, u_int32_t startingBlock, u_int32_t numBlocks); EXTERN_API_C( u_int32_t ) MetaZoneFreeBlocks(ExtendedVCB *vcb); /* File Extent Mapping routines*/ EXTERN_API_C( OSErr ) FlushExtentFile (ExtendedVCB * vcb); EXTERN_API_C( int32_t ) CompareExtentKeys (const HFSExtentKey * searchKey, const HFSExtentKey * trialKey); EXTERN_API_C( int32_t ) CompareExtentKeysPlus (const HFSPlusExtentKey *searchKey, const HFSPlusExtentKey *trialKey); EXTERN_API_C( OSErr ) TruncateFileC (ExtendedVCB * vcb, FCB * fcb, int64_t peof, Boolean truncateToExtent); EXTERN_API_C( OSErr ) ExtendFileC (ExtendedVCB * vcb, FCB * fcb, int64_t bytesToAdd, u_int32_t blockHint, u_int32_t flags, int64_t * actualBytesAdded); EXTERN_API_C( OSErr ) MapFileBlockC (ExtendedVCB * vcb, FCB * fcb, size_t numberOfBytes, off_t offset, daddr64_t * startBlock, size_t * availableBytes); OSErr HeadTruncateFile(ExtendedVCB *vcb, FCB *fcb, u_int32_t headblks); EXTERN_API_C( int ) AddFileExtent (ExtendedVCB *vcb, FCB *fcb, u_int32_t startBlock, u_int32_t blockCount); #if TARGET_API_MACOS_X EXTERN_API_C( Boolean ) NodesAreContiguous (ExtendedVCB * vcb, FCB * fcb, u_int32_t nodeSize); #endif /* Get the current time in UTC (GMT)*/ EXTERN_API_C( u_int32_t ) GetTimeUTC (void); EXTERN_API_C( u_int32_t ) LocalToUTC (u_int32_t localTime); EXTERN_API_C( u_int32_t ) UTCToLocal (u_int32_t utcTime); #ifdef __cplusplus } #endif #endif /* __APPLE_API_PRIVATE */ #endif /* KERNEL */ #endif /* __FILEMGRINTERNAL__ */ |