MS free space problem

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

MS free space problem

Post by Art »

Hi Guys,
I have always used this snippet to retrieve Memory Stick space remaining
I don't know how it works:

Code: Select all

void free_ms_memory() {
int memd;

sceIoDevctl("ms0:", 0x02425818, &pbuf, sizeof(pbuf), 0, 0);
for &#40;memd=0; memd<5; memd++&#41;;

freemem = buf&#91;2&#93; * buf&#91;3&#93; * buf&#91;4&#93;;
freememx = freemem;
freemem = freemem/1024;
freemem = freemem/1024;

sprintf&#40;filler, "    MS&#58; %d Mb",freemem&#41;;
printTextScreen&#40;3, 250, filler, Blue&#41;;
sceDisplayWaitVblankStart&#40;&#41;;
flipScreen&#40;&#41;;
&#125;
 
Problem is it doesn't work with Memory Sticks 8Gb and over.
Is there a commonly used replacement used for this purpose?
If not actually, then potentially.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

It works fine, you are just hitting a overflowing the integer arithmetic. You need to convert your 3 values to 64bit integers.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

thankyou :)
If not actually, then potentially.
PsPfReAK
Posts: 61
Joined: Sat Mar 28, 2009 9:02 am
Contact:

Post by PsPfReAK »

Would this work for the flash0 aswell?
m0skit0
Posts: 191
Joined: Tue Jun 02, 2009 8:58 pm

Post by m0skit0 »

Why would use that on flash0? It's fixed size :P
The Incredible Bill Gates wrote:The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
slasher2661996
Posts: 91
Joined: Sun Feb 22, 2009 8:32 am
Location: Melbourne Australia ZOMG

Post by slasher2661996 »

no it's not. You can partition it from DC
m0skit0
Posts: 191
Joined: Tue Jun 02, 2009 8:58 pm

Post by m0skit0 »

Ok, didnt know, sorry.

That code should work on flash partitions too as it uses sceIoDevctl().
The Incredible Bill Gates wrote:The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

I still didn't get the thing to work.
I assume the 64 bit integers are long long.
I got a 16Gb MS now.
If not actually, then potentially.
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post by cory1492 »

I've always assumed the actual io command (0x02425818) would be different for different devices, at least it seems to me it is for flushes at any rate.

Going by types.h a 64 bit is either u64 or s64, though signed 64bit should be long long. Are you sure you retyped all the buf/pbuf etc? Is there any particular reason to have that for loop on memd in there as it braces no code? I'd try my own ideas, but I lack anything over 4G.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Urm, what I meant when I said use 64bit ints is to keep the buf as is (leave as 32bit ints) then when doing the calculation cast each element to a 64bit int.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

TyRaNiD wrote:Urm, what I meant when I said use 64bit ints is to keep the buf as is (leave as 32bit ints) then when doing the calculation cast each element to a 64bit int.
When I divide u64 by a smaller value like (u64)1024 it crashes.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

That is unfortunate ;)
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

TyRaNiD wrote:That is unfortunate ;)
...
Even if I assign the result to a u64.
However if I have something like (u64var1 - u64var2)/small then it works. Presumably since the numerator equates to a 32bit value, like what usually occurs when using the RTC timer values in calculations.
Post Reply