Tom's Hardware > Forum > Windows 2000/NT > Windows 2000/NT General Discussion > Used cluster number of a hard disk partition come continuously...Is

Used cluster number of a hard disk partition come continuously...Is

Forum Windows 2000/NT : Windows 2000/NT General Discussion - Used cluster number of a hard disk partition come continuously...Is

Tom's Hardware: Over 1.4 million members in 6 different countries available to answer all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

hiii

I'm trying to copy the used clusters of a hard disk partition(NTFS,windows os) to another partition.

I used the "FSCTL_GET_VOLUME_BITMAP" to get the cluster usage details.And I'm getting the used and free cluster counts correctly.And the cluster number I got is continuous.This makes problem for me. I wanna copy the used clusters to a different partition.

What type of cluster number I'm getting.? ; but the answer is correct.It makes confusion to me.the clusters may not be continuous so what the following program segment gives..??



BOOL IsClusterUsed (UINT64 Cluster)
{
return ((BitmapDetail[Cluster / 32] & (1 << (Cluster % 32))) ? TRUE : FALSE);
}


STARTING_LCN_INPUT_BUFFER StartingLCN;
VOLUME_BITMAP_BUFFER *Bitmap = NULL;
UINT32 BitmapSize;
DWORD BytesReturned1;
BOOL Result;
ULONGLONG ClusterCount = 0;

StartingLCN.StartingLcn.QuadPart = 0;
BitmapSize = sizeof (VOLUME_BITMAP_BUFFER) + 4;
Bitmap = (VOLUME_BITMAP_BUFFER *) malloc (BitmapSize);

Result = DeviceIoControl(
h_MyDevice_src2,
FSCTL_GET_VOLUME_BITMAP,
&StartingLCN,
sizeof (StartingLCN),
Bitmap,
BitmapSize,
&BytesReturned1,
NULL);

if (Result == FALSE &&GetLastError()!= ERROR_MORE_DATA)
{
free (Bitmap);
cout<<"\n bitmap error occured";
goto label12;
}

ClusterCount = Bitmap->BitmapSize.QuadPart -
Bitmap->StartingLcn.QuadPart;//TOT noof clusters
cout<<"\n Tot no of clusters :"<<ClusterCount<<"\n";

BitmapSize = sizeof (VOLUME_BITMAP_BUFFER) + (Bitmap->BitmapSize.QuadPart / 8) + 1;
Bitmap = (VOLUME_BITMAP_BUFFER *) realloc (Bitmap, BitmapSize);

Result = DeviceIoControl(
h_MyDevice_src2,
FSCTL_GET_VOLUME_BITMAP,
&StartingLCN,
sizeof (StartingLCN),
Bitmap,
BitmapSize,
&BytesReturned,
NULL);

DWORD LastError = GetLastError ();
if (Result == FALSE)
{
printf ("\nCouldn't properly read volume bitmap\n" );
free (Bitmap);
goto label12;
}
BitmapDetail = (UINT32 *) malloc (sizeof(UINT32) * (1 + (ClusterCount / 32)));
memcpy (BitmapDetail, Bitmap->Buffer, sizeof(UINT32) * (1 + (ClusterCount / 32)));


UINT64 Max;
UINT64 cc;
Max=ClusterCount;
UINT64 usedcluster=0;


for (cc = 0; cc < Max; cc++)
{

if ( IsClusterUsed (cc)) // return 1 from buffer
{
// cluster used

usedcluster=usedcluster+1;

}
}


cout<<"\n Used no of clusters :"<<usedcluster<<"\n";

============================================================
============================================================
Getting the total cluster counts correctly
Getting the used cluster counts correctly
while printing the used cluster number it shows continuous numbers....?? why...?

I know.... Logical and virtual cluster numbers are there...Other than these original cluster number will be there....????

Sometimes my question may be totally wrong.....

with regards
Krish

Sponsored Links
Register or log in to remove.
Tom's Hardware > Forum > Windows 2000/NT > Windows 2000/NT General Discussion > Used cluster number of a hard disk partition come continuously...Is
Go to:

There are 1096 identified and unidentified users. To see the list of identified users, Click here.

Sponsored links
  • Ask the community now
  • Publish
Ad
They won a badge
Join us in greeting them