hdd partition size

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

hdd partition size

Post by radad »

When using dread on hdd:/ I get partition sizes that are a factor of 1024 too small.

In fioGetStatFiller of hdd_fio.c the size is returned like this:

Code: Select all

stat->size=clink->header->length;
Here size should be in bytes but what is length measured in? length is part of the apa_header structure.

To fix this I will change it to:

Code: Select all

stat->size=clink->header->length * 1024;
Do people agree with this?
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

Wouldn't that break proper support for partitions larger than 4GB?
GE Dominator
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

That change would. I have made a slightly more complicated change using the hisize variable as well. Using hisize in combination with size you get a 64 bit integer, big enough for much larger than 4GB.
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

personally i don't see that support for >4gb partition i just get wrong size and then problem with the free space (4gb = 4gb 5gb = 1gb 10gb = 2gb and so on) at lest with ps2pfs
EP
Posts: 39
Joined: Sat Nov 05, 2005 1:14 pm

Post by EP »

Radad, here are some issues I came across with your latest change to hdd_fio.c.

1. It won't compile with the older iop-2.8.1 compiler.
2. It still messes up size. Here is my list of partitions and the size of the partitions in bytes:

Code: Select all

Name     size before    size now         partition size
__boot   1048576        1073741824        512MB (536870912)
+MAIN    1048576        1073741824        512MB (536870912)
+MP3     1048576        1073741824        512MB (536870912)
+NEW1    1048576        1073741824        512MB (536870912)
+NEW2    8388608                 0       4096MB (4294967296)
+NEW3    2097152        2147483648       1024MB (1073741824)
+NEW4     262144         268435456        128MB (134217728)
PGEN 1.1  262144         268435456        128MB (134217728)
PS2OS	  262144         268435456        128MB (134217728)
As you can see stat.size still isn't quite right yet. The maximum working partition size is 4096MB and it now shows up as 0.

Anyway I changed this from:

Code: Select all

	apa_header *header;

	stat->mode=clink->header->type;
	stat->attr=clink->header->flags;
	stat->hisize=0;
	u64 size = clink->header->length;
	size *= 1024;
	stat->size=size & 0xFFFFFFFF;
	size >>= 32;
	stat->hisize=size & 0xFFFFFFFF;
	header=clink->header;
To this: (Note: this is compatible with the older iop compiler just declare size variable at the beginning).

Code: Select all

	apa_header *header;
	u64 size;

	stat->mode=clink->header->type;
	stat->attr=clink->header->flags;
	stat->hisize=0;
	size = clink->header->length;
	size *= 512;
	stat->size=size & 0xFFFFFFFF;
	size >>= 32;
	stat->hisize=size & 0xFFFFFFFF;
	header=clink->header;
My noted changes above results in:

Code: Select all

Name	  size           partition size
__boot    536870912      512MB (536870912)
+MAIN     536870912      512MB (536870912)
+MP3      536870912      512MB (536870912)
+NEW1	  536870912      512MB (536870912)
+NEW2             0     4096MB (4294967296)
+NEW3    1073741824     1024MB (1073741824)
+NEW4     134217728      128MB (134217728)
PGEN 1.1  134217728      128MB (134217728)
PS2OS     134217728      128MB (134217728)
OK, so hisize is what you use to get the other part of the size. So for example in another program:

Code: Select all

if( hisize > 0 )
  totalSize = 4294967295 + hisize;
else
  totalSize = size;
If that's right, then I understand how it works now. Radad, I'll let you decide on my two slight changes. Thanks.
Last edited by EP on Sun Dec 11, 2005 5:19 pm, edited 1 time in total.
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

EP wrote:OK, so hisize is what you use to get the other part of the size. So for example in another program:

Code: Select all

if( hisize > 0 )
  totalSize = 4294967295 + hisize;
else
  totalSize = size;
If that's right, then I understand how it works now. Radad, I'll let you decide on my two slight changes. Thanks.
No its more like:

Code: Select all

totalSize = hisize << 32 + size;
As for the change from 1024 to 512, I will have to look into it again as 1024 works for me.
EP
Posts: 39
Joined: Sat Nov 05, 2005 1:14 pm

Post by EP »

radad wrote:No its more like:

Code: Select all

totalSize = hisize << 32 + size;
Yeah OK, bit shift operator making use of both size and highsize. I just wonder how to convert u64 integers to string. I saw somewhere that printf can't handle 64-bit integers. I tried it and that's most likely why I only get zero for my +NEW2 partition. It only converts the first 32 bits and thats all.

ex.

Code: Select all

u64 max = 0xFFFFFFFFFFFFFFFF; // as big as it gets
char buffer&#91;21&#93;;
sprintf&#40;buffer, "%Lu", max&#41;;
printf&#40;"Max size is %s\n", buffer&#41;;
It results in "Max Size is 4294967295". It should be "18446744073709551615" so it only evaluates max as being 0xFFFFFFFF. Maybe it's easier than I'm making it out to be since I'm not really accustomed to C programming.

edit:
tried u64 values with an itoa function and get:
undefined reference to `__umoddi3'
undefined reference to `__udivdi3'

Can't divide or use modulo with a 64-bit integer. So is there any other way to simply take the two u32 values(hi and low side) and put them together into a string representation in base 10 format? All I need is the actual total size listed in a string format of base 10. Thanks
radad wrote:As for the change from 1024 to 512, I will have to look into it again as 1024 works for me.
Multiplying by 512 instead of 1024 looks right and appears to be more mathematically sound.
ex. using 1024
128 Megabytes != 268435456 Bytes, but 256 Megabytes ~= 268435456 Bytes

ex. using 512
128 Megabytes ~= 134217728 Bytes
EP
Posts: 39
Joined: Sat Nov 05, 2005 1:14 pm

Post by EP »

OK, I got what I wanted working so no further assistance is needed. I did use my two noted changes to hdd_fio.c. Here are the final results:

Code: Select all

dr--------   1 ps2      ps2     536870912 Feb  8  2005 __boot
dr--------   1 ps2      ps2     536870912 Feb  8  2005 +MAIN
dr--------   1 ps2      ps2     536870912 Feb  8  2005 +MP3
dr--------   1 ps2      ps2     536870912 Feb  8  2005 +NEW1
dr--------   1 ps2      ps2    4294967296 Feb  8  2005 +NEW2
dr--------   1 ps2      ps2    1073741824 Feb  8  2005 +NEW3
dr--------   1 ps2      ps2     134217728 Feb  8  2005 +NEW4
dr--------   1 ps2      ps2     134217728 Oct  9  2011 PGEN 1.1
dr--------   1 ps2      ps2     134217728 Feb  8  2005 PS2OS
Post Reply