ReactOS  0.4.13-dev-563-g0561610
memory.c File Reference
#include "ext2fs.h"
Include dependency graph for memory.c:

Go to the source code of this file.

Macros

#define is_power_of_2(x)   ((x) != 0 && (((x) & ((x) - 1)) == 0))
 

Functions

PEXT2_IRP_CONTEXT Ext2AllocateIrpContext (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID Ext2FreeIrpContext (IN PEXT2_IRP_CONTEXT IrpContext)
 
PEXT2_FCB Ext2AllocateFcb (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
 
VOID Ext2UnlinkFcb (IN PEXT2_FCB Fcb)
 
VOID Ext2FreeFcb (IN PEXT2_FCB Fcb)
 
VOID Ext2ReleaseFcb (IN PEXT2_FCB Fcb)
 
VOID Ext2InsertFcb (PEXT2_VCB Vcb, PEXT2_FCB Fcb)
 
PEXT2_CCB Ext2AllocateCcb (ULONG Flags, PEXT2_MCB SymLink)
 
VOID Ext2FreeCcb (IN PEXT2_VCB Vcb, IN PEXT2_CCB Ccb)
 
PEXT2_INODE Ext2AllocateInode (PEXT2_VCB Vcb)
 
VOID Ext2DestroyInode (IN PEXT2_VCB Vcb, IN PEXT2_INODE inode)
 
struct dentryExt2AllocateEntry ()
 
VOID Ext2FreeEntry (IN struct dentry *de)
 
struct dentryExt2BuildEntry (PEXT2_VCB Vcb, PEXT2_MCB Dcb, PUNICODE_STRING FileName)
 
PEXT2_EXTENT Ext2AllocateExtent ()
 
VOID Ext2FreeExtent (IN PEXT2_EXTENT Extent)
 
ULONG Ext2CountExtents (IN PEXT2_EXTENT Chain)
 
VOID Ext2JointExtents (IN PEXT2_EXTENT Chain, IN PEXT2_EXTENT Extent)
 
VOID Ext2DestroyExtentChain (IN PEXT2_EXTENT Chain)
 
BOOLEAN Ext2ListExtents (PLARGE_MCB Extents)
 
VOID Ext2CheckExtent (PLARGE_MCB Zone, LONGLONG Vbn, LONGLONG Lbn, LONGLONG Length, BOOLEAN bAdded)
 
VOID Ext2ClearAllExtents (PLARGE_MCB Zone)
 
BOOLEAN Ext2AddVcbExtent (IN PEXT2_VCB Vcb, IN LONGLONG Vbn, IN LONGLONG Length)
 
BOOLEAN Ext2RemoveVcbExtent (IN PEXT2_VCB Vcb, IN LONGLONG Vbn, IN LONGLONG Length)
 
BOOLEAN Ext2LookupVcbExtent (IN PEXT2_VCB Vcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG Length)
 
BOOLEAN Ext2AddMcbExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Lbn, IN LONGLONG Length)
 
BOOLEAN Ext2RemoveMcbExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Length)
 
BOOLEAN Ext2LookupMcbExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG Length)
 
BOOLEAN Ext2AddMcbMetaExts (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Block, IN ULONG Length)
 
BOOLEAN Ext2RemoveMcbMetaExts (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Block, IN ULONG Length)
 
BOOLEAN Ext2AddBlockExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Block, IN ULONG Number)
 
BOOLEAN Ext2LookupBlockExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN PULONG Block, IN PULONG Mapped)
 
BOOLEAN Ext2RemoveBlockExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Number)
 
NTSTATUS Ext2InitializeZone (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
 
NTSTATUS Ext2BuildExtents (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONGLONG Offset, IN ULONG Size, IN BOOLEAN bAlloc, OUT PEXT2_EXTENT *Chain)
 
BOOLEAN Ext2BuildName (IN OUT PUNICODE_STRING Target, IN PUNICODE_STRING File, IN PUNICODE_STRING Parent)
 
PEXT2_MCB Ext2AllocateMcb (IN PEXT2_VCB Vcb, IN PUNICODE_STRING FileName, IN PUNICODE_STRING Parent, IN ULONG FileAttr)
 
VOID Ext2FreeMcb (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
 
PEXT2_MCB Ext2SearchMcb (PEXT2_VCB Vcb, PEXT2_MCB Parent, PUNICODE_STRING FileName)
 
PEXT2_MCB Ext2SearchMcbWithoutLock (PEXT2_MCB Parent, PUNICODE_STRING FileName)
 
VOID Ext2InsertMcb (PEXT2_VCB Vcb, PEXT2_MCB Parent, PEXT2_MCB Child)
 
BOOLEAN Ext2RemoveMcb (PEXT2_VCB Vcb, PEXT2_MCB Mcb)
 
VOID Ext2CleanupAllMcbs (PEXT2_VCB Vcb)
 
BOOLEAN Ext2CheckSetBlock (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, LONGLONG Block)
 
BOOLEAN Ext2CheckBitmapConsistency (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
 
VOID Ext2InsertVcb (PEXT2_VCB Vcb)
 
VOID Ext2RemoveVcb (PEXT2_VCB Vcb)
 
NTSTATUS Ext2QueryVolumeParams (IN PEXT2_VCB Vcb, IN PUNICODE_STRING Params)
 
VOID Ext2ParseRegistryVolumeParams (IN PUNICODE_STRING Params, OUT PEXT2_VOLUME_PROPERTY3 Property)
 
NTSTATUS Ext2PerformRegistryVolumeParams (IN PEXT2_VCB Vcb)
 
NTSTATUS Ext2InitializeLabel (IN PEXT2_VCB Vcb, IN PEXT2_SUPER_BLOCK Sb)
 
static __inline BOOLEAN Ext2IsNullUuid (__u8 *uuid)
 
NTSTATUS Ext2InitializeVcb (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_SUPER_BLOCK sb, IN PDEVICE_OBJECT TargetDevice, IN PDEVICE_OBJECT VolumeDevice, IN PVPB Vpb)
 
VOID Ext2TearDownStream (IN PEXT2_VCB Vcb)
 
VOID Ext2DestroyVcb (IN PEXT2_VCB Vcb)
 
VOID Ext2SyncUninitializeCacheMap (IN PFILE_OBJECT FileObject)
 
VOID Ext2LinkTailMcb (PEXT2_VCB Vcb, PEXT2_MCB Mcb)
 
VOID Ext2LinkHeadMcb (PEXT2_VCB Vcb, PEXT2_MCB Mcb)
 
VOID Ext2UnlinkMcb (PEXT2_VCB Vcb, PEXT2_MCB Mcb)
 
PEXT2_MCB Ext2FirstUnusedMcb (PEXT2_VCB Vcb, BOOLEAN Wait, ULONG Number)
 
VOID NTAPI Ext2McbReaperThread (PVOID Context)
 
BOOLEAN Ext2QueryUnusedBH (PEXT2_VCB Vcb, PLIST_ENTRY head)
 
VOID NTAPI Ext2bhReaperThread (PVOID Context)
 
BOOLEAN Ext2QueryUnusedFcb (PEXT2_VCB Vcb, PLIST_ENTRY list)
 
VOID NTAPI Ext2FcbReaperThread (PVOID Context)
 
NTSTATUS Ext2StartReaper (PEXT2_REAPER Reaper, EXT2_REAPER_RELEASE Free)
 
VOID NTAPI Ext2StopReaper (PEXT2_REAPER Reaper)
 

Variables

PEXT2_GLOBAL Ext2Global
 

Macro Definition Documentation

◆ is_power_of_2

#define is_power_of_2 (   x)    ((x) != 0 && (((x) & ((x) - 1)) == 0))

Definition at line 2294 of file memory.c.

Function Documentation

◆ Ext2AddBlockExtent()

BOOLEAN Ext2AddBlockExtent ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Start,
IN ULONG  Block,
IN ULONG  Number 
)

Definition at line 1027 of file memory.c.

1034 {
1035  LONGLONG Vbn = 0;
1036  LONGLONG Lbn = 0;
1037  LONGLONG Length = 0;
1038 
1039  Vbn = ((LONGLONG) Start) << BLOCK_BITS;
1040  Lbn = ((LONGLONG) Block) << BLOCK_BITS;
1041  Length = ((LONGLONG)Number << BLOCK_BITS);
1042 
1043  if (Mcb) {
1044 #if EXT2_DEBUG
1045  ULONG _block = 0, _mapped = 0;
1046  BOOLEAN _rc = Ext2LookupBlockExtent(Vcb, Mcb, Start, &_block, &_mapped);
1047  if (_rc && _block != 0 && (_block != Block)) {
1048  DbgBreak();
1049  }
1050 #endif
1051  return Ext2AddMcbExtent(Vcb, Mcb, Vbn, Lbn, Length);
1052 
1053  }
1054 
1055  ASSERT(Start == Block);
1056  return Ext2AddVcbExtent(Vcb, Vbn, Length);
1057 }
BOOLEAN Ext2AddMcbExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Lbn, IN LONGLONG Length)
Definition: memory.c:790
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Lbn
Definition: fsrtlfuncs.h:479
BOOLEAN Ext2LookupBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN PULONG Block, IN PULONG Mapped)
Definition: memory.c:1061
BOOLEAN Ext2AddVcbExtent(IN PEXT2_VCB Vcb, IN LONGLONG Vbn, IN LONGLONG Length)
Definition: memory.c:648
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Definition: partlist.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
_In_ LONGLONG Vbn
Definition: fsrtlfuncs.h:470
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46

Referenced by Ext2BuildExtents(), Ext2ExpandBlock(), Ext2ExpandExtent(), Ext2ExpandLast(), Ext2InitializeZone(), submit_bh_mdl(), and submit_bh_pin().

◆ Ext2AddMcbExtent()

BOOLEAN Ext2AddMcbExtent ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN LONGLONG  Vbn,
IN LONGLONG  Lbn,
IN LONGLONG  Length 
)

Definition at line 790 of file memory.c.

797 {
798  ULONG TriedTimes = 0;
799  LONGLONG Base = 0;
800  UCHAR Bits = 0;
801  BOOLEAN rc = FALSE;
802 
804  Bits = (UCHAR)BLOCK_BITS;
805 
806  ASSERT ((Vbn & (Base - 1)) == 0);
807  ASSERT ((Lbn & (Base - 1)) == 0);
808  ASSERT ((Length & (Base - 1)) == 0);
809 
810  Vbn = (Vbn >> Bits) + 1;
811  Lbn = (Lbn >> Bits) + 1;
812  Length = (Length >> Bits);
813 
814 Again:
815 
816  _SEH2_TRY {
817 
819  &Mcb->Extents,
820  Vbn,
821  Lbn,
822  Length
823  );
824 
826 
827  DbgBreak();
828  rc = FALSE;
829  } _SEH2_END;
830 
831  if (!rc && ++TriedTimes < 10) {
832  Ext2Sleep(TriedTimes * 100);
833  goto Again;
834  }
835 
836  DEBUG(DL_EXT, ("Ext2AddMcbExtent: Vbn=%I64xh Lbn=%I64xh Length=%I64xh,"
837  " rc=%d Runs=%u\n", Vbn, Lbn, Length, rc,
838  FsRtlNumberOfRunsInLargeMcb(&Mcb->Extents)));
839 
840  if (rc) {
841  Ext2CheckExtent(&Mcb->Extents, Vbn, Lbn, Length, TRUE);
842  }
843 
844  return rc;
845 }
#define TRUE
Definition: types.h:120
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2327
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Lbn
Definition: fsrtlfuncs.h:479
ULONG NTAPI FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:769
VOID Ext2CheckExtent(PLARGE_MCB Zone, LONGLONG Vbn, LONGLONG Lbn, LONGLONG Length, BOOLEAN bAdded)
Definition: memory.c:583
_SEH2_TRY
Definition: create.c:4250
#define DL_EXT
Definition: ext2fs.h:1406
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
VOID Ext2Sleep(ULONG ms)
Definition: misc.c:297
int64_t LONGLONG
Definition: typedefs.h:66
#define BLOCK_SIZE
Definition: dlist.c:220
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN NTAPI FsRtlAddLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Lbn, IN LONGLONG SectorCount)
Definition: largemcb.c:282
unsigned char UCHAR
Definition: xmlstorage.h:181
_SEH2_END
Definition: create.c:4424
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
_In_ LONGLONG Vbn
Definition: fsrtlfuncs.h:470
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by Ext2AddBlockExtent().

◆ Ext2AddMcbMetaExts()

BOOLEAN Ext2AddMcbMetaExts ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Block,
IN ULONG  Length 
)

Definition at line 941 of file memory.c.

947 {
948  ULONG TriedTimes = 0;
949  LONGLONG Lbn = Block + 1;
950  BOOLEAN rc = TRUE;
951 
952 Again:
953 
954  _SEH2_TRY {
955 
957  &Mcb->MetaExts,
958  Lbn,
959  Lbn,
960  Length
961  );
962 
964 
965  DbgBreak();
966  rc = FALSE;
967  } _SEH2_END;
968 
969  if (!rc && ++TriedTimes < 10) {
970  Ext2Sleep(TriedTimes * 100);
971  goto Again;
972  }
973 
974  DEBUG(DL_EXT, ("Ext2AddMcbMetaExts: Block: %xh-%xh rc=%d Runs=%u\n", Block,
975  Length, rc, FsRtlNumberOfRunsInLargeMcb(&Mcb->MetaExts)));
976 
977  if (rc) {
978  Ext2CheckExtent(&Mcb->MetaExts, Lbn, Lbn, Length, TRUE);
979  }
980 
981  return rc;
982 }
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Lbn
Definition: fsrtlfuncs.h:479
ULONG NTAPI FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:769
VOID Ext2CheckExtent(PLARGE_MCB Zone, LONGLONG Vbn, LONGLONG Lbn, LONGLONG Length, BOOLEAN bAdded)
Definition: memory.c:583
_SEH2_TRY
Definition: create.c:4250
#define DL_EXT
Definition: ext2fs.h:1406
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
VOID Ext2Sleep(ULONG ms)
Definition: misc.c:297
int64_t LONGLONG
Definition: typedefs.h:66
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI FsRtlAddLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Lbn, IN LONGLONG SectorCount)
Definition: largemcb.c:282
_SEH2_END
Definition: create.c:4424
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by Ext2ExpandBlock(), Ext2ExpandLast(), and Ext2GetBlock().

◆ Ext2AddVcbExtent()

BOOLEAN Ext2AddVcbExtent ( IN PEXT2_VCB  Vcb,
IN LONGLONG  Vbn,
IN LONGLONG  Length 
)

Definition at line 648 of file memory.c.

653 {
654  ULONG TriedTimes = 0;
655 
656  LONGLONG Offset = 0;
657  BOOLEAN rc = FALSE;
658 
659  Offset = Vbn & (~(Vcb->IoUnitSize - 1));
660  Length = (Vbn - Offset + Length + Vcb->IoUnitSize - 1) &
661  ~(Vcb->IoUnitSize - 1);
662 
663  ASSERT ((Offset & (Vcb->IoUnitSize - 1)) == 0);
664  ASSERT ((Length & (Vcb->IoUnitSize - 1)) == 0);
665 
666  Offset = (Offset >> Vcb->IoUnitBits) + 1;
667  Length = (Length >> Vcb->IoUnitBits);
668 
669 Again:
670 
671  _SEH2_TRY {
673  &Vcb->Extents,
674  Offset,
675  Offset,
676  Length
677  );
679  DbgBreak();
680  rc = FALSE;
681  } _SEH2_END;
682 
683  if (!rc && ++TriedTimes < 10) {
684  Ext2Sleep(TriedTimes * 100);
685  goto Again;
686  }
687 
688  DEBUG(DL_EXT, ("Ext2AddVcbExtent: Vbn=%I64xh Length=%I64xh,"
689  " rc=%d Runs=%u\n", Offset, Length, rc,
690  FsRtlNumberOfRunsInLargeMcb(&Vcb->Extents)));
691 
692  if (rc) {
693  Ext2CheckExtent(&Vcb->Extents, Offset, Offset, Length, TRUE);
694  }
695 
696  return rc;
697 }
#define TRUE
Definition: types.h:120
ULONG NTAPI FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:769
VOID Ext2CheckExtent(PLARGE_MCB Zone, LONGLONG Vbn, LONGLONG Lbn, LONGLONG Length, BOOLEAN bAdded)
Definition: memory.c:583
_SEH2_TRY
Definition: create.c:4250
#define DL_EXT
Definition: ext2fs.h:1406
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
VOID Ext2Sleep(ULONG ms)
Definition: misc.c:297
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN NTAPI FsRtlAddLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Lbn, IN LONGLONG SectorCount)
Definition: largemcb.c:282
_SEH2_END
Definition: create.c:4424
_In_ LONGLONG Vbn
Definition: fsrtlfuncs.h:470
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by Ext2AddBlockExtent(), Ext2FreeBlock(), Ext2GetBlock(), Ext2TruncateBlock(), and Ext2WriteVolume().

◆ Ext2AllocateCcb()

PEXT2_CCB Ext2AllocateCcb ( ULONG  Flags,
PEXT2_MCB  SymLink 
)

Definition at line 320 of file memory.c.

321 {
322  PEXT2_CCB Ccb;
323 
324  Ccb = (PEXT2_CCB) (ExAllocateFromNPagedLookasideList(
326  if (!Ccb) {
327  return NULL;
328  }
329 
330  DEBUG(DL_RES, ( "ExtAllocateCcb: Ccb created: %ph.\n", Ccb));
331 
332  RtlZeroMemory(Ccb, sizeof(EXT2_CCB));
333 
335  Ccb->Identifier.Size = sizeof(EXT2_CCB);
336  Ccb->Flags = Flags;
337 
338  Ccb->SymLink = SymLink;
339  if (SymLink) {
340  ASSERT(SymLink->Refercount > 0);
341  Ext2ReferMcb(SymLink);
342  DEBUG(DL_INF, ( "ExtAllocateCcb: Ccb SymLink: %wZ.\n",
343  &Ccb->SymLink->FullName));
344  }
345 
346  Ccb->DirectorySearchPattern.Length = 0;
347  Ccb->DirectorySearchPattern.MaximumLength = 0;
348  Ccb->DirectorySearchPattern.Buffer = 0;
349 
350  INC_MEM_COUNT(PS_CCB, Ccb, sizeof(EXT2_CCB));
351 
352  return Ccb;
353 }
#define PS_CCB
Definition: common.h:19
#define Ext2ReferMcb(Mcb)
Definition: ext2fs.h:986
NPAGED_LOOKASIDE_LIST Ext2CcbLookasideList
Definition: ext2fs.h:546
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:598
struct _EXT2_CCB EXT2_CCB
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define DL_INF
Definition: ext2fs.h:1399
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Flags
Definition: ntfs.h:520
ULONG Refercount
Definition: ext2fs.h:917
ULONG Type
Definition: ntfs.h:95
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define DL_RES
Definition: ext2fs.h:1403
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DEBUG(args)
Definition: rdesktop.h:129
struct _EXT2_CCB * PEXT2_CCB
ULONG Size
Definition: ntfs.h:96

Referenced by Ext2CreateFile(), and Ext2CreateVolume().

◆ Ext2AllocateEntry()

struct dentry* Ext2AllocateEntry ( )

Definition at line 416 of file memory.c.

417 {
418  struct dentry *de;
419 
420  de = (struct dentry *)ExAllocateFromNPagedLookasideList(
422  if (!de) {
423  return NULL;
424  }
425 
426  RtlZeroMemory(de, sizeof(struct dentry));
427  INC_MEM_COUNT(PS_DENTRY, de, sizeof(struct dentry));
428 
429  return de;
430 }
#define PS_DENTRY
Definition: common.h:34
NPAGED_LOOKASIDE_LIST Ext2DentryLookasideList
Definition: ext2fs.h:549
smooth NULL
Definition: ftsmooth.c:416
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:598
Definition: fs.h:117
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by Ext2BuildEntry().

◆ Ext2AllocateExtent()

PEXT2_EXTENT Ext2AllocateExtent ( )

Definition at line 488 of file memory.c.

489 {
491 
492  Extent = (PEXT2_EXTENT)ExAllocateFromNPagedLookasideList(
494  if (!Extent) {
495  return NULL;
496  }
497 
498  RtlZeroMemory(Extent, sizeof(EXT2_EXTENT));
500 
501  return Extent;
502 }
#define PS_EXTENT
Definition: common.h:21
NPAGED_LOOKASIDE_LIST Ext2ExtLookasideList
Definition: ext2fs.h:548
smooth NULL
Definition: ftsmooth.c:416
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:598
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct _EXT2_EXTENT * PEXT2_EXTENT

Referenced by Ext2BuildExtents(), and Ext2WriteVolume().

◆ Ext2AllocateFcb()

PEXT2_FCB Ext2AllocateFcb ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb 
)

Definition at line 131 of file memory.c.

135 {
136  PEXT2_FCB Fcb;
137 
139 
140  Fcb = (PEXT2_FCB) ExAllocateFromNPagedLookasideList(
142 
143  if (!Fcb) {
144  return NULL;
145  }
146 
147  RtlZeroMemory(Fcb, sizeof(EXT2_FCB));
149  Fcb->Identifier.Size = sizeof(EXT2_FCB);
150 
151 #ifndef _WIN2K_TARGET_
152  ExInitializeFastMutex(&Fcb->Mutex);
153  FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->Mutex);
154 #endif
155 
156  FsRtlInitializeOplock(&Fcb->Oplock);
158  &Fcb->FileLockAnchor,
159  NULL,
160  NULL );
161 
162  Fcb->OpenHandleCount = 0;
163  Fcb->ReferenceCount = 0;
164  Fcb->Vcb = Vcb;
165  Fcb->Inode = &Mcb->Inode;
166 
167  ASSERT(Mcb->Fcb == NULL);
168  Ext2ReferMcb(Mcb);
169  Fcb->Mcb = Mcb;
170  Mcb->Fcb = Fcb;
171 
172  DEBUG(DL_RES, ("Ext2AllocateFcb: Fcb %p created: %wZ.\n",
173  Fcb, &Fcb->Mcb->FullName));
174 
176  Fcb->Header.NodeTypeCode = (USHORT) EXT2FCB;
177  Fcb->Header.NodeByteSize = sizeof(EXT2_FCB);
178  Fcb->Header.IsFastIoPossible = FastIoIsNotPossible;
179  Fcb->Header.Resource = &(Fcb->MainResource);
180  Fcb->Header.PagingIoResource = &(Fcb->PagingIoResource);
181 
182  Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size;
183  Fcb->Header.ValidDataLength.QuadPart = Mcb->Inode.i_size;
184  Fcb->Header.AllocationSize.QuadPart = CEILING_ALIGNED(ULONGLONG,
185  Fcb->Header.FileSize.QuadPart, (ULONGLONG)Vcb->BlockSize);
186 
187  Fcb->SectionObject.DataSectionObject = NULL;
188  Fcb->SectionObject.SharedCacheMap = NULL;
189  Fcb->SectionObject.ImageSectionObject = NULL;
190 
193 
195 
196  INC_MEM_COUNT(PS_FCB, Fcb, sizeof(EXT2_FCB));
197 
198  return Fcb;
199 }
struct _EXT2_FCB * PEXT2_FCB
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
VOID NTAPI FsRtlInitializeFileLock(IN PFILE_LOCK FileLock, IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteLockIrpRoutine OPTIONAL, IN PUNLOCK_ROUTINE UnlockRoutine OPTIONAL)
Definition: filelock.c:1261
#define CEILING_ALIGNED(T, A, B)
Definition: ext2fs.h:111
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
NPAGED_LOOKASIDE_LIST Ext2FcbLookasideList
Definition: ext2fs.h:545
#define Ext2ReferMcb(Mcb)
Definition: ext2fs.h:986
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
smooth NULL
Definition: ftsmooth.c:416
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:598
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1619
struct _EXT2_FCB EXT2_FCB
VOID Ext2InsertFcb(PEXT2_VCB Vcb, PEXT2_FCB Fcb)
Definition: memory.c:309
ULONG OpenHandleCount
Definition: ntfs.h:521
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define PS_FCB
Definition: common.h:18
uint64_t ULONGLONG
Definition: typedefs.h:65
VOID NTAPI FsRtlInitializeOplock(IN OUT POPLOCK Oplock)
Definition: oplock.c:1402
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CD_MCB Mcb
Definition: cdstruc.h:1022
ULONG Type
Definition: ntfs.h:95
ERESOURCE MainResource
Definition: ntfs.h:512
#define DL_RES
Definition: ext2fs.h:1403
unsigned short USHORT
Definition: pedump.c:61
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
ERESOURCE PagingIoResource
Definition: ntfs.h:511
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PVCB Vcb
Definition: cdstruc.h:939
#define DEBUG(args)
Definition: rdesktop.h:129
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG Size
Definition: ntfs.h:96

Referenced by Ext2CreateFile(), Ext2DeleteFile(), Ext2DeleteReparsePoint(), Ext2SetLinkInfo(), Ext2SetRenameInfo(), and Ext2SetReparsePoint().

◆ Ext2AllocateInode()

PEXT2_INODE Ext2AllocateInode ( PEXT2_VCB  Vcb)

Definition at line 387 of file memory.c.

388 {
389  PVOID inode = NULL;
390 
391  inode = ExAllocateFromNPagedLookasideList(
392  &(Vcb->InodeLookasideList));
393  if (!inode) {
394  return NULL;
395  }
396 
398 
399  DEBUG(DL_INF, ("ExtAllocateInode: Inode created: %ph.\n", inode));
401 
402  return inode;
403 }
#define INODE_SIZE
Definition: ext2fs.h:92
Definition: fs.h:78
#define PS_EXT2_INODE
Definition: common.h:33
smooth NULL
Definition: ftsmooth.c:416
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:598
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DEBUG(args)
Definition: rdesktop.h:129

Referenced by ext4_fs_get_xattr_ref().

◆ Ext2AllocateIrpContext()

PEXT2_IRP_CONTEXT Ext2AllocateIrpContext ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 35 of file memory.c.

37 {
39  PEXT2_IRP_CONTEXT IrpContext;
40 
42  ASSERT(Irp != NULL);
43 
45 
46  IrpContext = (PEXT2_IRP_CONTEXT) (
47  ExAllocateFromNPagedLookasideList(
49 
50  if (IrpContext == NULL) {
51  return NULL;
52  }
53 
54  RtlZeroMemory(IrpContext, sizeof(EXT2_IRP_CONTEXT) );
55 
56  IrpContext->Identifier.Type = EXT2ICX;
57  IrpContext->Identifier.Size = sizeof(EXT2_IRP_CONTEXT);
58 
59  IrpContext->Irp = Irp;
60  IrpContext->MajorFunction = irpSp->MajorFunction;
61  IrpContext->MinorFunction = irpSp->MinorFunction;
62  IrpContext->DeviceObject = DeviceObject;
63  IrpContext->FileObject = irpSp->FileObject;
64  if (NULL != IrpContext->FileObject) {
65  IrpContext->Fcb = (PEXT2_FCB)IrpContext->FileObject->FsContext;
66  IrpContext->Ccb = (PEXT2_CCB)IrpContext->FileObject->FsContext2;
67  }
68 
69  if (IrpContext->FileObject != NULL) {
70  IrpContext->RealDevice = IrpContext->FileObject->DeviceObject;
71  } else if (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL) {
72  if (irpSp->Parameters.MountVolume.Vpb) {
73  IrpContext->RealDevice = irpSp->Parameters.MountVolume.Vpb->RealDevice;
74  }
75  }
76 
77  if (IsFlagOn(irpSp->Flags, SL_WRITE_THROUGH)) {
79  }
80 
83  }
84 
85  if (IrpContext->MajorFunction == IRP_MJ_CLEANUP ||
86  IrpContext->MajorFunction == IRP_MJ_CLOSE ||
87  IrpContext->MajorFunction == IRP_MJ_SHUTDOWN ||
89  IrpContext->MajorFunction == IRP_MJ_PNP ) {
90 
91  if (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL ||
92  IrpContext->MajorFunction == IRP_MJ_PNP) {
95  SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
96  }
97  } else {
98  SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
99  }
100 
101  } else if (IoIsOperationSynchronous(Irp)) {
102 
103  SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
104  }
105 
106  IrpContext->IsTopLevel = (IoGetTopLevelIrp() == Irp);
107  IrpContext->ExceptionInProgress = FALSE;
108  INC_IRP_COUNT(IrpContext);
109 
110  return IrpContext;
111 }
struct _EXT2_FCB * PEXT2_FCB
#define IRP_CONTEXT_FLAG_VERIFY_READ
Definition: ext2fs.h:1083
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
NPAGED_LOOKASIDE_LIST Ext2IrpContextLookasideList
Definition: ext2fs.h:544
#define IRP_CONTEXT_FLAG_WRITE_THROUGH
Definition: ext2fs.h:1079
PDEVICE_OBJECT DeviceObject
Definition: ext2fs.h:1051
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
PIRP Irp
Definition: ext2fs.h:1041
#define INC_IRP_COUNT(IrpContext)
Definition: ext2fs.h:600
ULONG Flags
Definition: ext2fs.h:1044
BOOLEAN NTAPI IoIsOperationSynchronous(IN PIRP Irp)
Definition: irp.c:1882
PEXT2_CCB Ccb
Definition: ext2fs.h:1060
EXT2_IDENTIFIER_TYPE Type
Definition: ext2fs.h:472
PDEVICE_OBJECT RealDevice
Definition: ext2fs.h:1054
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1779
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
EXT2_IDENTIFIER Identifier
Definition: ext2fs.h:1038
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
BOOLEAN IsTopLevel
Definition: ext2fs.h:1063
struct ext2_icb EXT2_IRP_CONTEXT
#define IRP_MJ_FILE_SYSTEM_CONTROL
irpSp
Definition: iofuncs.h:2671
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
PFILE_OBJECT FileObject
Definition: ext2fs.h:1057
PEXT2_FCB Fcb
Definition: ext2fs.h:1059
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
UCHAR MajorFunction
Definition: ext2fs.h:1047
struct ext2_icb * PEXT2_IRP_CONTEXT
#define SL_WRITE_THROUGH
Definition: iotypes.h:1780
#define IRP_MJ_CLEANUP
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
UCHAR MinorFunction
Definition: ext2fs.h:1048
BOOLEAN ExceptionInProgress
Definition: ext2fs.h:1069

Referenced by Ext2BuildRequest().

◆ Ext2AllocateMcb()

PEXT2_MCB Ext2AllocateMcb ( IN PEXT2_VCB  Vcb,
IN PUNICODE_STRING  FileName,
IN PUNICODE_STRING  Parent,
IN ULONG  FileAttr 
)

Definition at line 1430 of file memory.c.

1436 {
1437  PEXT2_MCB Mcb = NULL;
1439 
1440  /* need wake the reaper thread if there are many Mcb allocated */
1441  if (Ext2Global->PerfStat.Current.Mcb > (((ULONG)Ext2Global->MaxDepth) * 4)) {
1443  }
1444 
1445  /* allocate Mcb from LookasideList */
1446  Mcb = (PEXT2_MCB) (ExAllocateFromNPagedLookasideList(
1448 
1449  if (Mcb == NULL) {
1450  return NULL;
1451  }
1452 
1453  /* initialize Mcb header */
1454  RtlZeroMemory(Mcb, sizeof(EXT2_MCB));
1455  Mcb->Identifier.Type = EXT2MCB;
1456  Mcb->Identifier.Size = sizeof(EXT2_MCB);
1457  Mcb->FileAttr = FileAttr;
1458 
1459  Mcb->Inode.i_priv = (PVOID)Mcb;
1460  Mcb->Inode.i_sb = &Vcb->sb;
1461 
1462  /* initialize Mcb names */
1463  if (FileName) {
1464 
1465 #if EXT2_DEBUG
1466  if ( FileName->Length == 2 &&
1467  FileName->Buffer[0] == L'\\') {
1468  DEBUG(DL_RES, ( "Ext2AllocateMcb: Root Mcb is to be created !\n"));
1469  }
1470 
1471  if ( FileName->Length == 2 &&
1472  FileName->Buffer[0] == L'.') {
1473  DbgBreak();
1474  }
1475 
1476  if ( FileName->Length == 4 &&
1477  FileName->Buffer[0] == L'.' &&
1478  FileName->Buffer[1] == L'.' ) {
1479  DbgBreak();
1480  }
1481 #endif
1482 
1483  if (( FileName->Length >= 4 && FileName->Buffer[0] == L'.') &&
1484  ((FileName->Length == 4 && FileName->Buffer[1] != L'.') ||
1485  FileName->Length >= 6 )) {
1486  SetFlag(Mcb->FileAttr, FILE_ATTRIBUTE_HIDDEN);
1487  }
1488 
1489  if (!Ext2BuildName(&Mcb->ShortName, FileName, NULL)) {
1490  goto errorout;
1491  }
1492  if (!Ext2BuildName(&Mcb->FullName, FileName, Parent)) {
1493  goto errorout;
1494  }
1495  }
1496 
1497  /* initialize Mcb Extents, it will raise an expcetion if failed */
1498  _SEH2_TRY {
1500  FsRtlInitializeLargeMcb(&(Mcb->MetaExts), NonPagedPool);
1503  DbgBreak();
1504  } _SEH2_END;
1505 
1506  if (!NT_SUCCESS(Status)) {
1507  goto errorout;
1508  }
1509 
1510  INC_MEM_COUNT(PS_MCB, Mcb, sizeof(EXT2_MCB));
1511  DEBUG(DL_INF, ( "Ext2AllocateMcb: Mcb %wZ created.\n", &Mcb->FullName));
1512 
1513  return Mcb;
1514 
1515 errorout:
1516 
1517  if (Mcb) {
1518 
1519  if (Mcb->ShortName.Buffer) {
1520  DEC_MEM_COUNT(PS_MCB_NAME, Mcb->ShortName.Buffer,
1521  Mcb->ShortName.MaximumLength);
1522  Ext2FreePool(Mcb->ShortName.Buffer, EXT2_FNAME_MAGIC);
1523  }
1524 
1525  if (Mcb->FullName.Buffer) {
1526  DEC_MEM_COUNT(PS_MCB_NAME, Mcb->FullName.Buffer,
1527  Mcb->FullName.MaximumLength);
1528  Ext2FreePool(Mcb->FullName.Buffer, EXT2_FNAME_MAGIC);
1529  }
1530 
1531  ExFreeToNPagedLookasideList(&(Ext2Global->Ext2McbLookasideList), Mcb);
1532  }
1533 
1534  return NULL;
1535 }
NPAGED_LOOKASIDE_LIST Ext2McbLookasideList
Definition: ext2fs.h:547
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT MaxDepth
Definition: ext2fs.h:550
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
LONG NTSTATUS
Definition: precomp.h:26
EXT2_PERF_STATISTICS_V2 PerfStat
Definition: ext2fs.h:573
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:716
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
_SEH2_TRY
Definition: create.c:4250
BOOLEAN Ext2BuildName(IN OUT PUNICODE_STRING Target, IN PUNICODE_STRING File, IN PUNICODE_STRING Parent)
Definition: memory.c:1361
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID NTAPI FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb, IN POOL_TYPE PoolType)
Definition: largemcb.c:450
smooth NULL
Definition: ftsmooth.c:416
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:598
void * PVOID
Definition: retypes.h:9
#define EXT2_FNAME_MAGIC
Definition: ext2fs.h:293
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
KEVENT Wait
Definition: ext2fs.h:497
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
static const WCHAR L[]
Definition: oid.c:1250
struct _EXT2_MCB EXT2_MCB
Definition: ext2fs.h:479
Status
Definition: gdiplustypes.h:24
#define PS_MCB
Definition: common.h:20
#define DL_RES
Definition: ext2fs.h:1403
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
unsigned int ULONG
Definition: retypes.h:1
#define PS_MCB_NAME
Definition: common.h:25
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DbgBreak()
Definition: ext2fs.h:46
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
struct _EXT2_MCB * PEXT2_MCB
Definition: ext2fs.h:479
EXT2_REAPER McbReaper
Definition: ext2fs.h:540
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by Ext2InitializeVcb(), Ext2LoadInternalJournal(), and Ext2LookupFile().

◆ Ext2bhReaperThread()

VOID NTAPI Ext2bhReaperThread ( PVOID  Context)

Definition at line 3219 of file memory.c.

3222 {
3223  PEXT2_REAPER Reaper = Context;
3224  PEXT2_VCB Vcb = NULL;
3225  LIST_ENTRY List, *Link;
3227 
3228  BOOLEAN GlobalAcquired = FALSE;
3229  BOOLEAN DidNothing = FALSE;
3230  BOOLEAN NonWait = FALSE;
3231 
3232  _SEH2_TRY {
3233 
3234  Reaper->Thread = PsGetCurrentThread();
3235 
3236  /* wake up DirverEntry */
3237  KeSetEvent(&Reaper->Engine, 0, FALSE);
3238 
3239  /* now process looping */
3240  while (!IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP)) {
3241 
3242  /* wait until it is waken or it times out */
3243  if (NonWait) {
3244  Timeout.QuadPart = (LONGLONG)-10*1000*10;
3245  NonWait = FALSE;
3246  } else if (DidNothing) {
3247  Timeout.QuadPart = Timeout.QuadPart * 2;
3248  } else {
3249  Timeout.QuadPart = (LONGLONG)-10*1000*1000*10; /* 10 seconds */
3250  }
3252  &Reaper->Wait,
3253  Executive,
3254  KernelMode,
3255  FALSE,
3256  &Timeout
3257  );
3258 
3259  if (IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP))
3260  break;
3261 
3263 
3264  /* acquire global exclusive lock */
3266  GlobalAcquired = TRUE;
3267  /* search all Vcb to get unused resources freed to system */
3268  for (Link = Ext2Global->VcbList.Flink;
3269  Link != &(Ext2Global->VcbList);
3270  Link = Link->Flink ) {
3271 
3272  Vcb = CONTAINING_RECORD(Link, EXT2_VCB, Next);
3273  NonWait = Ext2QueryUnusedBH(Vcb, &List);
3274  }
3275  DidNothing = IsListEmpty(&List);
3276  if (DidNothing) {
3277  KeClearEvent(&Reaper->Wait);
3278  }
3279  if (GlobalAcquired) {
3281  GlobalAcquired = FALSE;
3282  }
3283 
3284  while (!IsListEmpty(&List)) {
3285  struct buffer_head *bh;
3286  Link = RemoveHeadList(&List);
3287  bh = CONTAINING_RECORD(Link, struct buffer_head, b_link);
3288  ASSERT(0 == atomic_read(&bh->b_count));
3289  free_buffer_head(bh);
3290  }
3291  }
3292 
3293  } _SEH2_FINALLY {
3294 
3295  if (GlobalAcquired) {
3297  }
3298 
3299  KeSetEvent(&Reaper->Engine, 0, FALSE);
3300  } _SEH2_END;
3301 
3303 }
#define TRUE
Definition: types.h:120
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
atomic_t b_count
Definition: module.h:730
void free_buffer_head(struct buffer_head *bh)
Definition: linux.c:346
ERESOURCE Resource
Definition: ext2fs.h:510
LIST_ENTRY b_link
Definition: module.h:714
#define atomic_read(v)
Definition: atomic.h:23
LIST_ENTRY VcbList
Definition: ext2fs.h:536
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
static int Link(const char **args)
Definition: vfdcmd.c:2414
_SEH2_TRY
Definition: create.c:4250
#define EXT2_REAPER_FLAG_STOP
Definition: ext2fs.h:502
PETHREAD Thread
Definition: ext2fs.h:495
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
int64_t LONGLONG
Definition: typedefs.h:66
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY List
Definition: psmgr.c:57
KEVENT Wait
Definition: ext2fs.h:497
BOOLEAN Ext2QueryUnusedBH(PEXT2_VCB Vcb, PLIST_ENTRY head)
Definition: memory.c:3170
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:117
_SEH2_END
Definition: create.c:4424
static ULONG Timeout
Definition: ping.c:61
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
ULONG Flags
Definition: ext2fs.h:499
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1144
_SEH2_FINALLY
Definition: create.c:4395
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
struct tagContext Context
Definition: acpixf.h:1012
KEVENT Engine
Definition: ext2fs.h:496
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by DriverEntry().

◆ Ext2BuildEntry()

struct dentry* Ext2BuildEntry ( PEXT2_VCB  Vcb,
PEXT2_MCB  Dcb,
PUNICODE_STRING  FileName 
)

Definition at line 444 of file memory.c.

445 {
446  OEM_STRING Oem = { 0 };
447  struct dentry *de = NULL;
449 
450  _SEH2_TRY {
451 
452  de = Ext2AllocateEntry();
453  if (!de) {
454  DEBUG(DL_ERR, ("Ext2BuildEntry: failed to allocate dentry.\n"));
455  _SEH2_LEAVE;
456  }
457  de->d_sb = &Vcb->sb;
458  if (Dcb)
459  de->d_parent = Dcb->de;
460 
461  Oem.MaximumLength = (USHORT)Ext2UnicodeToOEMSize(Vcb, FileName) + 1;
462  Oem.Buffer = ExAllocatePool(PagedPool, Oem.MaximumLength);
463  if (!Oem.Buffer) {
464  DEBUG(DL_ERR, ( "Ex2BuildEntry: failed to allocate OEM name.\n"));
465  _SEH2_LEAVE;
466  }
467  de->d_name.name = Oem.Buffer;
468  RtlZeroMemory(Oem.Buffer, Oem.MaximumLength);
470  if (!NT_SUCCESS(Status)) {
471  DEBUG(DL_CP, ("Ext2BuildEntry: failed to convert %S to OEM.\n", FileName->Buffer));
472  _SEH2_LEAVE;
473  }
474  de->d_name.len = Oem.Length;
475 
476  } _SEH2_FINALLY {
477 
478  if (!NT_SUCCESS(Status)) {
479  if (de)
480  Ext2FreeEntry(de);
481  }
482  } _SEH2_END;
483 
484  return de;
485 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
struct super_block * d_sb
Definition: fs.h:126
STRING OEM_STRING
Definition: umtypes.h:203
struct dentry::@674 d_name
_SEH2_TRY
Definition: create.c:4250
struct dentry * Ext2AllocateEntry()
Definition: memory.c:416
NTSTATUS Ext2UnicodeToOEM(IN PEXT2_VCB Vcb, IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
Definition: misc.c:261
#define DL_CP
Definition: ext2fs.h:1405
smooth NULL
Definition: ftsmooth.c:416
Definition: fs.h:117
struct dentry * d_parent
Definition: fs.h:124
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
ULONG Ext2UnicodeToOEMSize(IN PEXT2_VCB Vcb, IN PUNICODE_STRING Unicode)
Definition: misc.c:239
VOID Ext2FreeEntry(IN struct dentry *de)
Definition: memory.c:432
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:24
#define DL_ERR
Definition: ext2fs.h:1397
_SEH2_END
Definition: create.c:4424
unsigned short USHORT
Definition: pedump.c:61
_SEH2_FINALLY
Definition: create.c:4395
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_LEAVE
Definition: filesup.c:20
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4157

Referenced by Ext2AddEntry(), Ext2InitializeVcb(), and Ext2ScanDir().

◆ Ext2BuildExtents()

NTSTATUS Ext2BuildExtents ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONGLONG  Offset,
IN ULONG  Size,
IN BOOLEAN  bAlloc,
OUT PEXT2_EXTENT Chain 
)

Definition at line 1207 of file memory.c.

1216 {
1217  ULONG Start, End;
1218  ULONG Total = 0;
1219 
1220  LONGLONG Lba = 0;
1222 
1224  PEXT2_EXTENT List = *Chain = NULL;
1225 
1226  if (!IsZoneInited(Mcb)) {
1227  Status = Ext2InitializeZone(IrpContext, Vcb, Mcb);
1228  if (!NT_SUCCESS(Status)) {
1229  DbgBreak();
1230  }
1231  }
1232 
1233  if ((IrpContext && IrpContext->Irp) &&
1234  ((IrpContext->Irp->Flags & IRP_NOCACHE) ||
1235  (IrpContext->Irp->Flags & IRP_PAGING_IO))) {
1236  Size = (Size + SECTOR_SIZE - 1) & (~(SECTOR_SIZE - 1));
1237  }
1238 
1239  Start = (ULONG)(Offset >> BLOCK_BITS);
1240  End = (ULONG)((Size + Offset + BLOCK_SIZE - 1) >> BLOCK_BITS);
1241 
1242  if (End > (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS) ) {
1243  End = (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS);
1244  }
1245 
1246  while (Size > 0 && Start < End) {
1247 
1248  ULONG Mapped = 0;
1249  ULONG Length = 0;
1250  ULONG Block = 0;
1251 
1252  BOOLEAN rc = FALSE;
1253 
1254  /* try to map file offset to ext2 block upon Extents cache */
1255  if (IsZoneInited(Mcb)) {
1256  rc = Ext2LookupBlockExtent(
1257  Vcb,
1258  Mcb,
1259  Start,
1260  &Block,
1261  &Mapped);
1262 
1263  if (!rc) {
1264  /* we likely get a sparse file here */
1265  Mapped = 1;
1266  Block = 0;
1267  }
1268  }
1269 
1270  /* try to BlockMap in case failed to access Extents cache */
1271  if (!IsZoneInited(Mcb) || (bAlloc && Block == 0)) {
1272 
1273  Status = Ext2BlockMap(
1274  IrpContext,
1275  Vcb,
1276  Mcb,
1277  Start,
1278  bAlloc,
1279  &Block,
1280  &Mapped
1281  );
1282  if (!NT_SUCCESS(Status)) {
1283  break;
1284  }
1285 
1286  /* skip wrong blocks, in case wrongly treating symlink
1287  target names as blocks, silly */
1288  if (Block >= TOTAL_BLOCKS) {
1289  Block = 0;
1290  }
1291 
1292  /* add new allocated blocks to Mcb zone */
1293  if (IsZoneInited(Mcb) && Block) {
1294  if (!Ext2AddBlockExtent(Vcb, Mcb, Start, Block, Mapped)) {
1295  DbgBreak();
1296  ClearFlag(Mcb->Flags, MCB_ZONE_INITED);
1297  Ext2ClearAllExtents(&Mcb->Extents);
1298  }
1299  }
1300  }
1301 
1302  /* calculate i/o extent */
1303  Lba = ((LONGLONG)Block << BLOCK_BITS) + Offset - ((LONGLONG)Start << BLOCK_BITS);
1304  Length = (ULONG)(((LONGLONG)(Start + Mapped) << BLOCK_BITS) - Offset);
1305  if (Length > Size) {
1306  Length = Size;
1307  }
1308 
1309  if (0 == Length) {
1310  DbgBreak();
1311  break;
1312  }
1313 
1314  Start += Mapped;
1316 
1317  if (Block != 0) {
1318 
1319  if (List && List->Lba + List->Length == Lba) {
1320 
1321  /* it's continuous upon previous Extent */
1322  List->Length += Length;
1323 
1324  } else {
1325 
1326  /* have to allocate a new Extent */
1328  if (!Extent) {
1330  DbgBreak();
1331  break;
1332  }
1333 
1334  Extent->Lba = Lba;
1335  Extent->Length = Length;
1336  Extent->Offset = Total;
1337 
1338  /* insert new Extent to chain */
1339  if (List) {
1340  List->Next = Extent;
1341  List = Extent;
1342  } else {
1343  *Chain = List = Extent;
1344  }
1345  }
1346  } else {
1347  if (bAlloc) {
1348  DbgBreak();
1349  }
1350  }
1351 
1352  Total += Length;
1353  Size -= Length;
1354  }
1355 
1356  return Status;
1357 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PEXT2_EXTENT Ext2AllocateExtent()
Definition: memory.c:488
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN Ext2AddBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Block, IN ULONG Number)
Definition: memory.c:1027
#define IRP_NOCACHE
uint64 Length
Definition: DriveVolume.h:48
BOOLEAN Ext2LookupBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN PULONG Block, IN PULONG Mapped)
Definition: memory.c:1061
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
#define SECTOR_SIZE
Definition: winldr.h:34
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define BLOCK_SIZE
Definition: dlist.c:220
LIST_ENTRY List
Definition: psmgr.c:57
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
NTSTATUS Ext2InitializeZone(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:1121
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Definition: partlist.h:33
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define MCB_ZONE_INITED
Definition: ext2fs.h:948
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
NTSTATUS Ext2BlockMap(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN bAlloc, OUT PULONG pBlock, OUT PULONG Number)
Definition: fileinfo.c:1122
#define IRP_PAGING_IO
VOID Ext2ClearAllExtents(PLARGE_MCB Zone)
Definition: memory.c:637
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define IsZoneInited(Mcb)
Definition: ext2fs.h:954

Referenced by bmap(), Ext2GetRetrievalPointers(), Ext2QueryExtentMappings(), Ext2ReadInode(), and Ext2WriteInode().

◆ Ext2BuildName()

BOOLEAN Ext2BuildName ( IN OUT PUNICODE_STRING  Target,
IN PUNICODE_STRING  File,
IN PUNICODE_STRING  Parent 
)

Definition at line 1361 of file memory.c.

1366 {
1367  USHORT Length = 0;
1368  USHORT ParentLen = 0;
1369  BOOLEAN bBackslash = TRUE;
1370 
1371  /* free the original buffer */
1372  if (Target->Buffer) {
1373  DEC_MEM_COUNT(PS_MCB_NAME, Target->Buffer, Target->MaximumLength);
1375  Target->Length = Target->MaximumLength = 0;
1376  }
1377 
1378  /* check the parent directory's name and backslash */
1379  if (Parent && Parent->Buffer && Parent->Length > 0) {
1380  ParentLen = Parent->Length / sizeof(WCHAR);
1381  if (Parent->Buffer[ParentLen - 1] == L'\\') {
1382  bBackslash = FALSE;
1383  }
1384  }
1385 
1386  if (Parent == NULL || File->Buffer[0] == L'\\') {
1387  /* must be root inode */
1388  ASSERT(ParentLen == 0);
1389  bBackslash = FALSE;
1390  }
1391 
1392  /* allocate and initialize new name buffer */
1393  Length = File->Length;
1394  Length += (ParentLen + (bBackslash ? 1 : 0)) * sizeof(WCHAR);
1395 
1396  Target->Buffer = Ext2AllocatePool(
1397  PagedPool,
1398  Length + 2,
1400  );
1401 
1402  if (!Target->Buffer) {
1403  DEBUG(DL_ERR, ( "Ex2BuildName: failed to allocate name bufer.\n"));
1404  return FALSE;
1405  }
1406  RtlZeroMemory(Target->Buffer, Length + 2);
1407 
1408  if (ParentLen) {
1409  RtlCopyMemory(&Target->Buffer[0],
1410  Parent->Buffer,
1411  ParentLen * sizeof(WCHAR));
1412  }
1413 
1414  if (bBackslash) {
1415  Target->Buffer[ParentLen++] = L'\\';
1416  }
1417 
1418  RtlCopyMemory( &Target->Buffer[ParentLen],
1419  File->Buffer,
1420  File->Length);
1421 
1422  INC_MEM_COUNT(PS_MCB_NAME, Target->Buffer, Length + 2);
1423  Target->Length = Length;
1424  Target->MaximumLength = Length + 2;
1425 
1426  return TRUE;
1427 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
UINT32 Length
Definition: actbl.h:109
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:716
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:598
#define EXT2_FNAME_MAGIC
Definition: ext2fs.h:293
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1067
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
#define DL_ERR
Definition: ext2fs.h:1397
unsigned short USHORT
Definition: pedump.c:61
#define PS_MCB_NAME
Definition: common.h:25
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
#define DEBUG(args)
Definition: rdesktop.h:129
Definition: File.h:15
PVOID Ext2AllocatePool(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: debug.c:2684

Referenced by Ext2AllocateMcb(), and Ext2SetRenameInfo().

◆ Ext2CheckBitmapConsistency()

BOOLEAN Ext2CheckBitmapConsistency ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb 
)

Definition at line 1895 of file memory.c.

1896 {
1897  ULONG i, j, InodeBlocks;
1898 
1899  for (i = 0; i < Vcb->sbi.s_groups_count; i++) {
1900 
1901  PEXT2_GROUP_DESC gd;
1902  struct buffer_head *bh = NULL;
1903 
1904  gd = ext4_get_group_desc(&Vcb->sb, i, &bh);
1905  if (!gd)
1906  continue;
1907  Ext2CheckSetBlock(IrpContext, Vcb, ext4_block_bitmap(&Vcb->sb, gd));
1908  Ext2CheckSetBlock(IrpContext, Vcb, ext4_inode_bitmap(&Vcb->sb, gd));
1909 
1910 
1911  if (i == Vcb->sbi.s_groups_count - 1) {
1912  InodeBlocks = ((INODES_COUNT % INODES_PER_GROUP) *
1913  Vcb->InodeSize + Vcb->BlockSize - 1) /
1914  (Vcb->BlockSize);
1915  } else {
1916  InodeBlocks = (INODES_PER_GROUP * Vcb->InodeSize +
1917  Vcb->BlockSize - 1) / (Vcb->BlockSize);
1918  }
1919 
1920  for (j = 0; j < InodeBlocks; j++ )
1921  Ext2CheckSetBlock(IrpContext, Vcb, ext4_inode_table(&Vcb->sb, gd) + j);
1922 
1923  fini_bh(&bh);
1924  }
1925 
1926  return TRUE;
1927 }
ext4_fsblk_t ext4_inode_table(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2408
#define TRUE
Definition: types.h:120
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2400
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2909
#define Vcb
Definition: cdprocs.h:1425
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2392
BOOLEAN Ext2CheckSetBlock(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, LONGLONG Block)
Definition: memory.c:1844
unsigned int ULONG
Definition: retypes.h:1
#define INODES_PER_GROUP
Definition: ext2fs.h:99
#define INODES_COUNT
Definition: ext2fs.h:97

Referenced by Ext2InitializeVcb().

◆ Ext2CheckExtent()

VOID Ext2CheckExtent ( PLARGE_MCB  Zone,
LONGLONG  Vbn,
LONGLONG  Lbn,
LONGLONG  Length,
BOOLEAN  bAdded 
)

Definition at line 583 of file memory.c.

590 {
591 #if EXT2_DEBUG
592  LONGLONG DirtyLbn;
593  LONGLONG DirtyLen;
594  LONGLONG RunStart;
595  LONGLONG RunLength;
596  ULONG Index;
597  BOOLEAN bFound = FALSE;
598 
599  bFound = FsRtlLookupLargeMcbEntry(
600  Zone,
601  Vbn,
602  &DirtyLbn,
603  &DirtyLen,
604  &RunStart,
605  &RunLength,
606  &Index );
607 
608  if (!bAdded && (!bFound || DirtyLbn == -1)) {
609  return;
610  }
611 
612  if ( !bFound || (DirtyLbn == -1) ||
613  (DirtyLbn != Lbn) ||
614  (DirtyLen < Length)) {
615 
616  DbgBreak();
617 
618  for (Index = 0; TRUE; Index++) {
619 
621  Zone,
622  Index,
623  &Vbn,
624  &Lbn,
625  &Length)) {
626  break;
627  }
628 
629  DEBUG(DL_EXT, ("Index = %xh Vbn = %I64xh Lbn = %I64xh Len = %I64xh\n",
630  Index, Vbn, Lbn, Length ));
631  }
632  }
633 #endif
634 }
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Lbn
Definition: fsrtlfuncs.h:479
BOOLEAN NTAPI FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb, IN ULONG RunIndex, OUT PLONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG SectorCount)
Definition: largemcb.c:391
#define DL_EXT
Definition: ext2fs.h:1406
unsigned char BOOLEAN
int64_t LONGLONG
Definition: typedefs.h:66
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn OPTIONAL, OUT PLONGLONG SectorCountFromLbn OPTIONAL, OUT PLONGLONG StartingLbn OPTIONAL, OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, OUT PULONG Index OPTIONAL)
Definition: largemcb.c:564
_In_ LONGLONG Vbn
Definition: fsrtlfuncs.h:470
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129

Referenced by Ext2AddMcbExtent(), Ext2AddMcbMetaExts(), Ext2AddVcbExtent(), Ext2RemoveMcbExtent(), Ext2RemoveMcbMetaExts(), and Ext2RemoveVcbExtent().

◆ Ext2CheckSetBlock()

BOOLEAN Ext2CheckSetBlock ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
LONGLONG  Block 
)

Definition at line 1844 of file memory.c.

1845 {
1846  PEXT2_GROUP_DESC gd;
1847  struct buffer_head *gb = NULL;
1848  struct buffer_head *bh = NULL;
1849  ULONG group, dwBlk, Length;
1851  BOOLEAN bModified = FALSE;
1852 
1854  dwBlk = (ULONG)(Block - EXT2_FIRST_DATA_BLOCK) % BLOCKS_PER_GROUP;
1855 
1856  gd = ext4_get_group_desc(&Vcb->sb, group, &gb);
1857  if (!gd) {
1858  return FALSE;
1859  }
1860  bh = sb_getblk(&Vcb->sb, ext4_block_bitmap(&Vcb->sb, gd));
1861 
1862  if (group == Vcb->sbi.s_groups_count - 1) {
1864 
1865  /* s_blocks_count is integer multiple of s_blocks_per_group */
1866  if (Length == 0)
1868  } else {
1870  }
1871 
1872  if (dwBlk >= Length) {
1873  fini_bh(&gb);
1874  fini_bh(&bh);
1875  return FALSE;
1876  }
1877 
1878 
1880 
1881  if (RtlCheckBit(&bitmap, dwBlk) == 0) {
1882  DbgBreak();
1883  RtlSetBits(&bitmap, dwBlk, 1);
1884  bModified = TRUE;
1885  mark_buffer_dirty(bh);
1886  }
1887 
1888  fini_bh(&gb);
1889  fini_bh(&bh);
1890 
1891  return (!bModified);
1892 }
#define TRUE
Definition: types.h:120
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:966
#define EXT2_FIRST_DATA_BLOCK
Definition: ext2fs.h:103
#define RtlCheckBit(BMH, BP)
Definition: rtlfuncs.h:3154
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2909
GLboolean GLuint group
Definition: glext.h:11120
Definition: uimain.c:88
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
char * b_data
Definition: module.h:725
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2392
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
static HBITMAP bitmap
Definition: clipboard.c:1344
#define BLOCKS_PER_GROUP
Definition: ext2fs.h:100

Referenced by Ext2CheckBitmapConsistency().

◆ Ext2CleanupAllMcbs()

VOID Ext2CleanupAllMcbs ( PEXT2_VCB  Vcb)

Definition at line 1810 of file memory.c.

1811 {
1812  BOOLEAN LockAcquired = FALSE;
1813  PEXT2_MCB Mcb = NULL;
1814 
1815  _SEH2_TRY {
1816 
1818  &Vcb->McbLock,
1819  TRUE );
1820  LockAcquired = TRUE;
1821 
1822  while ((Mcb = Ext2FirstUnusedMcb(Vcb, TRUE, Vcb->NumOfMcb)) != 0) {
1823  while (Mcb) {
1824  PEXT2_MCB Next = Mcb->Next;
1825  if (IsMcbSymLink(Mcb)) {
1826  Mcb->Target = NULL;
1827  }
1828  Ext2FreeMcb(Vcb, Mcb);
1829  Mcb = Next;
1830  }
1831  }
1832  Ext2FreeMcb(Vcb, Vcb->McbTree);
1833  Vcb->McbTree = NULL;
1834 
1835  } _SEH2_FINALLY {
1836 
1837  if (LockAcquired) {
1838  ExReleaseResourceLite(&Vcb->McbLock);
1839  }
1840  } _SEH2_END;
1841 }
#define TRUE
Definition: types.h:120
VOID Ext2FreeMcb(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:1538
PEXT2_MCB Ext2FirstUnusedMcb(PEXT2_VCB Vcb, BOOLEAN Wait, ULONG Number)
Definition: memory.c:2967
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define IsMcbSymLink(Mcb)
Definition: ext2fs.h:953
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
_SEH2_END
Definition: create.c:4424
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
_SEH2_FINALLY
Definition: create.c:4395

Referenced by Ext2DestroyVcb().

◆ Ext2ClearAllExtents()

VOID Ext2ClearAllExtents ( PLARGE_MCB  Zone)

Definition at line 637 of file memory.c.

638 {
639  _SEH2_TRY {
642  DbgBreak();
643  } _SEH2_END;
644 }
VOID NTAPI FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb, IN LONGLONG Vbn)
Definition: largemcb.c:1016
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
int64_t LONGLONG
Definition: typedefs.h:66
_SEH2_END
Definition: create.c:4424
#define DbgBreak()
Definition: ext2fs.h:46
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by Ext2BuildExtents(), Ext2ExpandBlock(), Ext2ExpandExtent(), Ext2ExpandLast(), Ext2InitializeZone(), Ext2TruncateBlock(), Ext2TruncateExtent(), Ext2TruncateFile(), and Ext2TruncateIndirectFast().

◆ Ext2CountExtents()

ULONG Ext2CountExtents ( IN PEXT2_EXTENT  Chain)

Definition at line 513 of file memory.c.

514 {
515  ULONG count = 0;
516  PEXT2_EXTENT List = Chain;
517 
518  while (List) {
519  count += 1;
520  List = List->Next;
521  }
522 
523  return count;
524 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
LIST_ENTRY List
Definition: psmgr.c:57
unsigned int ULONG
Definition: retypes.h:1

Referenced by Ext2QueryExtentMappings().

◆ Ext2DestroyExtentChain()

VOID Ext2DestroyExtentChain ( IN PEXT2_EXTENT  Chain)

Definition at line 546 of file memory.c.

547 {
548  PEXT2_EXTENT Extent = NULL, List = Chain;
549 
550  while (List) {
551  Extent = List->Next;
553  List = Extent;
554  }
555 }
VOID Ext2FreeExtent(IN PEXT2_EXTENT Extent)
Definition: memory.c:505
smooth NULL
Definition: ftsmooth.c:416
LIST_ENTRY List
Definition: psmgr.c:57

Referenced by Ext2GetRetrievalPointers(), Ext2QueryExtentMappings(), Ext2ReadInode(), Ext2WriteInode(), and Ext2WriteVolume().

◆ Ext2DestroyInode()

VOID Ext2DestroyInode ( IN PEXT2_VCB  Vcb,
IN PEXT2_INODE  inode 
)

Definition at line 406 of file memory.c.

407 {
408  ASSERT(inode != NULL);
409 
410  DEBUG(DL_INF, ("Ext2FreeInode: Inode = %ph.\n", inode));
411 
412  ExFreeToNPagedLookasideList(&(Vcb->InodeLookasideList), inode);
414 }
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
#define INODE_SIZE
Definition: ext2fs.h:92
Definition: fs.h:78
#define PS_EXT2_INODE
Definition: common.h:33
smooth NULL
Definition: ftsmooth.c:416
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DEBUG(args)
Definition: rdesktop.h:129

Referenced by ext4_fs_get_xattr_ref(), and ext4_fs_put_xattr_ref().

◆ Ext2DestroyVcb()

VOID Ext2DestroyVcb ( IN PEXT2_VCB  Vcb)

Definition at line 2813 of file memory.c.

2814 {
2815  ASSERT(Vcb != NULL);
2816  ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
2817  (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
2818 
2819  DEBUG(DL_FUN, ("Ext2DestroyVcb ...\n"));
2820 
2821  if (Vcb->Volume) {
2823  }
2824  ASSERT(NULL == Vcb->Volume);
2825 
2826  FsRtlNotifyUninitializeSync(&Vcb->NotifySync);
2827  Ext2ListExtents(&Vcb->Extents);
2828  FsRtlUninitializeLargeMcb(&(Vcb->Extents));
2829 
2831 
2832  Ext2DropBH(Vcb);
2833 
2834  if (Vcb->bd.bd_bh_cache)
2835  kmem_cache_destroy(Vcb->bd.bd_bh_cache);
2836  ExDeleteResourceLite(&Vcb->bd.bd_bh_lock);
2837 
2838  if (Vcb->SuperBlock) {
2839  Ext2FreePool(Vcb->SuperBlock, EXT2_SB_MAGIC);
2840  Vcb->SuperBlock = NULL;
2841  }
2842 
2843  if (IsFlagOn(Vcb->Flags, VCB_NEW_VPB)) {
2844  ASSERT(Vcb->Vpb2 != NULL);
2845  DEBUG(DL_DBG, ("Ext2DestroyVcb: Vpb2 to be freed: %p\n", Vcb->Vpb2));
2846  ExFreePoolWithTag(Vcb->Vpb2, TAG_VPB);
2847  DEC_MEM_COUNT(PS_VPB, Vcb->Vpb2, sizeof(VPB));
2848  Vcb->Vpb2 = NULL;
2849  }
2850 
2851  ObDereferenceObject(Vcb->TargetDeviceObject);
2852 
2853  ExDeleteNPagedLookasideList(&(Vcb->InodeLookasideList));
2854  ExDeleteResourceLite(&Vcb->FcbLock);
2855  ExDeleteResourceLite(&Vcb->McbLock);
2856  ExDeleteResourceLite(&Vcb->MetaInode);
2857  ExDeleteResourceLite(&Vcb->MetaBlock);
2858  ExDeleteResourceLite(&Vcb->sbi.s_gd_lock);
2859  ExDeleteResourceLite(&Vcb->PagingIoResource);
2860  ExDeleteResourceLite(&Vcb->MainResource);
2861 
2862  DEBUG(DL_DBG, ("Ext2DestroyVcb: DevObject=%p Vcb=%p\n", Vcb->DeviceObject, Vcb));
2863  IoDeleteDevice(Vcb->DeviceObject);
2864  DEC_MEM_COUNT(PS_VCB, Vcb->DeviceObject, sizeof(EXT2_VCB));
2865 }
VOID Ext2CleanupAllMcbs(PEXT2_VCB Vcb)
Definition: memory.c:1810
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define TAG_VPB
Definition: cdprocs.h:98
#define PS_VPB
Definition: common.h:23
#define VCB_NEW_VPB
Definition: ext2fs.h:783
VOID Ext2TearDownStream(IN PEXT2_VCB Vcb)
Definition: memory.c:2786
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
VOID Ext2DropBH(IN PEXT2_VCB Vcb)
Definition: generic.c:262
smooth NULL
Definition: ftsmooth.c:416
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN Ext2ListExtents(PLARGE_MCB Extents)
Definition: memory.c:558
#define PS_VCB
Definition: common.h:17
#define DL_FUN
Definition: ext2fs.h:1400
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
int kmem_cache_destroy(kmem_cache_t *kc)
Definition: linux.c:82
VOID NTAPI FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:1053
Definition: iotypes.h:166
#define EXT2_SB_MAGIC
Definition: ext2fs.h:297
#define DL_DBG
Definition: ext2fs.h:1398
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
#define DEBUG(args)
Definition: rdesktop.h:129
VOID NTAPI FsRtlNotifyUninitializeSync(IN PNOTIFY_SYNC *NotifySync)
Definition: notify.c:1639
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:174

Referenced by Ext2CheckDismount(), and Ext2MountVolume().

◆ Ext2FcbReaperThread()

VOID NTAPI Ext2FcbReaperThread ( PVOID  Context)

Definition at line 3367 of file memory.c.

3370 {
3371  PEXT2_REAPER Reaper = Context;
3372  PEXT2_VCB Vcb = NULL;
3373  LIST_ENTRY List, *Link;
3375 
3376  BOOLEAN GlobalAcquired = FALSE;
3377  BOOLEAN DidNothing = FALSE;
3378  BOOLEAN NonWait = FALSE;
3379 
3380  _SEH2_TRY {
3381 
3382  Reaper->Thread = PsGetCurrentThread();
3383 
3384  /* wake up DirverEntry */
3385  KeSetEvent(&Reaper->Engine, 0, FALSE);
3386 
3387  /* now process looping */
3388  while (!IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP)) {
3389 
3390  /* wait until it is waken or it times out */
3391  if (NonWait) {
3392  Timeout.QuadPart = (LONGLONG)-10*1000*100;
3393  NonWait = FALSE;
3394  } else if (DidNothing) {
3395  Timeout.QuadPart = Timeout.QuadPart * 2;
3396  } else {
3397  Timeout.QuadPart = (LONGLONG)-10*1000*1000*20; /* 20 seconds */
3398  }
3400  &Reaper->Wait,
3401  Executive,
3402  KernelMode,
3403  FALSE,
3404  &Timeout
3405  );
3406 
3407  if (IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP))
3408  break;
3409 
3411 
3412  /* acquire global exclusive lock */
3414  GlobalAcquired = TRUE;
3415  /* search all Vcb to get unused resources freed to system */
3416  for (Link = Ext2Global->VcbList.Flink;
3417  Link != &(Ext2Global->VcbList);
3418  Link = Link->Flink ) {
3419 
3420  Vcb = CONTAINING_RECORD(Link, EXT2_VCB, Next);
3421  NonWait = Ext2QueryUnusedFcb(Vcb, &List);
3422  }
3423  DidNothing = IsListEmpty(&List);
3424  if (DidNothing) {
3425  KeClearEvent(&Reaper->Wait);
3426  }
3427  if (GlobalAcquired) {
3429  GlobalAcquired = FALSE;
3430  }
3431 
3432  while (!IsListEmpty(&List)) {
3433  PEXT2_FCB Fcb;
3434  Link = RemoveHeadList(&List);
3435  Fcb = CONTAINING_RECORD(Link, EXT2_FCB, Next);
3436  ASSERT(0 == Fcb->ReferenceCount);
3437  Ext2FreeFcb(Fcb);
3438  }
3439  }
3440 
3441  } _SEH2_FINALLY {
3442 
3443  if (GlobalAcquired) {
3445  }
3446 
3447  KeSetEvent(&Reaper->Engine, 0, FALSE);
3448  } _SEH2_END;
3449 
3451 }
BOOLEAN Ext2QueryUnusedFcb(PEXT2_VCB Vcb, PLIST_ENTRY list)
Definition: memory.c:3308
#define TRUE
Definition: types.h:120
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
ERESOURCE Resource
Definition: ext2fs.h:510
VOID Ext2FreeFcb(IN PEXT2_FCB Fcb)
Definition: memory.c:240
LIST_ENTRY VcbList
Definition: ext2fs.h:536
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
static int Link(const char **args)
Definition: vfdcmd.c:2414
_SEH2_TRY
Definition: create.c:4250
#define EXT2_REAPER_FLAG_STOP
Definition: ext2fs.h:502
PETHREAD Thread
Definition: ext2fs.h:495
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
int64_t LONGLONG
Definition: typedefs.h:66
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY List
Definition: psmgr.c:57
KEVENT Wait
Definition: ext2fs.h:497
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:117
_SEH2_END
Definition: create.c:4424
static ULONG Timeout
Definition: ping.c:61
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
ULONG Flags
Definition: ext2fs.h:499
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1144
_SEH2_FINALLY
Definition: create.c:4395
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
struct tagContext Context
Definition: acpixf.h:1012
KEVENT Engine
Definition: ext2fs.h:496
_In_ PFCB Fcb
Definition: cdprocs.h:151
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by DriverEntry().

◆ Ext2FirstUnusedMcb()

PEXT2_MCB Ext2FirstUnusedMcb ( PEXT2_VCB  Vcb,
BOOLEAN  Wait,
ULONG  Number 
)

Definition at line 2967 of file memory.c.

2968 {
2969  PEXT2_MCB Head = NULL;
2970  PEXT2_MCB Tail = NULL;
2971  PEXT2_MCB Mcb = NULL;
2972  PLIST_ENTRY List = NULL;
2973  ULONG i = 0;
2975 
2976  if (!ExAcquireResourceExclusiveLite(&Vcb->McbLock, Wait)) {
2977  return NULL;
2978  }
2979 
2981 
2982  while (Number--) {
2983 
2984  BOOLEAN Skip = TRUE;
2985 
2986  if (IsListEmpty(&Vcb->McbList)) {
2987  break;
2988  }
2989 
2990  while (i++ < Vcb->NumOfMcb) {
2991 
2993  if (now.QuadPart > start.QuadPart + (LONGLONG)10*1000*1000) {
2994  break;
2995  }
2996 
2997  List = RemoveHeadList(&Vcb->McbList);
2999  ASSERT(IsFlagOn(Mcb->Flags, MCB_VCB_LINK));
3000 
3001  if (Mcb->Fcb == NULL && !IsMcbRoot(Mcb) &&
3002  Mcb->Refercount == 0 &&
3003  (Mcb->Child == NULL || IsMcbSymLink(Mcb))) {
3004 
3005  Ext2RemoveMcb(Vcb, Mcb);
3006  ClearLongFlag(Mcb->Flags, MCB_VCB_LINK);
3007  Ext2DerefXcb(&Vcb->NumOfMcb);
3008 
3009  /* attach all Mcb into a chain*/
3010  if (Head) {
3011  ASSERT(Tail != NULL);
3012  Tail->Next = Mcb;
3013  Tail = Mcb;
3014  } else {
3015  Head = Tail = Mcb;
3016  }
3017  Tail->Next = NULL;
3018  Skip = FALSE;
3019 
3020  } else {
3021 
3022  InsertTailList(&Vcb->McbList, &Mcb->Link);
3023  Mcb = NULL;
3024  }
3025  }
3026 
3027  if (Skip)
3028  break;
3029  }
3030 
3031  ExReleaseResourceLite(&Vcb->McbLock);
3032 
3033  return Head;
3034 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define MCB_VCB_LINK
Definition: ext2fs.h:944
#define TRUE
Definition: types.h:120
BOOLEAN Ext2RemoveMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: memory.c:1746
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
static int Link(const char **args)
Definition: vfdcmd.c:2414
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
time_t now
Definition: finger.c:65
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
#define ClearLongFlag(_F, _SF)
Definition: ext2fs.h:254
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
int64_t LONGLONG
Definition: typedefs.h:66
PEXT2_MCB Next
Definition: ext2fs.h:895
LIST_ENTRY List
Definition: psmgr.c:57
#define IsMcbSymLink(Mcb)
Definition: ext2fs.h:953
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:117
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
GLuint start
Definition: gl.h:1545
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
unsigned int ULONG
Definition: retypes.h:1
#define IsMcbRoot(Mcb)
Definition: ext2fs.h:956
#define Ext2DerefXcb(_C)
Definition: ext2fs.h:968
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by Ext2CleanupAllMcbs(), and Ext2McbReaperThread().

◆ Ext2FreeCcb()

VOID Ext2FreeCcb ( IN PEXT2_VCB  Vcb,
IN PEXT2_CCB  Ccb 
)

Definition at line 356 of file memory.c.

357 {
358  ASSERT(Ccb != NULL);
359  ASSERT((Ccb->Identifier.Type == EXT2CCB) &&
360  (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
361 
362  DEBUG(DL_RES, ( "Ext2FreeCcb: Ccb = %ph.\n", Ccb));
363 
364  if (Ccb->SymLink) {
365  DEBUG(DL_INF, ( "Ext2FreeCcb: Ccb SymLink: %wZ.\n",
366  &Ccb->SymLink->FullName));
367  if (IsFileDeleted(Ccb->SymLink->Target)) {
368  Ext2UnlinkMcb(Vcb, Ccb->SymLink);
369  Ext2DerefMcb(Ccb->SymLink);
370  Ext2LinkHeadMcb(Vcb, Ccb->SymLink);
371  } else {
372  Ext2DerefMcb(Ccb->SymLink);
373  }
374  }
375 
376  if (Ccb->DirectorySearchPattern.Buffer != NULL) {
377  DEC_MEM_COUNT(PS_DIR_PATTERN, Ccb->DirectorySearchPattern.Buffer,
378  Ccb->DirectorySearchPattern.MaximumLength );
379  Ext2FreePool(Ccb->DirectorySearchPattern.Buffer, EXT2_DIRSP_MAGIC);
380  }
381 
382  ExFreeToNPagedLookasideList(&(Ext2Global->Ext2CcbLookasideList), Ccb);
383  DEC_MEM_COUNT(PS_CCB, Ccb, sizeof(EXT2_CCB));
384 }
#define Ext2DerefMcb(Mcb)
Definition: ext2fs.h:987
#define PS_CCB
Definition: common.h:19
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
NPAGED_LOOKASIDE_LIST Ext2CcbLookasideList
Definition: ext2fs.h:546
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
#define EXT2_DIRSP_MAGIC
Definition: ext2fs.h:296
#define IsFileDeleted(Mcb)
Definition: ext2fs.h:959
smooth NULL
Definition: ftsmooth.c:416
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
VOID Ext2LinkHeadMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: memory.c:2923
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Type
Definition: ntfs.h:95
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define DL_RES
Definition: ext2fs.h:1403
#define PS_DIR_PATTERN
Definition: common.h:28
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
#define DEBUG(args)
Definition: rdesktop.h:129
ULONG Size
Definition: ntfs.h:96
VOID Ext2UnlinkMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: memory.c:2945

Referenced by Ext2Close(), and Ext2CreateFile().

◆ Ext2FreeEntry()

VOID Ext2FreeEntry ( IN struct dentry de)

Definition at line 432 of file memory.c.

433 {
434  ASSERT(de != NULL);
435 
436  if (de->d_name.name)
437  ExFreePool(de->d_name.name);
438 
439  ExFreeToNPagedLookasideList(&(Ext2Global->Ext2DentryLookasideList), de);
440  DEC_MEM_COUNT(PS_DENTRY, de, sizeof(struct dentry));
441 }
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
#define PS_DENTRY
Definition: common.h:34
NPAGED_LOOKASIDE_LIST Ext2DentryLookasideList
Definition: ext2fs.h:549
smooth NULL
Definition: ftsmooth.c:416
Definition: fs.h:117
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by Ext2AddEntry(), Ext2BuildEntry(), Ext2CreateInode(), Ext2FreeMcb(), Ext2LookupFile(), Ext2ScanDir(), and Ext2SetRenameInfo().

◆ Ext2FreeExtent()

VOID Ext2FreeExtent ( IN PEXT2_EXTENT  Extent)

Definition at line 505 of file memory.c.

506 {
507  ASSERT(Extent != NULL);
508  ExFreeToNPagedLookasideList(&(Ext2Global->Ext2ExtLookasideList), Extent);
510 }
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
#define PS_EXTENT
Definition: common.h:21
NPAGED_LOOKASIDE_LIST Ext2ExtLookasideList
Definition: ext2fs.h:548
smooth NULL
Definition: ftsmooth.c:416
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

Referenced by bmap(), and Ext2DestroyExtentChain().

◆ Ext2FreeFcb()

VOID Ext2FreeFcb ( IN PEXT2_FCB  Fcb)

Definition at line 240 of file memory.c.

241 {
242  PEXT2_VCB Vcb = Fcb->Vcb;
243 
244  _SEH2_TRY {
245 
246  ASSERT((Fcb != NULL) && (Fcb->Identifier.Type == EXT2FCB) &&
247  (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
248  ASSERT(0 == Fcb->ReferenceCount);
249 
250 #ifndef _WIN2K_TARGET_
252 #endif
253 
254  FsRtlUninitializeFileLock(&Fcb->FileLockAnchor);
255  FsRtlUninitializeOplock(&Fcb->Oplock);
258 
259  Fcb->Identifier.Type = 0;
260  Fcb->Identifier.Size = 0;
261 
262  ExFreeToNPagedLookasideList(&(Ext2Global->Ext2FcbLookasideList), Fcb);
263  DEC_MEM_COUNT(PS_FCB, Fcb, sizeof(EXT2_FCB));
264 
265  if (0 == Ext2DerefXcb(&Vcb->ReferenceCount)) {
266  if (!IsMounted(Vcb) || IsDispending(Vcb)) {
268  }
269  }
270 
271  } _SEH2_FINALLY {
272  } _SEH2_END;
273 }
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
VOID NTAPI FsRtlUninitializeFileLock(IN PFILE_LOCK FileLock)
Definition: filelock.c:1278
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
NPAGED_LOOKASIDE_LIST Ext2FcbLookasideList
Definition: ext2fs.h:545
VOID NTAPI FsRtlUninitializeOplock(IN POPLOCK Oplock)
Definition: oplock.c:1602
_SEH2_TRY
Definition: create.c:4250
BOOLEAN Ext2CheckDismount(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bForce)
Definition: fsctl.c:2592
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
smooth NULL
Definition: ftsmooth.c:416
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
VOID NTAPI FsRtlTeardownPerStreamContexts(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader)
Definition: filtrctx.c:368
#define PS_FCB
Definition: common.h:18
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Type
Definition: ntfs.h:95
#define IsDispending(Vcb)
Definition: ext2fs.h:804
ERESOURCE MainResource
Definition: ntfs.h:512
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
ERESOURCE PagingIoResource
Definition: ntfs.h:511
PVCB Vcb
Definition: cdstruc.h:939
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG Size
Definition: ntfs.h:96
#define Ext2DerefXcb(_C)
Definition: ext2fs.h:968

Referenced by Ext2FcbReaperThread().

◆ Ext2FreeIrpContext()

VOID Ext2FreeIrpContext ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 114 of file memory.c.

115 {
116  ASSERT(IrpContext != NULL);
117 
118  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
119  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
120 
121  /* free the IrpContext to NonPagedList */
122  IrpContext->Identifier.Type = 0;
123  IrpContext->Identifier.Size = 0;
124 
125  DEC_IRP_COUNT(IrpContext);
126  ExFreeToNPagedLookasideList(&(Ext2Global->Ext2IrpContextLookasideList), IrpContext);
127 }
#define DEC_IRP_COUNT(IrpContext)
Definition: ext2fs.h:601
NPAGED_LOOKASIDE_LIST Ext2IrpContextLookasideList
Definition: ext2fs.h:544
smooth NULL
Definition: ftsmooth.c:416
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

Referenced by Ext2CompleteIrpContext(), Ext2ExceptionFilter(), Ext2ExceptionHandler(), Ext2ReadFile(), Ext2ReadVolume(), Ext2WriteFile(), and Ext2WriteVolume().

◆ Ext2FreeMcb()

VOID Ext2FreeMcb ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb 
)

Definition at line 1538 of file memory.c.

1539 {
1540 #ifndef __REACTOS__
1541  PEXT2_MCB Parent = Mcb->Parent;
1542 #endif
1543 
1544  ASSERT(Mcb != NULL);
1545 
1546  ASSERT((Mcb->Identifier.Type == EXT2MCB) &&
1547  (Mcb->Identifier.Size == sizeof(EXT2_MCB)));
1548 
1549  if ((Mcb->Identifier.Type != EXT2MCB) ||
1550  (Mcb->Identifier.Size != sizeof(EXT2_MCB))) {
1551  return;
1552  }
1553 
1554  DEBUG(DL_INF, ( "Ext2FreeMcb: Mcb %wZ will be freed.\n", &Mcb->FullName));
1555 
1556  if (IsMcbSymLink(Mcb) && Mcb->Target) {
1557  Ext2DerefMcb(Mcb->Target);
1558  }
1559 
1560  if (FsRtlNumberOfRunsInLargeMcb(&Mcb->Extents)) {
1561  DEBUG(DL_EXT, ("List data extents for: %wZ\n", &Mcb->FullName));
1562  Ext2ListExtents(&Mcb->Extents);
1563  }
1564  FsRtlUninitializeLargeMcb(&(Mcb->Extents));
1565  if (FsRtlNumberOfRunsInLargeMcb(&Mcb->MetaExts)) {
1566  DEBUG(DL_EXT, ("List meta extents for: %wZ\n", &Mcb->FullName));
1567  Ext2ListExtents(&Mcb->MetaExts);
1568  }
1569  FsRtlUninitializeLargeMcb(&(Mcb->MetaExts));
1571 
1572  if (Mcb->ShortName.Buffer) {
1573  DEC_MEM_COUNT(PS_MCB_NAME, Mcb->ShortName.Buffer,
1574  Mcb->ShortName.MaximumLength);
1575  Ext2FreePool(Mcb->ShortName.Buffer, EXT2_FNAME_MAGIC);
1576  }
1577 
1578  if (Mcb->FullName.Buffer) {
1579  DEC_MEM_COUNT(PS_MCB_NAME, Mcb->FullName.Buffer,
1580  Mcb->FullName.MaximumLength);
1581  Ext2FreePool(Mcb->FullName.Buffer, EXT2_FNAME_MAGIC);
1582  }
1583 
1584  /* free dentry */
1585  if (Mcb->de) {
1586  Ext2FreeEntry(Mcb->de);
1587  }
1588 
1589  Mcb->Identifier.Type = 0;
1590  Mcb->Identifier.Size = 0;
1591 
1592  ExFreeToNPagedLookasideList(&(Ext2Global->Ext2McbLookasideList), Mcb);
1593  DEC_MEM_COUNT(PS_MCB, Mcb, sizeof(EXT2_MCB));
1594 }
#define Ext2DerefMcb(Mcb)
Definition: ext2fs.h:987
NPAGED_LOOKASIDE_LIST Ext2McbLookasideList
Definition: ext2fs.h:547
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:716
ULONG NTAPI FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:769
#define DL_EXT
Definition: ext2fs.h:1406
smooth NULL
Definition: ftsmooth.c:416
#define ClearLongFlag(_F, _SF)
Definition: ext2fs.h:254
#define EXT2_FNAME_MAGIC
Definition: ext2fs.h:293
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define DL_INF
Definition: ext2fs.h:1399
#define IsMcbSymLink(Mcb)
Definition: ext2fs.h:953
VOID Ext2FreeEntry(IN struct dentry *de)
Definition: memory.c:432
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN Ext2ListExtents(PLARGE_MCB Extents)
Definition: memory.c:558
#define PS_MCB
Definition: common.h:20
#define MCB_ZONE_INITED
Definition: ext2fs.h:948
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
VOID NTAPI FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:1053
#define PS_MCB_NAME
Definition: common.h:25
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
#define DEBUG(args)
Definition: rdesktop.h:129

Referenced by Ext2CleanupAllMcbs(), Ext2InitializeVcb(), Ext2LoadInternalJournal(), Ext2LookupFile(), Ext2McbReaperThread(), and Ext2RecoverJournal().

◆ Ext2InitializeLabel()

NTSTATUS Ext2InitializeLabel ( IN PEXT2_VCB  Vcb,
IN PEXT2_SUPER_BLOCK  Sb 
)

Definition at line 2241 of file memory.c.

2245 {
2246  NTSTATUS status;
2247 
2248  USHORT Length;
2251 
2252  Label.MaximumLength = 16 * sizeof(WCHAR);
2253  Label.Length = 0;
2254  Label.Buffer = Vcb->Vpb->VolumeLabel;
2255  Vcb->Vpb->VolumeLabelLength = 0;
2256  RtlZeroMemory(Label.Buffer, Label.MaximumLength);
2257 
2258  Length = 16;
2259  while ( (Length > 0) &&
2260  ((Sb->s_volume_name[Length -1] == 0x00) ||
2261  (Sb->s_volume_name[Length - 1] == 0x20) )
2262  ) {
2263  Length--;
2264  }
2265 
2266  if (Length == 0) {
2267  return STATUS_SUCCESS;
2268  }
2269 
2270  OemName.Buffer = Sb->s_volume_name;
2271  OemName.MaximumLength = 16;
2272  OemName.Length = Length;
2273 
2275  if (NT_SUCCESS(status)) {
2276  Vcb->Vpb->VolumeLabelLength = Label.Length;
2277  }
2278 
2279  return status;
2280 }
LONG NTSTATUS
Definition: precomp.h:26
STRING OEM_STRING
Definition: umtypes.h:203
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS Ext2OEMToUnicode(IN PEXT2_VCB Vcb, IN OUT PUNICODE_STRING Oem, IN POEM_STRING Unicode)
Definition: misc.c:206
unsigned short USHORT
Definition: pedump.c:61
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PWCHAR Label
Definition: format.c:70
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1294
return STATUS_SUCCESS
Definition: btrfs.c:2777
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by Ext2InitializeVcb(), and Ext2ProcessVolumeProperty().

◆ Ext2InitializeVcb()

NTSTATUS Ext2InitializeVcb ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_SUPER_BLOCK  sb,
IN PDEVICE_OBJECT  TargetDevice,
IN PDEVICE_OBJECT  VolumeDevice,
IN PVPB  Vpb 
)

Definition at line 2297 of file memory.c.

2303 {
2305  ULONG IoctlSize;
2306  LONGLONG DiskSize;
2307  LONGLONG PartSize;
2309  USHORT Buffer[2];
2310  ULONG ChangeCount = 0, features;
2312  int i, has_huge_files;
2313 
2314  BOOLEAN VcbResourceInitialized = FALSE;
2315  BOOLEAN NotifySyncInitialized = FALSE;
2316  BOOLEAN ExtentsInitialized = FALSE;
2317  BOOLEAN InodeLookasideInitialized = FALSE;
2318  BOOLEAN GroupLoaded = FALSE;
2319 
2320  _SEH2_TRY {
2321 
2322  if (Vpb == NULL) {
2324  _SEH2_LEAVE;
2325  }
2326 
2327  /* Reject mounting volume if we encounter unsupported incompat features */
2328  if (FlagOn(sb->s_feature_incompat, ~EXT4_FEATURE_INCOMPAT_SUPP)) {
2330  _SEH2_LEAVE;
2331  }
2332 
2333  /* Mount the volume RO if we encounter unsupported ro_compat features */
2334  if (FlagOn(sb->s_feature_ro_compat, ~EXT4_FEATURE_RO_COMPAT_SUPP)) {
2336  }
2337 
2338  /* Recognize the filesystem as Ext3fs if it supports journalling */
2339  if (IsFlagOn(sb->s_feature_compat, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
2340  Vcb->IsExt3fs = TRUE;
2341  }
2342 
2343  /* check block size */
2344  Vcb->BlockSize = (EXT2_MIN_BLOCK_SIZE << sb->s_log_block_size);
2345  /* we cannot handle volume with block size bigger than 64k */
2346  if (Vcb->BlockSize > EXT2_MAX_USER_BLKSIZE) {
2348  _SEH2_LEAVE;
2349  }
2350 
2351  if (Vcb->BlockSize >= PAGE_SIZE) {
2352  Vcb->IoUnitBits = PAGE_SHIFT;
2353  Vcb->IoUnitSize = PAGE_SIZE;
2354  } else {
2355  Vcb->IoUnitSize = Vcb->BlockSize;
2356  Vcb->IoUnitBits = Ext2Log2(Vcb->BlockSize);
2357  }
2358 
2359  /* initialize vcb header members ... */
2360  Vcb->Header.IsFastIoPossible = FastIoIsNotPossible;
2361  Vcb->Header.Resource = &(Vcb->MainResource);
2362  Vcb->Header.PagingIoResource = &(Vcb->PagingIoResource);
2363  Vcb->OpenVolumeCount = 0;
2364  Vcb->OpenHandleCount = 0;
2365  Vcb->ReferenceCount = 0;
2366 
2367  /* initialize eresources */
2368  ExInitializeResourceLite(&Vcb->MainResource);
2369  ExInitializeResourceLite(&Vcb->PagingIoResource);
2370  ExInitializeResourceLite(&Vcb->MetaInode);
2371  ExInitializeResourceLite(&Vcb->MetaBlock);
2372  ExInitializeResourceLite(&Vcb->McbLock);
2373  ExInitializeResourceLite(&Vcb->FcbLock);
2374  ExInitializeResourceLite(&Vcb->sbi.s_gd_lock);
2375 #ifndef _WIN2K_TARGET_
2376  ExInitializeFastMutex(&Vcb->Mutex);
2377  FsRtlSetupAdvancedHeader(&Vcb->Header, &Vcb->Mutex);
2378 #endif
2379  VcbResourceInitialized = TRUE;
2380 
2381  /* initialize Fcb list head */
2382  InitializeListHead(&Vcb->FcbList);
2383 
2384  /* initialize Mcb list head */
2385  InitializeListHead(&(Vcb->McbList));
2386 
2387  /* initialize directory notify list */
2388  InitializeListHead(&Vcb->NotifyList);
2389  FsRtlNotifyInitializeSync(&Vcb->NotifySync);
2390  NotifySyncInitialized = TRUE;
2391 
2392  /* superblock checking */
2393  Vcb->SuperBlock = sb;
2394 
2395  /* initialize Vpb and Label */
2396  Vcb->DeviceObject = VolumeDevice;
2397  Vcb->TargetDeviceObject = TargetDevice;
2398  Vcb->Vpb = Vpb;
2399  Vcb->RealDevice = Vpb->RealDevice;
2400  Vpb->DeviceObject = VolumeDevice;
2401 
2402  /* set inode size */
2403  Vcb->InodeSize = (ULONG)sb->s_inode_size;
2404  if (Vcb->InodeSize == 0) {
2405  Vcb->InodeSize = EXT2_GOOD_OLD_INODE_SIZE;
2406  }
2407 
2408  /* initialize inode lookaside list */
2409  ExInitializeNPagedLookasideList(&(Vcb->InodeLookasideList),
2410  NULL, NULL, 0, Vcb->InodeSize,
2411  'SNIE', 0);
2412 
2413  InodeLookasideInitialized = TRUE;
2414 
2415  /* initialize label in Vpb */
2417  if (!NT_SUCCESS(Status)) {
2418  DbgBreak();
2419  }
2420 
2421  /* check device characteristics flags */
2422  if (IsFlagOn(Vpb->RealDevice->Characteristics, FILE_REMOVABLE_MEDIA)) {
2424  }
2425 
2426  if (IsFlagOn(Vpb->RealDevice->Characteristics, FILE_FLOPPY_DISKETTE)) {
2427  SetLongFlag(Vcb->Flags, VCB_FLOPPY_DISK);
2428  }
2429 
2430  if (IsFlagOn(Vpb->RealDevice->Characteristics, FILE_READ_ONLY_DEVICE)) {
2432  }
2433 
2434  if (IsFlagOn(TargetDevice->Characteristics, FILE_READ_ONLY_DEVICE)) {
2436  }
2437 
2438  /* verify device is writable ? */
2439  if (Ext2IsMediaWriteProtected(IrpContext, TargetDevice)) {
2440  SetFlag(Vcb->Flags, VCB_WRITE_PROTECTED);
2441  }
2442 
2443  /* initialize UUID and serial number */
2444  if (Ext2IsNullUuid(sb->s_uuid)) {
2445  ExUuidCreate((UUID *)sb->s_uuid);
2446  }
2447  Vpb->SerialNumber = ((ULONG*)sb->s_uuid)[0] +
2448  ((ULONG*)sb->s_uuid)[1] +
2449  ((ULONG*)sb->s_uuid)[2] +
2450  ((ULONG*)sb->s_uuid)[3];
2451 
2452  /* query partition size and disk geometry parameters */
2453  DiskSize = Vcb->DiskGeometry.Cylinders.QuadPart *
2454  Vcb->DiskGeometry.TracksPerCylinder *
2455  Vcb->DiskGeometry.SectorsPerTrack *
2456  Vcb->DiskGeometry.BytesPerSector;
2457 
2458  IoctlSize = sizeof(PARTITION_INFORMATION);
2460  TargetDevice,
2462  NULL,
2463  0,
2464  &Vcb->PartitionInformation,
2465  &IoctlSize );
2466  if (NT_SUCCESS(Status)) {
2467  PartSize = Vcb->PartitionInformation.PartitionLength.QuadPart;
2468  } else {
2469  Vcb->PartitionInformation.StartingOffset.QuadPart = 0;
2470  Vcb->PartitionInformation.PartitionLength.QuadPart = DiskSize;
2471  PartSize = DiskSize;
2473  }
2474  Vcb->Header.AllocationSize.QuadPart =
2475  Vcb->Header.FileSize.QuadPart = PartSize;
2476 
2477  Vcb->Header.ValidDataLength.QuadPart =
2478  Vcb->Header.FileSize.QuadPart;
2479 
2480  /* verify count */
2481  IoctlSize = sizeof(ULONG);
2483  TargetDevice,
2485  NULL,
2486  0,
2487  &ChangeCount,
2488  &IoctlSize );
2489 
2490  if (!NT_SUCCESS(Status)) {
2491  _SEH2_LEAVE;
2492  }
2493  Vcb->ChangeCount = ChangeCount;
2494 
2495  /* create the stream object for ext2 volume */
2496  Vcb->Volume = IoCreateStreamFileObject(NULL, Vcb->Vpb->RealDevice);
2497  if (!Vcb->Volume) {
2499  _SEH2_LEAVE;
2500  }
2501 
2502  /* initialize streaming object file */
2503  Vcb->Volume->SectionObjectPointer = &(Vcb->SectionObject);
2504  Vcb->Volume->ReadAccess = TRUE;
2505  Vcb->Volume->WriteAccess = TRUE;
2506  Vcb->Volume->DeleteAccess = TRUE;
2507  Vcb->Volume->FsContext = (PVOID) Vcb;
2508  Vcb->Volume->FsContext2 = NULL;
2509  Vcb->Volume->Vpb = Vcb->Vpb;
2510 
2514  Vcb->Header.AllocationSize.QuadPart;
2515 
2516  CcInitializeCacheMap( Vcb->Volume,
2517  &FileSizes,
2518  TRUE,
2520  Vcb );
2521 
2522  /* initialize disk block LargetMcb and entry Mcb,
2523  it will raise an expcetion if failed */
2524  _SEH2_TRY {
2525  FsRtlInitializeLargeMcb(&(Vcb->Extents), PagedPool);
2528  DbgBreak();
2529  } _SEH2_END;
2530  if (!NT_SUCCESS(Status)) {
2531  _SEH2_LEAVE;
2532  }
2533  ExtentsInitialized = TRUE;
2534 
2535  /* set block device */
2536  Vcb->bd.bd_dev = Vcb->RealDevice;
2537  Vcb->bd.bd_geo = Vcb->DiskGeometry;
2538  Vcb->bd.bd_part = Vcb->PartitionInformation;
2539  Vcb->bd.bd_volume = Vcb->Volume;
2540  Vcb->bd.bd_priv = (void *) Vcb;
2541  memset(&Vcb->bd.bd_bh_root, 0, sizeof(struct rb_root));
2542  InitializeListHead(&Vcb->bd.bd_bh_free);
2543  ExInitializeResourceLite(&Vcb->bd.bd_bh_lock);
2544  KeInitializeEvent(&Vcb->bd.bd_bh_notify,
2546  Vcb->bd.bd_bh_cache = kmem_cache_create("bd_bh_buffer",
2547  Vcb->BlockSize, 0, 0, NULL);
2548  if (!Vcb->bd.bd_bh_cache) {
2550  _SEH2_LEAVE;
2551  }
2552 
2553  Vcb->SectorBits = Ext2Log2(SECTOR_SIZE);
2554  Vcb->sb.s_magic = sb->s_magic;
2555  Vcb->sb.s_bdev = &Vcb->bd;
2556  Vcb->sb.s_blocksize = BLOCK_SIZE;
2557  Vcb->sb.s_blocksize_bits = BLOCK_BITS;
2558  Vcb->sb.s_priv = (void *) Vcb;
2559  Vcb->sb.s_fs_info = &Vcb->sbi;
2560 
2561  Vcb->sbi.s_es = sb;
2562  Vcb->sbi.s_blocks_per_group = sb->s_blocks_per_group;
2563  Vcb->sbi.s_first_ino = sb->s_first_ino;
2564  Vcb->sbi.s_desc_size = sb->s_desc_size;
2565 
2567  if (Vcb->sbi.s_desc_size < EXT4_MIN_DESC_SIZE_64BIT ||
2568  Vcb->sbi.s_desc_size > EXT4_MAX_DESC_SIZE ||
2569  !is_power_of_2(Vcb->sbi.s_desc_size)) {
2570  DEBUG(DL_ERR, ("EXT4-fs: unsupported descriptor size %lu\n", Vcb->sbi.s_desc_size));
2572  _SEH2_LEAVE;
2573  }
2574  } else {
2575  Vcb->sbi.s_desc_size = EXT4_MIN_DESC_SIZE;
2576  }
2577 
2578  Vcb->sbi.s_blocks_per_group = sb->s_blocks_per_group;
2579  Vcb->sbi.s_inodes_per_group = sb->s_inodes_per_group;
2580  if (EXT3_INODES_PER_GROUP(&Vcb->sb) == 0) {
2582  _SEH2_LEAVE;
2583  }
2584  Vcb->sbi.s_inodes_per_block = BLOCK_SIZE / Vcb->InodeSize;
2585  if (Vcb->sbi.s_inodes_per_block == 0) {
2587  _SEH2_LEAVE;
2588  }
2589  Vcb->sbi.s_itb_per_group = Vcb->sbi.s_inodes_per_group /
2590  Vcb->sbi.s_inodes_per_block;
2591 
2592 
2593  Vcb->sbi.s_desc_per_block = BLOCK_SIZE / GROUP_DESC_SIZE;
2594  Vcb->sbi.s_desc_per_block_bits = ilog2(Vcb->sbi.s_desc_per_block);
2595 
2596  for (i=0; i < 4; i++) {
2597  Vcb->sbi.s_hash_seed[i] = sb->s_hash_seed[i];
2598  }
2599  Vcb->sbi.s_def_hash_version = sb->s_def_hash_version;
2600 
2601  if (le32_to_cpu(sb->s_rev_level) == EXT3_GOOD_OLD_REV &&
2602  (EXT3_HAS_COMPAT_FEATURE(&Vcb->sb, ~0U) ||
2603  EXT3_HAS_RO_COMPAT_FEATURE(&Vcb->sb, ~0U) ||
2604  EXT3_HAS_INCOMPAT_FEATURE(&Vcb->sb, ~0U))) {
2606  "EXT3-fs warning: feature flags set on rev 0 fs, "
2607  "running e2fsck is recommended\n");
2608  }
2609 
2610  /*
2611  * Check feature flags regardless of the revision level, since we
2612  * previously didn't change the revision level when setting the flags,
2613  * so there is a chance incompat flags are set on a rev 0 filesystem.
2614  */
2616  if (features & EXT4_FEATURE_INCOMPAT_DIRDATA) {
2617  SetLongFlag(Vcb->Flags, VCB_READ_ONLY);
2619  }
2620  if (features) {
2621  printk(KERN_ERR "EXT3-fs: %s: couldn't mount because of "
2622  "unsupported optional features (%x).\n",
2623  Vcb->sb.s_id, le32_to_cpu(features));
2625  _SEH2_LEAVE;
2626  }
2627 
2629  if (features) {
2630  printk(KERN_ERR "EXT3-fs: %s: unsupported optional features in this volume: (%x).\n",
2631  Vcb->sb.s_id, le32_to_cpu(features));
2632  if (CanIWrite(Vcb)) {
2633  } else {
2634  SetLongFlag(Vcb->Flags, VCB_READ_ONLY);
2635  }
2636  }
2637 
2639 
2640  Vcb->sb.s_maxbytes = ext3_max_size(BLOCK_BITS, has_huge_files);
2641  Vcb->max_bitmap_bytes = ext3_max_bitmap_size(BLOCK_BITS,
2642  has_huge_files);
2643  Vcb->max_bytes = ext3_max_size(BLOCK_BITS, has_huge_files);
2644 
2645  /* calculate maximum file bocks ... */
2646  {
2648  ULONG i;
2649 
2651 
2652  Vcb->sbi.s_groups_count = (ULONG)(ext3_blocks_count(sb) - sb->s_first_data_block +
2653  sb->s_blocks_per_group - 1) / sb->s_blocks_per_group;
2654 
2655  Vcb->max_data_blocks = 0;
2656  for (i = 0; i < EXT2_BLOCK_TYPES; i++) {
2657  if (BLOCK_BITS >= 12 && i == (EXT2_BLOCK_TYPES - 1)) {
2658  dwData[i] = 0x40000000;
2659  } else {
2660  dwData[i] = dwData[i] << ((BLOCK_BITS - 2) * i);
2661  }
2662  Vcb->max_blocks_per_layer[i] = dwData[i];
2663  Vcb->max_data_blocks += Vcb->max_blocks_per_layer[i];
2664  }
2665  }
2666 
2667  Vcb->sbi.s_gdb_count = (Vcb->sbi.s_groups_count + Vcb->sbi.s_desc_per_block - 1) /
2668  Vcb->sbi.s_desc_per_block;
2669  /* load all gorup desc */
2670  if (!Ext2LoadGroup(Vcb)) {
2672  _SEH2_LEAVE;
2673  }
2674  GroupLoaded = TRUE;
2675 
2676  /* recovery journal since it's ext3 */
2677  if (Vcb->IsExt3fs) {
2678  Ext2RecoverJournal(IrpContext, Vcb);
2679  if (IsFlagOn(Vcb->Flags, VCB_JOURNAL_RECOVER)) {
2680  SetLongFlag(Vcb->Flags, VCB_READ_ONLY);
2681  }
2682  }
2683 
2684  /* Now allocating the mcb for root ... */
2685  Buffer[0] = L'\\';
2686  Buffer[1] = 0;
2687  RootNode.Buffer = Buffer;
2688  RootNode.MaximumLength = RootNode.Length = 2;
2689  Vcb->McbTree = Ext2AllocateMcb(
2690  Vcb, &RootNode, NULL,
2692  );
2693  if (!Vcb->McbTree) {
2694  DbgBreak();
2696  _SEH2_LEAVE;
2697  }
2698 
2699  Vcb->sb.s_root = Ext2BuildEntry(Vcb, NULL, &RootNode);
2700  if (!Vcb->sb.s_root) {
2701  DbgBreak();
2703  _SEH2_LEAVE;
2704  }
2705  Vcb->sb.s_root->d_sb = &Vcb->sb;
2706  Vcb->sb.s_root->d_inode = &Vcb->McbTree->Inode;
2707  Vcb->McbTree->de = Vcb->sb.s_root;
2708 
2709  /* load root inode */
2710  Vcb->McbTree->Inode.i_ino = EXT2_ROOT_INO;
2711  Vcb->McbTree->Inode.i_sb = &Vcb->sb;
2712  if (!Ext2LoadInode(Vcb, &Vcb->McbTree->Inode)) {
2713  DbgBreak();
2715  _SEH2_LEAVE;
2716  }
2717 
2718  /* initializeroot node */
2719  Vcb->McbTree->CreationTime = Ext2NtTime(Vcb->McbTree->Inode.i_ctime);
2720  Vcb->McbTree->LastAccessTime = Ext2NtTime(Vcb->McbTree->Inode.i_atime);
2721  Vcb->McbTree->LastWriteTime = Ext2NtTime(Vcb->McbTree->Inode.i_mtime);
2722  Vcb->McbTree->ChangeTime = Ext2NtTime(Vcb->McbTree->Inode.i_mtime);
2723 
2724  /* check bitmap if user specifies it */
2726  Ext2CheckBitmapConsistency(IrpContext, Vcb);
2727  }
2728 
2729  /* get anything doen, then refer target device */
2730  ObReferenceObject(Vcb->TargetDeviceObject);
2731 
2732  /* query parameters from registry */
2734 
2735  SetLongFlag(Vcb->Flags, VCB_INITIALIZED);
2736 
2737  } _SEH2_FINALLY {
2738 
2739  if (!NT_SUCCESS(Status)) {
2740 
2741  if (Vcb->McbTree) {
2742  Ext2FreeMcb(Vcb, Vcb->McbTree);
2743  }
2744 
2745  if (InodeLookasideInitialized) {
2746  ExDeleteNPagedLookasideList(&(Vcb->InodeLookasideList));
2747  }
2748 
2749  if (ExtentsInitialized) {
2750  if (Vcb->bd.bd_bh_cache) {
2751  if (GroupLoaded)
2752  Ext2PutGroup(Vcb);
2753  kmem_cache_destroy(Vcb->bd.bd_bh_cache);
2754  }
2755  FsRtlUninitializeLargeMcb(&(Vcb->Extents));
2756  }
2757 
2758  if (Vcb->Volume) {
2759  if (Vcb->Volume->PrivateCacheMap) {
2761  }
2762  ObDereferenceObject(Vcb->Volume);
2763  }
2764 
2765  if (NotifySyncInitialized) {
2766  FsRtlNotifyUninitializeSync(&Vcb->NotifySync);
2767  }
2768 
2769  if (VcbResourceInitialized) {
2770  ExDeleteResourceLite(&Vcb->FcbLock);
2771  ExDeleteResourceLite(&Vcb->McbLock);
2772  ExDeleteResourceLite(&Vcb->MetaInode);
2773  ExDeleteResourceLite(&Vcb->MetaBlock);
2774  ExDeleteResourceLite(&Vcb->sbi.s_gd_lock);
2775  ExDeleteResourceLite(&Vcb->MainResource);
2776  ExDeleteResourceLite(&Vcb->PagingIoResource);
2777  }
2778  }
2779  } _SEH2_END;
2780 
2781  return Status;
2782 }
kmem_cache_t * kmem_cache_create(const char *name, size_t size, size_t offset, unsigned long flags, kmem_cache_cb_t ctor)
Definition: linux.c:48
#define EXT4_MIN_DESC_SIZE
Definition: ext3_fs.h:170
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define EXT4_FEATURE_COMPAT_HAS_JOURNAL
Definition: ext3_fs.h:691
#define TRUE
Definition: types.h:120
#define is_power_of_2(x)
Definition: memory.c:2294
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE
Definition: ext3_fs.h:699
NTSTATUS Ext2DiskIoControl(IN PDEVICE_OBJECT DeviceOjbect, IN ULONG IoctlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer, IN OUT PULONG OutputBufferSize)
Definition: block.c:589
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:688
LARGE_INTEGER Ext2NtTime(IN ULONG i_time)
Definition: misc.c:40
superblock * sb
Definition: btrfs.c:3952
loff_t ext3_max_size(int blkbits, int has_huge_files)
Definition: generic.c:2234
#define EXT2_BLOCK_TYPES
Definition: ext2fs.h:77
#define U(x)
Definition: wordpad.c:44
#define VCB_JOURNAL_RECOVER
Definition: ext2fs.h:792
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_DISK_CHECK_VERIFY
Definition: cdrw_usr.h:175
PEXT2_MCB Ext2AllocateMcb(IN PEXT2_VCB Vcb, IN PUNICODE_STRING FileName, IN PUNICODE_STRING Parent, IN ULONG FileAttr)
Definition: memory.c:1430
VOID Ext2FreeMcb(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:1538
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
static HANDLE ULONG_PTR dwData
Definition: file.c:35
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
static CC_FILE_SIZES FileSizes
#define CanIWrite(Vcb)
Definition: ext2fs.h:812
#define GROUP_DESC_SIZE
Definition: ext2fs.h:95
struct _PARTITION_INFORMATION PARTITION_INFORMATION
LARGE_INTEGER FileSize
Definition: cctypes.h:16
#define VCB_REMOVABLE_MEDIA
Definition: ext2fs.h:799
_SEH2_TRY
Definition: create.c:4250
#define EXT2_MIN_BLOCK_SIZE
Definition: ext2_fs.h:81
#define EXT4_MIN_DESC_SIZE_64BIT
Definition: ext3_fs.h:171
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SECTOR_SIZE
Definition: winldr.h:34
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
BOOLEAN Ext2LoadGroup(IN PEXT2_VCB Vcb)
Definition: generic.c:203
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define le32_to_cpu
Definition: module.h:147
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID NTAPI FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb, IN POOL_TYPE PoolType)
Definition: largemcb.c:450
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN Ext2LoadInode(IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:504
Definition: bufpool.h:45
NTKERNELAPI NTSTATUS ExUuidCreate(OUT UUID *Uuid)
Definition: uuid.c:403
void * PVOID
Definition: retypes.h:9
#define KERN_WARNING
Definition: module.h:224
#define EXT4_FEATURE_INCOMPAT_64BIT
Definition: ext3_fs.h:710
PFILE_OBJECT NTAPI IoCreateStreamFileObject(IN PFILE_OBJECT FileObject, IN PDEVICE_OBJECT DeviceObject)
Definition: file.c:3186
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define VCB_RO_COMPAT_READ_ONLY
Definition: ext2fs.h:794
#define EXT3_HAS_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:645
#define EXT2_ROOT_INO
Definition: ext2.h:177
int64_t LONGLONG
Definition: typedefs.h:66
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
asmlinkage int printk(const char *fmt,...)
Definition: output.c:76
#define BLOCK_SIZE
Definition: dlist.c:220
#define EXT2_NDIR_BLOCKS
Definition: ext2_fs.h:177
VOID NTAPI ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:222
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
Definition: fssup.c:193
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
#define Vcb
Definition: cdprocs.h:1425
#define KERN_ERR
Definition: module.h:223
#define for
Definition: utility.h:88
#define EXT3_HAS_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:647
NTSTATUS Ext2PerformRegistryVolumeParams(IN PEXT2_VCB Vcb)
Definition: memory.c:2169
#define EXT3_GOOD_OLD_REV
Definition: ext3_fs.h:633
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define VCB_WRITE_PROTECTED
Definition: ext2fs.h:796
loff_t ext3_max_bitmap_size(int bits, int has_huge_files)
Definition: generic.c:2270
#define EXT3_HAS_INCOMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:649
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:88
static const WCHAR L[]
Definition: oid.c:1250
#define EXT2_CHECKING_BITMAP
Definition: ext2fs.h:584
#define EXT4_FEATURE_INCOMPAT_SUPP
Definition: ext3_fs.h:718
#define ilog2(n)
Definition: log2.h:84
#define EXT4_MAX_DESC_SIZE
Definition: ext3_fs.h:172
LARGE_INTEGER ValidDataLength
Definition: cctypes.h:17
static __inline BOOLEAN Ext2IsNullUuid(__u8 *uuid)
Definition: memory.c:2282
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
struct dentry * Ext2BuildEntry(PEXT2_VCB Vcb, PEXT2_MCB Dcb, PUNICODE_STRING FileName)
Definition: memory.c:444
#define VCB_READ_ONLY
Definition: ext2fs.h:795
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define DL_ERR
Definition: ext2fs.h:1397
int kmem_cache_destroy(kmem_cache_t *kc)
Definition: linux.c:82
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define VCB_FLOPPY_DISK
Definition: ext2fs.h:797
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
LARGE_INTEGER AllocationSize
Definition: cctypes.h:15
unsigned short USHORT
Definition: pedump.c:61
ULONG Ext2Log2(ULONG Value)
Definition: misc.c:25
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
#define EXT3_INODES_PER_GROUP(s)
Definition: ext3_fs.h:191
_SEH2_FINALLY
Definition: create.c:4395
VOID NTAPI FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:1053
#define EXT2_GOOD_OLD_INODE_SIZE
Definition: ext2.h:54
#define EXT2_MAX_USER_BLKSIZE
Definition: ext2fs.h:348
VOID Ext2SyncUninitializeCacheMap(IN PFILE_OBJECT FileObject)
Definition: memory.c:2871
VOID NTAPI FsRtlNotifyInitializeSync(IN PNOTIFY_SYNC *NotifySync)
Definition: notify.c:1561
#define ObReferenceObject
Definition: obfuncs.h:204
#define STATUS_DISK_CORRUPT_ERROR
Definition: udferr_usr.h:147
VOID Ext2PutGroup(IN PEXT2_VCB Vcb)
Definition: generic.c:146
unsigned int ULONG
Definition: retypes.h:1
INT Ext2RecoverJournal(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
Definition: recover.c:95
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
VOID NTAPI FsRtlNotifyUninitializeSync(IN PNOTIFY_SYNC *NotifySync)
Definition: notify.c:1639
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
CACHE_MANAGER_CALLBACKS CacheManagerNoOpCallbacks
Definition: ext2fs.h:524
#define EXT4_FEATURE_RO_COMPAT_SUPP
Definition: ext3_fs.h:724
#define EXT4_FEATURE_INCOMPAT_DIRDATA
Definition: ext3_fs.h:713
#define VCB_INITIALIZED
Definition: ext2fs.h:779
BOOLEAN Ext2CheckBitmapConsistency(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
Definition: memory.c:1895
#define _SEH2_LEAVE
Definition: filesup.c:20
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
static ext3_fsblk_t ext3_blocks_count(struct ext3_super_block *es)
Definition: ext2fs.h:1692
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2777
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:174
#define memset(x, y, z)
Definition: compat.h:39
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664
#define FILE_READ_ONLY_DEVICE
Definition: nt_native.h:808
BOOLEAN Ext2IsMediaWriteProtected(IN PEXT2_IRP_CONTEXT IrpContext, IN PDEVICE_OBJECT TargetDevice)
Definition: fsctl.c:2005
ULONG Flags
Definition: ext2fs.h:514
LONGLONG QuadPart
Definition: typedefs.h:112
PCONFIGURATION_COMPONENT_DATA RootNode
Definition: macharm.c:19
#define STATUS_CANT_WAIT
Definition: ntstatus.h:438
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:65
NTSTATUS Ext2InitializeLabel(IN PEXT2_VCB Vcb, IN PEXT2_SUPER_BLOCK Sb)
Definition: memory.c:2241

◆ Ext2InitializeZone()

NTSTATUS Ext2InitializeZone ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb 
)

Definition at line 1121 of file memory.c.

1126 {
1128 
1129  ULONG Start = 0;
1130  ULONG End;
1131  ULONG Block;
1132  ULONG Mapped;
1133 
1134  Ext2ClearAllExtents(&Mcb->Extents);
1135  Ext2ClearAllExtents(&Mcb->MetaExts);
1136 
1137  ASSERT(Mcb != NULL);
1138  End = (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS);
1139 
1140  while (Start < End) {
1141 
1142  Block = Mapped = 0;
1143 
1144  /* mapping file offset to ext2 block */
1145  if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1147  IrpContext,
1148  Vcb,
1149  Mcb,
1150  Start,
1151  FALSE,
1152  &Block,
1153  &Mapped
1154  );
1155  } else {
1157  IrpContext,
1158  Vcb,
1159  Mcb,
1160  Start,
1161  FALSE,
1162  &Block,
1163  &Mapped
1164  );
1165  }
1166 
1167  if (!NT_SUCCESS(Status)) {
1168  goto errorout;
1169  }
1170 
1171  /* skip wrong blocks, in case wrongly treating symlink
1172  target names as blocks, silly */
1173  if (Block >= TOTAL_BLOCKS) {
1174  Block = 0;
1175  }
1176 
1177  if (Block) {
1178  if (!Ext2AddBlockExtent(Vcb, Mcb, Start, Block, Mapped)) {
1179  DbgBreak();
1180  ClearFlag(Mcb->Flags, MCB_ZONE_INITED);
1181  Ext2ClearAllExtents(&Mcb->Extents);
1183  goto errorout;
1184  }
1185  DEBUG(DL_MAP, ("Ext2InitializeZone %wZ: Block = %xh Mapped = %xh\n",
1186  &Mcb->FullName, Block, Mapped));
1187  }
1188 
1189  /* Mapped is total number of continous blocks or NULL blocks */
1190  Start += Mapped;
1191  }
1192 
1193  /* set mcb zone as initialized */
1194  SetLongFlag(Mcb->Flags, MCB_ZONE_INITED);
1195 
1196 errorout:
1197 
1198  if (!IsZoneInited(Mcb)) {
1199  Ext2ClearAllExtents(&Mcb->Extents);
1200  Ext2ClearAllExtents(&Mcb->MetaExts);
1201  }
1202 
1203  return Status;
1204 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN Ext2AddBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Block, IN ULONG Number)
Definition: memory.c:1027
NTSTATUS Ext2MapExtent(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN Alloc, OUT PULONG Block, OUT PULONG Number)
Definition: extents.c:25
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
#define DL_MAP
Definition: ext2fs.h:1407
#define BLOCK_SIZE
Definition: dlist.c:220
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
#define INODE_HAS_EXTENT(i)
Definition: ext4_ext.h:228
Definition: partlist.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define MCB_ZONE_INITED
Definition: ext2fs.h:948
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
NTSTATUS Ext2MapIndirect(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN bAlloc, OUT PULONG pBlock, OUT PULONG Number)
Definition: indirect.c:823
VOID Ext2ClearAllExtents(PLARGE_MCB Zone)
Definition: memory.c:637
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define IsZoneInited(Mcb)
Definition: ext2fs.h:954

Referenced by Ext2BuildExtents(), and Ext2TruncateIndirectFast().

◆ Ext2InsertFcb()

VOID Ext2InsertFcb ( PEXT2_VCB  Vcb,
PEXT2_FCB  Fcb 
)

Definition at line 309 of file memory.c.

310 {
312 
313  KeQuerySystemTime(&Fcb->TsDrop);
314  Ext2ReferXcb(&Vcb->FcbCount);
315  Ext2ReferXcb(&Vcb->ReferenceCount);
316  InsertTailList(&Vcb->FcbList, &Fcb->Next);
317 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define InsertTailList(ListHead, Entry)
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1619
#define Vcb
Definition: cdprocs.h:1425
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_ PFCB Fcb
Definition: cdprocs.h:151

Referenced by Ext2AllocateFcb().

◆ Ext2InsertMcb()

VOID Ext2InsertMcb ( PEXT2_VCB  Vcb,
PEXT2_MCB  Parent,
PEXT2_MCB  Child 
)

Definition at line 1686 of file memory.c.

1691 {
1692  BOOLEAN LockAcquired = FALSE;
1693  PEXT2_MCB Mcb = NULL;
1694 
1695  _SEH2_TRY {
1696 
1698  &Vcb->McbLock,
1699  TRUE );
1700  LockAcquired = TRUE;
1701 
1702  /* use it's target if it's a symlink */
1703  if (IsMcbSymLink(Parent)) {
1704  Parent = Parent->Target;
1706  }
1707 
1708  Mcb = Parent->Child;
1709  while (Mcb) {
1710  if (Mcb == Child) {
1711  break;
1712  }
1713  Mcb = Mcb->Next;
1714  }
1715 
1716  if (Mcb) {
1717  /* already attached in the list */
1718  DEBUG(DL_ERR, ( "Ext2InsertMcb: Child Mcb is alreay attached.\n"));
1719  if (!IsFlagOn(Mcb->Flags, MCB_ENTRY_TREE)) {
1720  SetLongFlag(Child->Flags, MCB_ENTRY_TREE);
1721  DEBUG(DL_ERR, ( "Ext2InsertMcb: Child Mcb's flag isn't set.\n"));
1722  }
1723 
1724  DbgBreak();
1725 
1726  } else {
1727 
1728  /* insert this Mcb into the head */
1729  Child->Next = Parent->Child;
1730  Parent->Child = Child;
1731  Child->Parent = Parent;
1732  Child->de->d_parent = Parent->de;
1734  SetLongFlag(Child->Flags, MCB_ENTRY_TREE);
1735  }
1736 
1737  } _SEH2_FINALLY {
1738 
1739  if (LockAcquired) {
1740  ExReleaseResourceLite(&Vcb->McbLock);
1741  }
1742  } _SEH2_END;
1743 }
#define TRUE
Definition: types.h:120
#define Ext2ReferMcb(Mcb)
Definition: ext2fs.h:986
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:716
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define MCB_ENTRY_TREE
Definition: ext2fs.h:945
#define IsMcbSymLink(Mcb)
Definition: ext2fs.h:953
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DL_ERR
Definition: ext2fs.h:1397
_SEH2_END
Definition: create.c:4424
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
_SEH2_FINALLY
Definition: create.c:4395
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE Child
Definition: acpixf.h:716
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129

Referenced by Ext2LookupFile(), and Ext2SetRenameInfo().

◆ Ext2InsertVcb()

VOID Ext2InsertVcb ( PEXT2_VCB  Vcb)

Definition at line 1931 of file memory.c.

1932 {
1933  InsertTailList(&(Ext2Global->VcbList), &Vcb->Next);
1934 }
LIST_ENTRY VcbList
Definition: ext2fs.h:536
#define InsertTailList(ListHead, Entry)
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define Vcb
Definition: cdprocs.h:1425

Referenced by Ext2MountVolume().

◆ Ext2IsNullUuid()

static __inline BOOLEAN Ext2IsNullUuid ( __u8 uuid)
static

Definition at line 2282 of file memory.c.

2283 {
2284  int i;
2285  for (i = 0; i < 16; i++) {
2286  if (uuid[i]) {
2287  break;
2288  }
2289  }
2290 
2291  return (i >= 16);
2292 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: msctf.idl:510

Referenced by Ext2InitializeVcb().

◆ Ext2JointExtents()

VOID Ext2JointExtents ( IN PEXT2_EXTENT  Chain,
IN PEXT2_EXTENT  Extent 
)

Definition at line 527 of file memory.c.

531 {
532 #ifndef __REACTOS__
533  ULONG count = 0;
534 #endif
535  PEXT2_EXTENT List = Chain;
536 
537  while (List->Next) {
538  List = List->Next;
539  }
540 
541  List->Next = Extent;
542 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
LIST_ENTRY List
Definition: psmgr.c:57
unsigned int ULONG
Definition: retypes.h:1

Referenced by Ext2QueryExtentMappings().

◆ Ext2LinkHeadMcb()

VOID Ext2LinkHeadMcb ( PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb 
)

Definition at line 2923 of file memory.c.

2924 {
2925  if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
2926  return;
2927  }
2928 
2930 
2931  if (!IsFlagOn(Mcb->Flags, MCB_VCB_LINK)) {
2932  InsertHeadList(&Vcb->McbList, &Mcb->Link);
2933  SetLongFlag(Mcb->Flags, MCB_VCB_LINK);
2934  Ext2ReferXcb(&Vcb->NumOfMcb);
2935  } else {
2936  DEBUG(DL_RES, ( "Ext2LinkHeadMcb: %wZ already linked.\n",
2937  &Mcb->FullName));
2938  }
2939  ExReleaseResourceLite(&Vcb->McbLock);
2940 }
#define MCB_VCB_LINK
Definition: ext2fs.h:944
#define TRUE
Definition: types.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define EXT2_ROOT_INO
Definition: ext2.h:177
#define Vcb
Definition: cdprocs.h:1425
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define DL_RES
Definition: ext2fs.h:1403
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
#define DEBUG(args)
Definition: rdesktop.h:129

Referenced by Ext2FreeCcb(), and Ext2UnlinkFcb().

◆ Ext2LinkTailMcb()

VOID Ext2LinkTailMcb ( PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb 
)

Definition at line 2900 of file memory.c.

2901 {
2902  if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
2903  return;
2904  }
2905 
2907 
2908  if (IsFlagOn(Mcb->Flags, MCB_VCB_LINK)) {
2909  DEBUG(DL_RES, ( "Ext2LinkTailMcb: %wZ already linked.\n",
2910  &Mcb->FullName));
2911  } else {
2912  InsertTailList(&Vcb->McbList, &Mcb->Link);
2913  SetLongFlag(Mcb->Flags, MCB_VCB_LINK);
2914  Ext2ReferXcb(&Vcb->NumOfMcb);
2915  }
2916 
2917  ExReleaseResourceLite(&Vcb->McbLock);
2918 }
#define MCB_VCB_LINK
Definition: ext2fs.h:944
#define TRUE
Definition: types.h:120
#define InsertTailList(ListHead, Entry)
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define EXT2_ROOT_INO
Definition: ext2.h:177
#define Vcb
Definition: cdprocs.h:1425
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define DL_RES
Definition: ext2fs.h:1403
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
#define DEBUG(args)
Definition: rdesktop.h:129

Referenced by Ext2LookupFile().

◆ Ext2ListExtents()

BOOLEAN Ext2ListExtents ( PLARGE_MCB  Extents)

Definition at line 558 of file memory.c.

559 {
560  if (FsRtlNumberOfRunsInLargeMcb(Extents) != 0) {
561 
562  LONGLONG DirtyVba;
563  LONGLONG DirtyLba;
564  LONGLONG DirtyLength;
565  int i, n = 0;
566 
567  for (i = 0; FsRtlGetNextLargeMcbEntry(
568  Extents, i, &DirtyVba,
569  &DirtyLba, &DirtyLength); i++) {
570  if (DirtyVba > 0 && DirtyLba != -1) {
571  DEBUG(DL_EXT, ("Vba:%I64xh Lba:%I64xh Len:%I64xh.\n", DirtyVba, DirtyLba, DirtyLength));
572  n++;
573  }
574  }
575 
576  return n ? TRUE : FALSE;
577  }
578 
579  return FALSE;
580 }
#define TRUE
Definition: types.h:120
GLdouble n
Definition: glext.h:7729
ULONG NTAPI FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:769
BOOLEAN NTAPI FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb, IN ULONG RunIndex, OUT PLONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG SectorCount)
Definition: largemcb.c:391
#define DL_EXT
Definition: ext2fs.h:1406
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int64_t LONGLONG
Definition: typedefs.h:66
#define DEBUG(args)
Definition: rdesktop.h:129

Referenced by Ext2DestroyVcb(), Ext2FreeMcb(), and Ext2TruncateFile().

◆ Ext2LookupBlockExtent()

BOOLEAN Ext2LookupBlockExtent ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Start,
IN PULONG  Block,
IN PULONG  Mapped 
)

Definition at line 1061 of file memory.c.

1068 {
1069  LONGLONG Vbn = 0;
1070  LONGLONG Lbn = 0;
1071  LONGLONG Length = 0;
1072 
1073  BOOLEAN rc = FALSE;
1074 
1075  Vbn = ((LONGLONG) Start) << BLOCK_BITS;
1076 
1077  if (Mcb) {
1078  rc = Ext2LookupMcbExtent(Vcb, Mcb, Vbn, &Lbn, &Length);
1079  } else {
1080  rc = Ext2LookupVcbExtent(Vcb, Vbn, &Lbn, &Length);
1081  }
1082 
1083  if (rc) {
1084  *Mapped = (ULONG)(Length >> BLOCK_BITS);
1085  if (Lbn != -1 && Length > 0) {
1086  *Block = (ULONG)(Lbn >> BLOCK_BITS);
1087  } else {
1088  *Block = 0;
1089  }
1090  }
1091 
1092  return rc;
1093 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Lbn
Definition: fsrtlfuncs.h:479
BOOLEAN Ext2LookupVcbExtent(IN PEXT2_VCB Vcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG Length)
Definition: memory.c:747
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN Ext2LookupMcbExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG Length)
Definition: memory.c:897
Definition: partlist.h:33
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
_In_ LONGLONG Vbn
Definition: fsrtlfuncs.h:470
unsigned int ULONG
Definition: retypes.h:1

Referenced by Ext2AddBlockExtent(), and Ext2BuildExtents().

◆ Ext2LookupMcbEx