From 908ef96c65fc9c6ffdbb294840d225acc48ab122 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 22 Jul 2022 13:32:55 +0200 Subject: [PATCH] Remove obsolete FSAEx functions (use FSA from coreinit instead) --- include/mocha/fsa.h | 55 +------------------------------------- source/fsa.cpp | 65 --------------------------------------------- 2 files changed, 1 insertion(+), 119 deletions(-) diff --git a/include/mocha/fsa.h b/include/mocha/fsa.h index eb80cfb..6abb28a 100644 --- a/include/mocha/fsa.h +++ b/include/mocha/fsa.h @@ -1,66 +1,13 @@ #pragma once #include +#include #include #ifdef __cplusplus extern "C" { #endif -typedef enum FSAMountFlags { - FSA_MOUNT_FLAG_LOCAL_MOUNT = 0, - FSA_MOUNT_FLAG_BIND_MOUNT = 1, - FSA_MOUNT_FLAG_GLOBAL_MOUNT = 2, -} FSAMountFlags; - -typedef enum FSAUnmountFlags { - FSA_UNMOUNT_FLAG_BIND_MOUNT = 0x80000000, -} FSAUnmountFlags; - -/** - * Mounts a source to a given path for a given FSClient (or globally if FSA_MOUNT_FLAG_GLOBAL_MOUNT is set) - * - * @param client valid FSClient pointer with unlocked permissions - * @param source Mount source e.g. /dev/sdcard01 - * @param target Must not start with /vol/storage_ if FSA_MOUNT_FLAG_GLOBAL_MOUNT is **not** set. Requires to start with "/vol/storage_" if FSA_MOUNT_FLAG_GLOBAL_MOUNT or FSA_UNMOUNT_FLAG_BIND_MOUNT is set - * @param flags Determines the mount type. - * @param arg_buf unknown - * @param arg_len unknown - * @return - */ -FSError FSAEx_Mount(FSClient *client, const char *source, const char *target, FSAMountFlags flags, void *arg_buf, uint32_t arg_len); - -/** - * Mounts a source to a given path for a given FSClient (or globally if FSA_MOUNT_FLAG_GLOBAL_MOUNT is set) - * - * @param clientHandle valid /dev/fsa handle with unlocked permissions - * @param source Mount source e.g. /dev/sdcard01 - * @param target Must not start with /vol/storage_ if FSA_MOUNT_FLAG_GLOBAL_MOUNT is **not** set. Requires to start with "/vol/storage_" if FSA_MOUNT_FLAG_GLOBAL_MOUNT is set - * @param flags Determines the mount type. - * @param arg_buf unknown - * @param arg_len unknown - * @return - */ -FSError FSAEx_MountEx(int clientHandle, const char *source, const char *target, FSAMountFlags flags, void *arg_buf, uint32_t arg_len); - -/** - * Unmounts a given path - * @param client valid FSClient pointer with unlocked permissions - * @param mountedTarget path where the mount is mounted to. - * @param flags FSA_UNMOUNT_FLAG_BIND_MOUNT is expected for a BindMount - * @return - */ -FSError FSAEx_Unmount(FSClient *client, const char *mountedTarget, FSAUnmountFlags flags); - -/** - * Unmounts a given path - * @param clientHandle valid /dev/fsa handle with unlocked permissions - * @param mountedTarget path where the mount is mounted to. - * @param flags FSA_UNMOUNT_FLAG_BIND_MOUNT is expected for a BindMount - * @return - */ -FSError FSAEx_UnmountEx(int clientHandle, const char *mountedTarget, FSAUnmountFlags flags); - /** * Opens a device for raw read/write * @param client valid FSClient pointer with unlocked permissions diff --git a/source/fsa.cpp b/source/fsa.cpp index ebe679e..fe14ab3 100644 --- a/source/fsa.cpp +++ b/source/fsa.cpp @@ -5,71 +5,6 @@ #include #include #include -#include -#include - -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, 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); - return res; - } - res = __FSAShimSend(buffer, 0); - free(buffer); - return res; -} - -FSError FSAEx_Unmount(FSClient *client, const char *mountedTarget, FSAUnmountFlags flags) { - if (!client) { - return FS_ERROR_INVALID_CLIENTHANDLE; - } - return FSAEx_UnmountEx(FSGetClientBody(client)->clientHandle, mountedTarget, 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; - } - - auto res = __FSAShimSetupRequestUnmount(buffer, clientHandle, mountedTarget, flags); - if (res != 0) { - free(buffer); - return res; - } - res = __FSAShimSend(buffer, 0); - free(buffer); - return res; -} FSError FSAEx_RawOpen(FSClient *client, char *device_path, int32_t *outHandle) { if (!client) {