Author: tthompson
Date: Fri Jul 8 11:59:25 2016
New Revision: 71857
URL:
http://svn.reactos.org/svn/reactos?rev=71857&view=rev
Log:
[NTFS]
Simplify GetLastClusterInDataRun() and clean up NtfsAllocateClusters(). No functional
changes.
Modified:
branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c
branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/volinfo.c
Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
==============================================================================
--- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c [iso-8859-1] (original)
+++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c [iso-8859-1] Fri Jul 8
11:59:25 2016
@@ -583,28 +583,16 @@
{
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;
- }
+ if (*DataRun == 0)
+ break;
}
return STATUS_SUCCESS;
Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/volinfo.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
==============================================================================
--- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/volinfo.c [iso-8859-1] (original)
+++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/volinfo.c [iso-8859-1] Fri Jul 8
11:59:25 2016
@@ -162,38 +162,35 @@
RtlInitializeBitMap(&Bitmap, (PULONG)BitmapData,
DeviceExt->NtfsInfo.ClusterCount);
FreeClusters = RtlNumberOfClearBits(&Bitmap);
- if (FreeClusters >= DesiredClusters)
- {
- // TODO: Observe MFT reservation zone
-
- // Can we get one contiguous run?
- ULONG AssignedRun = RtlFindClearBitsAndSet(&Bitmap, DesiredClusters,
FirstDesiredCluster);
- ULONG LengthWritten;
-
- if (AssignedRun != 0xFFFFFFFF)
+ if( FreeClusters < DesiredClusters )
+ Status = STATUS_DISK_FULL;
+
+ // TODO: Observe MFT reservation zone
+
+ // Can we get one contiguous run?
+ ULONG AssignedRun = RtlFindClearBitsAndSet(&Bitmap, DesiredClusters,
FirstDesiredCluster);
+ ULONG LengthWritten;
+
+ if (AssignedRun != 0xFFFFFFFF)
+ {
+ *FirstAssignedCluster = AssignedRun;
+ *AssignedClusters = DesiredClusters;
+ }
+ else
+ {
+ // we can't get one contiguous run
+ *AssignedClusters = RtlFindNextForwardRunClear(&Bitmap, FirstDesiredCluster,
FirstAssignedCluster);
+
+ if (*AssignedClusters == 0)
{
- *FirstAssignedCluster = AssignedRun;
- *AssignedClusters = DesiredClusters;
+ // we couldn't find any runs starting at DesiredFirstCluster
+ *AssignedClusters = RtlFindLongestRunClear(&Bitmap,
FirstAssignedCluster);
}
- else
- {
- // we can't get one contiguous run
- *AssignedClusters = RtlFindNextForwardRunClear(&Bitmap,
FirstDesiredCluster, FirstAssignedCluster);
-
- if (*AssignedClusters == 0)
- {
- // we couldn't find any runs starting at DesiredFirstCluster
- *AssignedClusters = RtlFindLongestRunClear(&Bitmap,
FirstAssignedCluster);
- }
- }
+ }
- Status = WriteAttribute(DeviceExt, DataContext, 0, BitmapData,
(ULONG)BitmapDataSize, &LengthWritten);
- }
- else
- Status = STATUS_DISK_FULL;
-
-
+ Status = WriteAttribute(DeviceExt, DataContext, 0, BitmapData, (ULONG)BitmapDataSize,
&LengthWritten);
+
ReleaseAttributeContext(DataContext);
ExFreePoolWithTag(BitmapData, TAG_NTFS);