 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Sat Nov 11, 2006 8:28 am Post subject: Free Space on Flash0? |
|
|
Hi Guys,
Is there a fix to this routine, or possibly another, that will give the amount
of available space on flash0, or flash1 for that matter?
I tried the obvious replacing the "ms0:" string, and I don't know what the
hex argument in the command is for, or what to try replacing it with.
| Code: |
int i;
unsigned int buf[5];
unsigned int *pbuf = buf;
sceIoDevctl("ms0:", 0x02425818, &pbuf, sizeof(pbuf), 0, 0);
for (i=0; i<5; i++);
pspDebugScreenPrintf("Free : %d bytes\n", buf[2] * buf[3] * buf[4]);
|
Any help appreciated.
Cheers, Art. |
|
| Back to top |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Sat Nov 11, 2006 9:19 am Post subject: |
|
|
| This devctl will not work for flash as it is a memory stick command. A devctl is a raw command sent to a device, so flash will definitively not have the same kind of commands as it is not the same type of device... |
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Sat Nov 11, 2006 10:01 am Post subject: |
|
|
well that's a bummer.
I wonder if I could find it anywhere in a raw binary dump of all the
nand filesystems... |
|
| Back to top |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Thu Nov 30, 2006 12:02 pm Post subject: |
|
|
Surely you know the size of the NAND, since it is fixed.
So just subtract the size of all the files that are there?
It might not be 100% accurate, due to possible block inefficiency, and I don't know whether IdStorage counts in the NAND size specification, but it should be good enough for most purposes. _________________ Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you! |
|
| Back to top |
|
 |
ryoko_no_usagi

Joined: 29 Nov 2005 Posts: 65
|
Posted: Thu Nov 30, 2006 3:45 pm Post subject: |
|
|
| flash0 is formatted as 24MB and flash1 as 4MB, as far as I recall. Might have changed in later fws (especially 3.00 I'm guessing). |
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Sun Dec 10, 2006 10:48 am Post subject: |
|
|
| Quote: | | So just subtract the size of all the files that are there? |
That looks to be the only option.
A little messy, and slow, but if it's the only way... |
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Thu Dec 14, 2006 1:17 pm Post subject: |
|
|
Well thanks fo rthe suggestions, I had already thought of other avenues,
but only as last resort.
I have a routine that counts the size of every file on flash0, and it accurate compared.
to a flash0 filedump size in Windows.
If I subtract the value from the 24Mb, there's a figure left that's apparently
considerably higher than the actual available space.
I suppose I need to approximate it based on the free space a 32Mb memory stick will
provide when partitioned
the same way (24Mb, 4Mb, 1Mb & 1Mb.), and with flash0 & 1 full of firmware files?????
I can't think of a better way.. |
|
| Back to top |
|
 |
kuroneko
Joined: 08 Dec 2005 Posts: 24 Location: Chigasaki, Japan
|
Posted: Thu Dec 14, 2006 7:06 pm Post subject: |
|
|
| Art wrote: | ... I have a routine that counts the size of every file on flash0, and it accurate compared to a flash0 filedump size in Windows.
If I subtract the value from the 24Mb, there's a figure left that's apparently
considerably higher than the actual available space. |
If a file has non-zero size you have to take the cluster size into account. Meaning, a file with the logical size of 1 byte still allocates 16K in the NAND.
Also, directories occupy at least one cluster and after that it becomes a bit uncertain. Clearly the directory size depends on the number of entries in it (and on the length of those entries -> long name mapping), however, if you create say 1000 files which extends the directory to a size of N clusters, then you delete the first 999 files again, chances are that those N clusters are kept (rather then compacting the chain down to 1).
HTH |
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Thu Dec 21, 2006 11:02 am Post subject: |
|
|
Fortunately with the onofficial SE firmwares, people have recently had a
logical format performed by the app that writes the firmware to flash.
It is still very difficult.
Anyway, here's the routine I wrote for telling how much is used.
I started with the SDK sample that dumps a filesystem.
Any variables that aren't declared are global in my program.
| Code: |
void add_file(const char *read_loc, const char *write_loc, const char *name) {
char readpath[256];
build_path(readpath, read_loc, name, 0);
int ffls;
int filef_size = 0;
ffls = sceIoOpen(readpath, PSP_O_RDONLY, 0777);
filef_size = sceIoLseek32(ffls, 0, SEEK_END);
sceIoClose(ffls);
flash_size = flash_size + filef_size;
mbflash_size = flash_size/1024; // derive Kilobytes used
mbflash_size = mbflash_size/1024; // derive Megabytes used
flashsi = mbflash_size; // derive integer for counting display
pspDebugScreenSetXY(21, 28);
printf("Flash0 Space Used: %d",flashsi);
pspDebugScreenSetXY(44, 28);
printf(" Mb ");
}
void add_flash(const char *root, const char *write_loc) {
int dfd;
char next_root[256];
char next_write[256];
dfd = sceIoDopen(root);
if(dfd > 0)
{
SceIoDirent dir;
while(sceIoDread(dfd, &dir) > 0)
{
if(dir.d_stat.st_attr & FIO_SO_IFDIR)
{
if(dir.d_name[0] != '.')
{
build_path(next_write, write_loc, dir.d_name, 0);
build_path(next_root, root, dir.d_name, 1);
add_flash(next_root, next_write);
}
}
else
{
add_file(root, write_loc, dir.d_name);
}
}
sceIoDclose(dfd);
}
}
|
Cheers, Art. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|