sceIoDread woes

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

Moderators: cheriff, TyRaNiD

Post Reply
Gary13579
Posts: 93
Joined: Mon Aug 15, 2005 7:43 am

sceIoDread woes

Post by Gary13579 »

First thing I want to say: I have searched, and the only thing I've found close to this is here. I can't use the way he managed to solve it due to OSLib wouldn't work properly then.

I can call sceIoDopen and get a valid SceUID (3), but as soon as I call sceIoDread on that UID, the PSP crashes (sometimes with the mem stick light on and sometimes with it off).

Here's some code:

Code: Select all

void loadDirectory(char* path) {
	int dfd, f = 0, i = 0;
	SceIoDirent dir;
	
	oslDebug("hi\n");
	dfd = sceIoDopen("ms0:/PSP/GAME/");
	if &#40;dfd <= 0&#41;
		oslFatalError&#40;"sceIoDopen returned %i", dfd&#41;;
		
	oslDebug&#40;"sceIoDopen returned&#58; %i\n", dfd&#41;;
	
	while &#40;sceIoDread&#40;dfd, &dir&#41; > 0&#41; &#123;
		oslDebug&#40;"%s\n", dir.d_name&#41;;
		if &#40;!dir.d_stat.st_attr & FIO_SO_IFDIR&#41; &#123;
			if &#40;dir.d_name&#91;0&#93; != '.'&#41; &#123;
				strcpy&#40;cwdFolders&#91;f&#93;, dir.d_name&#41;;
				f++;
			&#125;
		&#125; else &#123;
			strcpy&#40;cwdFiles&#91;i&#93;, dir.d_name&#41;;
			i++;
		&#125;
	&#125;
	
	oslDebug&#40;"bye\n"&#41;;
	sceIoDclose&#40;dfd&#41;;
&#125;
I get the debug message "hi", and the "sceIoDopen returned: 3", but it crashes on the call to sceIoDread. I never see the name or "bye" messages.

Edit: Just installed a quick exception handler if it helps.

Exception: Bus error (data)
EPC: 8802BAB8
Cause: 0000001C
Status: 60008603
BadVAddr: 412090C8
zr:00000000
a0:FFFFFFFF
t0:0000002E
t4:0000000D
s0:88229E88
s4:882E8878
t8:000001A1
gp:08950530
at:BC600000
a1:88229FAA
t1:00000000
t5:00001220
s1:882E8820
s5:00010000
t9:000001AE
sp:882E87A0
v0:00000000
a2:0000000D
t2:00000001
t6:00000244
s2:88229FA9
s6:08940000
k0:00000000
fp:08940000
v1:00000000
a3:FFFFFFFF
t3:88040000
t7:00000068
s3:00000003
s7:08940000
k1:00000003
ra:88151B88
jonny
Posts: 351
Joined: Thu Sep 22, 2005 5:46 pm
Contact:

Post by jonny »

this:
memset(&dir, 0, sizeof(SceIoDirent));
at the start of the function should solve
Gary13579
Posts: 93
Joined: Mon Aug 15, 2005 7:43 am

Post by Gary13579 »

Thanks, a friend on IRC was just telling me this. I'll try it in a sec and see if it works.

What's throwing me off is that samples/kernel/fileio/main.c (function dump_filesystem) does not do this, so I assumed it wasn't needed.

Edit: It's working great now.
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

jonny wrote:this:
memset(&dir, 0, sizeof(SceIoDirent));
at the start of the function should solve
It seems that all of us had the same problem in the past ;)
(the curious thing is that isn't needed when listing files from the flash, that made more difficult to point that out the first and last time i had that problem :S )

The lesson: always memzero a structure before using it...

P.S.: someone should edit the example that comes in the pspsdk that copies the files from the flash, to avoid spreading more this error.
jonny
Posts: 351
Joined: Thu Sep 22, 2005 5:46 pm
Contact:

Post by jonny »

It seems that all of us had the same problem in the past ;)
hehe yes, i'll never forget sceIoDread :)
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

:P indeed fixy fix
10011011 00101010 11010111 10001001 10111010
Post Reply