| View previous topic :: View next topic |
| Author |
Message |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Wed Feb 04, 2009 10:28 am Post subject: Get name of File from file descriptor. |
|
|
| 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 |
|
 |
Dariusc123456
Joined: 12 Aug 2008 Posts: 394
|
Posted: Wed Feb 04, 2009 11:33 am Post subject: |
|
|
| Torch, I just want to ask what are you trying todo? |
|
| Back to top |
|
 |
ctszy
Joined: 12 Apr 2008 Posts: 18
|
Posted: Wed Feb 04, 2009 12:14 pm Post subject: |
|
|
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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Wed Feb 04, 2009 8:18 pm Post subject: |
|
|
| 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 |
|
 |
ctszy
Joined: 12 Apr 2008 Posts: 18
|
Posted: Wed Feb 04, 2009 8:35 pm Post subject: |
|
|
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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Wed Feb 04, 2009 8:46 pm Post subject: |
|
|
| 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 |
|
 |
ctszy
Joined: 12 Apr 2008 Posts: 18
|
Posted: Wed Feb 04, 2009 9:35 pm Post subject: |
|
|
| 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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Wed Feb 04, 2009 10:52 pm Post subject: |
|
|
| sceKernelGetUIDcontrolBlock returns SCE_KERNEL_ERROR_UNKNOWN_UID for all the UIDs I receive in sceIoDread. |
|
| Back to top |
|
 |
ctszy
Joined: 12 Apr 2008 Posts: 18
|
Posted: Wed Feb 04, 2009 11:35 pm Post subject: |
|
|
| 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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Wed Feb 04, 2009 11:48 pm Post subject: |
|
|
| 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 |
|
 |
ctszy
Joined: 12 Apr 2008 Posts: 18
|
Posted: Wed Feb 04, 2009 11:58 pm Post subject: |
|
|
| 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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Thu Feb 05, 2009 4:59 am Post subject: |
|
|
| 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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Thu Feb 05, 2009 5:03 am Post subject: |
|
|
| 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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Thu Feb 05, 2009 6:51 am Post subject: |
|
|
| 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 |
|
 |
|