Reclaim the lost space on memory stick

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

Moderators: cheriff, TyRaNiD

Post Reply
bulb
Posts: 50
Joined: Thu Jan 19, 2006 10:59 pm

Reclaim the lost space on memory stick

Post by bulb »

Hi,

I have written a large file on memory stick without checking for free space on it. The file was larger than available space, so subsequent sceIoWrite() calls failed. I have quit the application and removed the file that showed size 0. After checking the size of memory stick, it was full! I can't reclaim the lost space. I now have 0.8 Gb memory stick, instead of 1 Gb. :)

I know I could format the stick (I don't have important data on it anyway), but I would really like to solve this programatically. Do you know how to find used blocks that aren't really used?

Anyway, I think there is a potential to make a memory stick optimize/defrag tool.
User avatar
nullp01nter
Posts: 26
Joined: Wed Jan 04, 2006 7:40 am
Location: Saxony/Germany

Post by nullp01nter »

As I think it is a FAT32 filesystem (correct me if I'm wrong), you have to access the stick on a sector basis. Then you'll have to search for lost clusters (look here: http://staff.washington.edu/dittrich/misc/fatgen103.pdf for a description of FAT32). Alternatively you can try to fix it via USB (use a filesystem repair utility, probably a chkdsk would be enough).
bulb
Posts: 50
Joined: Thu Jan 19, 2006 10:59 pm

Post by bulb »

null,

You were right - chkdsk did the trick.

The posted document look cool. I have one question though, do you know how to physically (not logically) read the memory stick (via PSP, not Windows or any other system)?

Thanx
User avatar
nullp01nter
Posts: 26
Joined: Wed Jan 04, 2006 7:40 am
Location: Saxony/Germany

Post by nullp01nter »

The posted document look cool. I have one question though, do you know how to physically (not logically) read the memory stick (via PSP, not Windows or any other system)?
Well, ..., no. I searched the SDK for some candidates to do that kind of "direct access", but as I understood, e. g. the fread() and fwrite() functions are more or less directly processed by the PSP firmware. So when I tried to trace the function call from fread() backwards, I was stopped at the doors of the firmware :)

At the time when I suggested to directly play with the FAT32 I had no clue that there's no (or hard to find?) functions which do the job. Or can someone of the SDK developer give a hint?

Thoralt
Post Reply