Filesystem Usage Example
Filesystem Usage Example
Hello everyone. Your favorite newbie, here, with another exciting topic.
I have been looking for code related to file systems and the hard drive, and have come up a bit short. I made this small example to try to see if I could access my hard drive partitions on my PS2, but it just hangs at whatever "hdd...()" function I try to execute. I'm obviously missing something, but I'm a little befuddled. Could someone shed some light on this issue? Thanks. =)
EDIT:
Example code has been moved to the bottom of the thread.
I have been looking for code related to file systems and the hard drive, and have come up a bit short. I made this small example to try to see if I could access my hard drive partitions on my PS2, but it just hangs at whatever "hdd...()" function I try to execute. I'm obviously missing something, but I'm a little befuddled. Could someone shed some light on this issue? Thanks. =)
EDIT:
Example code has been moved to the bottom of the thread.
Last edited by whatisdot on Thu Jun 05, 2008 3:37 am, edited 1 time in total.
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
Okay, I'm trying to load the modules, but I don't know which modules need to be loaded. I've already tried these, but the 'ps2hdd' and 'ps2fs' don't want to load. I can only assume they rely on some other module that I have yet to find...
What am I missing???
Code: Select all
SifLoadModule("host0:fileXio.irx", 0, NULL);
SifLoadModule("host0:ps2hdd.irx", 0, NULL);
SifLoadModule("host0:ps2fs.irx", 0, NULL);
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
So far I've loaded these modules:
Load correctly
Refuse to load
Load correctly
Code: Select all
SifLoadModule("rom0:SIO2MAN", 0, NULL);
SifLoadModule("rom0:MCMAN", 0, NULL);
SifLoadModule("rom0:MCSERV", 0, NULL);
SifLoadModule("host0:fileXio.irx", 0, NULL);
SifLoadModule("host0:ps2atad.irx", 0, NULL);
Code: Select all
SifLoadModule("host0:ps2hdd.irx", 0, NULL);
SifLoadModule("host0:ps2fs.irx", 0, NULL);
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
-
- Posts: 202
- Joined: Wed Aug 09, 2006 1:00 am
If you look at the imports.lst files for the IOP modules you need, you can usually tell what modules need to be loaded.
You might need to include some arguments for ps2fs.irx and ps2hdd.irx, as well. These are the arguments I use that I gleaned from other sources, and I think this is the way to load them with SifLoadModule().
static char hddarg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
SifLoadModule("host0:ps2hdd.irx", sizeof(hddarg), hddarg);
static char pfsarg[] = "-m" "\0" "4" "\0" "-o" "\0" "10" "\0" "-n" "\0" "40";
SifLoadModule("host0:ps2fs.irx", sizeof(pfsarg), pfsarg);
-o is maxopen and -n is cachesize for ps2hdd.irx
-m is maxmounts, -o is maxopen, and -n is for the number of buffers for ps2fs.irx
You might need to include some arguments for ps2fs.irx and ps2hdd.irx, as well. These are the arguments I use that I gleaned from other sources, and I think this is the way to load them with SifLoadModule().
static char hddarg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
SifLoadModule("host0:ps2hdd.irx", sizeof(hddarg), hddarg);
static char pfsarg[] = "-m" "\0" "4" "\0" "-o" "\0" "10" "\0" "-n" "\0" "40";
SifLoadModule("host0:ps2fs.irx", sizeof(pfsarg), pfsarg);
-o is maxopen and -n is cachesize for ps2hdd.irx
-m is maxmounts, -o is maxopen, and -n is for the number of buffers for ps2fs.irx
Thanks for the responses. The modules load correctly now, but it still freezes when I execute one of the hdd...() functions. It turns out that "poweroff.irx" was also needed.
A bit more info on my setup; I have a 250GB hard drive in my PS2 and I have formatted a couple of partitions using the PS2HDD application, as well as storing a number of PS2 games on it using HDLoader. At this point I am just trying to get a listing of the partitions. Once I can do this, I was going to try to mount them to folders in my formatted partitions on the HDD. I am also using PS2Link to test it.
EDIT:
Sample code has been moved to the bottom of this thread.
A bit more info on my setup; I have a 250GB hard drive in my PS2 and I have formatted a couple of partitions using the PS2HDD application, as well as storing a number of PS2 games on it using HDLoader. At this point I am just trying to get a listing of the partitions. Once I can do this, I was going to try to mount them to folders in my formatted partitions on the HDD. I am also using PS2Link to test it.
EDIT:
Sample code has been moved to the bottom of this thread.
Last edited by whatisdot on Thu Jun 05, 2008 3:34 am, edited 1 time in total.
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
Hey Mega Man! That did the trick! Thanks a bunch. I'll rework this code and repost it when it is cleaned up. Thanks for all the help, everyone!
EDIT:
I hope someone else finds this code useful. I hope it saves them the time and energy it took me, and the people who responded to this thread. Feel free to respond if someone sees some redundancy or flaw.
Here is the bare bottom code for checking the hard drive and it's partitions. I was checking this at runtime using PS2Link. I made sure to copy the following modules into my executable's directory:
poweroff.irx
fileXio.irx
ps2atad.irx
ps2fs.irx
ps2hdd.irx
(the order in which these modules are loaded is important)
And here's the code:
Makefile
file_system.c
EDIT:
I hope someone else finds this code useful. I hope it saves them the time and energy it took me, and the people who responded to this thread. Feel free to respond if someone sees some redundancy or flaw.
Here is the bare bottom code for checking the hard drive and it's partitions. I was checking this at runtime using PS2Link. I made sure to copy the following modules into my executable's directory:
poweroff.irx
fileXio.irx
ps2atad.irx
ps2fs.irx
ps2hdd.irx
(the order in which these modules are loaded is important)
And here's the code:
Makefile
Code: Select all
EE_BIN = file_system.elf
EE_OBJS = file_system.o
EE_LIBS = -ldebug -lhdd -lfileXio -lpoweroff
all: $(EE_BIN)
clean:
rm -f *.elf *.o *.a
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
Code: Select all
#include <tamtypes.h>
#include <stdio.h>
#include <debug.h>
#include <libhdd.h>
#include <libpwroff.h>
#include <fileXio_rpc.h>
#include <sifrpc.h>
#include <loadfile.h>
#define MAX_PARTITIONS 100
// The space that will hold the information about the
// partitions on the hard drive.
t_hddFilesystem parties[MAX_PARTITIONS] __attribute__((aligned(64)));
int main() {
char *printStr;
int i=0, nparty=0;
// Initialize the screen (clear it)
init_scr();
// Initialize the Remote Proceedure Call manager
SifInitRpc(0);
printStr = "Loading modules...\n";
// print to PS2 Screen
scr_printf( printStr );
// print to console window
printf( printStr );
// Load the needed modules
SifLoadModule("host0:poweroff.irx", 0, NULL);
SifLoadModule("host0:fileXio.irx", 0, NULL);
SifLoadModule("host0:ps2atad.irx", 0, NULL);
// set the arguments for loading 'ps2fs'
// -m 4 (maxmounts 4)
// -o 10 (maxopen 10)
// -n 40 (number of buffers 40)
static char pfsarg[] = "-m" "\0" "4" "\0" "-o" "\0" "10" "\0" "-n" "\0" "40";
SifLoadModule("host0:ps2fs.irx", sizeof(pfsarg), pfsarg);
// set the arguments for loading 'ps2hdd'
// -o 4 (maxopen 4)
// -n 20 (cachesize 20)
static char hddarg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
SifLoadModule("host0:ps2hdd.irx", sizeof(hddarg), hddarg);
printStr = "Finished loading modules.\nChecking the hard drive...\n";
scr_printf( printStr );
printf( printStr );
if( hddCheckPresent() < 0 ) {
printStr = "NO HDD FOUND!\n";
scr_printf( printStr );
printf( printStr );
return -1;
} else {
printStr = "Found HDD!\n";
scr_printf( printStr );
printf( printStr );
}
if( hddCheckFormatted() < 0 ) {
printStr = "HDD Not Formatted!\n";
scr_printf( printStr );
printf( printStr );
return -1;
} else {
printStr = "HDD Is Formatted!\n";
scr_printf( printStr );
printf( printStr );
}
// populate 'parties' with information on each partition
i = hddGetFilesystemList(parties, MAX_PARTITIONS);
// "# partitions"
printStr = "%i partitions\n";
scr_printf( printStr, i);
printf( printStr, i);
// List each partition name
nparty=i-1;
for(i=nparty;i>=0;i--) {
printStr = "Partition: %s\n";
scr_printf( printStr, parties[i].name);
printf( printStr, parties[i].name);
}
printStr = "All done!\nGoodbye\n";
scr_printf( printStr );
printf( printStr );
return 0;
}
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
Hint: You can have the Makefile copy the IRX files into the directory for you.
Code: Select all
EE_BIN = file_system.elf
EE_OBJS = file_system.o
EE_LIBS = -ldebug -lhdd -lfileXio -lpoweroff
IRXS = poweroff.irx fileXio.irx ps2atad.irx ps2fs.irx ps2hdd.irx
all: $(EE_BIN) $(IRXS)
%.irx:
cp $(PS2SDK)/iop/irx/$@ $@
clean:
rm -f *.elf *.o *.a *.irx
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
Yes I do indeed. Many thanks.whatisdot wrote:I hope someone else finds this code useful.
BTW: If you're into sharing code for helping others you could setup a free subversion repository, using www.assembla.com ou others (like google code) and commit the source there. This has also the big advantage to yourself that is inherent to the use of a source control version system, since you can obviously decide if your repositories will be public or not.
My public is at http://svn2.assembla.com/svn/pedroduarteps2dev_public . Feel free to browse, although not much code is there yet.
Very nice! I made an account and uploaded some of the things I have done. I augmented the example here to mount a file system on the hard drive and list its directories. You can find this and my other examples here:
http://www.assembla.com/spaces/files/ps2sdk-demos
http://www.assembla.com/spaces/files/ps2sdk-demos
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
Hi ptek,
I have never gotten around to looking into SVN, but now is as good a time as any. I found this after doing some searching.
http://svnbook.red-bean.com/
I have some reading to do. Thanks for the encouragement. =)
I have never gotten around to looking into SVN, but now is as good a time as any. I found this after doing some searching.
http://svnbook.red-bean.com/
I have some reading to do. Thanks for the encouragement. =)
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------
"A witty saying proves nothing."
--------------------------------------------------------------