📄 fatprocs.h
字号:
/*++
Copyright (c) 1989-2000 Microsoft Corporation
Module Name:
FatProcs.h
Abstract:
This module defines all of the globally used procedures in the FAT
file system.
--*/
#ifndef _FATPROCS_
#define _FATPROCS_
#include <ntifs.h>
#include <ntddcdrm.h>
#include <ntdddisk.h>
#include <ntddstor.h>
#include "nodetype.h"
#include "Fat.h"
#include "Lfn.h"
#include "FatStruc.h"
#include "FatData.h"
#ifndef INLINE
#define INLINE __inline
#endif
//
// We must explicitly tag our allocations.
//
#undef FsRtlAllocatePool
#undef FsRtlAllocatePoolWithQuota
//
// A function that returns finished denotes if it was able to complete the
// operation (TRUE) or could not complete the operation (FALSE) because the
// wait value stored in the irp context was false and we would have had
// to block for a resource or I/O
//
typedef BOOLEAN FINISHED;
//
// Size (characters) of stack allocated name component buffers in
// the create/rename paths.
//
#define FAT_CREATE_INITIAL_NAME_BUF_SIZE 32
//
// Some string buffer handling functions, implemented in strucsup.c
//
VOID
FatFreeStringBuffer(
IN PVOID String
);
VOID
FatEnsureStringBufferEnough(
IN OUT PVOID String,
IN USHORT DesiredBufferSize
);
BOOLEAN
FatAddMcbEntry (
IN PVCB Vcb,
IN PLARGE_MCB Mcb,
IN VBO Vbo,
IN LBO Lbo,
IN ULONG SectorCount
);
BOOLEAN
FatLookupMcbEntry (
IN PVCB Vcb,
IN PLARGE_MCB Mcb,
IN VBO Vbo,
OUT PLBO Lbo,
OUT PULONG SectorCount OPTIONAL,
OUT PULONG Index OPTIONAL
);
BOOLEAN
FatLookupLastMcbEntry (
IN PVCB Vcb,
IN PLARGE_MCB Mcb,
OUT PVBO Vbo,
OUT PLBO Lbo,
OUT PULONG Index OPTIONAL
);
BOOLEAN
FatGetNextMcbEntry (
IN PVCB Vcb,
IN PLARGE_MCB Mcb,
IN ULONG RunIndex,
OUT PVBO Vbo,
OUT PLBO Lbo,
OUT PULONG SectorCount
);
VOID
FatRemoveMcbEntry (
IN PVCB Vcb,
IN PLARGE_MCB Mcb,
IN VBO Vbo,
IN ULONG SectorCount
);
//
// File access check routine, implemented in AcChkSup.c
//
BOOLEAN
FatCheckFileAccess (
PIRP_CONTEXT IrpContext,
IN UCHAR DirentAttributes,
IN PACCESS_MASK DesiredAccess
);
NTSTATUS
FatExplicitDeviceAccessGranted (
IN PIRP_CONTEXT IrpContext,
IN PDEVICE_OBJECT DeviceObject,
IN PACCESS_STATE AccessState,
IN KPROCESSOR_MODE ProcessorMode
);
//
// Allocation support routines, implemented in AllocSup.c
//
INLINE
BOOLEAN
FatIsIoRangeValid (
IN PVCB Vcb,
IN LARGE_INTEGER Start,
IN ULONG Length
)
/*++
Routine Description:
This routine enforces the restriction that object space must be
representable in 32 bits.
Arguments:
Vcb - the volume the range is on
Start - starting byte (zero based) of the range
Length - size of the range
Return Value:
BOOLEAN - if, considering the cluster size, the neccesary size of
the object to contain the range can be represented in 32 bits.
--*/
{
//
// The only restriction on a FAT object is that the filesize must
// fit in 32bits, i.e. <= 0xffffffff. This then implies that the
// range of valid byte offsets is [0, fffffffe].
//
// Two phases which check for illegality
//
// - if the high 32bits are nonzero
// - if the length would cause a 32bit overflow
//
return !(Start.HighPart ||
Start.LowPart + Length < Start.LowPart);
}
VOID
FatSetupAllocationSupport (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb
);
VOID
FatTearDownAllocationSupport (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb
);
VOID
FatLookupFileAllocation (
IN PIRP_CONTEXT IrpContext,
IN PFCB FcbOrDcb,
IN VBO Vbo,
OUT PLBO Lbo,
OUT PULONG ByteCount,
OUT PBOOLEAN Allocated,
OUT PBOOLEAN EndOnMax,
OUT PULONG Index OPTIONAL
);
VOID
FatAddFileAllocation (
IN PIRP_CONTEXT IrpContext,
IN PFCB FcbOrDcb,
IN PFILE_OBJECT FileObject OPTIONAL,
IN ULONG AllocationSize
);
VOID
FatTruncateFileAllocation (
IN PIRP_CONTEXT IrpContext,
IN PFCB FcbOrDcb,
IN ULONG AllocationSize
);
VOID
FatLookupFileAllocationSize (
IN PIRP_CONTEXT IrpContext,
IN PFCB FcbOrDcb
);
VOID
FatAllocateDiskSpace (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN ULONG AbsoluteClusterHint,
IN OUT PULONG ByteCount,
IN BOOLEAN ExactMatchRequired,
OUT PLARGE_MCB Mcb
);
VOID
FatDeallocateDiskSpace (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN PLARGE_MCB Mcb
);
VOID
FatSplitAllocation (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN OUT PLARGE_MCB Mcb,
IN VBO SplitAtVbo,
OUT PLARGE_MCB RemainingMcb
);
VOID
FatMergeAllocation (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN OUT PLARGE_MCB Mcb,
IN PLARGE_MCB SecondMcb
);
VOID
FatSetFatEntry (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN ULONG FatIndex,
IN FAT_ENTRY FatEntry
);
UCHAR
FatLogOf(
IN ULONG Value
);
//
// Buffer control routines for data caching, implemented in CacheSup.c
//
VOID
FatReadVolumeFile (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN VBO StartingVbo,
IN ULONG ByteCount,
OUT PBCB *Bcb,
OUT PVOID *Buffer
);
VOID
FatPrepareWriteVolumeFile (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN VBO StartingVbo,
IN ULONG ByteCount,
OUT PBCB *Bcb,
OUT PVOID *Buffer,
IN BOOLEAN Reversible,
IN BOOLEAN Zero
);
VOID
FatReadDirectoryFile (
IN PIRP_CONTEXT IrpContext,
IN PDCB Dcb,
IN VBO StartingVbo,
IN ULONG ByteCount,
IN BOOLEAN Pin,
OUT PBCB *Bcb,
OUT PVOID *Buffer,
OUT PNTSTATUS Status
);
VOID
FatPrepareWriteDirectoryFile (
IN PIRP_CONTEXT IrpContext,
IN PDCB Dcb,
IN VBO StartingVbo,
IN ULONG ByteCount,
OUT PBCB *Bcb,
OUT PVOID *Buffer,
IN BOOLEAN Zero,
IN BOOLEAN Reversible,
OUT PNTSTATUS Status
);
VOID
FatOpenDirectoryFile (
IN PIRP_CONTEXT IrpContext,
IN PDCB Dcb
);
PFILE_OBJECT
FatOpenEaFile (
IN PIRP_CONTEXT IrpContext,
IN PFCB EaFcb
);
VOID
FatCloseEaFile (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN BOOLEAN FlushFirst
);
VOID
FatSetDirtyBcb (
IN PIRP_CONTEXT IrpContext,
IN PBCB Bcb,
IN PVCB Vcb OPTIONAL,
IN BOOLEAN Reversible
);
VOID
FatRepinBcb (
IN PIRP_CONTEXT IrpContext,
IN PBCB Bcb
);
VOID
FatUnpinRepinnedBcbs (
IN PIRP_CONTEXT IrpContext
);
FINISHED
FatZeroData (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN PFILE_OBJECT FileObject,
IN ULONG StartingZero,
IN ULONG ByteCount
);
NTSTATUS
FatCompleteMdl (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp
);
VOID
FatPinMappedData (
IN PIRP_CONTEXT IrpContext,
IN PDCB Dcb,
IN VBO StartingVbo,
IN ULONG ByteCount,
OUT PBCB *Bcb
);
//
// VOID
// FatUnpinBcb (
// IN PIRP_CONTEXT IrpContext,
// IN OUT PBCB Bcb,
// );
//
//
// This macro unpins a Bcb, in the checked build make sure all
// requests unpin all Bcbs before leaving.
//
#if DBG
#define FatUnpinBcb(IRPCONTEXT,BCB) { \
if ((BCB) != NULL) { \
CcUnpinData((BCB)); \
ASSERT( (IRPCONTEXT)->PinCount ); \
(IRPCONTEXT)->PinCount -= 1; \
(BCB) = NULL; \
} \
}
#else
#define FatUnpinBcb(IRPCONTEXT,BCB) { \
if ((BCB) != NULL) { \
CcUnpinData((BCB)); \
(BCB) = NULL; \
} \
}
#endif // DBG
VOID
FatSyncUninitializeCacheMap (
IN PIRP_CONTEXT IrpContext,
IN PFILE_OBJECT FileObject
);
//
// Device I/O routines, implemented in DevIoSup.c
//
// These routines perform the actual device read and writes. They only affect
// the on disk structure and do not alter any other data structures.
//
VOID
FatPagingFileIo (
IN PIRP Irp,
IN PFCB Fcb
);
NTSTATUS
FatNonCachedIo (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp,
IN PFCB FcbOrDcb,
IN ULONG StartingVbo,
IN ULONG ByteCount,
IN ULONG UserByteCount
);
VOID
FatNonCachedNonAlignedRead (
IN PIRP_CONTEXT IrpContext,
IN PIRP Irp,
IN PFCB FcbOrDcb,
IN ULONG StartingVbo,
IN ULONG ByteCount
);
VOID
FatMultipleAsync (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN PIRP Irp,
IN ULONG MultipleIrpCount,
IN PIO_RUN IoRuns
);
VOID
FatSingleAsync (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN LBO Lbo,
IN ULONG ByteCount,
IN PIRP Irp
);
VOID
FatWaitSync (
IN PIRP_CONTEXT IrpContext
);
VOID
FatLockUserBuffer (
IN PIRP_CONTEXT IrpContext,
IN OUT PIRP Irp,
IN LOCK_OPERATION Operation,
IN ULONG BufferLength
);
PVOID
FatBufferUserBuffer (
IN PIRP_CONTEXT IrpContext,
IN OUT PIRP Irp,
IN ULONG BufferLength
);
PVOID
FatMapUserBuffer (
IN PIRP_CONTEXT IrpContext,
IN OUT PIRP Irp
);
NTSTATUS
FatToggleMediaEjectDisable (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN BOOLEAN PreventRemoval
);
NTSTATUS
FatPerformDevIoCtrl (
IN PIRP_CONTEXT IrpContext,
IN ULONG IoControlCode,
IN PDEVICE_OBJECT Device,
OUT PVOID OutputBuffer OPTIONAL,
IN ULONG OutputBufferLength,
IN BOOLEAN InternalDeviceIoControl,
IN BOOLEAN OverrideVerify,
OUT PIO_STATUS_BLOCK Iosb OPTIONAL
);
//
// Dirent support routines, implemented in DirSup.c
//
//
// Tunneling is a deletion precursor (all tunneling cases do
// not involve deleting dirents, however)
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -