mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 10:20:03 +00:00
[0.4.10][NTFS] PrintAllVCNs(): Fix a typo in an ASSERT() (#4682), DPRINT1->DPRINT, EOL-WS
First part with the typo in the assert was introduced by5579428b4f
which was merged into ros by a merge-task during 0.4.8-dev'ing. releases/0.4.7 didn't have that code yet. fix picked from 0.4.15-dev-5035-gf308c6a2bc
---------- [NTFS] Do not print debug message for every function call by default That 2nd part was picked from 0.4.13-dev-450-g1552434940
---------- And for all the files that I had to touch for the 2nd part in the older branches, I ported back also some EOL-whitespace-fixes within like they were done during 0.4.15-dev'ing.
This commit is contained in:
parent
51b4d6fa79
commit
6034251432
|
@ -56,7 +56,7 @@ PrintAllVCNs(PDEVICE_EXTENSION Vcb,
|
||||||
|
|
||||||
BytesRead = ReadAttribute(Vcb, IndexAllocationContext, 0, (PCHAR)Buffer, BufferSize);
|
BytesRead = ReadAttribute(Vcb, IndexAllocationContext, 0, (PCHAR)Buffer, BufferSize);
|
||||||
|
|
||||||
ASSERT(BytesRead = BufferSize);
|
ASSERT(BytesRead == BufferSize);
|
||||||
|
|
||||||
CurrentNode = Buffer;
|
CurrentNode = Buffer;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ PrintAllVCNs(PDEVICE_EXTENSION Vcb,
|
||||||
* @returns
|
* @returns
|
||||||
* STATUS_SUCCESS in case of success.
|
* STATUS_SUCCESS in case of success.
|
||||||
* STATUS_NOT_IMPLEMENTED if there's no $I30 bitmap attribute in the file record.
|
* STATUS_NOT_IMPLEMENTED if there's no $I30 bitmap attribute in the file record.
|
||||||
*
|
*
|
||||||
* @remarks
|
* @remarks
|
||||||
* AllocateIndexNode() doesn't write any data to the index record it creates. Called by UpdateIndexNode().
|
* AllocateIndexNode() doesn't write any data to the index record it creates. Called by UpdateIndexNode().
|
||||||
* Don't call PrintAllVCNs() or NtfsDumpFileRecord() after calling AllocateIndexNode() before UpdateIndexNode() finishes.
|
* Don't call PrintAllVCNs() or NtfsDumpFileRecord() after calling AllocateIndexNode() before UpdateIndexNode() finishes.
|
||||||
|
@ -173,7 +173,7 @@ AllocateIndexNode(PDEVICE_EXTENSION DeviceExt,
|
||||||
// Windows seems to allocate the bitmap in 8-byte chunks to keep any bytes from being wasted on padding
|
// Windows seems to allocate the bitmap in 8-byte chunks to keep any bytes from being wasted on padding
|
||||||
BytesNeeded = ALIGN_UP(BytesNeeded, ATTR_RECORD_ALIGNMENT);
|
BytesNeeded = ALIGN_UP(BytesNeeded, ATTR_RECORD_ALIGNMENT);
|
||||||
|
|
||||||
// Allocate memory for the bitmap, including some padding; RtlInitializeBitmap() wants a pointer
|
// Allocate memory for the bitmap, including some padding; RtlInitializeBitmap() wants a pointer
|
||||||
// that's ULONG-aligned, and it wants the size of the memory allocated for it to be a ULONG-multiple.
|
// that's ULONG-aligned, and it wants the size of the memory allocated for it to be a ULONG-multiple.
|
||||||
BitmapMem = ExAllocatePoolWithTag(NonPagedPool, BytesNeeded + sizeof(ULONG), TAG_NTFS);
|
BitmapMem = ExAllocatePoolWithTag(NonPagedPool, BytesNeeded + sizeof(ULONG), TAG_NTFS);
|
||||||
if (!BitmapMem)
|
if (!BitmapMem)
|
||||||
|
@ -248,7 +248,7 @@ AllocateIndexNode(PDEVICE_EXTENSION DeviceExt,
|
||||||
|
|
||||||
// Set the bit for the new index record
|
// Set the bit for the new index record
|
||||||
RtlSetBits(&Bitmap, NextNodeNumber, 1);
|
RtlSetBits(&Bitmap, NextNodeNumber, 1);
|
||||||
|
|
||||||
// Write the new bitmap attribute
|
// Write the new bitmap attribute
|
||||||
Status = WriteAttribute(DeviceExt,
|
Status = WriteAttribute(DeviceExt,
|
||||||
BitmapCtx,
|
BitmapCtx,
|
||||||
|
@ -304,7 +304,7 @@ CreateDummyKey(BOOLEAN HasChildNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlZeroMemory(NewIndexEntry, EntrySize);
|
RtlZeroMemory(NewIndexEntry, EntrySize);
|
||||||
|
|
||||||
if (HasChildNode)
|
if (HasChildNode)
|
||||||
{
|
{
|
||||||
NewIndexEntry->Flags = NTFS_INDEX_ENTRY_NODE | NTFS_INDEX_ENTRY_END;
|
NewIndexEntry->Flags = NTFS_INDEX_ENTRY_NODE | NTFS_INDEX_ENTRY_END;
|
||||||
|
@ -443,7 +443,7 @@ CompareTreeKeys(PB_TREE_KEY Key1, PB_TREE_KEY Key2, BOOLEAN CaseSensitive)
|
||||||
{
|
{
|
||||||
// Truncate KeyName2 to be the same length as KeyName1
|
// Truncate KeyName2 to be the same length as KeyName1
|
||||||
Key2Name.Length = Key1Name.Length;
|
Key2Name.Length = Key1Name.Length;
|
||||||
|
|
||||||
// Compare the names of the same length
|
// Compare the names of the same length
|
||||||
Comparison = RtlCompareUnicodeString(&Key1Name, &Key2Name, !CaseSensitive);
|
Comparison = RtlCompareUnicodeString(&Key1Name, &Key2Name, !CaseSensitive);
|
||||||
|
|
||||||
|
@ -471,12 +471,12 @@ CompareTreeKeys(PB_TREE_KEY Key1, PB_TREE_KEY Key2, BOOLEAN CaseSensitive)
|
||||||
/**
|
/**
|
||||||
* @name CountBTreeKeys
|
* @name CountBTreeKeys
|
||||||
* @implemented
|
* @implemented
|
||||||
*
|
*
|
||||||
* Counts the number of linked B-Tree keys, starting with FirstKey.
|
* Counts the number of linked B-Tree keys, starting with FirstKey.
|
||||||
*
|
*
|
||||||
* @param FirstKey
|
* @param FirstKey
|
||||||
* Pointer to a B_TREE_KEY that will be the first key to be counted.
|
* Pointer to a B_TREE_KEY that will be the first key to be counted.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* The number of keys in a linked-list, including FirstKey and the final dummy key.
|
* The number of keys in a linked-list, including FirstKey and the final dummy key.
|
||||||
*/
|
*/
|
||||||
|
@ -485,7 +485,7 @@ CountBTreeKeys(PB_TREE_KEY FirstKey)
|
||||||
{
|
{
|
||||||
ULONG Count = 0;
|
ULONG Count = 0;
|
||||||
PB_TREE_KEY Current = FirstKey;
|
PB_TREE_KEY Current = FirstKey;
|
||||||
|
|
||||||
while (Current != NULL)
|
while (Current != NULL)
|
||||||
{
|
{
|
||||||
Count++;
|
Count++;
|
||||||
|
@ -674,7 +674,7 @@ CreateBTreeNodeFromIndexNode(PDEVICE_EXTENSION Vcb,
|
||||||
* @returns
|
* @returns
|
||||||
* STATUS_SUCCESS on success.
|
* STATUS_SUCCESS on success.
|
||||||
* STATUS_INSUFFICIENT_RESOURCES if an allocation fails.
|
* STATUS_INSUFFICIENT_RESOURCES if an allocation fails.
|
||||||
*
|
*
|
||||||
* @remarks
|
* @remarks
|
||||||
* Allocates memory for the entire tree. Caller is responsible for destroying the tree with DestroyBTree().
|
* Allocates memory for the entire tree. Caller is responsible for destroying the tree with DestroyBTree().
|
||||||
*/
|
*/
|
||||||
|
@ -694,7 +694,7 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb,
|
||||||
PNTFS_ATTR_CONTEXT IndexAllocationContext = NULL;
|
PNTFS_ATTR_CONTEXT IndexAllocationContext = NULL;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT1("CreateBTreeFromIndex(%p, %p)\n", IndexRoot, NewTree);
|
DPRINT("CreateBTreeFromIndex(%p, %p)\n", IndexRoot, NewTree);
|
||||||
|
|
||||||
if (!Tree || !RootNode || !CurrentKey)
|
if (!Tree || !RootNode || !CurrentKey)
|
||||||
{
|
{
|
||||||
|
@ -861,7 +861,7 @@ GetSizeOfIndexEntries(PB_TREE_FILENAME_NODE Node)
|
||||||
PB_TREE_KEY CurrentKey = Node->FirstKey;
|
PB_TREE_KEY CurrentKey = Node->FirstKey;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
for (i = 0; i < Node->KeyCount; i++)
|
for (i = 0; i < Node->KeyCount; i++)
|
||||||
{
|
{
|
||||||
ASSERT(CurrentKey->IndexEntry->Length != 0);
|
ASSERT(CurrentKey->IndexEntry->Length != 0);
|
||||||
|
|
||||||
// Add the length of the current node
|
// Add the length of the current node
|
||||||
|
@ -902,7 +902,7 @@ GetSizeOfIndexEntries(PB_TREE_FILENAME_NODE Node)
|
||||||
* STATUS_SUCCESS on success.
|
* STATUS_SUCCESS on success.
|
||||||
* STATUS_INSUFFICIENT_RESOURCES if an allocation fails.
|
* STATUS_INSUFFICIENT_RESOURCES if an allocation fails.
|
||||||
* STATUS_NOT_IMPLEMENTED if the new index can't fit within MaxIndexSize.
|
* STATUS_NOT_IMPLEMENTED if the new index can't fit within MaxIndexSize.
|
||||||
*
|
*
|
||||||
* @remarks
|
* @remarks
|
||||||
* If the function succeeds, it's the caller's responsibility to free IndexRoot with ExFreePoolWithTag().
|
* If the function succeeds, it's the caller's responsibility to free IndexRoot with ExFreePoolWithTag().
|
||||||
*/
|
*/
|
||||||
|
@ -920,7 +920,7 @@ CreateIndexRootFromBTree(PDEVICE_EXTENSION DeviceExt,
|
||||||
DeviceExt->NtfsInfo.BytesPerFileRecord,
|
DeviceExt->NtfsInfo.BytesPerFileRecord,
|
||||||
TAG_NTFS);
|
TAG_NTFS);
|
||||||
|
|
||||||
DPRINT1("CreateIndexRootFromBTree(%p, %p, 0x%lx, %p, %p)\n", DeviceExt, Tree, MaxIndexSize, IndexRoot, Length);
|
DPRINT("CreateIndexRootFromBTree(%p, %p, 0x%lx, %p, %p)\n", DeviceExt, Tree, MaxIndexSize, IndexRoot, Length);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
DumpBTree(Tree);
|
DumpBTree(Tree);
|
||||||
|
@ -953,7 +953,7 @@ CreateIndexRootFromBTree(PDEVICE_EXTENSION DeviceExt,
|
||||||
|
|
||||||
// Setup each Node Entry
|
// Setup each Node Entry
|
||||||
CurrentKey = Tree->RootNode->FirstKey;
|
CurrentKey = Tree->RootNode->FirstKey;
|
||||||
CurrentNodeEntry = (PINDEX_ENTRY_ATTRIBUTE)((ULONG_PTR)NewIndexRoot
|
CurrentNodeEntry = (PINDEX_ENTRY_ATTRIBUTE)((ULONG_PTR)NewIndexRoot
|
||||||
+ FIELD_OFFSET(INDEX_ROOT_ATTRIBUTE, Header)
|
+ FIELD_OFFSET(INDEX_ROOT_ATTRIBUTE, Header)
|
||||||
+ NewIndexRoot->Header.FirstEntryOffset);
|
+ NewIndexRoot->Header.FirstEntryOffset);
|
||||||
for (i = 0; i < Tree->RootNode->KeyCount; i++)
|
for (i = 0; i < Tree->RootNode->KeyCount; i++)
|
||||||
|
@ -1021,7 +1021,7 @@ CreateIndexBufferFromBTreeNode(PDEVICE_EXTENSION DeviceExt,
|
||||||
|
|
||||||
// Windows seems to alternate between using 0x28 and 0x40 for the first entry offset of each index buffer.
|
// Windows seems to alternate between using 0x28 and 0x40 for the first entry offset of each index buffer.
|
||||||
// Interestingly, neither Windows nor chkdsk seem to mind if we just use 0x28 for every index record.
|
// Interestingly, neither Windows nor chkdsk seem to mind if we just use 0x28 for every index record.
|
||||||
IndexBuffer->Header.FirstEntryOffset = 0x28;
|
IndexBuffer->Header.FirstEntryOffset = 0x28;
|
||||||
IndexBuffer->Header.AllocatedSize = BufferSize - FIELD_OFFSET(INDEX_BUFFER, Header);
|
IndexBuffer->Header.AllocatedSize = BufferSize - FIELD_OFFSET(INDEX_BUFFER, Header);
|
||||||
|
|
||||||
// Start summing the total size of this node's entries
|
// Start summing the total size of this node's entries
|
||||||
|
@ -1091,7 +1091,7 @@ DemoteBTreeRoot(PB_TREE Tree)
|
||||||
PB_TREE_FILENAME_NODE NewSubNode, NewIndexRoot;
|
PB_TREE_FILENAME_NODE NewSubNode, NewIndexRoot;
|
||||||
PB_TREE_KEY DummyKey;
|
PB_TREE_KEY DummyKey;
|
||||||
|
|
||||||
DPRINT1("Collapsing Index Root into sub-node.\n");
|
DPRINT("Collapsing Index Root into sub-node.\n");
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
DumpBTree(Tree);
|
DumpBTree(Tree);
|
||||||
|
@ -1192,7 +1192,7 @@ UpdateIndexAllocation(PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG IndexAllocationOffset;
|
ULONG IndexAllocationOffset;
|
||||||
|
|
||||||
DPRINT1("UpdateIndexAllocation() called.\n");
|
DPRINT("UpdateIndexAllocation() called.\n");
|
||||||
|
|
||||||
Status = FindAttribute(DeviceExt, FileRecord, AttributeIndexAllocation, L"$I30", 4, &IndexAllocationContext, &IndexAllocationOffset);
|
Status = FindAttribute(DeviceExt, FileRecord, AttributeIndexAllocation, L"$I30", 4, &IndexAllocationContext, &IndexAllocationOffset);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
|
@ -1237,7 +1237,7 @@ UpdateIndexAllocation(PDEVICE_EXTENSION DeviceExt,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advance end marker
|
// Advance end marker
|
||||||
EndMarker = (PNTFS_ATTR_RECORD)((ULONG_PTR)EndMarker + EndMarker->Length);
|
EndMarker = (PNTFS_ATTR_RECORD)((ULONG_PTR)EndMarker + EndMarker->Length);
|
||||||
|
|
||||||
// Add index bitmap to the very end of the file record
|
// Add index bitmap to the very end of the file record
|
||||||
|
@ -1355,7 +1355,7 @@ UpdateIndexNode(PDEVICE_EXTENSION DeviceExt,
|
||||||
DPRINT1("ERROR: Failed to update child node!\n");
|
DPRINT1("ERROR: Failed to update child node!\n");
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the Index Entry large enough to store the VCN?
|
// Is the Index Entry large enough to store the VCN?
|
||||||
if (!BooleanFlagOn(CurrentKey->IndexEntry->Flags, NTFS_INDEX_ENTRY_NODE))
|
if (!BooleanFlagOn(CurrentKey->IndexEntry->Flags, NTFS_INDEX_ENTRY_NODE))
|
||||||
{
|
{
|
||||||
|
@ -1708,16 +1708,16 @@ NtfsInsertKey(PB_TREE Tree,
|
||||||
*MedianKey = NULL;
|
*MedianKey = NULL;
|
||||||
*NewRightHandSibling = NULL;
|
*NewRightHandSibling = NULL;
|
||||||
|
|
||||||
DPRINT1("NtfsInsertKey(%p, 0x%I64x, %p, %p, %s, %lu, %lu, %p, %p)\n",
|
DPRINT("NtfsInsertKey(%p, 0x%I64x, %p, %p, %s, %lu, %lu, %p, %p)\n",
|
||||||
Tree,
|
Tree,
|
||||||
FileReference,
|
FileReference,
|
||||||
FileNameAttribute,
|
FileNameAttribute,
|
||||||
Node,
|
Node,
|
||||||
CaseSensitive ? "TRUE" : "FALSE",
|
CaseSensitive ? "TRUE" : "FALSE",
|
||||||
MaxIndexRootSize,
|
MaxIndexRootSize,
|
||||||
IndexRecordSize,
|
IndexRecordSize,
|
||||||
MedianKey,
|
MedianKey,
|
||||||
NewRightHandSibling);
|
NewRightHandSibling);
|
||||||
|
|
||||||
// Create the key for the filename attribute
|
// Create the key for the filename attribute
|
||||||
NewKey = CreateBTreeKeyFromFilename(FileReference, FileNameAttribute);
|
NewKey = CreateBTreeKeyFromFilename(FileReference, FileNameAttribute);
|
||||||
|
@ -1756,7 +1756,7 @@ NtfsInsertKey(PB_TREE Tree,
|
||||||
CaseSensitive,
|
CaseSensitive,
|
||||||
MaxIndexRootSize,
|
MaxIndexRootSize,
|
||||||
IndexRecordSize,
|
IndexRecordSize,
|
||||||
&NewLeftKey,
|
&NewLeftKey,
|
||||||
&NewChild);
|
&NewChild);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -1821,9 +1821,9 @@ NtfsInsertKey(PB_TREE Tree,
|
||||||
// Calculate maximum size of index entries without any headers
|
// Calculate maximum size of index entries without any headers
|
||||||
AllocatedNodeSize = IndexRecordSize - FIELD_OFFSET(INDEX_BUFFER, Header);
|
AllocatedNodeSize = IndexRecordSize - FIELD_OFFSET(INDEX_BUFFER, Header);
|
||||||
|
|
||||||
// TODO: Replace magic with math
|
// TODO: Replace magic with math
|
||||||
MaxNodeSizeWithoutHeader = AllocatedNodeSize - 0x28;
|
MaxNodeSizeWithoutHeader = AllocatedNodeSize - 0x28;
|
||||||
|
|
||||||
// Has the node grown larger than its allocated size?
|
// Has the node grown larger than its allocated size?
|
||||||
if (NodeSize > MaxNodeSizeWithoutHeader)
|
if (NodeSize > MaxNodeSizeWithoutHeader)
|
||||||
{
|
{
|
||||||
|
@ -1870,7 +1870,7 @@ NtfsInsertKey(PB_TREE Tree,
|
||||||
* @param CaseSensitive
|
* @param CaseSensitive
|
||||||
* Boolean indicating if the function should operate in case-sensitive mode. This will be TRUE
|
* Boolean indicating if the function should operate in case-sensitive mode. This will be TRUE
|
||||||
* if an application created the file with the FILE_FLAG_POSIX_SEMANTICS flag.
|
* if an application created the file with the FILE_FLAG_POSIX_SEMANTICS flag.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* STATUS_SUCCESS on success.
|
* STATUS_SUCCESS on success.
|
||||||
* STATUS_INSUFFICIENT_RESOURCES if an allocation fails.
|
* STATUS_INSUFFICIENT_RESOURCES if an allocation fails.
|
||||||
|
@ -1893,7 +1893,7 @@ SplitBTreeNode(PB_TREE Tree,
|
||||||
ULONG SizeSum;
|
ULONG SizeSum;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
DPRINT1("SplitBTreeNode(%p, %p, %p, %p, %s) called\n",
|
DPRINT("SplitBTreeNode(%p, %p, %p, %p, %s) called\n",
|
||||||
Tree,
|
Tree,
|
||||||
Node,
|
Node,
|
||||||
MedianKey,
|
MedianKey,
|
||||||
|
|
|
@ -111,7 +111,7 @@ NtfsMoonWalkID(PDEVICE_EXTENSION DeviceExt,
|
||||||
WCHAR FullPath[MAX_PATH];
|
WCHAR FullPath[MAX_PATH];
|
||||||
ULONG WritePosition = MAX_PATH - 1;
|
ULONG WritePosition = MAX_PATH - 1;
|
||||||
|
|
||||||
DPRINT1("NtfsMoonWalkID(%p, %I64x, %p)\n", DeviceExt, Id, OutPath);
|
DPRINT("NtfsMoonWalkID(%p, %I64x, %p)\n", DeviceExt, Id, OutPath);
|
||||||
|
|
||||||
RtlZeroMemory(FullPath, sizeof(FullPath));
|
RtlZeroMemory(FullPath, sizeof(FullPath));
|
||||||
MftRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
|
MftRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
|
||||||
|
@ -181,7 +181,7 @@ NtfsOpenFileById(PDEVICE_EXTENSION DeviceExt,
|
||||||
PNTFS_FCB FCB;
|
PNTFS_FCB FCB;
|
||||||
PFILE_RECORD_HEADER MftRecord;
|
PFILE_RECORD_HEADER MftRecord;
|
||||||
|
|
||||||
DPRINT1("NtfsOpenFileById(%p, %p, %I64x, %p)\n", DeviceExt, FileObject, MftId, FoundFCB);
|
DPRINT("NtfsOpenFileById(%p, %p, %I64x, %p)\n", DeviceExt, FileObject, MftId, FoundFCB);
|
||||||
|
|
||||||
ASSERT(MftId < NTFS_FILE_FIRST_USER_FILE);
|
ASSERT(MftId < NTFS_FILE_FIRST_USER_FILE);
|
||||||
if (MftId > 0xb) /* No entries are used yet beyond this */
|
if (MftId > 0xb) /* No entries are used yet beyond this */
|
||||||
|
@ -250,7 +250,7 @@ NtfsOpenFile(PDEVICE_EXTENSION DeviceExt,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PWSTR AbsFileName = NULL;
|
PWSTR AbsFileName = NULL;
|
||||||
|
|
||||||
DPRINT1("NtfsOpenFile(%p, %p, %S, %s, %p)\n",
|
DPRINT("NtfsOpenFile(%p, %p, %S, %s, %p)\n",
|
||||||
DeviceExt,
|
DeviceExt,
|
||||||
FileObject,
|
FileObject,
|
||||||
FileName,
|
FileName,
|
||||||
|
@ -339,7 +339,7 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
|
||||||
UNICODE_STRING FullPath;
|
UNICODE_STRING FullPath;
|
||||||
PIRP Irp = IrpContext->Irp;
|
PIRP Irp = IrpContext->Irp;
|
||||||
|
|
||||||
DPRINT1("NtfsCreateFile(%p, %p) called\n", DeviceObject, IrpContext);
|
DPRINT("NtfsCreateFile(%p, %p) called\n", DeviceObject, IrpContext);
|
||||||
|
|
||||||
DeviceExt = DeviceObject->DeviceExtension;
|
DeviceExt = DeviceObject->DeviceExtension;
|
||||||
ASSERT(DeviceExt);
|
ASSERT(DeviceExt);
|
||||||
|
@ -499,7 +499,7 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check for appropriate access
|
// TODO: check for appropriate access
|
||||||
|
|
||||||
ExAcquireResourceExclusiveLite(&(Fcb->MainResource), TRUE);
|
ExAcquireResourceExclusiveLite(&(Fcb->MainResource), TRUE);
|
||||||
|
|
||||||
fileRecord = ExAllocateFromNPagedLookasideList(&Fcb->Vcb->FileRecLookasideList);
|
fileRecord = ExAllocateFromNPagedLookasideList(&Fcb->Vcb->FileRecLookasideList);
|
||||||
|
@ -522,8 +522,8 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Status = STATUS_NO_MEMORY;
|
Status = STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
DoneOverwriting:
|
DoneOverwriting:
|
||||||
if (fileRecord)
|
if (fileRecord)
|
||||||
ExFreeToNPagedLookasideList(&Fcb->Vcb->FileRecLookasideList, fileRecord);
|
ExFreeToNPagedLookasideList(&Fcb->Vcb->FileRecLookasideList, fileRecord);
|
||||||
|
@ -536,7 +536,7 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
|
||||||
{
|
{
|
||||||
NtfsCloseFile(DeviceExt, FileObject);
|
NtfsCloseFile(DeviceExt, FileObject);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RequestedDisposition == FILE_SUPERSEDE)
|
if (RequestedDisposition == FILE_SUPERSEDE)
|
||||||
{
|
{
|
||||||
|
@ -695,7 +695,7 @@ NtfsCreateDirectory(PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONG MaxIndexRootSize;
|
ULONG MaxIndexRootSize;
|
||||||
ULONG RootLength;
|
ULONG RootLength;
|
||||||
|
|
||||||
DPRINT1("NtfsCreateFileRecord(%p, %p, %s, %s)\n",
|
DPRINT("NtfsCreateFileRecord(%p, %p, %s, %s)\n",
|
||||||
DeviceExt,
|
DeviceExt,
|
||||||
FileObject,
|
FileObject,
|
||||||
CaseSensitive ? "TRUE" : "FALSE",
|
CaseSensitive ? "TRUE" : "FALSE",
|
||||||
|
@ -740,7 +740,7 @@ NtfsCreateDirectory(PDEVICE_EXTENSION DeviceExt,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate maximum size of index root
|
// Calculate maximum size of index root
|
||||||
MaxIndexRootSize = DeviceExt->NtfsInfo.BytesPerFileRecord
|
MaxIndexRootSize = DeviceExt->NtfsInfo.BytesPerFileRecord
|
||||||
- ((ULONG_PTR)NextAttribute - (ULONG_PTR)FileRecord)
|
- ((ULONG_PTR)NextAttribute - (ULONG_PTR)FileRecord)
|
||||||
- sizeof(ULONG) * 2;
|
- sizeof(ULONG) * 2;
|
||||||
|
|
||||||
|
@ -810,7 +810,7 @@ NtfsCreateDirectory(PDEVICE_EXTENSION DeviceExt,
|
||||||
*
|
*
|
||||||
* @param DeviceExt
|
* @param DeviceExt
|
||||||
* Pointer to the DEVICE_EXTENSION of the target volume the file record will be stored on.
|
* Pointer to the DEVICE_EXTENSION of the target volume the file record will be stored on.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* A pointer to the newly-created FILE_RECORD_HEADER if the function succeeds, NULL otherwise.
|
* A pointer to the newly-created FILE_RECORD_HEADER if the function succeeds, NULL otherwise.
|
||||||
*/
|
*/
|
||||||
|
@ -820,7 +820,7 @@ NtfsCreateEmptyFileRecord(PDEVICE_EXTENSION DeviceExt)
|
||||||
PFILE_RECORD_HEADER FileRecord;
|
PFILE_RECORD_HEADER FileRecord;
|
||||||
PNTFS_ATTR_RECORD NextAttribute;
|
PNTFS_ATTR_RECORD NextAttribute;
|
||||||
|
|
||||||
DPRINT1("NtfsCreateEmptyFileRecord(%p)\n", DeviceExt);
|
DPRINT("NtfsCreateEmptyFileRecord(%p)\n", DeviceExt);
|
||||||
|
|
||||||
// allocate memory for file record
|
// allocate memory for file record
|
||||||
FileRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
|
FileRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
|
||||||
|
@ -875,11 +875,11 @@ NtfsCreateEmptyFileRecord(PDEVICE_EXTENSION DeviceExt)
|
||||||
* @param CanWait
|
* @param CanWait
|
||||||
* Boolean indicating if the function is allowed to wait for exclusive access to the master file table.
|
* Boolean indicating if the function is allowed to wait for exclusive access to the master file table.
|
||||||
* This will only be relevant if the MFT doesn't have any free file records and needs to be enlarged.
|
* This will only be relevant if the MFT doesn't have any free file records and needs to be enlarged.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* STATUS_SUCCESS on success.
|
* STATUS_SUCCESS on success.
|
||||||
* STATUS_INSUFFICIENT_RESOURCES if unable to allocate memory for the file record.
|
* STATUS_INSUFFICIENT_RESOURCES if unable to allocate memory for the file record.
|
||||||
* STATUS_CANT_WAIT if CanWait was FALSE and the function needed to resize the MFT but
|
* STATUS_CANT_WAIT if CanWait was FALSE and the function needed to resize the MFT but
|
||||||
* couldn't get immediate, exclusive access to it.
|
* couldn't get immediate, exclusive access to it.
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -895,7 +895,7 @@ NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONGLONG ParentMftIndex;
|
ULONGLONG ParentMftIndex;
|
||||||
ULONGLONG FileMftIndex;
|
ULONGLONG FileMftIndex;
|
||||||
|
|
||||||
DPRINT1("NtfsCreateFileRecord(%p, %p, %s, %s)\n",
|
DPRINT("NtfsCreateFileRecord(%p, %p, %s, %s)\n",
|
||||||
DeviceExt,
|
DeviceExt,
|
||||||
FileObject,
|
FileObject,
|
||||||
CaseSensitive ? "TRUE" : "FALSE",
|
CaseSensitive ? "TRUE" : "FALSE",
|
||||||
|
|
|
@ -378,7 +378,7 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
UNICODE_STRING Pattern;
|
UNICODE_STRING Pattern;
|
||||||
ULONG Written;
|
ULONG Written;
|
||||||
|
|
||||||
DPRINT1("NtfsQueryDirectory() called\n");
|
DPRINT("NtfsQueryDirectory() called\n");
|
||||||
|
|
||||||
ASSERT(IrpContext);
|
ASSERT(IrpContext);
|
||||||
Irp = IrpContext->Irp;
|
Irp = IrpContext->Irp;
|
||||||
|
@ -591,7 +591,7 @@ NtfsDirectoryControl(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
DPRINT1("NtfsDirectoryControl() called\n");
|
DPRINT("NtfsDirectoryControl() called\n");
|
||||||
|
|
||||||
switch (IrpContext->MinorFunction)
|
switch (IrpContext->MinorFunction)
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,7 +140,7 @@ NtfsFCBIsReparsePoint(PNTFS_FCB Fcb)
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NtfsFCBIsCompressed(PNTFS_FCB Fcb)
|
NtfsFCBIsCompressed(PNTFS_FCB Fcb)
|
||||||
{
|
{
|
||||||
return ((Fcb->Entry.FileAttributes & NTFS_FILE_TYPE_COMPRESSED) == NTFS_FILE_TYPE_COMPRESSED);
|
return ((Fcb->Entry.FileAttributes & NTFS_FILE_TYPE_COMPRESSED) == NTFS_FILE_TYPE_COMPRESSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
@ -389,7 +389,7 @@ NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
|
||||||
PNTFS_FCB rcFCB;
|
PNTFS_FCB rcFCB;
|
||||||
ULONGLONG Size, AllocatedSize;
|
ULONGLONG Size, AllocatedSize;
|
||||||
|
|
||||||
DPRINT1("NtfsMakeFCBFromDirEntry(%p, %p, %wZ, %p, %p, %p)\n", Vcb, DirectoryFCB, Name, Stream, Record, fileFCB);
|
DPRINT("NtfsMakeFCBFromDirEntry(%p, %p, %wZ, %p, %p, %p)\n", Vcb, DirectoryFCB, Name, Stream, Record, fileFCB);
|
||||||
|
|
||||||
FileName = GetBestFileNameFromRecord(Vcb, Record);
|
FileName = GetBestFileNameFromRecord(Vcb, Record);
|
||||||
if (!FileName)
|
if (!FileName)
|
||||||
|
@ -516,12 +516,12 @@ NtfsDirFindFile(PNTFS_VCB Vcb,
|
||||||
PNTFS_ATTR_CONTEXT DataContext;
|
PNTFS_ATTR_CONTEXT DataContext;
|
||||||
USHORT Length = 0;
|
USHORT Length = 0;
|
||||||
|
|
||||||
DPRINT1("NtfsDirFindFile(%p, %p, %S, %s, %p)\n",
|
DPRINT("NtfsDirFindFile(%p, %p, %S, %s, %p)\n",
|
||||||
Vcb,
|
Vcb,
|
||||||
DirectoryFcb,
|
DirectoryFcb,
|
||||||
FileToFind,
|
FileToFind,
|
||||||
CaseSensitive ? "TRUE" : "FALSE",
|
CaseSensitive ? "TRUE" : "FALSE",
|
||||||
FoundFCB);
|
FoundFCB);
|
||||||
|
|
||||||
*FoundFCB = NULL;
|
*FoundFCB = NULL;
|
||||||
RtlInitUnicodeString(&File, FileToFind);
|
RtlInitUnicodeString(&File, FileToFind);
|
||||||
|
@ -723,7 +723,7 @@ NtfsGetFCBForFile(PNTFS_VCB Vcb,
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NtfsReadFCBAttribute(PNTFS_VCB Vcb,
|
NtfsReadFCBAttribute(PNTFS_VCB Vcb,
|
||||||
PNTFS_FCB pFCB,
|
PNTFS_FCB pFCB,
|
||||||
ULONG Type,
|
ULONG Type,
|
||||||
PCWSTR Name,
|
PCWSTR Name,
|
||||||
ULONG NameLength,
|
ULONG NameLength,
|
||||||
PVOID * Data)
|
PVOID * Data)
|
||||||
|
|
|
@ -46,7 +46,7 @@ NtfsGetStandardInformation(PNTFS_FCB Fcb,
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(DeviceObject);
|
UNREFERENCED_PARAMETER(DeviceObject);
|
||||||
|
|
||||||
DPRINT1("NtfsGetStandardInformation(%p, %p, %p, %p)\n", Fcb, DeviceObject, StandardInfo, BufferLength);
|
DPRINT("NtfsGetStandardInformation(%p, %p, %p, %p)\n", Fcb, DeviceObject, StandardInfo, BufferLength);
|
||||||
|
|
||||||
if (*BufferLength < sizeof(FILE_STANDARD_INFORMATION))
|
if (*BufferLength < sizeof(FILE_STANDARD_INFORMATION))
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
|
@ -102,7 +102,7 @@ NtfsGetBasicInformation(PFILE_OBJECT FileObject,
|
||||||
{
|
{
|
||||||
PFILENAME_ATTRIBUTE FileName = &Fcb->Entry;
|
PFILENAME_ATTRIBUTE FileName = &Fcb->Entry;
|
||||||
|
|
||||||
DPRINT1("NtfsGetBasicInformation(%p, %p, %p, %p, %p)\n", FileObject, Fcb, DeviceObject, BasicInfo, BufferLength);
|
DPRINT("NtfsGetBasicInformation(%p, %p, %p, %p, %p)\n", FileObject, Fcb, DeviceObject, BasicInfo, BufferLength);
|
||||||
|
|
||||||
if (*BufferLength < sizeof(FILE_BASIC_INFORMATION))
|
if (*BufferLength < sizeof(FILE_BASIC_INFORMATION))
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
|
@ -136,7 +136,7 @@ NtfsGetNameInformation(PFILE_OBJECT FileObject,
|
||||||
UNREFERENCED_PARAMETER(FileObject);
|
UNREFERENCED_PARAMETER(FileObject);
|
||||||
UNREFERENCED_PARAMETER(DeviceObject);
|
UNREFERENCED_PARAMETER(DeviceObject);
|
||||||
|
|
||||||
DPRINT1("NtfsGetNameInformation(%p, %p, %p, %p, %p)\n", FileObject, Fcb, DeviceObject, NameInfo, BufferLength);
|
DPRINT("NtfsGetNameInformation(%p, %p, %p, %p, %p)\n", FileObject, Fcb, DeviceObject, NameInfo, BufferLength);
|
||||||
|
|
||||||
ASSERT(NameInfo != NULL);
|
ASSERT(NameInfo != NULL);
|
||||||
ASSERT(Fcb != NULL);
|
ASSERT(Fcb != NULL);
|
||||||
|
@ -200,7 +200,7 @@ NtfsGetNetworkOpenInformation(PNTFS_FCB Fcb,
|
||||||
{
|
{
|
||||||
PFILENAME_ATTRIBUTE FileName = &Fcb->Entry;
|
PFILENAME_ATTRIBUTE FileName = &Fcb->Entry;
|
||||||
|
|
||||||
DPRINT1("NtfsGetNetworkOpenInformation(%p, %p, %p, %p)\n", Fcb, DeviceExt, NetworkInfo, BufferLength);
|
DPRINT("NtfsGetNetworkOpenInformation(%p, %p, %p, %p)\n", Fcb, DeviceExt, NetworkInfo, BufferLength);
|
||||||
|
|
||||||
if (*BufferLength < sizeof(FILE_NETWORK_OPEN_INFORMATION))
|
if (*BufferLength < sizeof(FILE_NETWORK_OPEN_INFORMATION))
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
|
@ -552,8 +552,8 @@ NtfsQueryInformation(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
* STATUS_INSUFFICIENT_RESOURCES if an allocation failed,
|
* STATUS_INSUFFICIENT_RESOURCES if an allocation failed,
|
||||||
* STATUS_ACCESS_DENIED if target file is a volume or if paging is involved.
|
* STATUS_ACCESS_DENIED if target file is a volume or if paging is involved.
|
||||||
*
|
*
|
||||||
* @remarks As this function sets the size of a file at the file-level
|
* @remarks As this function sets the size of a file at the file-level
|
||||||
* (and not at the attribute level) it's not recommended to use this
|
* (and not at the attribute level) it's not recommended to use this
|
||||||
* function alongside functions that operate on the data attribute directly.
|
* function alongside functions that operate on the data attribute directly.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -709,7 +709,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
|
||||||
*
|
*
|
||||||
* @remarks Called by NtfsDispatch() in response to an IRP_MJ_SET_INFORMATION request.
|
* @remarks Called by NtfsDispatch() in response to an IRP_MJ_SET_INFORMATION request.
|
||||||
* Only the FileEndOfFileInformation InformationClass is fully implemented. FileAllocationInformation
|
* Only the FileEndOfFileInformation InformationClass is fully implemented. FileAllocationInformation
|
||||||
* is a hack and not a true implementation, but it's enough to make SetEndOfFile() work.
|
* is a hack and not a true implementation, but it's enough to make SetEndOfFile() work.
|
||||||
* All other information classes are TODO.
|
* All other information classes are TODO.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -727,7 +727,7 @@ NtfsSetInformation(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
DPRINT1("NtfsSetInformation(%p)\n", IrpContext);
|
DPRINT("NtfsSetInformation(%p)\n", IrpContext);
|
||||||
|
|
||||||
Irp = IrpContext->Irp;
|
Irp = IrpContext->Irp;
|
||||||
Stack = IrpContext->Stack;
|
Stack = IrpContext->Stack;
|
||||||
|
@ -750,9 +750,9 @@ NtfsSetInformation(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
{
|
{
|
||||||
PFILE_END_OF_FILE_INFORMATION EndOfFileInfo;
|
PFILE_END_OF_FILE_INFORMATION EndOfFileInfo;
|
||||||
|
|
||||||
/* TODO: Allocation size is not actually the same as file end for NTFS,
|
/* TODO: Allocation size is not actually the same as file end for NTFS,
|
||||||
however, few applications are likely to make the distinction. */
|
however, few applications are likely to make the distinction. */
|
||||||
case FileAllocationInformation:
|
case FileAllocationInformation:
|
||||||
DPRINT1("FIXME: Using hacky method of setting FileAllocationInformation.\n");
|
DPRINT1("FIXME: Using hacky method of setting FileAllocationInformation.\n");
|
||||||
case FileEndOfFileInformation:
|
case FileEndOfFileInformation:
|
||||||
EndOfFileInfo = (PFILE_END_OF_FILE_INFORMATION)SystemBuffer;
|
EndOfFileInfo = (PFILE_END_OF_FILE_INFORMATION)SystemBuffer;
|
||||||
|
@ -763,7 +763,7 @@ NtfsSetInformation(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
BooleanFlagOn(Stack->Flags, SL_CASE_SENSITIVE),
|
BooleanFlagOn(Stack->Flags, SL_CASE_SENSITIVE),
|
||||||
&EndOfFileInfo->EndOfFile);
|
&EndOfFileInfo->EndOfFile);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// TODO: all other information classes
|
// TODO: all other information classes
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
* PURPOSE: NTFS filesystem driver
|
* PURPOSE: NTFS filesystem driver
|
||||||
* PROGRAMMER: Eric Kohl
|
* PROGRAMMER: Eric Kohl
|
||||||
* Valentin Verkhovsky
|
* Valentin Verkhovsky
|
||||||
* Pierre Schweitzer
|
* Pierre Schweitzer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
@ -50,7 +50,7 @@ NtfsHasFileSystem(PDEVICE_OBJECT DeviceToMount)
|
||||||
PBOOT_SECTOR BootSector;
|
PBOOT_SECTOR BootSector;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT1("NtfsHasFileSystem() called\n");
|
DPRINT("NtfsHasFileSystem() called\n");
|
||||||
|
|
||||||
Size = sizeof(DISK_GEOMETRY);
|
Size = sizeof(DISK_GEOMETRY);
|
||||||
Status = NtfsDeviceIoControl(DeviceToMount,
|
Status = NtfsDeviceIoControl(DeviceToMount,
|
||||||
|
@ -147,7 +147,7 @@ NtfsHasFileSystem(PDEVICE_OBJECT DeviceToMount)
|
||||||
|
|
||||||
/* Check cluster size */
|
/* Check cluster size */
|
||||||
ClusterSize = BootSector->BPB.BytesPerSector * BootSector->BPB.SectorsPerCluster;
|
ClusterSize = BootSector->BPB.BytesPerSector * BootSector->BPB.SectorsPerCluster;
|
||||||
if (ClusterSize != 512 && ClusterSize != 1024 &&
|
if (ClusterSize != 512 && ClusterSize != 1024 &&
|
||||||
ClusterSize != 2048 && ClusterSize != 4096 &&
|
ClusterSize != 2048 && ClusterSize != 4096 &&
|
||||||
ClusterSize != 8192 && ClusterSize != 16384 &&
|
ClusterSize != 8192 && ClusterSize != 16384 &&
|
||||||
ClusterSize != 32768 && ClusterSize != 65536)
|
ClusterSize != 32768 && ClusterSize != 65536)
|
||||||
|
@ -425,7 +425,7 @@ NtfsMountVolume(PDEVICE_OBJECT DeviceObject,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
BOOLEAN Lookaside = FALSE;
|
BOOLEAN Lookaside = FALSE;
|
||||||
|
|
||||||
DPRINT1("NtfsMountVolume() called\n");
|
DPRINT("NtfsMountVolume() called\n");
|
||||||
|
|
||||||
if (DeviceObject != NtfsGlobalData->DeviceObject)
|
if (DeviceObject != NtfsGlobalData->DeviceObject)
|
||||||
{
|
{
|
||||||
|
@ -737,7 +737,7 @@ GetVolumeBitmap(PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONGLONG ToCopy;
|
ULONGLONG ToCopy;
|
||||||
BOOLEAN Overflow = FALSE;
|
BOOLEAN Overflow = FALSE;
|
||||||
|
|
||||||
DPRINT1("GetVolumeBitmap(%p, %p)\n", DeviceExt, Irp);
|
DPRINT("GetVolumeBitmap(%p, %p)\n", DeviceExt, Irp);
|
||||||
|
|
||||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
|
@ -904,7 +904,7 @@ NtfsUserFsRequest(PDEVICE_OBJECT DeviceObject,
|
||||||
PIO_STACK_LOCATION Stack;
|
PIO_STACK_LOCATION Stack;
|
||||||
PDEVICE_EXTENSION DeviceExt;
|
PDEVICE_EXTENSION DeviceExt;
|
||||||
|
|
||||||
DPRINT1("NtfsUserFsRequest(%p, %p)\n", DeviceObject, Irp);
|
DPRINT("NtfsUserFsRequest(%p, %p)\n", DeviceObject, Irp);
|
||||||
|
|
||||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
DeviceExt = DeviceObject->DeviceExtension;
|
DeviceExt = DeviceObject->DeviceExtension;
|
||||||
|
@ -966,7 +966,7 @@ NtfsFileSystemControl(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
|
||||||
DPRINT1("NtfsFileSystemControl() called\n");
|
DPRINT("NtfsFileSystemControl() called\n");
|
||||||
|
|
||||||
DeviceObject = IrpContext->DeviceObject;
|
DeviceObject = IrpContext->DeviceObject;
|
||||||
Irp = IrpContext->Irp;
|
Irp = IrpContext->Irp;
|
||||||
|
|
|
@ -60,7 +60,7 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
|
||||||
PCHAR ReadBuffer = (PCHAR)Buffer;
|
PCHAR ReadBuffer = (PCHAR)Buffer;
|
||||||
ULONGLONG StreamSize;
|
ULONGLONG StreamSize;
|
||||||
|
|
||||||
DPRINT1("NtfsReadFile(%p, %p, %p, %lu, %lu, %lx, %p)\n", DeviceExt, FileObject, Buffer, Length, ReadOffset, IrpFlags, LengthRead);
|
DPRINT("NtfsReadFile(%p, %p, %p, %lu, %lu, %lx, %p)\n", DeviceExt, FileObject, Buffer, Length, ReadOffset, IrpFlags, LengthRead);
|
||||||
|
|
||||||
*LengthRead = 0;
|
*LengthRead = 0;
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ NtfsRead(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
* @implemented
|
* @implemented
|
||||||
*
|
*
|
||||||
* Writes a file to the disk. It presently borrows a lot of code from NtfsReadFile() and
|
* Writes a file to the disk. It presently borrows a lot of code from NtfsReadFile() and
|
||||||
* VFatWriteFileData(). It needs some more work before it will be complete; it won't handle
|
* VFatWriteFileData(). It needs some more work before it will be complete; it won't handle
|
||||||
* page files, asnyc io, cached writes, etc.
|
* page files, asnyc io, cached writes, etc.
|
||||||
*
|
*
|
||||||
* @param DeviceExt
|
* @param DeviceExt
|
||||||
|
|
|
@ -45,7 +45,7 @@ NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt)
|
||||||
ULONG Read = 0;
|
ULONG Read = 0;
|
||||||
RTL_BITMAP Bitmap;
|
RTL_BITMAP Bitmap;
|
||||||
|
|
||||||
DPRINT1("NtfsGetFreeClusters(%p)\n", DeviceExt);
|
DPRINT("NtfsGetFreeClusters(%p)\n", DeviceExt);
|
||||||
|
|
||||||
BitmapRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
|
BitmapRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
|
||||||
if (BitmapRecord == NULL)
|
if (BitmapRecord == NULL)
|
||||||
|
@ -97,15 +97,15 @@ NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt)
|
||||||
return FreeClusters;
|
return FreeClusters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NtfsAllocateClusters
|
* NtfsAllocateClusters
|
||||||
* Allocates a run of clusters. The run allocated might be smaller than DesiredClusters.
|
* Allocates a run of clusters. The run allocated might be smaller than DesiredClusters.
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
|
NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONG FirstDesiredCluster,
|
ULONG FirstDesiredCluster,
|
||||||
ULONG DesiredClusters,
|
ULONG DesiredClusters,
|
||||||
PULONG FirstAssignedCluster,
|
PULONG FirstAssignedCluster,
|
||||||
PULONG AssignedClusters)
|
PULONG AssignedClusters)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -118,7 +118,7 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONG AssignedRun;
|
ULONG AssignedRun;
|
||||||
ULONG LengthWritten;
|
ULONG LengthWritten;
|
||||||
|
|
||||||
DPRINT1("NtfsAllocateClusters(%p, %lu, %lu, %p, %p)\n", DeviceExt, FirstDesiredCluster, DesiredClusters, FirstAssignedCluster, AssignedClusters);
|
DPRINT("NtfsAllocateClusters(%p, %lu, %lu, %p, %p)\n", DeviceExt, FirstDesiredCluster, DesiredClusters, FirstAssignedCluster, AssignedClusters);
|
||||||
|
|
||||||
BitmapRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
|
BitmapRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
|
||||||
if (BitmapRecord == NULL)
|
if (BitmapRecord == NULL)
|
||||||
|
@ -151,9 +151,9 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT1("Total clusters: %I64x\n", DeviceExt->NtfsInfo.ClusterCount);
|
DPRINT("Total clusters: %I64x\n", DeviceExt->NtfsInfo.ClusterCount);
|
||||||
DPRINT1("Total clusters in bitmap: %I64x\n", BitmapDataSize * 8);
|
DPRINT("Total clusters in bitmap: %I64x\n", BitmapDataSize * 8);
|
||||||
DPRINT1("Diff in size: %I64d B\n", ((BitmapDataSize * 8) - DeviceExt->NtfsInfo.ClusterCount) * DeviceExt->NtfsInfo.SectorsPerCluster * DeviceExt->NtfsInfo.BytesPerSector);
|
DPRINT("Diff in size: %I64d B\n", ((BitmapDataSize * 8) - DeviceExt->NtfsInfo.ClusterCount) * DeviceExt->NtfsInfo.SectorsPerCluster * DeviceExt->NtfsInfo.BytesPerSector);
|
||||||
|
|
||||||
ReadAttribute(DeviceExt, DataContext, 0, (PCHAR)BitmapData, (ULONG)BitmapDataSize);
|
ReadAttribute(DeviceExt, DataContext, 0, (PCHAR)BitmapData, (ULONG)BitmapDataSize);
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
|
||||||
ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, BitmapRecord);
|
ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, BitmapRecord);
|
||||||
return STATUS_DISK_FULL;
|
return STATUS_DISK_FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Observe MFT reservation zone
|
// TODO: Observe MFT reservation zone
|
||||||
|
|
||||||
// Can we get one contiguous run?
|
// Can we get one contiguous run?
|
||||||
|
@ -183,17 +183,17 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
|
||||||
{
|
{
|
||||||
// we can't get one contiguous run
|
// we can't get one contiguous run
|
||||||
*AssignedClusters = RtlFindNextForwardRunClear(&Bitmap, FirstDesiredCluster, FirstAssignedCluster);
|
*AssignedClusters = RtlFindNextForwardRunClear(&Bitmap, FirstDesiredCluster, FirstAssignedCluster);
|
||||||
|
|
||||||
if (*AssignedClusters == 0)
|
if (*AssignedClusters == 0)
|
||||||
{
|
{
|
||||||
// we couldn't find any runs starting at DesiredFirstCluster
|
// we couldn't find any runs starting at DesiredFirstCluster
|
||||||
*AssignedClusters = RtlFindLongestRunClear(&Bitmap, FirstAssignedCluster);
|
*AssignedClusters = RtlFindLongestRunClear(&Bitmap, FirstAssignedCluster);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = WriteAttribute(DeviceExt, DataContext, 0, BitmapData, (ULONG)BitmapDataSize, &LengthWritten, BitmapRecord);
|
Status = WriteAttribute(DeviceExt, DataContext, 0, BitmapData, (ULONG)BitmapDataSize, &LengthWritten, BitmapRecord);
|
||||||
|
|
||||||
ReleaseAttributeContext(DataContext);
|
ReleaseAttributeContext(DataContext);
|
||||||
|
|
||||||
ExFreePoolWithTag(BitmapData, TAG_NTFS);
|
ExFreePoolWithTag(BitmapData, TAG_NTFS);
|
||||||
|
|
Loading…
Reference in a new issue