#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 UInt32 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 )
MarkVCBDirty (ExtendedVCB *vcb);
EXTERN_API_C( void )
MarkVCBClean (ExtendedVCB *vcb);
EXTERN_API_C( Boolean )
IsVCBDirty (ExtendedVCB *vcb);
#define MarkVCBDirty(vcb) { ((vcb)->vcbFlags |= 0xFF00); }
#define MarkVCBClean(vcb) { ((vcb)->vcbFlags &= 0x00FF); }
#define IsVCBDirty(vcb) ((Boolean) ((vcb->vcbFlags & 0xFF00) != 0))
EXTERN_API_C( void )
ReturnIfError (OSErr result);
#define ReturnIfError(result) if ( (result) != noErr ) return (result); else ;
EXTERN_API_C( void )
ExitOnError (OSErr result);
#define ExitOnError( result ) if ( ( result ) != noErr ) goto ErrorExit; else ;
EXTERN_API_C( OSErr )
ExchangeFileIDs (ExtendedVCB * volume,
ConstUTF8Param srcName,
ConstUTF8Param destName,
HFSCatalogNodeID srcID,
HFSCatalogNodeID destID,
UInt32 srcHint,
UInt32 destHint );
typedef CALLBACK_API_C( SInt32 , KeyCompareProcPtr )(void *a, void *b);
EXTERN_API_C( OSErr )
SearchBTreeRecord (FileReference refNum,
const void * key,
UInt32 hint,
void * foundKey,
void * data,
UInt16 * dataSize,
UInt32 * newHint);
EXTERN_API_C( OSErr )
ReplaceBTreeRecord (FileReference refNum,
const void * key,
UInt32 hint,
void * newData,
UInt16 dataSize,
UInt32 * newHint);
EXTERN_API_C( OSErr )
BlockAllocate (ExtendedVCB * vcb,
UInt32 startingBlock,
UInt32 minBlocks,
UInt32 maxBlocks,
Boolean forceContiguous,
Boolean useMetaZone,
UInt32 * startBlock,
UInt32 * actualBlocks);
EXTERN_API_C( OSErr )
BlockDeallocate (ExtendedVCB * vcb,
UInt32 firstBlock,
UInt32 numBlocks);
EXTERN_API_C( OSErr )
BlockMarkAllocated(ExtendedVCB *vcb, UInt32 startingBlock, UInt32 numBlocks);
EXTERN_API_C( OSErr )
BlockMarkFree( ExtendedVCB *vcb, UInt32 startingBlock, UInt32 numBlocks);
EXTERN_API_C( UInt32 )
MetaZoneFreeBlocks(ExtendedVCB *vcb);
EXTERN_API_C( OSErr )
FlushExtentFile (ExtendedVCB * vcb);
EXTERN_API_C( SInt32 )
CompareExtentKeys (const HFSExtentKey * searchKey,
const HFSExtentKey * trialKey);
EXTERN_API_C( SInt32 )
CompareExtentKeysPlus (const HFSPlusExtentKey *searchKey,
const HFSPlusExtentKey *trialKey);
EXTERN_API_C( OSErr )
TruncateFileC (ExtendedVCB * vcb,
FCB * fcb,
SInt64 peof,
Boolean truncateToExtent);
EXTERN_API_C( OSErr )
ExtendFileC (ExtendedVCB * vcb,
FCB * fcb,
SInt64 bytesToAdd,
UInt32 blockHint,
UInt32 flags,
SInt64 * 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, UInt32 headblks);
EXTERN_API_C( int )
AddFileExtent (ExtendedVCB *vcb, FCB *fcb, UInt32 startBlock, UInt32 blockCount);
#if TARGET_API_MACOS_X
EXTERN_API_C( Boolean )
NodesAreContiguous (ExtendedVCB * vcb,
FCB * fcb,
UInt32 nodeSize);
#endif
EXTERN_API_C( UInt32 )
GetTimeUTC (void);
EXTERN_API_C( UInt32 )
LocalToUTC (UInt32 localTime);
EXTERN_API_C( UInt32 )
UTCToLocal (UInt32 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