ReactOS  0.4.13-dev-482-ge57f103
memory.c File Reference
#include "ntifs.h"
#include "ffsdrv.h"
Include dependency graph for memory.c:

Go to the source code of this file.

Macros

#define MCB_NUM_SHIFT   0x04
 

Functions

__drv_mustHoldCriticalRegion PFFS_IRP_CONTEXT FFSAllocateIrpContext (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
__drv_mustHoldCriticalRegion VOID FFSFreeIrpContext (IN PFFS_IRP_CONTEXT IrpContext)
 
VOID FFSRepinBcb (IN PFFS_IRP_CONTEXT IrpContext, IN PBCB Bcb)
 
VOID FFSUnpinRepinnedBcbs (IN PFFS_IRP_CONTEXT IrpContext)
 
__drv_mustHoldCriticalRegion PFFS_FCB FFSv1AllocateFcb (IN PFFS_VCB Vcb, IN PFFS_MCB FFSMcb, IN PFFSv1_INODE dinode1)
 
__drv_mustHoldCriticalRegion PFFS_FCB FFSv2AllocateFcb (IN PFFS_VCB Vcb, IN PFFS_MCB FFSMcb, IN PFFSv2_INODE dinode2)
 
__drv_mustHoldCriticalRegion VOID FFSFreeFcb (IN PFFS_FCB Fcb)
 
__drv_mustHoldCriticalRegion PFFS_CCB FFSAllocateCcb (VOID)
 
__drv_mustHoldCriticalRegion VOID FFSFreeCcb (IN PFFS_CCB Ccb)
 
__drv_mustHoldCriticalRegion PFFS_MCB FFSAllocateMcb (PFFS_VCB Vcb, PUNICODE_STRING FileName, ULONG FileAttr)
 
__drv_mustHoldCriticalRegion VOID FFSFreeMcb (IN PFFS_MCB Mcb)
 
__drv_mustHoldCriticalRegion PFFS_FCB FFSCreateFcbFromMcb (PFFS_VCB Vcb, PFFS_MCB Mcb)
 
BOOLEAN FFSGetFullFileName (PFFS_MCB Mcb, PUNICODE_STRING FileName)
 
PFFS_MCB FFSSearchMcbTree (PFFS_VCB Vcb, PFFS_MCB FFSMcb, ULONG Inode)
 
PFFS_MCB FFSSearchMcb (PFFS_VCB Vcb, PFFS_MCB Parent, PUNICODE_STRING FileName)
 
VOID FFSRefreshMcb (PFFS_VCB Vcb, PFFS_MCB Mcb)
 
VOID FFSAddMcbNode (PFFS_VCB Vcb, PFFS_MCB Parent, PFFS_MCB Child)
 
BOOLEAN FFSDeleteMcbNode (PFFS_VCB Vcb, PFFS_MCB McbTree, PFFS_MCB FFSMcb)
 
__drv_mustHoldCriticalRegion VOID FFSFreeMcbTree (PFFS_MCB McbTree)
 
BOOLEAN FFSCheckSetBlock (PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, ULONG Block)
 
BOOLEAN FFSCheckBitmapConsistency (PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb)
 
VOID FFSInsertVcb (PFFS_VCB Vcb)
 
VOID FFSRemoveVcb (PFFS_VCB Vcb)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSInitializeVcb (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_SUPER_BLOCK FFSSb, IN PDEVICE_OBJECT TargetDevice, IN PDEVICE_OBJECT VolumeDevice, IN PVPB Vpb)
 
__drv_mustHoldCriticalRegion VOID FFSFreeVcb (IN PFFS_VCB Vcb)
 
VOID FFSSyncUninitializeCacheMap (IN PFILE_OBJECT FileObject)
 

Variables

PFFS_GLOBAL FFSGlobal
 

Macro Definition Documentation

◆ MCB_NUM_SHIFT

#define MCB_NUM_SHIFT   0x04

Function Documentation

◆ FFSAddMcbNode()

VOID FFSAddMcbNode ( PFFS_VCB  Vcb,
PFFS_MCB  Parent,
PFFS_MCB  Child 
)

Definition at line 1278 of file memory.c.

1282 {
1283  PFFS_MCB TmpMcb = Parent->Child;
1284 
1285  PAGED_CODE();
1286 
1287  if(IsFlagOn(Child->Flags, MCB_IN_TREE))
1288  {
1289  FFSBreakPoint();
1290  FFSPrint((DBG_ERROR, "FFSAddMcbNode: Child Mcb is alreay in the tree.\n"));
1291  return;
1292  }
1293 
1294  if (TmpMcb)
1295  {
1296  ASSERT(TmpMcb->Parent == Parent);
1297 
1298  while (TmpMcb->Next)
1299  {
1300  TmpMcb = TmpMcb->Next;
1301  ASSERT(TmpMcb->Parent == Parent);
1302  }
1303 
1304  TmpMcb->Next = Child;
1305  Child->Parent = Parent;
1306  Child->Next = NULL;
1307  }
1308  else
1309  {
1310  Parent->Child = Child;
1311  Child->Parent = Parent;
1312  Child->Next = NULL;
1313  }
1314 
1315  InsertTailList(&(Vcb->McbList), &(Child->Link));
1316  SetFlag(Child->Flags, MCB_IN_TREE);
1317 }
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
#define InsertTailList(ListHead, Entry)
#define PAGED_CODE()
Definition: video.h:57
#define FFSBreakPoint()
Definition: ffsdrv.h:43
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
smooth NULL
Definition: ftsmooth.c:416
PFFS_MCB Next
Definition: ffsdrv.h:652
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define MCB_IN_TREE
Definition: ffsdrv.h:679
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
PFFS_MCB Parent
Definition: ffsdrv.h:650

Referenced by FFSSetRenameInfo(), FFSv1LookupFileName(), and FFSv2LookupFileName().

◆ FFSAllocateCcb()

Definition at line 803 of file memory.c.

805 {
806  PFFS_CCB Ccb;
807 
808  PAGED_CODE();
809 
812  TRUE);
813 
814  Ccb = (PFFS_CCB)(ExAllocateFromNPagedLookasideList(&(FFSGlobal->FFSCcbLookasideList)));
815 
819 
820  if (Ccb == NULL)
821  {
823 
824  RtlZeroMemory(Ccb, sizeof(FFS_CCB));
825 
827  }
828  else
829  {
830  RtlZeroMemory(Ccb, sizeof(FFS_CCB));
831  }
832 
833  if (!Ccb)
834  {
835  return NULL;
836  }
837 
839  Ccb->Identifier.Size = sizeof(FFS_CCB);
840 
841  Ccb->CurrentByteOffset = 0;
842 
843  Ccb->DirectorySearchPattern.Length = 0;
844  Ccb->DirectorySearchPattern.MaximumLength = 0;
845  Ccb->DirectorySearchPattern.Buffer = 0;
846 
847  return Ccb;
848 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
NPAGED_LOOKASIDE_LIST FFSCcbLookasideList
Definition: ffsdrv.h:380
struct _FFS_CCB FFS_CCB
Definition: ffsdrv.h:282
smooth NULL
Definition: ftsmooth.c:416
ERESOURCE LAResource
Definition: ffsdrv.h:358
ULONG Flags
Definition: ntfs.h:520
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG Type
Definition: ntfs.h:95
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
struct _FFS_CCB * PFFS_CCB
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define CCB_FROM_POOL
Definition: ext2fs.h:1022
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
ULONG Size
Definition: ntfs.h:96

Referenced by FFSCreateFile(), and FFSCreateVolume().

◆ FFSAllocateIrpContext()

__drv_mustHoldCriticalRegion PFFS_IRP_CONTEXT FFSAllocateIrpContext ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 52 of file memory.c.

55 {
56  PIO_STACK_LOCATION IoStackLocation;
57  PFFS_IRP_CONTEXT IrpContext;
58 
59  PAGED_CODE();
60 
62  ASSERT(Irp != NULL);
63 
64  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
65 
68  TRUE);
69 
70  IrpContext = (PFFS_IRP_CONTEXT)(ExAllocateFromNPagedLookasideList(&(FFSGlobal->FFSIrpContextLookasideList)));
71 
75 
76  if (IrpContext == NULL)
77  {
79 
80  //
81  // Zero out the irp context and indicate that it is from pool and
82  // not region allocated
83  //
84 
85  RtlZeroMemory(IrpContext, sizeof(FFS_IRP_CONTEXT));
86 
88  }
89  else
90  {
91  //
92  // Zero out the irp context and indicate that it is from zone and
93  // not pool allocated
94  //
95 
96  RtlZeroMemory(IrpContext, sizeof(FFS_IRP_CONTEXT));
97  }
98 
99  if (!IrpContext)
100  {
101  return NULL;
102  }
103 
104  IrpContext->Identifier.Type = FFSICX;
105  IrpContext->Identifier.Size = sizeof(FFS_IRP_CONTEXT);
106 
107  IrpContext->Irp = Irp;
108 
109  IrpContext->MajorFunction = IoStackLocation->MajorFunction;
110  IrpContext->MinorFunction = IoStackLocation->MinorFunction;
111 
112  IrpContext->DeviceObject = DeviceObject;
113 
114  IrpContext->FileObject = IoStackLocation->FileObject;
115 
116  if (IrpContext->FileObject != NULL)
117  {
118  IrpContext->RealDevice = IrpContext->FileObject->DeviceObject;
119  }
120  else if (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL)
121  {
122  if (IoStackLocation->Parameters.MountVolume.Vpb)
123  {
124  IrpContext->RealDevice =
125  IoStackLocation->Parameters.MountVolume.Vpb->RealDevice;
126  }
127  }
128 
129  if (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL ||
130  IrpContext->MajorFunction == IRP_MJ_DEVICE_CONTROL ||
131  IrpContext->MajorFunction == IRP_MJ_SHUTDOWN)
132  {
133  IrpContext->IsSynchronous = TRUE;
134  }
135  else if (IrpContext->MajorFunction == IRP_MJ_CLEANUP ||
136  IrpContext->MajorFunction == IRP_MJ_CLOSE)
137  {
138  IrpContext->IsSynchronous = FALSE;
139  }
140 #if (_WIN32_WINNT >= 0x0500)
141  else if (IrpContext->MajorFunction == IRP_MJ_PNP)
142  {
144  {
145  IrpContext->IsSynchronous = TRUE;
146  }
147  else
148  {
150  }
151  }
152 #endif //(_WIN32_WINNT >= 0x0500)
153  else
154  {
156  }
157 
158 #if 0
159  //
160  // Temporary workaround for a bug in close that makes it reference a
161  // fileobject when it is no longer valid.
162  //
163  if (IrpContext->MajorFunction == IRP_MJ_CLOSE)
164  {
165  IrpContext->IsSynchronous = TRUE;
166  }
167 #endif
168 
169  IrpContext->IsTopLevel = (IoGetTopLevelIrp() == Irp);
170 
171  IrpContext->ExceptionInProgress = FALSE;
172 
173  return IrpContext;
174 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
UCHAR MajorFunction
Definition: ffsdrv.h:731
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
struct _FFS_IRP_CONTEXT FFS_IRP_CONTEXT
NPAGED_LOOKASIDE_LIST FFSIrpContextLookasideList
Definition: ffsdrv.h:378
#define IRP_CONTEXT_FLAG_FROM_POOL
Definition: ext2fs.h:1077
Definition: ffsdrv.h:283
PFILE_OBJECT FileObject
Definition: ffsdrv.h:741
BOOLEAN NTAPI IoIsOperationSynchronous(IN PIRP Irp)
Definition: irp.c:1882
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
BOOLEAN ExceptionInProgress
Definition: ffsdrv.h:756
BOOLEAN IsTopLevel
Definition: ffsdrv.h:750
struct _FFS_IRP_CONTEXT * PFFS_IRP_CONTEXT
smooth NULL
Definition: ftsmooth.c:416
FFS_IDENTIFIER_TYPE Type
Definition: ffsdrv.h:294
ULONG Size
Definition: ffsdrv.h:295
ERESOURCE LAResource
Definition: ffsdrv.h:358
#define IRP_MJ_FILE_SYSTEM_CONTROL
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
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
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
FFS_IDENTIFIER Identifier
Definition: ffsdrv.h:722
PDEVICE_OBJECT DeviceObject
Definition: ffsdrv.h:735
#define IRP_MJ_CLEANUP
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
PDEVICE_OBJECT RealDevice
Definition: ffsdrv.h:738
BOOLEAN IsSynchronous
Definition: ffsdrv.h:747
UCHAR MinorFunction
Definition: ffsdrv.h:732
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by FFSBuildRequest().

◆ FFSAllocateMcb()

__drv_mustHoldCriticalRegion PFFS_MCB FFSAllocateMcb ( PFFS_VCB  Vcb,
PUNICODE_STRING  FileName,
ULONG  FileAttr 
)

Definition at line 889 of file memory.c.

893 {
894  PFFS_MCB Mcb = NULL;
896 
897  ULONG Extra = 0;
898 
899  PAGED_CODE();
900 
901 #define MCB_NUM_SHIFT 0x04
902 
904  Extra = FFSGlobal->McbAllocated -
907 
909  "FFSAllocateMcb: CurrDepth=%xh/%xh/%xh FileName=%S\n",
912  FFSGlobal->FcbAllocated,
913  FileName->Buffer));
914 
915  List = Vcb->McbList.Flink;
916 
917  while ((List != &(Vcb->McbList)) && (Extra > 0))
918  {
920  List = List->Flink;
921 
922  if ((Mcb->Inode != 2) && (Mcb->Child == NULL) &&
923  (Mcb->FFSFcb == NULL) && (!IsMcbUsed(Mcb)))
924  {
925  FFSPrint((DBG_INFO, "FFSAllocateMcb: Mcb %S will be freed.\n",
926  Mcb->ShortName.Buffer));
927 
928  if (FFSDeleteMcbNode(Vcb, Vcb->McbTree, Mcb))
929  {
930  FFSFreeMcb(Mcb);
931 
932  Extra--;
933  }
934  }
935  }
936 
939  TRUE);
940 
941  Mcb = (PFFS_MCB)(ExAllocateFromPagedLookasideList(
943 
947 
948  if (Mcb == NULL)
949  {
951 
952  RtlZeroMemory(Mcb, sizeof(FFS_MCB));
953 
954  SetFlag(Mcb->Flags, MCB_FROM_POOL);
955  }
956  else
957  {
958  RtlZeroMemory(Mcb, sizeof(FFS_MCB));
959  }
960 
961  if (!Mcb)
962  {
963  return NULL;
964  }
965 
966  Mcb->Identifier.Type = FFSMCB;
967  Mcb->Identifier.Size = sizeof(FFS_MCB);
968 
969  if (FileName && FileName->Length)
970  {
971  Mcb->ShortName.Length = FileName->Length;
972  Mcb->ShortName.MaximumLength = Mcb->ShortName.Length + 2;
973 
974  Mcb->ShortName.Buffer = ExAllocatePoolWithTag(PagedPool, Mcb->ShortName.MaximumLength, FFS_POOL_TAG);
975 
976  if (!Mcb->ShortName.Buffer)
977  goto errorout;
978 
979  RtlZeroMemory(Mcb->ShortName.Buffer, Mcb->ShortName.MaximumLength);
980  RtlCopyMemory(Mcb->ShortName.Buffer, FileName->Buffer, Mcb->ShortName.Length);
981  }
982 
983  Mcb->FileAttr = FileAttr;
984 
987  TRUE);
988 
990 
994 
995  return Mcb;
996 
997 errorout:
998 
999  if (Mcb)
1000  {
1001  if (Mcb->ShortName.Buffer)
1002  ExFreePool(Mcb->ShortName.Buffer);
1003 
1004  if (FlagOn(Mcb->Flags, MCB_FROM_POOL))
1005  {
1006  ExFreePool(Mcb);
1007  }
1008  else
1009  {
1012  TRUE);
1013 
1014  ExFreeToPagedLookasideList(&(FFSGlobal->FFSMcbLookasideList), Mcb);
1015 
1019  }
1020  }
1021 
1022  return NULL;
1023 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
BOOLEAN FFSDeleteMcbNode(PFFS_VCB Vcb, PFFS_MCB McbTree, PFFS_MCB FFSMcb)
Definition: memory.c:1321
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define MCB_FROM_POOL
Definition: ext2fs.h:943
USHORT MaxDepth
Definition: ffsdrv.h:377
static int Link(const char **args)
Definition: vfdcmd.c:2414
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
USHORT McbAllocated
Definition: ffsdrv.h:384
ERESOURCE CountResource
Definition: ffsdrv.h:355
Definition: ffsdrv.h:285
smooth NULL
Definition: ftsmooth.c:416
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
ERESOURCE LAResource
Definition: ffsdrv.h:358
LIST_ENTRY List
Definition: psmgr.c:57
struct _FFS_MCB * PFFS_MCB
Definition: ffsdrv.h:301
#define Vcb
Definition: cdprocs.h:1425
__drv_mustHoldCriticalRegion VOID FFSFreeMcb(IN PFFS_MCB Mcb)
Definition: memory.c:1028
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: typedefs.h:117
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
#define MCB_NUM_SHIFT
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define IsMcbUsed(Mcb)
Definition: ext2fs.h:952
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
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 RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define DBG_INFO
Definition: ffsdrv.h:1034
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PAGED_LOOKASIDE_LIST FFSMcbLookasideList
Definition: ffsdrv.h:381
struct _FFS_MCB FFS_MCB
Definition: ffsdrv.h:301

Referenced by FFSInitializeVcb(), FFSv1LookupFileName(), and FFSv2LookupFileName().

◆ FFSCheckBitmapConsistency()

BOOLEAN FFSCheckBitmapConsistency ( PFFS_IRP_CONTEXT  IrpContext,
PFFS_VCB  Vcb 
)

Definition at line 1500 of file memory.c.

1503 {
1504  PAGED_CODE();
1505 #if 0
1506  ULONG i, j, InodeBlocks;
1507 
1508  for (i = 0; i < Vcb->ffs_groups; i++)
1509  {
1510  FFSCheckSetBlock(IrpContext, Vcb, Vcb->ffs_group_desc[i].bg_block_bitmap);
1511  FFSCheckSetBlock(IrpContext, Vcb, Vcb->ffs_group_desc[i].bg_inode_bitmap);
1512 
1513 
1514  if (i == Vcb->ffs_groups - 1)
1515  {
1516  InodeBlocks = ((INODES_COUNT % INODES_PER_GROUP) * sizeof(FFS_INODE) + Vcb->BlockSize - 1) / (Vcb->BlockSize);
1517  }
1518  else
1519  {
1520  InodeBlocks = (INODES_PER_GROUP * sizeof(FFS_INODE) + Vcb->BlockSize - 1) / (Vcb->BlockSize);
1521  }
1522 
1523  for (j = 0; j < InodeBlocks; j++)
1524  FFSCheckSetBlock(IrpContext, Vcb, Vcb->ffs_group_desc[i].bg_inode_table + j);
1525  }
1526 
1527  return TRUE;
1528 #endif
1529  return FALSE;
1530 }
#define TRUE
Definition: types.h:120
BOOLEAN FFSCheckSetBlock(PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, ULONG Block)
Definition: memory.c:1412
#define PAGED_CODE()
Definition: video.h:57
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
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
#define Vcb
Definition: cdprocs.h:1425
unsigned int ULONG
Definition: retypes.h:1
#define INODES_PER_GROUP
Definition: ext2fs.h:99
#define INODES_COUNT
Definition: ext2fs.h:97

Referenced by FFSInitializeVcb().

◆ FFSCheckSetBlock()

BOOLEAN FFSCheckSetBlock ( PFFS_IRP_CONTEXT  IrpContext,
PFFS_VCB  Vcb,
ULONG  Block 
)

Definition at line 1412 of file memory.c.

1416 {
1417  PAGED_CODE();
1418 #if 0
1419  ULONG Group, dwBlk, Length;
1420 
1421  RTL_BITMAP BlockBitmap;
1422  PVOID BitmapCache;
1423  PBCB BitmapBcb;
1424 
1426 
1427  BOOLEAN bModified = FALSE;
1428 
1429 
1430  //Group = (Block - FFS_FIRST_DATA_BLOCK) / BLOCKS_PER_GROUP;
1431 
1432  dwBlk = (Block - FFS_FIRST_DATA_BLOCK) % BLOCKS_PER_GROUP;
1433 
1434 
1435  Offset.QuadPart = (LONGLONG) Vcb->BlockSize;
1436  Offset.QuadPart = Offset.QuadPart * Vcb->ffs_group_desc[Group].bg_block_bitmap;
1437 
1438  if (Group == Vcb->ffs_groups - 1)
1439  {
1441 
1442  /* s_blocks_count is integer multiple of s_blocks_per_group */
1443  if (Length == 0)
1445  }
1446  else
1447  {
1449  }
1450 
1451  if (dwBlk >= Length)
1452  return FALSE;
1453 
1454  if (!CcPinRead(Vcb->StreamObj,
1455  &Offset,
1456  Vcb->BlockSize,
1457  PIN_WAIT,
1458  &BitmapBcb,
1459  &BitmapCache))
1460  {
1461  FFSPrint((DBG_ERROR, "FFSDeleteBlock: PinReading error ...\n"));
1462  return FALSE;
1463  }
1464 
1465  RtlInitializeBitMap(&BlockBitmap,
1466  BitmapCache,
1467  Length);
1468 
1469  if (RtlCheckBit(&BlockBitmap, dwBlk) == 0)
1470  {
1471  FFSBreakPoint();
1472  RtlSetBits(&BlockBitmap, dwBlk, 1);
1473  bModified = TRUE;
1474  }
1475 
1476  if (bModified)
1477  {
1478  CcSetDirtyPinnedData(BitmapBcb, NULL);
1479 
1480  FFSRepinBcb(IrpContext, BitmapBcb);
1481 
1482  FFSAddMcbEntry(Vcb, Offset.QuadPart, (LONGLONG)Vcb->BlockSize);
1483  }
1484 
1485  {
1486  CcUnpinData(BitmapBcb);
1487  BitmapBcb = NULL;
1488  BitmapCache = NULL;
1489 
1490  RtlZeroMemory(&BlockBitmap, sizeof(RTL_BITMAP));
1491  }
1492 
1493  return (!bModified);
1494 #endif
1495  return FALSE;
1496 }
#define TRUE
Definition: types.h:120
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
Definition: cachesub.c:121
_In_opt_ PSID Group
Definition: rtlfuncs.h:1606
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
#define PIN_WAIT
#define RtlCheckBit(BMH, BP)
Definition: rtlfuncs.h:3154
#define FFS_FIRST_DATA_BLOCK
Definition: ffsdrv.h:256
VOID FFSRepinBcb(IN PFFS_IRP_CONTEXT IrpContext, IN PBCB Bcb)
Definition: memory.c:221
#define PAGED_CODE()
Definition: video.h:57
#define FFSBreakPoint()
Definition: ffsdrv.h:43
__drv_mustHoldCriticalRegion BOOLEAN FFSAddMcbEntry(IN PFFS_VCB Vcb, IN LONGLONG Lba, IN LONGLONG Length)
Definition: ffs.c:2673
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
#define BLOCKS_PER_GROUP
Definition: ext2fs.h:100

Referenced by FFSCheckBitmapConsistency().

◆ FFSCreateFcbFromMcb()

__drv_mustHoldCriticalRegion PFFS_FCB FFSCreateFcbFromMcb ( PFFS_VCB  Vcb,
PFFS_MCB  Mcb 
)

Definition at line 1077 of file memory.c.

1080 {
1081  PFFS_FCB Fcb = NULL;
1082  FFSv1_INODE dinode1;
1083  FFSv2_INODE dinode2;
1084 
1085  PAGED_CODE();
1086 
1087  if (Mcb->FFSFcb)
1088  return Mcb->FFSFcb;
1089 
1090  if (FS_VERSION == 1)
1091  {
1092  if (FFSv1LoadInode(Vcb, Mcb->Inode, &dinode1))
1093  {
1095  if (!pTmpInode)
1096  {
1097  goto errorout;
1098  }
1099 
1100  RtlCopyMemory(pTmpInode, &dinode1, DINODE1_SIZE);
1101  Fcb = FFSv1AllocateFcb(Vcb, Mcb, pTmpInode);
1102  if (!Fcb)
1103  {
1104  ExFreePool(pTmpInode);
1105  }
1106  }
1107  }
1108  else
1109  {
1110  if (FFSv2LoadInode(Vcb, Mcb->Inode, &dinode2))
1111  {
1113  if (!pTmpInode)
1114  {
1115  goto errorout;
1116  }
1117 
1118  RtlCopyMemory(pTmpInode, &dinode2, DINODE2_SIZE);
1119  Fcb = FFSv2AllocateFcb(Vcb, Mcb, pTmpInode);
1120  if (!Fcb)
1121  {
1122  ExFreePool(pTmpInode);
1123  }
1124  }
1125  }
1126 
1127 errorout:
1128 
1129  return Fcb;
1130 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define FS_VERSION
Definition: ffsdrv.h:81
BOOLEAN FFSv2LoadInode(IN PFFS_VCB Vcb, IN ULONG inode, IN PFFSv2_INODE dinode2)
Definition: ffs.c:336
#define PAGED_CODE()
Definition: video.h:57
__drv_mustHoldCriticalRegion PFFS_FCB FFSv1AllocateFcb(IN PFFS_VCB Vcb, IN PFFS_MCB FFSMcb, IN PFFSv1_INODE dinode1)
Definition: memory.c:383
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN FFSv1LoadInode(IN PFFS_VCB Vcb, IN ULONG inode, IN PFFSv1_INODE dinode1)
Definition: ffs.c:302
#define Vcb
Definition: cdprocs.h:1425
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
__drv_mustHoldCriticalRegion PFFS_FCB FFSv2AllocateFcb(IN PFFS_VCB Vcb, IN PFFS_MCB FFSMcb, IN PFFSv2_INODE dinode2)
Definition: memory.c:549
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
#define DINODE2_SIZE
Definition: dinode.h:175
#define DINODE1_SIZE
Definition: dinode.h:174
_In_ PFCB Fcb
Definition: cdprocs.h:151
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSDeleteFile(), and FFSSetRenameInfo().

◆ FFSDeleteMcbNode()

BOOLEAN FFSDeleteMcbNode ( PFFS_VCB  Vcb,
PFFS_MCB  McbTree,
PFFS_MCB  FFSMcb 
)

Definition at line 1321 of file memory.c.

1325 {
1326  PFFS_MCB TmpMcb;
1327 
1328  PAGED_CODE();
1329 
1330  if(!IsFlagOn(FFSMcb->Flags, MCB_IN_TREE))
1331  {
1332  return TRUE;
1333  }
1334 
1335  if (FFSMcb->Parent)
1336  {
1337  if (FFSMcb->Parent->Child == FFSMcb)
1338  {
1339  FFSMcb->Parent->Child = FFSMcb->Next;
1340  }
1341  else
1342  {
1343  TmpMcb = FFSMcb->Parent->Child;
1344 
1345  while (TmpMcb && TmpMcb->Next != FFSMcb)
1346  TmpMcb = TmpMcb->Next;
1347 
1348  if (TmpMcb)
1349  {
1350  TmpMcb->Next = FFSMcb->Next;
1351  }
1352  else
1353  {
1354  // error
1355  return FALSE;
1356  }
1357  }
1358  }
1359  else if (FFSMcb->Child)
1360  {
1361  return FALSE;
1362  }
1363 
1364  RemoveEntryList(&(FFSMcb->Link));
1365  ClearFlag(FFSMcb->Flags, MCB_IN_TREE);
1366 
1367  return TRUE;
1368 }
#define TRUE
Definition: types.h:120
#define PAGED_CODE()
Definition: video.h:57
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
PFFS_MCB Next
Definition: ffsdrv.h:652
LIST_ENTRY Link
Definition: ffsdrv.h:672
ULONG Flags
Definition: ffsdrv.h:646
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
#define MCB_IN_TREE
Definition: ffsdrv.h:679
PFFS_MCB Child
Definition: ffsdrv.h:651
PFFS_MCB Parent
Definition: ffsdrv.h:650

Referenced by FFSAllocateMcb(), FFSDeleteFile(), FFSFreeFcb(), and FFSSetRenameInfo().

◆ FFSFreeCcb()

Definition at line 853 of file memory.c.

855 {
856  PAGED_CODE();
857 
858  ASSERT(Ccb != NULL);
859 
860  ASSERT((Ccb->Identifier.Type == FFSCCB) &&
861  (Ccb->Identifier.Size == sizeof(FFS_CCB)));
862 
863  if (Ccb->DirectorySearchPattern.Buffer != NULL)
864  {
865  ExFreePool(Ccb->DirectorySearchPattern.Buffer);
866  }
867 
868  if (FlagOn(Ccb->Flags, CCB_FROM_POOL))
869  {
870  ExFreePool(Ccb);
871  }
872  else
873  {
876  TRUE);
877 
878  ExFreeToNPagedLookasideList(&(FFSGlobal->FFSCcbLookasideList), Ccb);
879 
883  }
884 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
NPAGED_LOOKASIDE_LIST FFSCcbLookasideList
Definition: ffsdrv.h:380
Definition: ffsdrv.h:282
smooth NULL
Definition: ftsmooth.c:416
ERESOURCE LAResource
Definition: ffsdrv.h:358
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Flags
Definition: ntfs.h:520
ULONG Type
Definition: ntfs.h:95
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define CCB_FROM_POOL
Definition: ext2fs.h:1022
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
ULONG Size
Definition: ntfs.h:96
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSClose().

◆ FFSFreeFcb()

Definition at line 715 of file memory.c.

717 {
718  PFFS_VCB Vcb;
719 
720  PAGED_CODE();
721 
722  ASSERT(Fcb != NULL);
723 
724  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
725  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
726 
727  Vcb = Fcb->Vcb;
728 
729  FsRtlUninitializeFileLock(&Fcb->FileLockAnchor);
730 
732 
734 
735  Fcb->FFSMcb->FFSFcb = NULL;
736 
738  {
739  if (Fcb->FFSMcb)
740  {
741  FFSDeleteMcbNode(Vcb, Fcb->FFSMcb->Parent, Fcb->FFSMcb);
742  FFSFreeMcb(Fcb->FFSMcb);
743  }
744  }
745 
746  if (Fcb->LongName.Buffer)
747  {
748  ExFreePool(Fcb->LongName.Buffer);
749  Fcb->LongName.Buffer = NULL;
750  }
751 
752 #if DBG
753  ExFreePool(Fcb->AnsiFileName.Buffer);
754 #endif
755 
756  if (FS_VERSION == 1)
757  {
758  ExFreePool(Fcb->dinode1);
759  }
760  else
761  {
762  ExFreePool(Fcb->dinode2);
763  }
764 
765  Fcb->Header.NodeTypeCode = (SHORT)0xCCCC;
766  Fcb->Header.NodeByteSize = (SHORT)0xC0C0;
767 
768  if (FlagOn(Fcb->Flags, FCB_FROM_POOL))
769  {
770  ExFreePool(Fcb);
771  }
772  else
773  {
776  TRUE);
777 
778  ExFreeToNPagedLookasideList(&(FFSGlobal->FFSFcbLookasideList), Fcb);
779 
783  }
784 
785 #if DBG
786 
789  TRUE);
790 
791  FFSGlobal->FcbAllocated--;
792 
796 #endif
797 
798 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
Definition: ffsdrv.h:281
BOOLEAN FFSDeleteMcbNode(PFFS_VCB Vcb, PFFS_MCB McbTree, PFFS_MCB FFSMcb)
Definition: memory.c:1321
#define TRUE
Definition: types.h:120
#define FS_VERSION
Definition: ffsdrv.h:81
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
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
ERESOURCE CountResource
Definition: ffsdrv.h:355
short SHORT
Definition: pedump.c:59
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
smooth NULL
Definition: ftsmooth.c:416
ERESOURCE LAResource
Definition: ffsdrv.h:358
NPAGED_LOOKASIDE_LIST FFSFcbLookasideList
Definition: ffsdrv.h:379
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
__drv_mustHoldCriticalRegion VOID FFSFreeMcb(IN PFFS_MCB Mcb)
Definition: memory.c:1028
ULONG Flags
Definition: ntfs.h:520
ULONG Type
Definition: ntfs.h:95
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
ERESOURCE MainResource
Definition: ntfs.h:512
#define FCB_FROM_POOL
Definition: ext2fs.h:871
#define FCB_FILE_DELETED
Definition: ffsdrv.h:635
ERESOURCE PagingIoResource
Definition: ntfs.h:511
PVCB Vcb
Definition: cdstruc.h:939
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
_In_ PFCB Fcb
Definition: cdprocs.h:151
union _FCB::@692 LongName
ULONG Size
Definition: ntfs.h:96
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSClose(), and FFSPurgeVolume().

◆ FFSFreeIrpContext()

__drv_mustHoldCriticalRegion VOID FFSFreeIrpContext ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 179 of file memory.c.

181 {
182  PAGED_CODE();
183 
184  ASSERT(IrpContext != NULL);
185 
186  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
187  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
188 
189  FFSUnpinRepinnedBcbs(IrpContext);
190 
191  // Return the Irp context record to the region or to pool depending on
192  // its flag
193 
194  if (FlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_FROM_POOL))
195  {
196  IrpContext->Identifier.Type = 0;
197  IrpContext->Identifier.Size = 0;
198 
199  ExFreePool(IrpContext);
200  }
201  else
202  {
203  IrpContext->Identifier.Type = 0;
204  IrpContext->Identifier.Size = 0;
205 
208  TRUE);
209 
210  ExFreeToNPagedLookasideList(&(FFSGlobal->FFSIrpContextLookasideList), IrpContext);
211 
215 
216  }
217 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
NPAGED_LOOKASIDE_LIST FFSIrpContextLookasideList
Definition: ffsdrv.h:378
#define IRP_CONTEXT_FLAG_FROM_POOL
Definition: ext2fs.h:1077
Definition: ffsdrv.h:283
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
smooth NULL
Definition: ftsmooth.c:416
ERESOURCE LAResource
Definition: ffsdrv.h:358
VOID FFSUnpinRepinnedBcbs(IN PFFS_IRP_CONTEXT IrpContext)
Definition: memory.c:276
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSCompleteIrpContext(), FFSExceptionFilter(), FFSExceptionHandler(), FFSReadFile(), FFSReadVolume(), FFSWriteFile(), and FFSWriteVolume().

◆ FFSFreeMcb()

Definition at line 1028 of file memory.c.

1030 {
1031 #ifndef __REACTOS__
1032  PFFS_MCB Parent = Mcb->Parent;
1033 #endif
1034  PAGED_CODE();
1035 
1036  ASSERT(Mcb != NULL);
1037 
1038  ASSERT((Mcb->Identifier.Type == FFSMCB) &&
1039  (Mcb->Identifier.Size == sizeof(FFS_MCB)));
1040 
1041  FFSPrint((DBG_INFO, "FFSFreeMcb: Mcb %S will be freed.\n", Mcb->ShortName.Buffer));
1042 
1043  if (Mcb->ShortName.Buffer)
1044  ExFreePool(Mcb->ShortName.Buffer);
1045 
1046  if (FlagOn(Mcb->Flags, MCB_FROM_POOL))
1047  {
1048  ExFreePool(Mcb);
1049  }
1050  else
1051  {
1054  TRUE);
1055 
1056  ExFreeToPagedLookasideList(&(FFSGlobal->FFSMcbLookasideList), Mcb);
1057 
1061  }
1062 
1065  TRUE);
1066 
1068 
1072 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
#define MCB_FROM_POOL
Definition: ext2fs.h:943
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
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
USHORT McbAllocated
Definition: ffsdrv.h:384
ERESOURCE CountResource
Definition: ffsdrv.h:355
Definition: ffsdrv.h:285
smooth NULL
Definition: ftsmooth.c:416
ERESOURCE LAResource
Definition: ffsdrv.h:358
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define DBG_INFO
Definition: ffsdrv.h:1034
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PAGED_LOOKASIDE_LIST FFSMcbLookasideList
Definition: ffsdrv.h:381

Referenced by FFSAllocateMcb(), FFSFreeFcb(), and FFSFreeMcbTree().

◆ FFSFreeMcbTree()

__drv_mustHoldCriticalRegion VOID FFSFreeMcbTree ( PFFS_MCB  McbTree)

Definition at line 1373 of file memory.c.

1375 {
1376  PAGED_CODE();
1377 
1378  if (!McbTree)
1379  return;
1380 
1381  if (McbTree->Child)
1382  {
1383  FFSFreeMcbTree(McbTree->Child);
1384  }
1385 
1386  if (McbTree->Next)
1387  {
1388  PFFS_MCB Current;
1389  PFFS_MCB Next;
1390 
1391  Current = McbTree->Next;
1392 
1393  while (Current)
1394  {
1395  Next = Current->Next;
1396 
1397  if (Current->Child)
1398  {
1399  FFSFreeMcbTree(Current->Child);
1400  }
1401 
1402  FFSFreeMcb(Current);
1403  Current = Next;
1404  }
1405  }
1406 
1407  FFSFreeMcb(McbTree);
1408 }
__drv_mustHoldCriticalRegion VOID FFSFreeMcbTree(PFFS_MCB McbTree)
Definition: memory.c:1373
#define PAGED_CODE()
Definition: video.h:57
PFFS_MCB Next
Definition: ffsdrv.h:652
__drv_mustHoldCriticalRegion VOID FFSFreeMcb(IN PFFS_MCB Mcb)
Definition: memory.c:1028
PFFS_MCB Child
Definition: ffsdrv.h:651

Referenced by FFSFreeVcb().

◆ FFSFreeVcb()

Definition at line 1886 of file memory.c.

1888 {
1889  PAGED_CODE();
1890 
1891  ASSERT(Vcb != NULL);
1892 
1893  ASSERT((Vcb->Identifier.Type == FFSVCB) &&
1894  (Vcb->Identifier.Size == sizeof(FFS_VCB)));
1895 
1896  FsRtlNotifyUninitializeSync(&Vcb->NotifySync);
1897 
1898  if (Vcb->StreamObj)
1899  {
1900  if (IsFlagOn(Vcb->StreamObj->Flags, FO_FILE_MODIFIED))
1901  {
1903 
1904  CcFlushCache(&(Vcb->SectionObject), NULL, 0, &IoStatus);
1905  ClearFlag(Vcb->StreamObj->Flags, FO_FILE_MODIFIED);
1906  }
1907 
1908  if (Vcb->StreamObj->PrivateCacheMap)
1909  FFSSyncUninitializeCacheMap(Vcb->StreamObj);
1910 
1911  ObDereferenceObject(Vcb->StreamObj);
1912  Vcb->StreamObj = NULL;
1913  }
1914 
1915 #if DBG
1916  if (FsRtlNumberOfRunsInLargeMcb(&(Vcb->DirtyMcbs)) != 0)
1917  {
1918  LONGLONG DirtyVba;
1919  LONGLONG DirtyLba;
1920  LONGLONG DirtyLength;
1921  int i;
1922 
1923  for (i = 0; FsRtlGetNextLargeMcbEntry (&(Vcb->DirtyMcbs), i, &DirtyVba, &DirtyLba, &DirtyLength); i++)
1924  {
1925  FFSPrint((DBG_INFO, "DirtyVba = %I64xh\n", DirtyVba));
1926  FFSPrint((DBG_INFO, "DirtyLba = %I64xh\n", DirtyLba));
1927  FFSPrint((DBG_INFO, "DirtyLen = %I64xh\n\n", DirtyLength));
1928  }
1929 
1930  FFSBreakPoint();
1931  }
1932 #endif
1933 
1934  FsRtlUninitializeLargeMcb(&(Vcb->DirtyMcbs));
1935 
1936  FFSFreeMcbTree(Vcb->McbTree);
1937 
1938  if (Vcb->ffs_super_block)
1939  {
1940  ExFreePool(Vcb->ffs_super_block);
1941  Vcb->ffs_super_block = NULL;
1942  }
1943 
1944  ExDeleteResourceLite(&Vcb->McbResource);
1945 
1946  ExDeleteResourceLite(&Vcb->PagingIoResource);
1947 
1948  ExDeleteResourceLite(&Vcb->MainResource);
1949 
1950  IoDeleteDevice(Vcb->DeviceObject);
1951 }
__drv_mustHoldCriticalRegion VOID FFSFreeMcbTree(PFFS_MCB McbTree)
Definition: memory.c:1373
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
ULONG NTAPI FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:769
#define PAGED_CODE()
Definition: video.h:57
#define FFSBreakPoint()
Definition: ffsdrv.h:43
BOOLEAN NTAPI FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb, IN ULONG RunIndex, OUT PLONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG SectorCount)
Definition: largemcb.c:391
#define FO_FILE_MODIFIED
Definition: iotypes.h:1744
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 IsFlagOn(a, b)
Definition: ext2fs.h:177
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ffsdrv.h:280
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
VOID FFSSyncUninitializeCacheMap(IN PFILE_OBJECT FileObject)
Definition: memory.c:1955
VOID NTAPI FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:1053
#define DBG_INFO
Definition: ffsdrv.h:1034
VOID NTAPI FsRtlNotifyUninitializeSync(IN PNOTIFY_SYNC *NotifySync)
Definition: notify.c:1639
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSCheckDismount(), and FFSClose().

◆ FFSGetFullFileName()

BOOLEAN FFSGetFullFileName ( PFFS_MCB  Mcb,
PUNICODE_STRING  FileName 
)

Definition at line 1134 of file memory.c.

1137 {
1138  USHORT Length = 0;
1139  PFFS_MCB TmpMcb = Mcb;
1140  PUNICODE_STRING FileNames[256];
1141  SHORT Count = 0 , i = 0, j = 0;
1142 
1143  PAGED_CODE();
1144 
1145  while(TmpMcb && Count < 256)
1146  {
1147  if (TmpMcb->Inode == FFS_ROOT_INO)
1148  break;
1149 
1150  FileNames[Count++] = &TmpMcb->ShortName;
1151  Length += (2 + TmpMcb->ShortName.Length);
1152 
1153  TmpMcb = TmpMcb->Parent;
1154  }
1155 
1156  if (Count >= 256)
1157  return FALSE;
1158 
1159  if (Count == 0)
1160  Length = 2;
1161 
1162  FileName->Length = Length;
1163  FileName->MaximumLength = Length + 2;
1165 
1166  if (!FileName->Buffer)
1167  {
1168  return FALSE;
1169  }
1170 
1171  RtlZeroMemory(FileName->Buffer, FileName->MaximumLength);
1172 
1173  if (Count == 0)
1174  {
1175  FileName->Buffer[0] = L'\\';
1176  return TRUE;
1177  }
1178 
1179  for (i = Count - 1; i >= 0 && j < (SHORT)(FileName->MaximumLength); i--)
1180  {
1181  FileName->Buffer[j++] = L'\\';
1182 
1183  RtlCopyMemory(&(FileName->Buffer[j]),
1184  FileNames[i]->Buffer,
1185  FileNames[i]->Length);
1186 
1187  j += FileNames[i]->Length / 2;
1188  }
1189 
1190  return TRUE;
1191 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define FFS_ROOT_INO
Definition: ffsdrv.h:204
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define PAGED_CODE()
Definition: video.h:57
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
short SHORT
Definition: pedump.c:59
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
UNICODE_STRING ShortName
Definition: ffsdrv.h:660
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
unsigned short USHORT
Definition: pedump.c:61
ULONG Inode
Definition: ffsdrv.h:663
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PFFS_MCB Parent
Definition: ffsdrv.h:650

Referenced by FFSNotifyChangeDirectory(), and FFSNotifyReportChange().

◆ FFSInitializeVcb()

__drv_mustHoldCriticalRegion NTSTATUS FFSInitializeVcb ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN PFFS_SUPER_BLOCK  FFSSb,
IN PDEVICE_OBJECT  TargetDevice,
IN PDEVICE_OBJECT  VolumeDevice,
IN PVPB  Vpb 
)

Definition at line 1551 of file memory.c.

1558 {
1559  BOOLEAN VcbResourceInitialized = FALSE;
1560  USHORT VolumeLabelLength;
1561  ULONG IoctlSize;
1562  BOOLEAN NotifySyncInitialized = FALSE;
1563  LONGLONG DiskSize;
1564  LONGLONG PartSize;
1567  USHORT Buffer[2];
1568  ULONG ChangeCount;
1569 
1570  PAGED_CODE();
1571 
1572  _SEH2_TRY
1573  {
1574  if (!Vpb)
1575  {
1577  _SEH2_LEAVE;
1578  }
1579 
1580  Buffer[0] = L'\\';
1581  Buffer[1] = 0;
1582 
1583  RootNode.Buffer = Buffer;
1584  RootNode.MaximumLength = RootNode.Length = 2;
1585 
1586  Vcb->McbTree = FFSAllocateMcb(Vcb, &RootNode,
1588 
1589  if (!Vcb->McbTree)
1590  {
1591  _SEH2_LEAVE;
1592  }
1593 
1594 #if FFS_READ_ONLY
1595  SetFlag(Vcb->Flags, VCB_READ_ONLY);
1596 #endif // FFS_READ_ONLY
1597 
1598  if (IsFlagOn(Vpb->RealDevice->Characteristics, FILE_REMOVABLE_MEDIA))
1599  {
1600  SetFlag(Vcb->Flags, VCB_REMOVABLE_MEDIA);
1601  }
1602 
1603  if (IsFlagOn(Vpb->RealDevice->Characteristics, FILE_FLOPPY_DISKETTE))
1604  {
1605  SetFlag(Vcb->Flags, VCB_FLOPPY_DISK);
1606  }
1607 #if 0
1609  {
1611  {
1612  ClearFlag(Vcb->Flags, VCB_READ_ONLY);
1613  }
1614  else
1615  {
1616  SetFlag(Vcb->Flags, VCB_READ_ONLY);
1617  }
1618  }
1619  else
1620 #endif
1621  {
1622  SetFlag(Vcb->Flags, VCB_READ_ONLY);
1623  }
1624 
1625  ExInitializeResourceLite(&Vcb->MainResource);
1626  ExInitializeResourceLite(&Vcb->PagingIoResource);
1627 
1628  ExInitializeResourceLite(&Vcb->McbResource);
1629 
1630  VcbResourceInitialized = TRUE;
1631 
1632  Vcb->McbTree->Inode = FFS_ROOT_INO;
1633 
1634  Vcb->Vpb = Vpb;
1635 
1636  Vcb->RealDevice = Vpb->RealDevice;
1637  Vpb->DeviceObject = VolumeDevice;
1638 
1639  {
1640  UNICODE_STRING LabelName;
1642 
1643  LabelName.MaximumLength = 16 * 2;
1644  LabelName.Length = 0;
1645  LabelName.Buffer = Vcb->Vpb->VolumeLabel;
1646 
1647  RtlZeroMemory(LabelName.Buffer, LabelName.MaximumLength);
1648 
1649  VolumeLabelLength = 16;
1650 
1651  while((VolumeLabelLength > 0) &&
1652  ((FFSSb->fs_volname[VolumeLabelLength-1] == 0x00) ||
1653  (FFSSb->fs_volname[VolumeLabelLength-1] == 0x20)))
1654  {
1655  VolumeLabelLength--;
1656  }
1657 
1658  OemName.Buffer = FFSSb->fs_volname;
1659  OemName.MaximumLength = 16;
1660  OemName.Length = VolumeLabelLength;
1661 
1662  Status = FFSOEMToUnicode(&LabelName,
1663  &OemName);
1664 
1665  if (!NT_SUCCESS(Status))
1666  {
1667  _SEH2_LEAVE;
1668  }
1669 
1670  Vpb->VolumeLabelLength = LabelName.Length;
1671  }
1672 
1673  Vpb->SerialNumber = ((ULONG*)FFSSb->fs_id)[0] + ((ULONG*)FFSSb->fs_id)[1];
1674 
1675  Vcb->StreamObj = IoCreateStreamFileObject(NULL, Vcb->Vpb->RealDevice);
1676 
1677  if (Vcb->StreamObj)
1678  {
1679  Vcb->StreamObj->SectionObjectPointer = &(Vcb->SectionObject);
1680  Vcb->StreamObj->Vpb = Vcb->Vpb;
1681  Vcb->StreamObj->ReadAccess = TRUE;
1682  if (IsFlagOn(Vcb->Flags, VCB_READ_ONLY))
1683  {
1684  Vcb->StreamObj->WriteAccess = TRUE;
1685  Vcb->StreamObj->DeleteAccess = TRUE;
1686  }
1687  else
1688  {
1689  Vcb->StreamObj->WriteAccess = TRUE;
1690  Vcb->StreamObj->DeleteAccess = TRUE;
1691  }
1692  Vcb->StreamObj->FsContext = (PVOID) Vcb;
1693  Vcb->StreamObj->FsContext2 = NULL;
1694  Vcb->StreamObj->Vpb = Vcb->Vpb;
1695 
1696  SetFlag(Vcb->StreamObj->Flags, FO_NO_INTERMEDIATE_BUFFERING);
1697  }
1698  else
1699  {
1700  _SEH2_LEAVE;
1701  }
1702 
1703  InitializeListHead(&Vcb->FcbList);
1704 
1705  InitializeListHead(&Vcb->NotifyList);
1706 
1707  FsRtlNotifyInitializeSync(&Vcb->NotifySync);
1708 
1709  NotifySyncInitialized = TRUE;
1710 
1711  Vcb->DeviceObject = VolumeDevice;
1712 
1713  Vcb->TargetDeviceObject = TargetDevice;
1714 
1715  Vcb->OpenFileHandleCount = 0;
1716 
1717  Vcb->ReferenceCount = 0;
1718 
1719  Vcb->ffs_super_block = FFSSb;
1720 
1721  Vcb->Header.NodeTypeCode = (USHORT) FFSVCB;
1722  Vcb->Header.NodeByteSize = sizeof(FFS_VCB);
1723  Vcb->Header.IsFastIoPossible = FastIoIsNotPossible;
1724  Vcb->Header.Resource = &(Vcb->MainResource);
1725  Vcb->Header.PagingIoResource = &(Vcb->PagingIoResource);
1726 
1727  Vcb->Vpb->SerialNumber = 'PS';
1728 
1729  DiskSize =
1730  Vcb->DiskGeometry.Cylinders.QuadPart *
1731  Vcb->DiskGeometry.TracksPerCylinder *
1732  Vcb->DiskGeometry.SectorsPerTrack *
1733  Vcb->DiskGeometry.BytesPerSector;
1734 
1735  IoctlSize = sizeof(PARTITION_INFORMATION);
1736 
1738  TargetDevice,
1740  NULL,
1741  0,
1742  &Vcb->PartitionInformation,
1743  &IoctlSize);
1744 
1745  PartSize = Vcb->PartitionInformation.PartitionLength.QuadPart;
1746 
1747  if (!NT_SUCCESS(Status))
1748  {
1749  Vcb->PartitionInformation.StartingOffset.QuadPart = 0;
1750 
1751  Vcb->PartitionInformation.PartitionLength.QuadPart =
1752  DiskSize;
1753 
1754  PartSize = DiskSize;
1755 
1757  }
1758 
1759  IoctlSize = sizeof(ULONG);
1761  TargetDevice,
1763  NULL,
1764  0,
1765  &ChangeCount,
1766  &IoctlSize);
1767 
1768  if (!NT_SUCCESS(Status))
1769  {
1770  _SEH2_LEAVE;
1771  }
1772 
1773  Vcb->ChangeCount = ChangeCount;
1774 
1775  Vcb->Header.AllocationSize.QuadPart =
1776  Vcb->Header.FileSize.QuadPart = PartSize;
1777 
1778  Vcb->Header.ValidDataLength.QuadPart =
1779  (LONGLONG)(0x7fffffffffffffff);
1780  /*
1781  Vcb->Header.AllocationSize.QuadPart = (LONGLONG)(ffs_super_block->s_blocks_count - ffs_super_block->s_free_blocks_count)
1782  * (FFS_MIN_BLOCK << ffs_super_block->s_log_block_size);
1783  Vcb->Header.FileSize.QuadPart = Vcb->Header.AllocationSize.QuadPart;
1784  Vcb->Header.ValidDataLength.QuadPart = Vcb->Header.AllocationSize.QuadPart;
1785  */
1786 
1787  {
1789 
1792  Vcb->Header.AllocationSize.QuadPart;
1793 
1794  FileSizes.ValidDataLength.QuadPart= (LONGLONG)(0x7fffffffffffffff);
1795 
1796  CcInitializeCacheMap(Vcb->StreamObj,
1797  &FileSizes,
1798  TRUE,
1800  Vcb);
1801  }
1802 #if 0 // LoadGroup XXX
1803  if (!FFSLoadGroup(Vcb))
1804  {
1806  _SEH2_LEAVE;
1807  }
1808 #endif
1809  FsRtlInitializeLargeMcb(&(Vcb->DirtyMcbs), PagedPool);
1810  InitializeListHead(&(Vcb->McbList));
1811 
1813  {
1814  FFSCheckBitmapConsistency(IrpContext, Vcb);
1815  }
1816 
1817  {
1818  ULONG dwData[FFS_BLOCK_TYPES] = {NDADDR, 1, 1, 1};
1819  ULONG dwMeta[FFS_BLOCK_TYPES] = {0, 0, 0, 0};
1820  ULONG i;
1821 
1822  if (FS_VERSION == 1)
1823  {
1824  for (i = 0; i < FFS_BLOCK_TYPES; i++)
1825  {
1826  dwData[i] = dwData[i] << ((BLOCK_BITS - 2) * i);
1827 
1828  if (i > 0)
1829  {
1830  dwMeta[i] = 1 + (dwMeta[i - 1] << (BLOCK_BITS - 2));
1831  }
1832 
1833  Vcb->dwData[i] = dwData[i];
1834  Vcb->dwMeta[i] = dwMeta[i];
1835  }
1836  }
1837  else
1838  {
1839  for (i = 0; i < FFS_BLOCK_TYPES; i++)
1840  {
1841  dwData[i] = dwData[i] << ((BLOCK_BITS - 3) * i);
1842 
1843  if (i > 0)
1844  {
1845  dwMeta[i] = 1 + (dwMeta[i - 1] << (BLOCK_BITS - 3));
1846  }
1847 
1848  Vcb->dwData[i] = dwData[i];
1849  Vcb->dwMeta[i] = dwMeta[i];
1850  }
1851  }
1852  }
1853 
1854  SetFlag(Vcb->Flags, VCB_INITIALIZED);
1855  }
1856 
1858  {
1859  if (!NT_SUCCESS(Status))
1860  {
1861  if (NotifySyncInitialized)
1862  {
1863  FsRtlNotifyUninitializeSync(&Vcb->NotifySync);
1864  }
1865 
1866  if (Vcb->ffs_super_block)
1867  {
1868  ExFreePool(Vcb->ffs_super_block);
1869  Vcb->ffs_super_block = NULL;
1870  }
1871 
1872  if (VcbResourceInitialized)
1873  {
1874  ExDeleteResourceLite(&Vcb->MainResource);
1875  ExDeleteResourceLite(&Vcb->PagingIoResource);
1876  }
1877  }
1878  } _SEH2_END;
1879 
1880  return Status;
1881 }
CACHE_MANAGER_CALLBACKS CacheManagerNoOpCallbacks
Definition: ffsdrv.h:365
#define NDADDR
Definition: dinode.h:77
#define TRUE
Definition: types.h:120
#define FFS_ROOT_INO
Definition: ffsdrv.h:204
#define FFS_SUPPORT_WRITING
Definition: ffsdrv.h:405
BOOLEAN FFSLoadGroup(IN PFFS_VCB Vcb)
#define FS_VERSION
Definition: ffsdrv.h:81
USHORT MaximumLength
Definition: env_spec_w32.h:370
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:688
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_DISK_CHECK_VERIFY
Definition: cdrw_usr.h:175
ULONG Flags
Definition: ffsdrv.h:395
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
BOOLEAN FFSCheckBitmapConsistency(PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb)
Definition: memory.c:1500
NTSTATUS FFSDiskIoControl(IN PDEVICE_OBJECT DeviceOjbect, IN ULONG IoctlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer, IN OUT PULONG OutputBufferSize)
Definition: block.c:500
static CC_FILE_SIZES FileSizes
#define FO_NO_INTERMEDIATE_BUFFERING
Definition: iotypes.h:1734
STRING OEM_STRING
Definition: umtypes.h:203
struct _PARTITION_INFORMATION PARTITION_INFORMATION
#define FFS_CHECKING_BITMAP
Definition: ffsdrv.h:406
#define PAGED_CODE()
Definition: video.h:57
LARGE_INTEGER FileSize
Definition: cctypes.h:16
#define VCB_REMOVABLE_MEDIA
Definition: ext2fs.h:799
_SEH2_TRY
Definition: create.c:4250
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
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 FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
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
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
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 FFS_BLOCK_TYPES
Definition: ffsdrv.h:67
int64_t LONGLONG
Definition: typedefs.h:66
#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
#define Vcb
Definition: cdprocs.h:1425
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:88
static const WCHAR L[]
Definition: oid.c:1250
Definition: ffsdrv.h:280
LARGE_INTEGER ValidDataLength
Definition: cctypes.h:17
#define VCB_READ_ONLY
Definition: ext2fs.h:795
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define VCB_FLOPPY_DISK
Definition: ext2fs.h:797
LARGE_INTEGER AllocationSize
Definition: cctypes.h:15
unsigned short USHORT
Definition: pedump.c:61
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_SEH2_FINALLY
Definition: create.c:4395
VOID NTAPI FsRtlNotifyInitializeSync(IN PNOTIFY_SYNC *NotifySync)
Definition: notify.c:1561
NTSTATUS FFSOEMToUnicode(IN OUT PUNICODE_STRING Unicode, IN POEM_STRING Oem)
Definition: misc.c:80
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI FsRtlNotifyUninitializeSync(IN PNOTIFY_SYNC *NotifySync)
Definition: notify.c:1639
#define VCB_INITIALIZED
Definition: ext2fs.h:779
#define _SEH2_LEAVE
Definition: filesup.c:20
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1294
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2777
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
struct _FFS_VCB FFS_VCB
LONGLONG QuadPart
Definition: typedefs.h:112
__drv_mustHoldCriticalRegion PFFS_MCB FFSAllocateMcb(PFFS_VCB Vcb, PUNICODE_STRING FileName, ULONG FileAttr)
Definition: memory.c:889
PCONFIGURATION_COMPONENT_DATA RootNode
Definition: macharm.c:19
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:65

Referenced by FFSMountVolume().

◆ FFSInsertVcb()

VOID FFSInsertVcb ( PFFS_VCB  Vcb)

Definition at line 1534 of file memory.c.

1536 {
1537  InsertTailList(&(FFSGlobal->VcbList), &Vcb->Next);
1538 }
#define InsertTailList(ListHead, Entry)
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
#define Vcb
Definition: cdprocs.h:1425
LIST_ENTRY VcbList
Definition: ffsdrv.h:374

Referenced by FFSMountVolume().

◆ FFSRefreshMcb()

VOID FFSRefreshMcb ( PFFS_VCB  Vcb,
PFFS_MCB  Mcb 
)

Definition at line 1264 of file memory.c.

1267 {
1268  PAGED_CODE();
1269 
1270  ASSERT (IsFlagOn(Mcb->Flags, MCB_IN_TREE));
1271 
1272  RemoveEntryList(&(Mcb->Link));
1273  InsertTailList(&(Vcb->McbList), &(Mcb->Link));
1274 }
#define InsertTailList(ListHead, Entry)
#define PAGED_CODE()
Definition: video.h:57
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define MCB_IN_TREE
Definition: ffsdrv.h:679
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334

Referenced by FFSSearchMcb(), and FFSSearchMcbTree().

◆ FFSRemoveVcb()

VOID FFSRemoveVcb ( PFFS_VCB  Vcb)

Definition at line 1542 of file memory.c.

1544 {
1545  RemoveEntryList(&Vcb->Next);
1546 }
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define Vcb
Definition: cdprocs.h:1425

Referenced by FFSCheckDismount(), and FFSClose().

◆ FFSRepinBcb()

VOID FFSRepinBcb ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PBCB  Bcb 
)

Definition at line 221 of file memory.c.

224 {
225  PFFS_REPINNED_BCBS Repinned;
226  ULONG i;
227 
228  Repinned = &IrpContext->Repinned;
229 
230 
231  return;
232 
233  while (Repinned)
234  {
235  for (i = 0; i < FFS_REPINNED_BCBS_ARRAY_SIZE; i += 1)
236  {
237  if (Repinned->Bcb[i] == Bcb)
238  {
239  return;
240  }
241  }
242 
243  Repinned = Repinned->Next;
244  }
245 
246  while (TRUE)
247  {
248  for (i = 0; i < FFS_REPINNED_BCBS_ARRAY_SIZE; i += 1)
249  {
250  if (Repinned->Bcb[i] == Bcb)
251  {
252  return;
253  }
254 
255  if (Repinned->Bcb[i] == NULL)
256  {
257  Repinned->Bcb[i] = Bcb;
258  CcRepinBcb(Bcb);
259 
260  return;
261  }
262  }
263 
264  if (Repinned->Next == NULL)
265  {
267  RtlZeroMemory(Repinned->Next, sizeof(FFS_REPINNED_BCBS));
268  }
269 
270  Repinned = Repinned->Next;
271  }
272 }
#define TRUE
Definition: types.h:120
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
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
PBCB Bcb[FFS_REPINNED_BCBS_ARRAY_SIZE]
Definition: ffsdrv.h:327
smooth NULL
Definition: ftsmooth.c:416
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
struct _FFS_REPINNED_BCBS * Next
Definition: ffsdrv.h:318
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI CcRepinBcb(IN PVOID Bcb)
Definition: cachesub.c:331
#define FFS_REPINNED_BCBS_ARRAY_SIZE
Definition: ffsdrv.h:310

Referenced by FFSCheckSetBlock(), FFSFreeBlock(), FFSFreeInode(), FFSNewBlock(), FFSNewInode(), FFSSaveBuffer(), and FFSTruncateBlock().

◆ FFSSearchMcb()

PFFS_MCB FFSSearchMcb ( PFFS_VCB  Vcb,
PFFS_MCB  Parent,
PUNICODE_STRING  FileName 
)

Definition at line 1235 of file memory.c.

1239 {
1240  PFFS_MCB TmpMcb = Parent->Child;
1241 
1242  PAGED_CODE();
1243 
1244  while (TmpMcb)
1245  {
1247  &(TmpMcb->ShortName),
1248  FileName, TRUE))
1249  break;
1250 
1251  TmpMcb = TmpMcb->Next;
1252  }
1253 
1254  if (TmpMcb)
1255  {
1256  FFSRefreshMcb(Vcb, TmpMcb);
1257  }
1258 
1259  return TmpMcb;
1260 }
#define TRUE
Definition: types.h:120
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
#define PAGED_CODE()
Definition: video.h:57
VOID FFSRefreshMcb(PFFS_VCB Vcb, PFFS_MCB Mcb)
Definition: memory.c:1264
PFFS_MCB Next
Definition: ffsdrv.h:652
UNICODE_STRING ShortName
Definition: ffsdrv.h:660
#define Vcb
Definition: cdprocs.h:1425
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31

Referenced by FFSv1LookupFileName(), and FFSv2LookupFileName().

◆ FFSSearchMcbTree()

PFFS_MCB FFSSearchMcbTree ( PFFS_VCB  Vcb,
PFFS_MCB  FFSMcb,
ULONG  Inode 
)

Definition at line 1195 of file memory.c.

1199 {
1200  PFFS_MCB Mcb = NULL;
1201  PLIST_ENTRY List = NULL;
1202  BOOLEAN bFind = FALSE;
1203 
1204  PAGED_CODE();
1205 
1206  List = Vcb->McbList.Flink;
1207 
1208  while ((!bFind) && (List != &(Vcb->McbList)))
1209  {
1211  List = List->Flink;
1212 
1213  if (Mcb->Inode == Inode)
1214  {
1215  bFind = TRUE;
1216  break;
1217  }
1218  }
1219 
1220  if (bFind)
1221  {
1222  ASSERT(Mcb != NULL);
1223  FFSRefreshMcb(Vcb, Mcb);
1224  }
1225  else
1226  {
1227  Mcb = NULL;
1228  }
1229 
1230  return Mcb;
1231 }
#define TRUE
Definition: types.h:120
static int Link(const char **args)
Definition: vfdcmd.c:2414
#define PAGED_CODE()
Definition: video.h:57
VOID FFSRefreshMcb(PFFS_VCB Vcb, PFFS_MCB Mcb)
Definition: memory.c:1264
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY List
Definition: psmgr.c:57
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:117
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334

◆ FFSSyncUninitializeCacheMap()

VOID FFSSyncUninitializeCacheMap ( IN PFILE_OBJECT  FileObject)

Definition at line 1955 of file memory.c.

1957 {
1958  CACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent;
1959  NTSTATUS WaitStatus;
1960  LARGE_INTEGER FFSLargeZero = {0, 0};
1961 
1962  PAGED_CODE();
1963 
1964  KeInitializeEvent(&UninitializeCompleteEvent.Event,
1966  FALSE);
1967 
1969  &FFSLargeZero,
1970  &UninitializeCompleteEvent);
1971 
1972  WaitStatus = KeWaitForSingleObject(&UninitializeCompleteEvent.Event,
1973  Executive,
1974  KernelMode,
1975  FALSE,
1976  NULL);
1977 
1978  ASSERT (NT_SUCCESS(WaitStatus));
1979 }
LONG NTSTATUS
Definition: precomp.h:26
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
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:284

Referenced by FFSFreeVcb().

◆ FFSUnpinRepinnedBcbs()

VOID FFSUnpinRepinnedBcbs ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 276 of file memory.c.

278 {
279  IO_STATUS_BLOCK RaiseIosb;
280  PFFS_REPINNED_BCBS Repinned;
281  BOOLEAN WriteThroughToDisk;
283  BOOLEAN ForceVerify = FALSE;
284  ULONG i;
285 
286  Repinned = &IrpContext->Repinned;
287  RaiseIosb.Status = STATUS_SUCCESS;
288 
289  WriteThroughToDisk = (BOOLEAN)(IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WRITE_THROUGH) ||
290  IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_FLOPPY));
291 
292  while (Repinned != NULL)
293  {
294  for (i = 0; i < FFS_REPINNED_BCBS_ARRAY_SIZE; i += 1)
295  {
296  if (Repinned->Bcb[i] != NULL)
297  {
299 
301 
302  if (FlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_FLOPPY))
303  {
304  FileObject = CcGetFileObjectFromBcb(Repinned->Bcb[i]);
305  }
306 
308 
309  CcUnpinRepinnedBcb(Repinned->Bcb[i],
310  WriteThroughToDisk,
311  &Iosb);
312 
314 
315  if (!NT_SUCCESS(Iosb.Status))
316  {
317  if (RaiseIosb.Status == STATUS_SUCCESS)
318  {
319  RaiseIosb = Iosb;
320  }
321 
322  if (FlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_FLOPPY) &&
323  (IrpContext->MajorFunction != IRP_MJ_CLEANUP) &&
324  (IrpContext->MajorFunction != IRP_MJ_FLUSH_BUFFERS) &&
325  (IrpContext->MajorFunction != IRP_MJ_SET_INFORMATION))
326  {
327 
328  CcPurgeCacheSection(FileObject->SectionObjectPointer,
329  NULL,
330  0,
331  FALSE);
332 
333  ForceVerify = TRUE;
334  }
335  }
336 
337  Repinned->Bcb[i] = NULL;
338 
339  }
340  else
341  {
342  break;
343  }
344  }
345 
346  if (Repinned != &IrpContext->Repinned)
347  {
348  PFFS_REPINNED_BCBS Saved;
349 
350  Saved = Repinned->Next;
351  ExFreePool(Repinned);
352  Repinned = Saved;
353 
354  }
355  else
356  {
357  Repinned = Repinned->Next;
358  IrpContext->Repinned.Next = NULL;
359  }
360  }
361 
362  if (!NT_SUCCESS(RaiseIosb.Status))
363  {
364  FFSBreakPoint();
365 
366  if (ForceVerify && FileObject)
367  {
368  SetFlag(FileObject->DeviceObject->Flags, DO_VERIFY_VOLUME);
369  IoSetHardErrorOrVerifyDevice(IrpContext->Irp,
370  FileObject->DeviceObject);
371  }
372 
373  IrpContext->Irp->IoStatus = RaiseIosb;
374  FFSNormalizeAndRaiseStatus(IrpContext, RaiseIosb.Status);
375  }
376 
377  return;
378 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fssup.c:384
#define TRUE
Definition: types.h:120
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_CONTEXT_FLAG_WRITE_THROUGH
Definition: ext2fs.h:1079
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
#define FFSNormalizeAndRaiseStatus(IRPCONTEXT, STATUS)
Definition: ffsdrv.h:144
PFILE_OBJECT NTAPI CcGetFileObjectFromBcb(PVOID Bcb)
Definition: fssup.c:623
#define FFSBreakPoint()
Definition: ffsdrv.h:43
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 IsFlagOn(a, b)
Definition: ext2fs.h:177
PBCB Bcb[FFS_REPINNED_BCBS_ARRAY_SIZE]
Definition: ffsdrv.h:327
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
VOID NTAPI CcUnpinRepinnedBcb(IN PVOID Bcb, IN BOOLEAN WriteThrough, OUT PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:343
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HRESULT Next([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] STATPROPSETSTG *rgelt, [out] ULONG *pceltFetched)
* PFILE_OBJECT
Definition: iotypes.h:1954
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define IRP_CONTEXT_FLAG_FLOPPY
Definition: ext2fs.h:1080
struct _FFS_REPINNED_BCBS * Next
Definition: ffsdrv.h:318
#define IRP_MJ_CLEANUP
#define BOOLEAN
Definition: pedump.c:73
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI IoSetHardErrorOrVerifyDevice(IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:316
#define FFS_REPINNED_BCBS_ARRAY_SIZE
Definition: ffsdrv.h:310
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSCreate(), and FFSFreeIrpContext().

◆ FFSv1AllocateFcb()

__drv_mustHoldCriticalRegion PFFS_FCB FFSv1AllocateFcb ( IN PFFS_VCB  Vcb,
IN PFFS_MCB  FFSMcb,
IN PFFSv1_INODE  dinode1 
)

Definition at line 383 of file memory.c.

387 {
388  PFFS_FCB Fcb;
389 
390  PAGED_CODE();
391 
394  TRUE);
395 
396  Fcb = (PFFS_FCB)(ExAllocateFromNPagedLookasideList(&(FFSGlobal->FFSFcbLookasideList)));
397 
401 
402  if (Fcb == NULL)
403  {
405 
406  RtlZeroMemory(Fcb, sizeof(FFS_FCB));
407 
409  }
410  else
411  {
412  RtlZeroMemory(Fcb, sizeof(FFS_FCB));
413  }
414 
415  if (!Fcb)
416  {
417  return NULL;
418  }
419 
421  Fcb->Identifier.Size = sizeof(FFS_FCB);
422 
424  &Fcb->FileLockAnchor,
425  NULL,
426  NULL);
427 
428  Fcb->OpenHandleCount = 0;
429  Fcb->ReferenceCount = 0;
430 
431  Fcb->Vcb = Vcb;
432 
433 #if DBG
434 
435  Fcb->AnsiFileName.MaximumLength = (USHORT)
436  RtlxUnicodeStringToOemSize(&(FFSMcb->ShortName)) + 1;
437 
438  Fcb->AnsiFileName.Buffer = (PUCHAR)
439  ExAllocatePoolWithTag(PagedPool, Fcb->AnsiFileName.MaximumLength, FFS_POOL_TAG);
440 
441  if (!Fcb->AnsiFileName.Buffer)
442  {
443  goto errorout;
444  }
445 
446  RtlZeroMemory(Fcb->AnsiFileName.Buffer, Fcb->AnsiFileName.MaximumLength);
447 
448  FFSUnicodeToOEM(&(Fcb->AnsiFileName),
449  &(FFSMcb->ShortName));
450 
451 #endif
452 
453  FFSMcb->FileAttr = FILE_ATTRIBUTE_NORMAL;
454 
455  if ((dinode1->di_mode & IFMT) == IFDIR)
456  {
457  SetFlag(FFSMcb->FileAttr, FILE_ATTRIBUTE_DIRECTORY);
458  }
459 
460  if (IsFlagOn(Vcb->Flags, VCB_READ_ONLY) ||
461  FFSIsReadOnly(dinode1->di_mode))
462  {
463  SetFlag(FFSMcb->FileAttr, FILE_ATTRIBUTE_READONLY);
464  }
465 
466  Fcb->dinode1 = dinode1;
467 
468  Fcb->FFSMcb = FFSMcb;
469  FFSMcb->FFSFcb = Fcb;
470 
472 
473  Fcb->Header.NodeTypeCode = (USHORT)FFSFCB;
474  Fcb->Header.NodeByteSize = sizeof(FFS_FCB);
475  Fcb->Header.IsFastIoPossible = FastIoIsNotPossible;
476  Fcb->Header.Resource = &(Fcb->MainResource);
477  Fcb->Header.PagingIoResource = &(Fcb->PagingIoResource);
478 
479  {
480  ULONG Totalblocks = (Fcb->dinode1->di_blocks);
481  Fcb->Header.AllocationSize.QuadPart =
482  (((LONGLONG)FFSDataBlocks(Vcb, Totalblocks)) << BLOCK_BITS);
483  }
484 
485  Fcb->Header.FileSize.QuadPart = (LONGLONG)(Fcb->dinode1->di_size);
486  Fcb->Header.ValidDataLength.QuadPart = (LONGLONG)(0x7fffffffffffffff);
487 
488  Fcb->SectionObject.DataSectionObject = NULL;
489  Fcb->SectionObject.SharedCacheMap = NULL;
490  Fcb->SectionObject.ImageSectionObject = NULL;
491 
494 
495  InsertTailList(&Vcb->FcbList, &Fcb->Next);
496 
497 #if DBG
498 
501  TRUE);
502 
503  FFSGlobal->FcbAllocated++;
504 
508 #endif
509 
510  return Fcb;
511 
512 #if DBG
513 errorout:
514 #endif
515 
516  if (Fcb)
517  {
518 
519 #if DBG
520  if (Fcb->AnsiFileName.Buffer)
521  ExFreePool(Fcb->AnsiFileName.Buffer);
522 #endif
523 
524  if (FlagOn(Fcb->Flags, FCB_FROM_POOL))
525  {
526  ExFreePool(Fcb);
527  }
528  else
529  {
532  TRUE);
533 
534  ExFreeToNPagedLookasideList(&(FFSGlobal->FFSFcbLookasideList), Fcb);
535 
539  }
540 
541  }
542 
543  return NULL;
544 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
Definition: ffsdrv.h:281
#define TRUE
Definition: types.h:120
#define FFSIsReadOnly(m)
Definition: ffsdrv.h:254
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
unsigned char * PUCHAR
Definition: retypes.h:3
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
struct _FFS_FCB FFS_FCB
#define InsertTailList(ListHead, Entry)
struct _FFS_FCB * PFFS_FCB
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
NTSTATUS FFSUnicodeToOEM(IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
Definition: misc.c:106
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
ERESOURCE CountResource
Definition: ffsdrv.h:355
ULONG FFSDataBlocks(PFFS_VCB Vcb, ULONG TotalBlocks)
Definition: ffs.c:2930
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
ULONG OpenHandleCount
Definition: ntfs.h:521
int64_t LONGLONG
Definition: typedefs.h:66
ERESOURCE LAResource
Definition: ffsdrv.h:358
NPAGED_LOOKASIDE_LIST FFSFcbLookasideList
Definition: ffsdrv.h:379
#define IFDIR
Definition: dinode.h:166
#define Vcb
Definition: cdprocs.h:1425
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
ULONG Flags
Definition: ntfs.h:520
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
ULONG Type
Definition: ntfs.h:95
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
ERESOURCE MainResource
Definition: ntfs.h:512
#define VCB_READ_ONLY
Definition: ext2fs.h:795
#define FCB_FROM_POOL
Definition: ext2fs.h:871
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define IFMT
Definition: dinode.h:163
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI ULONG NTAPI RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString)
Definition: unicode.c:1080
unsigned int ULONG
Definition: retypes.h:1
ERESOURCE PagingIoResource
Definition: ntfs.h:511
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PVCB Vcb
Definition: cdstruc.h:939
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG Size
Definition: ntfs.h:96
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSCreateFcbFromMcb(), and FFSCreateFile().

◆ FFSv2AllocateFcb()

__drv_mustHoldCriticalRegion PFFS_FCB FFSv2AllocateFcb ( IN PFFS_VCB  Vcb,
IN PFFS_MCB  FFSMcb,
IN PFFSv2_INODE  dinode2 
)

Definition at line 549 of file memory.c.

553 {
554  PFFS_FCB Fcb;
555 
556  PAGED_CODE();
557 
560  TRUE);
561 
562  Fcb = (PFFS_FCB)(ExAllocateFromNPagedLookasideList(&(FFSGlobal->FFSFcbLookasideList)));
563 
567 
568  if (Fcb == NULL)
569  {
571 
572  RtlZeroMemory(Fcb, sizeof(FFS_FCB));
573 
575  }
576  else
577  {
578  RtlZeroMemory(Fcb, sizeof(FFS_FCB));
579  }
580 
581  if (!Fcb)
582  {
583  return NULL;
584  }
585 
587  Fcb->Identifier.Size = sizeof(FFS_FCB);
588 
590  &Fcb->FileLockAnchor,
591  NULL,
592  NULL);
593 
594  Fcb->OpenHandleCount = 0;
595  Fcb->ReferenceCount = 0;
596 
597  Fcb->Vcb = Vcb;
598 
599 #if DBG
600 
601  Fcb->AnsiFileName.MaximumLength = (USHORT)
602  RtlxUnicodeStringToOemSize(&(FFSMcb->ShortName)) + 1;
603 
604  Fcb->AnsiFileName.Buffer = (PUCHAR)
605  ExAllocatePoolWithTag(PagedPool, Fcb->AnsiFileName.MaximumLength, FFS_POOL_TAG);
606 
607  if (!Fcb->AnsiFileName.Buffer)
608  {
609  goto errorout;
610  }
611 
612  RtlZeroMemory(Fcb->AnsiFileName.Buffer, Fcb->AnsiFileName.MaximumLength);
613 
614  FFSUnicodeToOEM(&(Fcb->AnsiFileName),
615  &(FFSMcb->ShortName));
616 
617 #endif
618 
619  FFSMcb->FileAttr = FILE_ATTRIBUTE_NORMAL;
620 
621  if ((dinode2->di_mode & IFMT) == IFDIR)
622  {
623  SetFlag(FFSMcb->FileAttr, FILE_ATTRIBUTE_DIRECTORY);
624  }
625 
626  if (IsFlagOn(Vcb->Flags, VCB_READ_ONLY) ||
627  FFSIsReadOnly(dinode2->di_mode))
628  {
629  SetFlag(FFSMcb->FileAttr, FILE_ATTRIBUTE_READONLY);
630  }
631 
632  Fcb->dinode2 = dinode2;
633 
634  Fcb->FFSMcb = FFSMcb;
635  FFSMcb->FFSFcb = Fcb;
636 
638 
639  Fcb->Header.NodeTypeCode = (USHORT)FFSFCB;
640  Fcb->Header.NodeByteSize = sizeof(FFS_FCB);
641  Fcb->Header.IsFastIoPossible = FastIoIsNotPossible;
642  Fcb->Header.Resource = &(Fcb->MainResource);
643  Fcb->Header.PagingIoResource = &(Fcb->PagingIoResource);
644 
645  {
646  ULONG Totalblocks = (ULONG)(Fcb->dinode2->di_blocks);
647  Fcb->Header.AllocationSize.QuadPart =
648  (((LONGLONG)FFSDataBlocks(Vcb, Totalblocks)) << BLOCK_BITS);
649  }
650 
651  Fcb->Header.FileSize.QuadPart = (LONGLONG)(Fcb->dinode2->di_size);
652  Fcb->Header.ValidDataLength.QuadPart = (LONGLONG)(0x7fffffffffffffff);
653 
654  Fcb->SectionObject.DataSectionObject = NULL;
655  Fcb->SectionObject.SharedCacheMap = NULL;
656  Fcb->SectionObject.ImageSectionObject = NULL;
657 
660 
661  InsertTailList(&Vcb->FcbList, &Fcb->Next);
662 
663 #if DBG
664 
667  TRUE);
668 
669  FFSGlobal->FcbAllocated++;
670 
674 #endif
675 
676  return Fcb;
677 
678 #if DBG
679 errorout:
680 #endif
681 
682  if (Fcb)
683  {
684 
685 #if DBG
686  if (Fcb->AnsiFileName.Buffer)
687  ExFreePool(Fcb->AnsiFileName.Buffer);
688 #endif
689 
690  if (FlagOn(Fcb->Flags, FCB_FROM_POOL))
691  {
692  ExFreePool(Fcb);
693  }
694  else
695  {
698  TRUE);
699 
700  ExFreeToNPagedLookasideList(&(FFSGlobal->FFSFcbLookasideList), Fcb);
701 
705  }
706 
707  }
708 
709  return NULL;
710 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
Definition: ffsdrv.h:281
#define TRUE
Definition: types.h:120
#define FFSIsReadOnly(m)
Definition: ffsdrv.h:254
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
unsigned char * PUCHAR
Definition: retypes.h:3
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
struct _FFS_FCB FFS_FCB
#define InsertTailList(ListHead, Entry)
struct _FFS_FCB * PFFS_FCB
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
NTSTATUS FFSUnicodeToOEM(IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
Definition: misc.c:106
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
ERESOURCE CountResource
Definition: ffsdrv.h:355
ULONG FFSDataBlocks(PFFS_VCB Vcb, ULONG TotalBlocks)
Definition: ffs.c:2930
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
ULONG OpenHandleCount
Definition: ntfs.h:521
int64_t LONGLONG
Definition: typedefs.h:66
ERESOURCE LAResource
Definition: ffsdrv.h:358
NPAGED_LOOKASIDE_LIST FFSFcbLookasideList
Definition: ffsdrv.h:379
#define IFDIR
Definition: dinode.h:166
#define Vcb
Definition: cdprocs.h:1425
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
ULONG Flags
Definition: ntfs.h:520
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
ULONG Type
Definition: ntfs.h:95
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
ERESOURCE MainResource
Definition: ntfs.h:512
#define VCB_READ_ONLY
Definition: ext2fs.h:795
#define FCB_FROM_POOL
Definition: ext2fs.h:871
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define IFMT
Definition: dinode.h:163
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI ULONG NTAPI RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString)
Definition: unicode.c:1080
unsigned int ULONG
Definition: retypes.h:1
ERESOURCE PagingIoResource
Definition: ntfs.h:511
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PVCB Vcb
Definition: cdstruc.h:939
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG Size
Definition: ntfs.h:96
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSCreateFcbFromMcb(), and FFSCreateFile().

Variable Documentation

◆ FFSGlobal