Remove obsolete FSAEx functions (use FSA from coreinit instead)

This commit is contained in:
Maschell 2022-07-22 13:32:55 +02:00
parent 4ba77767ad
commit c36ac435db
2 changed files with 1 additions and 119 deletions

View File

@ -1,66 +1,13 @@
#pragma once #pragma once
#include <coreinit/filesystem.h> #include <coreinit/filesystem.h>
#include <coreinit/filesystem_fsa.h>
#include <stdint.h> #include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #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 * Opens a device for raw read/write
* @param client valid FSClient pointer with unlocked permissions * @param client valid FSClient pointer with unlocked permissions

View File

@ -5,71 +5,6 @@
#include <coreinit/filesystem_fsa.h> #include <coreinit/filesystem_fsa.h>
#include <cstring> #include <cstring>
#include <malloc.h> #include <malloc.h>
#include <mocha/fsa.h>
#include <string_view>
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) { FSError FSAEx_RawOpen(FSClient *client, char *device_path, int32_t *outHandle) {
if (!client) { if (!client) {