forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Get name of File from file descriptor.

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Wed Feb 04, 2009 10:28 am    Post subject: Get name of File from file descriptor. Reply with quote

If I have a file descriptor fd that was from sceIoOpen, how do I get the name of the file associated with fd? Or name of the Directory if the file descriptor is from sceIoDopen.
Back to top
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Wed Feb 04, 2009 11:33 am    Post subject: Reply with quote

Torch, I just want to ask what are you trying todo?
Back to top
View user's profile Send private message AIM Address
ctszy



Joined: 12 Apr 2008
Posts: 18

PostPosted: Wed Feb 04, 2009 12:14 pm    Post subject: Reply with quote

I think the best way is to hook the sceIoOpen|sceIoDopen function.

also, if you're just looking for filename, there's another solution:
Find the uidblock of your fd,
(the uidblock of latest opened fd is the next of the one with the name of "Iob", you may reopen the descriptor to get it.)
and uidname is the filename. if your descriptor is opened by sceIoDopen, then uidname would be the full path.
(However, the length is limited by 27 chars.)
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Wed Feb 04, 2009 8:18 pm    Post subject: Reply with quote

ctszy wrote:
I think the best way is to hook the sceIoOpen|sceIoDopen function.

also, if you're just looking for filename, there's another solution:
Find the uidblock of your fd,
(the uidblock of latest opened fd is the next of the one with the name of "Iob", you may reopen the descriptor to get it.)
and uidname is the filename. if your descriptor is opened by sceIoDopen, then uidname would be the full path.
(However, the length is limited by 27 chars.)


I've already hooked the Open/Dopen functions. So I *could* maintain a list of fd's and assoiciated files names. But that would be a waste of memory. I'll try getting the UID block.

What did you mean its limited by 27 chars? The name is a char * in the uid block struct.
Back to top
View user's profile Send private message
ctszy



Joined: 12 Apr 2008
Posts: 18

PostPosted: Wed Feb 04, 2009 8:35 pm    Post subject: Reply with quote

well, maybe I got it wrong..
BTW, normally there wouldn't be more than 0x10 fd's opening at the same time, and the length limit of full path in FAT is 255.
so I don't think 4K will be a great waste, even in Kernel mode;)
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Wed Feb 04, 2009 8:46 pm    Post subject: Reply with quote

ctszy wrote:
well, maybe I got it wrong..
BTW, normally there wouldn't be more than 0x10 fd's opening at the same time, and the length limit of full path in FAT is 255.
so I don't think 4K will be a great waste, even in Kernel mode;)


Only 16 fs's ??? That sounds wrong. I know that most other stuff like power callbacks etc are limited to 16, but fd's? That sounds wrong.
Back to top
View user's profile Send private message
ctszy



Joined: 12 Apr 2008
Posts: 18

PostPosted: Wed Feb 04, 2009 9:35 pm    Post subject: Reply with quote

Torch wrote:
Only 16 fs's ??? That sounds wrong. I know that most other stuff like power callbacks etc are limited to 16, but fd's? That sounds wrong.

I didnt mean it's limited to 16.. I just mean in most cases there won't be too many file descriptors working at the same time, that number was just an example.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Wed Feb 04, 2009 10:52 pm    Post subject: Reply with quote

sceKernelGetUIDcontrolBlock returns SCE_KERNEL_ERROR_UNKNOWN_UID for all the UIDs I receive in sceIoDread.
Back to top
View user's profile Send private message
ctszy



Joined: 12 Apr 2008
Posts: 18

PostPosted: Wed Feb 04, 2009 11:35 pm    Post subject: Reply with quote

Torch wrote:
sceKernelGetUIDcontrolBlock returns SCE_KERNEL_ERROR_UNKNOWN_UID for all the UIDs I receive in sceIoDread.


well, if you output the fd given by sce functions you'll see it is not the "absolute" UID.
For example, you may get a fd with value of 0x05, but in fact its UID is 0x04E3EA21.
(different each time, given by system)
SceUID type doesn't mean it is a real UID.

(there's one exception: when vshcontrol module loads file in /ISO and /GAME I saw it uses the real UID.)

That's why I mentioned how to get the real one on above :)
You can use PSPLINK to output a list of UIDs and take a look, that will help
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Wed Feb 04, 2009 11:48 pm    Post subject: Reply with quote

ctszy wrote:

That's why I mentioned how to get the real one on above :)
You can use PSPLINK to output a list of UIDs and take a look, that will help


But int sceIoReopen requires a file name AND an old fd ?? What am I supposed to do?
Back to top
View user's profile Send private message
ctszy



Joined: 12 Apr 2008
Posts: 18

PostPosted: Wed Feb 04, 2009 11:58 pm    Post subject: Reply with quote

Torch wrote:

But int sceIoReopen requires a file name AND an old fd ?? What am I supposed to do?

Oh ... yes, sorry I forgot you cannot reopen it without the filename :<
I used this method in a specific example that works for every FIO so it just didn't matter... It's my negligence, sorry again.
So just do the hook then :) It is also the most stable solution.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Feb 05, 2009 4:59 am    Post subject: Reply with quote

There is a hard limit (or there used to be) on open fd's on the memory stick, I think it was around 16 or so :)
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Thu Feb 05, 2009 5:03 am    Post subject: Reply with quote

I'm currently keeping track of all the Dopen fd's created. Do you know a better way to find out the 'path' if you simply have the fd ?
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Feb 05, 2009 6:51 am    Post subject: Reply with quote

Unfortunately I don't think the kernel stores much in the way of the the actual file name as from the PSP's point of view it doesn't much care. Seems there is some stuff in the Iob UID block (not seen that one before :P) but not much. I think as pointed out the only way would be to capture it at sceIoOpen/sceIoDopen time.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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