VFS Implementation

From Vita Development Wiki
Revision as of 16:29, 1 October 2017 by Motoharu (talk | contribs)
Jump to navigation Jump to search

VFS Nodes

Module Name Comment
SceSdstor sdstor_dev_fs
SceExfatfs exfat
SceIofilemgr dummy_ttyp_dev_fs
ScePfsMgr PFS_REDIRECT_INF Redirect Pseudo Drive.
ScePfsMgr PFS_GDSD_INF Gamedata/Savedata Pseudo Drive.
ScePfsMgr PFS_AC_INF AC Pseudo Drive.

VFS Operations

  • implemented operation is marked as implemented
  • not implemented is marked as
  • return 0 placeholder is marked as 0
  • return error is marked with corresponding error name
Function sdstor_dev_fs exfat dummy_ttyp_dev_fs PFS_REDIRECT_INF PFS_GDSD_INF PFS_AC_INF
1 implemented implemented implemented implemented implemented implemented
2 SCE_ERROR_ERRNO_EBUSY implemented 0 implemented implemented implemented
3 implemented implemented implemented implemented implemented implemented
4 implemented
5
6
7 implemented 0 implemented implemented
8
9 0 0 0 0 0 0
10 0 0 0 0 0
11
12 implemented implemented implemented implemented implemented
13 implemented implemented implemented implemented implemented

VFS Node Operations

  • implemented operation is marked as implemented
  • not implemented is marked as
  • return 0 placeholder is marked as 0
  • return error is marked with corresponding error name
Function sdstor_dev_fs exfat dummy_ttyp_dev_fs PFS_REDIRECT_INF PFS_GDSD_INF PFS_AC_INF
1 implemented implemented 0 implemented implemented implemented
2 implemented implemented implemented implemented
3 implemented implemented 0 implemented implemented implemented
4 implemented implemented implemented implemented implemented implemented
5 implemented implemented 0 implemented implemented implemented
6 implemented implemented implemented implemented implemented implemented
7 implemented implemented 0 implemented implemented implemented
8 SCE_ERROR_ERRNO_EUNSUP 0 implemented implemented implemented
9 implemented implemented implemented implemented implemented
10 implemented implemented implemented implemented
11 implemented implemented implemented implemented
12 implemented implemented implemented implemented
13 implemented implemented implemented implemented
14 implemented implemented implemented implemented
15 implemented implemented implemented implemented
16 implemented implemented implemented implemented
17 implemented implemented implemented implemented
18
19 implemented implemented implemented implemented implemented
20 implemented implemented implemented implemented implemented
21 0 implemented 0 implemented implemented implemented
22 implemented
23 implemented
24 0 implemented implemented implemented implemented
25 implemented implemented implemented implemented
26 implemented implemented implemented implemented
27 implemented implemented implemented implemented
28 implemented implemented implemented implemented
29

Typical i/o operation execution

This is a very brief desctiption for overall understanding of io vfs_node operations. Implementation of SceIofilemgr is quite solid and most of the functions are implemented in the same manner however there could be exceptions. When io operation like sceIoLseek is called here is what happens:

  • all user space arguments are copied to kernel space, usually onto the kernel stack. all user space uids are converted to kernel space uids
  • optionally control may be passed to wrapper function that also does conversion
  • then control is passed to kernel level function like sceIoLseekForDriver
  • kernel level function checks 0x2198 (IoSchedulerDispatcher initialized) flag

if dispatcher is not initialized:

  • kernel level function updates 0x1964 (i/o dirty) and 0x1980 (i/o counter) flags
  • kernel level function spawns separate thread and passes all arguments in single structure
  • separate thread then unpacks all arguments, finds vfs_node and calls exported function like vfs_node_func7
  • exported function packs all arguments into single stucture and calls real callback since it has vfs_node with node operation table
  • callback routine should be located in generic device driver, like SceSdstor, SceExfatfs or ScePfsMgr. It unpacks the arguments and then does something. For example SceSdstor dispatches the call further to SceSdif, SceWlanBt, SceMsif and SceUsbMass.
  • kernel level function updates 0x1980 (i/o counter) flag

if dispatcher is initialized:

  • kernel level function passes arguments to wrapper
  • wrapper initializes io_contex and assigns i/o operation index
  • wrapper updates 0x1964 (i/o dirty) and 0x1980 (i/o counter) flags
  • wrapper runs dispatcher function (offset 0x17C00) in separate thread. this function selects proper vfs_node function based on i/o operation index.
  • wrapper updates 0x1980 (i/o counter) flag

i/o operation index

Typically operations are dispatched from kernel functions.

However there are exceptions: sceIoLseek32, sceIoDopenAsync, sceIoDreadAsync, sceIoDcloseAsync user functions can be dispatched.

Typically operations have normal and async version - regulated by async flag in io_context.

However there are exceptions: sceIoLseek32, sceIoIoctlForDriver, sceIoDevctlForDriver, sceIoGetstatForDriver_2, sceIoChstatForDriver_2, sceIoDreadForDriver_2 do not have async version.

Index Normal Operation Async Operation Vfs Node Function Vfs Function
1 sceIoOpenForDriver sceIoOpenAsyncForDriver
2 sceIoCloseForDriver sceIoCloseAsyncForDriver
3 sceIoReadForDriver sceIoReadAsyncForDriver 5 N/A
4 sceIoWriteForDriver sceIoWriteAsyncForDriver 6 N/A
5 sceIoLseekForDriver sceIoLseekAsyncForDriver 7 N/A
6 sceIoLseek32 N/A 7 N/A
7 sceIoIoctlForDriver N/A 8 N/A
8 sceIoRemoveForDriver sceIoRemoveAsyncForDriver
9 sceIoDopenForDriver sceIoDopenAsyncForDriver
10 sceIoDcloseForDriver sceIoDcloseAsyncForDriver
11 sceIoDreadForDriver sceIoDreadAsyncForDriver 14 N/A
12 sceIoMkdirForDriver sceIoMkdirAsyncForDriver 10 N/A
13 sceIoRmdirForDriver sceIoRmdirAsyncForDriver
14 sceIoRenameForDriver sceIoRenameAsyncForDriver
15 sceIoChstatForDriver sceIoChstatAsyncForDriver 16 N/A
16 sceIoChstatByFdForDriver sceIoChstatByFdAsyncForDriver 26 N/A
17 sceIoGetstatForDriver sceIoGetstatAsyncForDriver 15 N/A
18 sceIoGetstatByFdForDriver sceIoGetstatByFdAsyncForDriver 25 N/A
19 sceIoDevctlForDriver N/A N/A 12
20 sceIoSyncForDriver sceIoSyncAsyncForDriver 24 N/A
21 sceIoSyncByFdForDriver sceIoSyncByFdAsyncForDriver 24 N/A
22 sceIoPreadForDriver sceIoPreadAsyncForDriver 19 N/A
23 sceIoPwriteForDriver sceIoPwriteAsyncForDriver 20 N/A
24 sceIoGetstatForDriver_2 N/A 15 N/A
25 sceIoChstatForDriver_2 N/A 16 N/A
26 sceIoDreadForDriver_2 N/A 14 N/A
27 N/A sceIoDopenAsync
28 N/A sceIoDreadAsync
29 N/A sceIoDcloseAsync