Author: tthompson Date: Fri Aug 4 17:58:06 2017 New Revision: 75479 URL: http://svn.reactos.org/svn/reactos?rev=75479&view=rev Log: [NTFS] - Fix index entries storing the wrong allocated file size when the file is resident. Fix a typo in a DPRINT.
Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/finfo.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/rw.c Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/finfo.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/finfo.c?rev=75479&r1=75478&r2=75479&view=diff ============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/finfo.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/finfo.c [iso-8859-1] Fri Aug 4 17:58:06 2017 @@ -597,7 +597,7 @@ 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 @@ 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, Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c?rev=75479&r1=75478&r2=75479&view=diff ============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c [iso-8859-1] Fri Aug 4 17:58:06 2017 @@ -173,7 +173,7 @@ 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 @@ { 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, Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/rw.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/rw.c?rev=75479&r1=75478&r2=75479&view=diff ============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/rw.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/rw.c [iso-8859-1] Fri Aug 4 17:58:06 2017 @@ -432,11 +432,8 @@ 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); @@ -444,6 +441,8 @@ *LengthWritten = 0; 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