/dev/fsa

From WiiUBrew
Jump to navigation Jump to search

/dev/fsa is the IOSU device node for the virtual filesystem API. It exposes a generic interface for accessing various filesystems supported by the Wii U, including the internal storage filesystem (ISFS), game disc filesystems, and SD cards. These filesystems can be mounted on directories under /vol and accessed through a common API. Once opened, ioctl() and ioctlv() requests can be issued to the interface, which are documented below.

Structures

Request Blocks

The parameters to FSA functions are passed in a 0x520-byte request block. While the size is constant, the structure varies by call, as shown below:

/* Read/write request block */
typedef struct
{
    char unknown0[0x4-0x0];
    void *buffer;                  // Not looked at by FSA
    uint32_t size, count;
    char unknown10[0x14-0x10];
    uint32_t handle;
    char unknown18[0x1c-0x18];
    uint32_t unknown1c;            // Always 0x6e000000
    char unknown20[0x284-0x20];
    uint32_t unknown284;           // Always 0x77000000
    char unknown288[0x294-0x288];
    uint32_t unknown294;           // Always 0x660
    char unknown298[0x520-0x298];
} rw_req_t;

Status Blocks

All FSA functions return the status of the call in a 0x293-byte buffer.

Tables

List of Functions (Ioctl/Ioctlv/IoctlAsync)

Command Function Ioctl Ioctlv IoctlAsync Notes
0x01 FSMount      X
0x01 FSAMount
FSMountAsync
FSBindMount
     X
0x02 FSAUnmount
FSUnmountAsync
FSBindUnmount
FSBindUnmountAsync
     X
0x03 FSAGetVolumeInfo
FSGetVolumeInfoAsync
     X
0x04 FSAInit         X
0x05 FSAChangeDir
FSChangeDirAsync
     X
0x06 FSAGetCwd
FSGetCwdAsync
     X
0x07 FSAMakeDir      X      X
0x08 FSARemove      X      X
0x09 FSARename      X
0x0A FSOpenDir      X      X
0x0B FSReadDir      X
0x0C FSRewindDir      X
0x0D FSCloseDir      X
0x0E FSAOpenFile
FSAOpenFileEx
     X
0x0F FSAReadFile
FSReadFileWithPos
     X This function is used to read data from an open file. It takes 1 input buffer through the ioctlv interface, a read request block, and 2 output buffers, a buffer for file data and a status block.
0x10 FSWriteFile
FSWriteFileWithPos
     X This function is used to write data to an open file. It takes 2 input buffers through the ioctlv interface, a read request block and a data buffer, and 1 output buffer, a status block.
0x11 FSGetPosFile      X
0x12 FSSetPosFile      X
0x13 FSIsEof      X
0x14 FSAStatFile      X
0x15 FSACloseFile      X
0x16 FSAGetError      X
0x17 FSFlushFile      X
0x18 FSGetStat
FSGetFreeSpaceSize
FSGetEntryNum
FSGetFileSystemInfo
     X      X
0x19 FSAppendFile
FSAppendFileEx
     X
0x1A FSTruncateFile      X
0x1B FSAFlushVolume      X      X
0x1C FSARollbackVolume      X      X
0x1D FSMakeQuota      X      X
0x1E FSFlushQuota      X      X
0x1F FSRollbackQuota
FSARollbackQuotaForce
     X      X
0x20 FSChangeMode      X      X
0x21 FSAOpenFileByStat
FSOpenFileByStatAsync
     X
0x22 FSRegisterFlushQuota      X      X
0x23 FSFlushMultiQuota      X      X
0x25 FSGetFileBlockAddress      X
0x65 AddUserProcess ‎ ‎ ‎ ‎ ‎ X
0x66 DelUserProcess ‎ ‎ ‎ ‎ ‎ X
0x67 FSAMountWithProcess       ‎ ‎ ‎ ‎ ‎ X
0x68 FSAUnmountWithProcess ‎ ‎ ‎ ‎ ‎ X
0x69 FSAFormat ‎ ‎ ‎ ‎ ‎ X
0x6A FSARawOpen ‎ ‎ ‎ ‎ ‎ X
0x6B FSARawRead       ‎ ‎ ‎ ‎ ‎ X
0x6C FSARawWrite       ‎ ‎ ‎ ‎ ‎ X
0x6D FSARawClose ‎ ‎ ‎ ‎ ‎ X
0x6E GetLastFailedVolume ‎ ‎ ‎ ‎ ‎ X
0x6F GetVolumeExistence ‎ ‎ ‎ ‎ ‎ X
0x70 FSAChangeOwner ‎ ‎ ‎ ‎ ‎ X
0x71 CancelGetAttach ‎ ‎ ‎ ‎ ‎ X
0x72 FSARemoveQuota ‎ ‎ ‎ ‎ ‎ X ‎ ‎ ‎ ‎ ‎ X
0x73 SetClientPriority ‎ ‎ ‎ ‎ ‎ X
0x74 ApplyMemoryCache ‎ ‎ ‎ ‎ ‎ X
0x75 FSMakeLinkAsync ‎ ‎ ‎ ‎ ‎ X ‎ ‎ ‎ ‎ ‎ X
0x76 XferParams ‎ ‎ ‎ ‎ ‎ X
0x82 SetProcessConfig ‎ ‎ ‎ ‎ ‎ X
Subcommand Name Notes
0x83 scfmSetMemoryCacheBuffer
0x84 scfmUnsetMemoryCacheBuffer
0x85 Unknown FAT
0x86 scfmSetMemoryCacheArea
0x87 scfmEnableSetMemoryCacheArea
0x88 scfmUnsetMemoryCacheArea
0x89 Unknown
0x8A Unknown Sets an ATFS flag that affects whether a volume will be dropped for having an expired version in its header.
0x8B Unknown SCFM
0x8C GetProcResourceUsage ‎ ‎ ‎ ‎ ‎ ‎X Debug/test only
0x8D GetAllResourceUsage ‎ ‎ ‎ ‎ ‎ ‎X Debug/test only
0x8E SendProfileCmd ‎ ‎ ‎ ‎ ‎ ‎‎X Debug/test only