#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"
#if PRAGMA_ONCE
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if PRAGMA_IMPORT
#pragma import on
#endif
#if PRAGMA_STRUCT_ALIGN
#pragma options align=mac68k
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(push, 2)
#elif PRAGMA_STRUCT_PACK
#pragma pack(2)
#endif
typedef u_int32_t HFSCatalogNodeID;
#if TARGET_API_MACOS_X
#define ERR_BASE -32767
#else
#define ERR_BASE 0
#endif
enum {
fxRangeErr = ERR_BASE + 16,
fxOvFlErr = ERR_BASE + 17,
uniTooLongErr = ERR_BASE + 24,
uniBufferTooSmallErr = ERR_BASE + 25,
uniNotMappableErr = ERR_BASE + 26,
btNotFound = ERR_BASE + 32,
btExists = ERR_BASE + 33,
btNoSpaceAvail = ERR_BASE + 34,
btNoFit = ERR_BASE + 35,
btBadNode = ERR_BASE + 36,
btBadHdr = ERR_BASE + 37,
dsBadRotate = ERR_BASE + 64,
cmNotFound = ERR_BASE + 48,
cmExists = ERR_BASE + 49,
cmNotEmpty = ERR_BASE + 50,
cmRootCN = ERR_BASE + 51,
cmBadNews = ERR_BASE + 52,
cmFThdDirErr = ERR_BASE + 53,
cmFThdGone = ERR_BASE + 54,
cmParentNotFound = ERR_BASE + 55,
fsDSIntErr = -127
};
enum {
kEFAllMask = 0x01,
kEFContigMask = 0x02,
kEFReserveMask = 0x04,
kEFDeferMask = 0x08,
kEFNoClumpMask = 0x10,
kEFMetadataMask = 0x20,
kTFTrunExtBit = 0,
kTFTrunExtMask = 1
};
enum {
kUndefinedStrLen = 0,
kNoHint = 0,
kNumExtentsToCache = 4
};
union ExtentKey {
HFSExtentKey hfs;
HFSPlusExtentKey hfsPlus;
};
typedef union ExtentKey ExtentKey;
union ExtentDescriptor {
HFSExtentDescriptor hfs;
HFSPlusExtentDescriptor hfsPlus;
};
typedef union ExtentDescriptor ExtentDescriptor;
union ExtentRecord {
HFSExtentRecord hfs;
HFSPlusExtentRecord hfsPlus;
};
typedef union ExtentRecord ExtentRecord;
enum {
CMMaxCName = kHFSMaxFileNameChars
};
union CatalogName {
Str31 pstr;
HFSUniStr255 ustr;
};
typedef union CatalogName CatalogName;
#define GetFileControlBlock(fref) VTOF((fref))
#define GetFileRefNumFromFCB(fcb) FTOV((fcb))
EXTERN_API_C( void )
ReturnIfError (OSErr result);
#define ReturnIfError(result) do { if ( (result) != noErr ) return (result); } while(0)
EXTERN_API_C( void )
ExitOnError (OSErr result);
#define ExitOnError( result ) do { if ( ( result ) != noErr ) goto ErrorExit; } while(0)
EXTERN_API_C( OSErr )
ExchangeFileIDs (ExtendedVCB * volume,
ConstUTF8Param srcName,
ConstUTF8Param destName,
HFSCatalogNodeID srcID,
HFSCatalogNodeID destID,
u_int32_t srcHint,
u_int32_t destHint );
typedef CALLBACK_API_C( int32_t , KeyCompareProcPtr )(void *a, void *b);
EXTERN_API_C( OSErr )
SearchBTreeRecord (FileReference refNum,
const void * key,
u_int32_t hint,
void * foundKey,
void * data,
u_int16_t * dataSize,
u_int32_t * newHint);
EXTERN_API_C( OSErr )
ReplaceBTreeRecord (FileReference refNum,
const void * key,
u_int32_t hint,
void * newData,
u_int16_t dataSize,
u_int32_t * newHint);
EXTERN_API_C( OSErr )
BlockAllocate (ExtendedVCB * vcb,
u_int32_t startingBlock,
u_int32_t minBlocks,
u_int32_t maxBlocks,
Boolean forceContiguous,
Boolean useMetaZone,
u_int32_t * startBlock,
u_int32_t * actualBlocks);
EXTERN_API_C( OSErr )
BlockDeallocate (ExtendedVCB * vcb,
u_int32_t firstBlock,
u_int32_t numBlocks);
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);
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
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);
#if PRAGMA_STRUCT_ALIGN
#pragma options align=reset
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(pop)
#elif PRAGMA_STRUCT_PACK
#pragma pack()
#endif
#ifdef PRAGMA_IMPORT_OFF
#pragma import off
#elif PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif
#endif
#endif
#endif