https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f2e47474f0cb3cd2d60ee…
commit f2e47474f0cb3cd2d60ee8068a5040b998c82325
Author: Trevor Thompson <tmt256(a)email.vccs.edu>
AuthorDate: Fri Aug 4 17:58:06 2017 +0000
[NTFS] - Fix index entries storing the wrong allocated file size when the file is
resident. Fix a typo in a DPRINT.
svn path=/branches/GSoC_2016/NTFS/; revision=75479
---
drivers/filesystems/ntfs/finfo.c | 4 ++--
drivers/filesystems/ntfs/mft.c | 4 ++--
drivers/filesystems/ntfs/rw.c | 5 ++---
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/filesystems/ntfs/finfo.c b/drivers/filesystems/ntfs/finfo.c
index aee8aa51e2..37debba2ca 100644
--- a/drivers/filesystems/ntfs/finfo.c
+++ b/drivers/filesystems/ntfs/finfo.c
@@ -597,7 +597,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
DPRINT("Found record for %wS\n", Fcb->ObjectName);
- CurrentFileSize.QuadPart = NtfsGetFileSize(DeviceExt, FileRecord, L"", 0,
(PULONGLONG)&CurrentFileSize);
+ CurrentFileSize.QuadPart = NtfsGetFileSize(DeviceExt, FileRecord, L"", 0,
NULL);
// Are we trying to decrease the file size?
if (NewFileSize->QuadPart < CurrentFileSize.QuadPart)
@@ -673,7 +673,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
FileName.Length = FileNameAttribute->NameLength * sizeof(WCHAR);
FileName.MaximumLength = FileName.Length;
- AllocationSize = ROUND_UP(NewFileSize->QuadPart,
Fcb->Vcb->NtfsInfo.BytesPerCluster);
+ AllocationSize = AttributeAllocatedLength(&DataContext->Record);
Status = UpdateFileNameRecord(Fcb->Vcb,
ParentMFTId,
diff --git a/drivers/filesystems/ntfs/mft.c b/drivers/filesystems/ntfs/mft.c
index 1df31aee0c..83c966972a 100644
--- a/drivers/filesystems/ntfs/mft.c
+++ b/drivers/filesystems/ntfs/mft.c
@@ -173,7 +173,7 @@ AttributeAllocatedLength(PNTFS_ATTR_RECORD AttrRecord)
if (AttrRecord->IsNonResident)
return AttrRecord->NonResident.AllocatedSize;
else
- return AttrRecord->Resident.ValueLength;
+ return ALIGN_UP_BY(AttrRecord->Resident.ValueLength, ATTR_RECORD_ALIGNMENT);
}
@@ -399,7 +399,7 @@ SetAttributeDataLength(PFILE_OBJECT FileObject,
{
NTSTATUS Status = STATUS_SUCCESS;
- DPRINT1("SetAttributeDataLenth(%p, %p, %p, %lu, %p, %I64u)\n",
+ DPRINT1("SetAttributeDataLength(%p, %p, %p, %lu, %p, %I64u)\n",
FileObject,
Fcb,
AttrContext,
diff --git a/drivers/filesystems/ntfs/rw.c b/drivers/filesystems/ntfs/rw.c
index 7ef808f8c2..cb4646495f 100644
--- a/drivers/filesystems/ntfs/rw.c
+++ b/drivers/filesystems/ntfs/rw.c
@@ -432,11 +432,8 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
DataSize.QuadPart = WriteOffset + Length;
- AllocationSize = ROUND_UP(DataSize.QuadPart,
Fcb->Vcb->NtfsInfo.BytesPerCluster);
-
// set the attribute data length
Status = SetAttributeDataLength(FileObject, Fcb, DataContext,
AttributeOffset, FileRecord, &DataSize);
-
if (!NT_SUCCESS(Status))
{
ReleaseAttributeContext(DataContext);
@@ -445,6 +442,8 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
return Status;
}
+ AllocationSize = AttributeAllocatedLength(&DataContext->Record);
+
// now we need to update this file's size in every directory index entry
that references it
// TODO: put this code in its own function and adapt it to work with every
filename / hardlink
// stored in the file record.