#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
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 );
EXTERN_API_C( OSErr )
MoveData( ExtendedVCB *vcb, HFSCatalogNodeID srcID, HFSCatalogNodeID destID, int rsrc);
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);
#define HFS_ALLOC_FORCECONTIG 0x1
#define HFS_ALLOC_METAZONE 0x2
#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 )
ResetVCBFreeExtCache(struct hfsmount *hfsmp);
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( OSErr )
BlockMarkFreeUnused( ExtendedVCB *vcb, u_int32_t startingBlock, u_int32_t numBlocks);
EXTERN_API_C( u_int32_t )
MetaZoneFreeBlocks(ExtendedVCB *vcb);
EXTERN_API_C( u_int32_t )
UpdateAllocLimit (struct hfsmount *hfsmp, u_int32_t new_end_block);
#if CONFIG_HFS_ALLOC_RBTREE
EXTERN_API_C( u_int32_t )
GenerateTree( struct hfsmount *hfsmp, u_int32_t end_block, int *flags, int initialscan);
EXTERN_API_C( void )
DestroyTrees( struct hfsmount *hfsmp);
EXTERN_API_C( u_int32_t )
InitTree(struct hfsmount *hfsmp);
#endif
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, int deleted,
int rsrc, uint32_t fileid, 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);
#ifdef __cplusplus
}
#endif
#endif
#endif
#endif