I am writing a simple application to format the PS2 HDD. Everything goes fine: it's detected, it's formatted (i can see the internal HDD orange led flashing while it's being formatted).
At the end of the proccess, I just poweroff the PS2. But if I run the application again, it recognizes my HDD like UNFORMATTED, i. e., the program was just "pretending" it was formatting my HDD. At this point, the second time the application is run, it should display "Nothing to do! HDD is already formatted", because that was done already in the first execution, but no: I just get the formatting routine again! :(
Here goes my code:
Code: Select all
#include <kernel.h>
#include <sifrpc.h>
#include <libhdd.h>
#include <debug.h>
#include <string.h>
#include <libmc.h>
#include <loadfile.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
extern u8 *iomanx_irx;
extern int size_iomanx_irx;
extern u8 *filexio_irx;
extern int size_filexio_irx;
extern u8 *ps2dev9_irx;
extern int size_ps2dev9_irx;
extern u8 *ps2atad_irx;
extern int size_ps2atad_irx;
extern u8 *ps2hdd_irx;
extern int size_ps2hdd_irx;
extern u8 *ps2fs_irx;
extern int size_ps2fs_irx;
extern u8 *poweroff_irx;
extern int size_poweroff_irx;
extern u8 *cdvd_irx;
extern int size_cdvd_irx;
void loadModules(void);
int main()
{
SifInitRpc(0);
init_scr();
loadModules();
if(hddCheckPresent() == 0) {
if(hddCheckFormatted() != 0) {
if(hddFormat() == 0)
scr_printf("HDD formated successfuly\n\n");
else
scr_printf("Error! Could not format HDD\n\n");
} else
scr_printf("Nothing to do! HDD is already formatted\n\n");
} else
scr_printf("Error! HDD not found!\n\n");
while(1);
return 0;
}
void loadModules(void) {
static char hddarg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
static char pfsarg[] = "-m" "\0" "4" "\0" "-o" "\0" "10" "\0" "-n" "\0" "40";
int ret;
hddPreparePoweroff();
SifLoadModule("rom0:SIO2MAN", 0, NULL);
SifExecModuleBuffer(&poweroff_irx, size_poweroff_irx, 0, NULL, &ret);
SifExecModuleBuffer(&iomanx_irx, size_iomanx_irx, 0, NULL, &ret);
SifExecModuleBuffer(&filexio_irx, size_filexio_irx, 0, NULL, &ret);
SifExecModuleBuffer(&ps2dev9_irx, size_ps2dev9_irx, 0, NULL, &ret);
SifExecModuleBuffer(&ps2atad_irx, size_ps2atad_irx, 0, NULL, &ret);
SifExecModuleBuffer(&ps2hdd_irx, size_ps2hdd_irx, sizeof(hddarg), hddarg, &ret);
SifExecModuleBuffer(&ps2fs_irx, size_ps2fs_irx, sizeof(pfsarg), pfsarg, &ret);
}
Thanks in advance!
sparrow