lf_hfs_file_mgr_internal.h [plain text]
#ifndef lf_hfs_file_mgr_internal_h
#define lf_hfs_file_mgr_internal_h
#include <MacTypes.h>
#include "lf_hfs.h"
#include "lf_hfs_defs.h"
#include "lf_hfs_format.h"
#include "lf_hfs_cnode.h"
typedef u_int32_t HFSCatalogNodeID;
#define ERR_BASE -32767
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
};
typedef union ExtentKey {
HFSExtentKey hfs;
HFSPlusExtentKey hfsPlus;
} ExtentKey;
typedef union ExtentDescriptor {
HFSExtentDescriptor hfs;
HFSPlusExtentDescriptor hfsPlus;
} ExtentDescriptor;
typedef union ExtentRecord {
HFSExtentRecord hfs;
HFSPlusExtentRecord hfsPlus;
} ExtentRecord;
enum {
CMMaxCName = kHFSMaxFileNameChars
};
typedef union CatalogName {
Str31 pstr;
HFSUniStr255 ustr;
} CatalogName;
#define GetFileControlBlock(fref) VTOF((fref))
#define GetFileRefNumFromFCB(fcb) FTOV((fcb))
#define ReturnIfError(result) do { if ( (result) != noErr ) return (result); } while(0)
#define ExitOnError(result) do { if ( (result) != noErr ) goto ErrorExit; } while(0)
OSErr ExchangeFileIDs( ExtendedVCB *volume,
ConstUTF8Param srcName,
ConstUTF8Param destName,
HFSCatalogNodeID srcID,
HFSCatalogNodeID destID,
u_int32_t srcHint,
u_int32_t destHint );
OSErr MoveData( ExtendedVCB *vcb, HFSCatalogNodeID srcID, HFSCatalogNodeID destID, int rsrc);
typedef int32_t (*KeyCompareProcPtr)(void *a, void *b);
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 0x001 //force contiguous block allocation; minblocks must be allocated
#define HFS_ALLOC_METAZONE 0x002 //can use metazone blocks
#define HFS_ALLOC_SKIPFREEBLKS 0x004 //skip checking/updating freeblocks during alloc/dealloc
#define HFS_ALLOC_FLUSHTXN 0x008 //pick best fit for allocation, even if a jnl flush is req'd
#define HFS_ALLOC_TENTATIVE 0x010 //reserved allocation that can be claimed back
#define HFS_ALLOC_LOCKED 0x020 //reserved allocation that can't be claimed back
#define HFS_ALLOC_IGNORE_TENTATIVE 0x040 //Steal tentative blocks if necessary
#define HFS_ALLOC_IGNORE_RESERVED 0x080 //Ignore tentative/committed blocks
#define HFS_ALLOC_USE_TENTATIVE 0x100 //Use the supplied tentative range (if possible)
#define HFS_ALLOC_COMMIT 0x200 //Commit the supplied extent to disk
#define HFS_ALLOC_TRY_HARD 0x400 //Search hard to try and get maxBlocks; implies HFS_ALLOC_FLUSHTXN
#define HFS_ALLOC_ROLL_BACK 0x800 //Reallocate blocks that were just deallocated
typedef uint32_t hfs_block_alloc_flags_t;
OSErr BlockAllocate( ExtendedVCB *vcb,
u_int32_t startingBlock,
u_int32_t minBlocks,
u_int32_t maxBlocks,
hfs_block_alloc_flags_t flags,
u_int32_t *startBlock,
u_int32_t *actualBlocks );
struct rl_entry;
typedef struct hfs_alloc_extra_args {
uint32_t max_blocks;
struct rl_entry **reservation_in;
struct rl_entry **reservation_out;
int alignment;
int alignment_offset;
} hfs_alloc_extra_args_t;
errno_t hfs_block_alloc( hfsmount_t *hfsmp,
HFSPlusExtentDescriptor *extent,
hfs_block_alloc_flags_t flags,
hfs_alloc_extra_args_t *extra_args );
OSErr BlockDeallocate( ExtendedVCB *vcb,
u_int32_t firstBlock,
u_int32_t numBlocks,
hfs_block_alloc_flags_t flags );
OSErr BlockMarkAllocated( ExtendedVCB *vcb, u_int32_t startingBlock, u_int32_t numBlocks );
OSErr BlockMarkFree( ExtendedVCB *vcb, u_int32_t startingBlock, u_int32_t numBlocks );
OSErr BlockMarkFreeUnused( ExtendedVCB *vcb, u_int32_t startingBlock, u_int32_t numBlocks );
u_int32_t MetaZoneFreeBlocks( ExtendedVCB *vcb );
u_int32_t ScanUnmapBlocks( struct hfsmount *hfsmp );
int hfs_init_summary( struct hfsmount *hfsmp );
errno_t hfs_find_free_extents( struct hfsmount *hfsmp, void (*callback)(void *data, off_t), void *callback_arg );
void hfs_free_tentative( hfsmount_t *hfsmp, struct rl_entry **reservation );
void hfs_free_locked( hfsmount_t *hfsmp, struct rl_entry **reservation );
u_int32_t GetTimeUTC( void );
u_int32_t LocalToUTC( u_int32_t localTime );
u_int32_t UTCToLocal( u_int32_t utcTime );
#endif