Simplify GetLastClusterInDataRun() and clean up NtfsAllocateClusters(). No functional changes.

svn path=/branches/GSoC_2016/NTFS/; revision=71857
This commit is contained in:
Trevor Thompson 2016-07-08 11:59:25 +00:00 committed by Thomas Faber
parent c08d37d182
commit 7a6e9bcdf6
2 changed files with 29 additions and 44 deletions

View file

@ -583,29 +583,17 @@ GetLastClusterInDataRun(PDEVICE_EXTENSION Vcb, PNTFS_ATTR_RECORD Attribute, PULO
{
DataRun = DecodeRun(DataRun, &DataRunOffset, &DataRunLength);
if (DataRunOffset == -1)
{
// sparse run
if (*DataRun == 0)
{
// if it's the last run, return the last cluster of the last run
*LastCluster = LastLCN + DataRunLength - 1;
break;
}
}
else
if (DataRunOffset != -1)
{
// Normal data run.
DataRunStartLCN = LastLCN + DataRunOffset;
LastLCN = DataRunStartLCN;
*LastCluster = LastLCN + DataRunLength - 1;
}
if (*DataRun == 0)
{
*LastCluster = LastLCN + DataRunLength - 1;
break;
}
}
return STATUS_SUCCESS;
}

View file

@ -162,8 +162,9 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
RtlInitializeBitMap(&Bitmap, (PULONG)BitmapData, DeviceExt->NtfsInfo.ClusterCount);
FreeClusters = RtlNumberOfClearBits(&Bitmap);
if (FreeClusters >= DesiredClusters)
{
if( FreeClusters < DesiredClusters )
Status = STATUS_DISK_FULL;
// TODO: Observe MFT reservation zone
// Can we get one contiguous run?
@ -189,10 +190,6 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
}
Status = WriteAttribute(DeviceExt, DataContext, 0, BitmapData, (ULONG)BitmapDataSize, &LengthWritten);
}
else
Status = STATUS_DISK_FULL;
ReleaseAttributeContext(DataContext);