mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[NTFS] - Add some minor fixes and improvements:
Improve, add, or fix some DPRINTs. In particular, ULONG's should use %lu, not %u. Also, don't be silent about filesystem corruption. NtfsFindMftRecord() - move CaseSensitive parameter before output parameter in parameter list. svn path=/branches/GSoC_2016/NTFS/; revision=75199
This commit is contained in:
parent
e4aab26781
commit
38c947b7ab
5 changed files with 50 additions and 22 deletions
|
@ -188,8 +188,8 @@ AddFileName(PFILE_RECORD_HEADER FileRecord,
|
||||||
&Current,
|
&Current,
|
||||||
&FirstEntry,
|
&FirstEntry,
|
||||||
FALSE,
|
FALSE,
|
||||||
&CurrentMFTIndex,
|
CaseSensitive,
|
||||||
CaseSensitive);
|
&CurrentMFTIndex);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1173,7 +1173,7 @@ NtfsDumpIndexRootAttribute(PNTFS_ATTR_RECORD Attribute)
|
||||||
while (currentOffset < IndexRootAttr->Header.TotalSizeOfEntries)
|
while (currentOffset < IndexRootAttr->Header.TotalSizeOfEntries)
|
||||||
{
|
{
|
||||||
PINDEX_ENTRY_ATTRIBUTE currentIndexExtry = (PINDEX_ENTRY_ATTRIBUTE)((ULONG_PTR)IndexRootAttr + 0x10 + currentOffset);
|
PINDEX_ENTRY_ATTRIBUTE currentIndexExtry = (PINDEX_ENTRY_ATTRIBUTE)((ULONG_PTR)IndexRootAttr + 0x10 + currentOffset);
|
||||||
DbgPrint(" Index Node Entry %u", currentNode++);
|
DbgPrint(" Index Node Entry %lu", currentNode++);
|
||||||
if (currentIndexExtry->Flags & NTFS_INDEX_ENTRY_NODE)
|
if (currentIndexExtry->Flags & NTFS_INDEX_ENTRY_NODE)
|
||||||
DbgPrint(" (Branch)");
|
DbgPrint(" (Branch)");
|
||||||
else
|
else
|
||||||
|
|
|
@ -52,7 +52,7 @@ NtfsReadDisk(IN PDEVICE_OBJECT DeviceObject,
|
||||||
BOOLEAN AllocatedBuffer = FALSE;
|
BOOLEAN AllocatedBuffer = FALSE;
|
||||||
PUCHAR ReadBuffer = Buffer;
|
PUCHAR ReadBuffer = Buffer;
|
||||||
|
|
||||||
DPRINT("NtfsReadDisk(%p, %I64x, %u, %u, %p, %d)\n", DeviceObject, StartingOffset, Length, SectorSize, Buffer, Override);
|
DPRINT("NtfsReadDisk(%p, %I64x, %lu, %lu, %p, %d)\n", DeviceObject, StartingOffset, Length, SectorSize, Buffer, Override);
|
||||||
|
|
||||||
KeInitializeEvent(&Event,
|
KeInitializeEvent(&Event,
|
||||||
NotificationEvent,
|
NotificationEvent,
|
||||||
|
@ -176,7 +176,7 @@ NtfsWriteDisk(IN PDEVICE_OBJECT DeviceObject,
|
||||||
BOOLEAN AllocatedBuffer = FALSE;
|
BOOLEAN AllocatedBuffer = FALSE;
|
||||||
PUCHAR TempBuffer = NULL;
|
PUCHAR TempBuffer = NULL;
|
||||||
|
|
||||||
DPRINT("NtfsWriteDisk(%p, %I64x, %u, %u, %p)\n", DeviceObject, StartingOffset, Length, SectorSize, Buffer);
|
DPRINT("NtfsWriteDisk(%p, %I64x, %lu, %lu, %p)\n", DeviceObject, StartingOffset, Length, SectorSize, Buffer);
|
||||||
|
|
||||||
if (Length == 0)
|
if (Length == 0)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
|
@ -119,7 +119,7 @@ FindAttribute(PDEVICE_EXTENSION Vcb,
|
||||||
FIND_ATTR_CONTXT Context;
|
FIND_ATTR_CONTXT Context;
|
||||||
PNTFS_ATTR_RECORD Attribute;
|
PNTFS_ATTR_RECORD Attribute;
|
||||||
|
|
||||||
DPRINT("FindAttribute(%p, %p, 0x%x, %S, %u, %p)\n", Vcb, MftRecord, Type, Name, NameLength, AttrCtx);
|
DPRINT("FindAttribute(%p, %p, 0x%x, %S, %lu, %p, %p)\n", Vcb, MftRecord, Type, Name, NameLength, AttrCtx, Offset);
|
||||||
|
|
||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
Status = FindFirstAttribute(&Context, Vcb, MftRecord, FALSE, &Attribute);
|
Status = FindFirstAttribute(&Context, Vcb, MftRecord, FALSE, &Attribute);
|
||||||
|
@ -396,6 +396,14 @@ SetAttributeDataLength(PFILE_OBJECT FileObject,
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
DPRINT1("SetAttributeDataLenth(%p, %p, %p, %lu, %p, %I64u)\n",
|
||||||
|
FileObject,
|
||||||
|
Fcb,
|
||||||
|
AttrContext,
|
||||||
|
AttrOffset,
|
||||||
|
FileRecord,
|
||||||
|
DataSize->QuadPart);
|
||||||
|
|
||||||
// are we truncating the file?
|
// are we truncating the file?
|
||||||
if (DataSize->QuadPart < AttributeDataLength(&AttrContext->Record))
|
if (DataSize->QuadPart < AttributeDataLength(&AttrContext->Record))
|
||||||
{
|
{
|
||||||
|
@ -1336,7 +1344,7 @@ ReadFileRecord(PDEVICE_EXTENSION Vcb,
|
||||||
BytesRead = ReadAttribute(Vcb, Vcb->MFTContext, index * Vcb->NtfsInfo.BytesPerFileRecord, (PCHAR)file, Vcb->NtfsInfo.BytesPerFileRecord);
|
BytesRead = ReadAttribute(Vcb, Vcb->MFTContext, index * Vcb->NtfsInfo.BytesPerFileRecord, (PCHAR)file, Vcb->NtfsInfo.BytesPerFileRecord);
|
||||||
if (BytesRead != Vcb->NtfsInfo.BytesPerFileRecord)
|
if (BytesRead != Vcb->NtfsInfo.BytesPerFileRecord)
|
||||||
{
|
{
|
||||||
DPRINT1("ReadFileRecord failed: %I64u read, %u expected\n", BytesRead, Vcb->NtfsInfo.BytesPerFileRecord);
|
DPRINT1("ReadFileRecord failed: %I64u read, %lu expected\n", BytesRead, Vcb->NtfsInfo.BytesPerFileRecord);
|
||||||
return STATUS_PARTIAL_COPY;
|
return STATUS_PARTIAL_COPY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1370,11 +1378,11 @@ UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG CurrentEntry = 0;
|
ULONG CurrentEntry = 0;
|
||||||
|
|
||||||
DPRINT("UpdateFileNameRecord(%p, %I64d, %wZ, %u, %I64u, %I64u, %s)\n",
|
DPRINT("UpdateFileNameRecord(%p, %I64d, %wZ, %s, %I64u, %I64u, %s)\n",
|
||||||
Vcb,
|
Vcb,
|
||||||
ParentMFTIndex,
|
ParentMFTIndex,
|
||||||
FileName,
|
FileName,
|
||||||
DirSearch,
|
DirSearch ? "TRUE" : "FALSE",
|
||||||
NewDataSize,
|
NewDataSize,
|
||||||
NewAllocationSize,
|
NewAllocationSize,
|
||||||
CaseSensitive ? "TRUE" : "FALSE");
|
CaseSensitive ? "TRUE" : "FALSE");
|
||||||
|
@ -1466,7 +1474,20 @@ UpdateIndexEntryFileNameSize(PDEVICE_EXTENSION Vcb,
|
||||||
ULONGLONG IndexAllocationSize;
|
ULONGLONG IndexAllocationSize;
|
||||||
PINDEX_BUFFER IndexBuffer;
|
PINDEX_BUFFER IndexBuffer;
|
||||||
|
|
||||||
DPRINT("UpdateIndexEntrySize(%p, %p, %p, %u, %p, %p, %wZ, %u, %u, %u, %I64u, %I64u)\n", Vcb, MftRecord, IndexRecord, IndexBlockSize, FirstEntry, LastEntry, FileName, *StartEntry, *CurrentEntry, DirSearch, NewDataSize, NewAllocatedSize);
|
DPRINT("UpdateIndexEntrySize(%p, %p, %p, %lu, %p, %p, %wZ, %lu, %lu, %s, %I64u, %I64u, %s)\n",
|
||||||
|
Vcb,
|
||||||
|
MftRecord,
|
||||||
|
IndexRecord,
|
||||||
|
IndexBlockSize,
|
||||||
|
FirstEntry,
|
||||||
|
LastEntry,
|
||||||
|
FileName,
|
||||||
|
*StartEntry,
|
||||||
|
*CurrentEntry,
|
||||||
|
DirSearch ? "TRUE" : "FALSE",
|
||||||
|
NewDataSize,
|
||||||
|
NewAllocatedSize,
|
||||||
|
CaseSensitive ? "TRUE" : "FALSE");
|
||||||
|
|
||||||
// find the index entry responsible for the file we're trying to update
|
// find the index entry responsible for the file we're trying to update
|
||||||
IndexEntry = FirstEntry;
|
IndexEntry = FirstEntry;
|
||||||
|
@ -1933,7 +1954,7 @@ BrowseIndexEntries(PDEVICE_EXTENSION Vcb,
|
||||||
ULONGLONG IndexAllocationSize;
|
ULONGLONG IndexAllocationSize;
|
||||||
PINDEX_BUFFER IndexBuffer;
|
PINDEX_BUFFER IndexBuffer;
|
||||||
|
|
||||||
DPRINT("BrowseIndexEntries(%p, %p, %p, %u, %p, %p, %wZ, %u, %u, %s, %s, %p)\n",
|
DPRINT("BrowseIndexEntries(%p, %p, %p, %lu, %p, %p, %wZ, %lu, %lu, %s, %s, %p)\n",
|
||||||
Vcb,
|
Vcb,
|
||||||
MftRecord,
|
MftRecord,
|
||||||
IndexRecord,
|
IndexRecord,
|
||||||
|
@ -1981,7 +2002,7 @@ BrowseIndexEntries(PDEVICE_EXTENSION Vcb,
|
||||||
Status = FindAttribute(Vcb, MftRecord, AttributeIndexAllocation, L"$I30", 4, &IndexAllocationCtx, NULL);
|
Status = FindAttribute(Vcb, MftRecord, AttributeIndexAllocation, L"$I30", 4, &IndexAllocationCtx, NULL);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Corrupted filesystem!\n");
|
DPRINT1("Corrupted filesystem!\n");
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2031,8 +2052,8 @@ NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
|
||||||
PUNICODE_STRING FileName,
|
PUNICODE_STRING FileName,
|
||||||
PULONG FirstEntry,
|
PULONG FirstEntry,
|
||||||
BOOLEAN DirSearch,
|
BOOLEAN DirSearch,
|
||||||
ULONGLONG *OutMFTIndex,
|
BOOLEAN CaseSensitive,
|
||||||
BOOLEAN CaseSensitive)
|
ULONGLONG *OutMFTIndex)
|
||||||
{
|
{
|
||||||
PFILE_RECORD_HEADER MftRecord;
|
PFILE_RECORD_HEADER MftRecord;
|
||||||
PNTFS_ATTR_CONTEXT IndexRootCtx;
|
PNTFS_ATTR_CONTEXT IndexRootCtx;
|
||||||
|
@ -2042,7 +2063,14 @@ NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG CurrentEntry = 0;
|
ULONG CurrentEntry = 0;
|
||||||
|
|
||||||
DPRINT("NtfsFindMftRecord(%p, %I64d, %wZ, %u, %u, %p)\n", Vcb, MFTIndex, FileName, *FirstEntry, DirSearch, OutMFTIndex);
|
DPRINT("NtfsFindMftRecord(%p, %I64d, %wZ, %lu, %s, %s, %p)\n",
|
||||||
|
Vcb,
|
||||||
|
MFTIndex,
|
||||||
|
FileName,
|
||||||
|
*FirstEntry,
|
||||||
|
DirSearch ? "TRUE" : "FALSE",
|
||||||
|
CaseSensitive ? "TRUE" : "FALSE",
|
||||||
|
OutMFTIndex);
|
||||||
|
|
||||||
MftRecord = ExAllocatePoolWithTag(NonPagedPool,
|
MftRecord = ExAllocatePoolWithTag(NonPagedPool,
|
||||||
Vcb->NtfsInfo.BytesPerFileRecord,
|
Vcb->NtfsInfo.BytesPerFileRecord,
|
||||||
|
@ -2129,7 +2157,7 @@ NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
|
||||||
{
|
{
|
||||||
DPRINT("Current: %wZ\n", &Current);
|
DPRINT("Current: %wZ\n", &Current);
|
||||||
|
|
||||||
Status = NtfsFindMftRecord(Vcb, CurrentMFTIndex, &Current, &FirstEntry, FALSE, &CurrentMFTIndex, CaseSensitive);
|
Status = NtfsFindMftRecord(Vcb, CurrentMFTIndex, &Current, &FirstEntry, FALSE, CaseSensitive, &CurrentMFTIndex);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -2222,7 +2250,7 @@ NtfsFindFileAt(PDEVICE_EXTENSION Vcb,
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("NtfsFindFileAt(%p, %wZ, %u, %p, %p, %I64x, %s)\n",
|
DPRINT("NtfsFindFileAt(%p, %wZ, %lu, %p, %p, %I64x, %s)\n",
|
||||||
Vcb,
|
Vcb,
|
||||||
SearchPattern,
|
SearchPattern,
|
||||||
*FirstEntry,
|
*FirstEntry,
|
||||||
|
@ -2231,7 +2259,7 @@ NtfsFindFileAt(PDEVICE_EXTENSION Vcb,
|
||||||
CurrentMFTIndex,
|
CurrentMFTIndex,
|
||||||
(CaseSensitive ? "TRUE" : "FALSE"));
|
(CaseSensitive ? "TRUE" : "FALSE"));
|
||||||
|
|
||||||
Status = NtfsFindMftRecord(Vcb, CurrentMFTIndex, SearchPattern, FirstEntry, TRUE, &CurrentMFTIndex, CaseSensitive);
|
Status = NtfsFindMftRecord(Vcb, CurrentMFTIndex, SearchPattern, FirstEntry, TRUE, CaseSensitive, &CurrentMFTIndex);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("NtfsFindFileAt: NtfsFindMftRecord() failed with status 0x%08lx\n", Status);
|
DPRINT("NtfsFindFileAt: NtfsFindMftRecord() failed with status 0x%08lx\n", Status);
|
||||||
|
|
|
@ -1003,8 +1003,8 @@ NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
|
||||||
PUNICODE_STRING FileName,
|
PUNICODE_STRING FileName,
|
||||||
PULONG FirstEntry,
|
PULONG FirstEntry,
|
||||||
BOOLEAN DirSearch,
|
BOOLEAN DirSearch,
|
||||||
ULONGLONG *OutMFTIndex,
|
BOOLEAN CaseSensitive,
|
||||||
BOOLEAN CaseSensitive);
|
ULONGLONG *OutMFTIndex);
|
||||||
|
|
||||||
/* misc.c */
|
/* misc.c */
|
||||||
|
|
||||||
|
|
|
@ -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, %u, %u, %x, %p)\n", DeviceExt, FileObject, Buffer, Length, ReadOffset, IrpFlags, LengthRead);
|
DPRINT1("NtfsReadFile(%p, %p, %p, %lu, %lu, %lx, %p)\n", DeviceExt, FileObject, Buffer, Length, ReadOffset, IrpFlags, LengthRead);
|
||||||
|
|
||||||
*LengthRead = 0;
|
*LengthRead = 0;
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONG AttributeOffset;
|
ULONG AttributeOffset;
|
||||||
ULONGLONG StreamSize;
|
ULONGLONG StreamSize;
|
||||||
|
|
||||||
DPRINT("NtfsWriteFile(%p, %p, %p, %u, %u, %x, %s, %p)\n",
|
DPRINT("NtfsWriteFile(%p, %p, %p, %lu, %lu, %x, %s, %p)\n",
|
||||||
DeviceExt,
|
DeviceExt,
|
||||||
FileObject,
|
FileObject,
|
||||||
Buffer,
|
Buffer,
|
||||||
|
|
Loading…
Reference in a new issue