XBPartitioner version 1.1 is not coded to correctly handle clusters. I just tried this with a 1.5TB drive installed (using a SATA-IDE adapter) and all it would do is 64k clusters, which means something is wrong with the code and we need a new release. I think everyone assumed it would work but no one could test it since they didn't have a drive larger than 1 TB to test it with. Here is the problem code:
QUOTE
void SelectClusterSize()
{
g_iClusterSize = 16;
ULONG compare = 0x20000000;
while (PartTbl.TableEntries[g_iCurrentPart].LBASize > compare)
{
compare = compare * 2;
g_iClusterSize = g_iClusterSize * 2;
}
}
{
g_iClusterSize = 16;
ULONG compare = 0x20000000;
while (PartTbl.TableEntries[g_iCurrentPart].LBASize > compare)
{
compare = compare * 2;
g_iClusterSize = g_iClusterSize * 2;
}
}
With this code, the program will format partitions incorrectly like so:
0GB - 512GB ====> 16k clusters
512GB - 1TB ====> 32k clusters
1TB - 2TB ====> 64k clusters
2TB - 4TB ====> 128k clusters
...and so on
Instead we would like partitions formatted like so:
0GB - 256GB ====> 16k clusters
256GB - 512GB ====> 32k clusters
512GB - 1TB ====> 64k clusters
1TB - 2TB ====> 128k clusters
...and so on
The fix is quite simple. Here is the code once again, but this time with the fix. I have bolded the fix for clarity:
QUOTE
void SelectClusterSize()
{
g_iClusterSize = 16;
ULONG compare = 0x10000000;
while (PartTbl.TableEntries[g_iCurrentPart].LBASize > compare)
{
compare = compare * 2;
g_iClusterSize = g_iClusterSize * 2;
}
}
{
g_iClusterSize = 16;
ULONG compare = 0x10000000;
while (PartTbl.TableEntries[g_iCurrentPart].LBASize > compare)
{
compare = compare * 2;
g_iClusterSize = g_iClusterSize * 2;
}
}
Notice that "compare" is a hexadecimal number that represents the kilobyte upper limit on each cluster size. If we examine the problem code, we see that "compare" is initially set to 0x20000000. Convert this to decimal and we get 536870912 kilobytes, or 512 gigabytes. So the code is saying that as long as partition is less than or equal to 512 gigabytes, set the cluster size to "g_iClusterSize", which is initially set to 16. This is wrong.
Now, if we change the initialization of compare to 0x10000000 (268435456 kilobytes, or 256 gigabytes), everything works out as it should. Does this make sense to anyone, or am I missing something?
I would love to compile this new code myself to test but I don't have the XDK, and without compiling and debugging it, I can't be 100% certain...
Can someone please recompile this so we can get some bigger drives working in the XBox? Thanks!!
