mirror of
https://github.com/wiiu-env/libmocha.git
synced 2026-09-07 17:55:09 -05:00
Add FSA documentation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "mocha/fsa.h"
|
||||
#include "utils.h"
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/filesystem.h>
|
||||
@@ -5,19 +6,38 @@
|
||||
#include <cstring>
|
||||
#include <malloc.h>
|
||||
#include <mocha/fsa.h>
|
||||
#include <string_view>
|
||||
|
||||
FSError FSAEx_Mount(FSClient *client, const char *source, const char *target, uint32_t flags, void *arg_buf, uint32_t arg_len) {
|
||||
FSError FSAEx_Mount(FSClient *client, const char *source, const char *target, FSAMountFlags flags, void *arg_buf, uint32_t arg_len) {
|
||||
if (!client) {
|
||||
return FS_ERROR_INVALID_CLIENTHANDLE;
|
||||
}
|
||||
return FSAEx_MountEx(FSGetClientBody(client)->clientHandle, source, target, flags, arg_buf, arg_len);
|
||||
}
|
||||
|
||||
FSError FSAEx_MountEx(int clientHandle, const char *source, const char *target, uint32_t flags, void *arg_buf, uint32_t arg_len) {
|
||||
FSError FSAEx_MountEx(int clientHandle, const char *source, const char *target, FSAMountFlags flags, void *arg_buf, uint32_t arg_len) {
|
||||
auto *buffer = (FSAShimBuffer *) memalign(0x40, sizeof(FSAShimBuffer));
|
||||
if (!buffer) {
|
||||
return FS_ERROR_INVALID_BUFFER;
|
||||
}
|
||||
|
||||
// Check if source and target path is valid.
|
||||
if (!std::string_view(target).starts_with("/vol/") || !std::string_view(source).starts_with("/dev/")) {
|
||||
return FS_ERROR_INVALID_PATH;
|
||||
}
|
||||
|
||||
if (flags == FSA_MOUNT_FLAG_BIND_MOUNT || flags == FSA_MOUNT_FLAG_GLOBAL_MOUNT) {
|
||||
// Return error if target path DOES NOT start with "/vol/storage_"
|
||||
if (!std::string_view(target).starts_with("/vol/storage_")) {
|
||||
return FS_ERROR_INVALID_PATH;
|
||||
}
|
||||
} else {
|
||||
// Return error if target path starts with "/vol/storage_"
|
||||
if (std::string_view(target).starts_with("/vol/storage_")) {
|
||||
return FS_ERROR_INVALID_PATH;
|
||||
}
|
||||
}
|
||||
|
||||
auto res = __FSAShimSetupRequestMount(buffer, clientHandle, source, target, 2, arg_buf, arg_len);
|
||||
if (res != 0) {
|
||||
free(buffer);
|
||||
@@ -28,14 +48,14 @@ FSError FSAEx_MountEx(int clientHandle, const char *source, const char *target,
|
||||
return res;
|
||||
}
|
||||
|
||||
FSError FSAEx_Unmount(FSClient *client, const char *mountedTarget, int flags) {
|
||||
FSError FSAEx_Unmount(FSClient *client, const char *mountedTarget, FSAUnmountFlags flags) {
|
||||
if (!client) {
|
||||
return FS_ERROR_INVALID_CLIENTHANDLE;
|
||||
}
|
||||
return FSAEx_UnmountEx(FSGetClientBody(client)->clientHandle, mountedTarget);
|
||||
return FSAEx_UnmountEx(FSGetClientBody(client)->clientHandle, mountedTarget, flags);
|
||||
}
|
||||
|
||||
FSError FSAEx_UnmountEx(int clientHandle, const char *mountedTarget, int flags) {
|
||||
FSError FSAEx_UnmountEx(int clientHandle, const char *mountedTarget, FSAUnmountFlags flags) {
|
||||
auto *buffer = (FSAShimBuffer *) memalign(0x40, sizeof(FSAShimBuffer));
|
||||
if (!buffer) {
|
||||
return FS_ERROR_INVALID_BUFFER;
|
||||
|
||||
Reference in New Issue
Block a user