2019-11-24 14:20:08 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2008
|
|
|
|
* Joseph Jordan <joe.ftpii@psychlaw.com.au>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010
|
|
|
|
* by Dimok
|
|
|
|
*
|
|
|
|
* This software is provided 'as-is', without any express or implied
|
|
|
|
* warranty. In no event will the authors be held liable for any
|
|
|
|
* damages arising from the use of this software.
|
|
|
|
*
|
|
|
|
* Permission is granted to anyone to use this software for any
|
|
|
|
* purpose, including commercial applications, and to alter it and
|
|
|
|
* redistribute it freely, subject to the following restrictions:
|
|
|
|
*
|
|
|
|
* 1. The origin of this software must not be misrepresented; you
|
|
|
|
* must not claim that you wrote the original software. If you use
|
|
|
|
* this software in a product, an acknowledgment in the product
|
|
|
|
* documentation would be appreciated but is not required.
|
|
|
|
*
|
|
|
|
* 2. Altered source versions must be plainly marked as such, and
|
|
|
|
* must not be misrepresented as being the original software.
|
|
|
|
*
|
|
|
|
* 3. This notice may not be removed or altered from any source
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* for WiiXplorer 2010
|
|
|
|
***************************************************************************/
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "virtualpath.h"
|
|
|
|
#include "utils/logger.h"
|
|
|
|
|
|
|
|
uint8_t MAX_VIRTUAL_PARTITIONS = 0;
|
2020-12-06 00:04:22 +01:00
|
|
|
VIRTUAL_PARTITION *VIRTUAL_PARTITIONS = NULL;
|
|
|
|
|
|
|
|
uint8_t MAX_VIRTUAL_FS = 0;
|
|
|
|
VIRTUAL_PARTITION *VIRTUAL_FS = NULL;
|
|
|
|
|
|
|
|
uint8_t MAX_VIRTUAL_FS_VOL = 0;
|
|
|
|
VIRTUAL_PARTITION *VIRTUAL_FS_VOL = NULL;
|
2019-11-24 14:20:08 +01:00
|
|
|
|
|
|
|
void VirtualMountDevice(const char * path)
|
|
|
|
{
|
|
|
|
if(!path)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
char name[255];
|
|
|
|
char alias[255];
|
|
|
|
char prefix[255];
|
|
|
|
bool namestop = false;
|
|
|
|
|
|
|
|
alias[0] = '/';
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if(path[i] == ':')
|
|
|
|
namestop = true;
|
|
|
|
|
|
|
|
if(!namestop)
|
|
|
|
{
|
|
|
|
name[i] = path[i];
|
|
|
|
name[i+1] = '\0';
|
|
|
|
alias[i+1] = path[i];
|
|
|
|
alias[i+2] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
prefix[i] = path[i];
|
|
|
|
prefix[i+1] = '\0';
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
while(path[i-1] != '/');
|
|
|
|
AddVirtualPath(name, alias, prefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddVirtualPath(const char *name, const char *alias, const char *prefix)
|
|
|
|
{
|
2021-01-01 01:52:20 +01:00
|
|
|
if (!VIRTUAL_PARTITIONS) {
|
|
|
|
VIRTUAL_PARTITIONS = (VIRTUAL_PARTITION *) malloc(sizeof(VIRTUAL_PARTITION));
|
|
|
|
}
|
|
|
|
|
|
|
|
VIRTUAL_PARTITION *tmp = realloc(VIRTUAL_PARTITIONS, sizeof(VIRTUAL_PARTITION) * (MAX_VIRTUAL_PARTITIONS + 1));
|
|
|
|
if (!tmp) {
|
|
|
|
free(VIRTUAL_PARTITIONS);
|
|
|
|
VIRTUAL_PARTITIONS = NULL;
|
|
|
|
MAX_VIRTUAL_PARTITIONS = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIRTUAL_PARTITIONS = tmp;
|
|
|
|
|
|
|
|
VIRTUAL_PARTITIONS[MAX_VIRTUAL_PARTITIONS].name = strdup(name);
|
|
|
|
VIRTUAL_PARTITIONS[MAX_VIRTUAL_PARTITIONS].alias = strdup(alias);
|
|
|
|
VIRTUAL_PARTITIONS[MAX_VIRTUAL_PARTITIONS].prefix = strdup(prefix);
|
|
|
|
VIRTUAL_PARTITIONS[MAX_VIRTUAL_PARTITIONS].inserted = true;
|
|
|
|
|
|
|
|
MAX_VIRTUAL_PARTITIONS++;
|
2019-11-24 14:20:08 +01:00
|
|
|
}
|
|
|
|
|
2020-12-06 00:04:22 +01:00
|
|
|
|
|
|
|
void AddVirtualFSPath(const char *name, const char *alias, const char *prefix) {
|
|
|
|
if (!VIRTUAL_FS) {
|
|
|
|
VIRTUAL_FS = (VIRTUAL_PARTITION *) malloc(sizeof(VIRTUAL_PARTITION));
|
|
|
|
}
|
|
|
|
|
|
|
|
VIRTUAL_PARTITION *tmp = realloc(VIRTUAL_FS, sizeof(VIRTUAL_PARTITION) * (MAX_VIRTUAL_FS + 1));
|
|
|
|
if (!tmp) {
|
2021-01-01 01:52:20 +01:00
|
|
|
if (VIRTUAL_FS) {
|
|
|
|
free(VIRTUAL_FS);
|
|
|
|
VIRTUAL_FS = 0;
|
|
|
|
}
|
2020-12-06 00:04:22 +01:00
|
|
|
MAX_VIRTUAL_FS = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIRTUAL_FS = tmp;
|
|
|
|
|
|
|
|
VIRTUAL_FS[MAX_VIRTUAL_FS].name = strdup(name);
|
|
|
|
|
|
|
|
MAX_VIRTUAL_FS++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddVirtualFSVOLPath(const char *name, const char *alias, const char *prefix) {
|
|
|
|
if (!VIRTUAL_FS_VOL) {
|
|
|
|
VIRTUAL_FS_VOL = (VIRTUAL_PARTITION *) malloc(sizeof(VIRTUAL_PARTITION));
|
|
|
|
}
|
|
|
|
|
|
|
|
VIRTUAL_PARTITION *tmp = realloc(VIRTUAL_FS_VOL, sizeof(VIRTUAL_PARTITION) * (MAX_VIRTUAL_FS_VOL + 1));
|
|
|
|
if (!tmp) {
|
|
|
|
free(VIRTUAL_FS_VOL);
|
|
|
|
MAX_VIRTUAL_FS_VOL = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIRTUAL_FS_VOL = tmp;
|
|
|
|
|
|
|
|
VIRTUAL_FS_VOL[MAX_VIRTUAL_FS_VOL].name = strdup(name);
|
|
|
|
|
|
|
|
MAX_VIRTUAL_FS_VOL++;
|
|
|
|
}
|
|
|
|
|
2019-11-24 14:20:08 +01:00
|
|
|
void MountVirtualDevices()
|
|
|
|
{
|
|
|
|
VirtualMountDevice("fs:/");
|
|
|
|
VirtualMountDevice("slccmpt01:/");
|
|
|
|
VirtualMountDevice("storage_odd_tickets:/");
|
|
|
|
VirtualMountDevice("storage_odd_updates:/");
|
|
|
|
VirtualMountDevice("storage_odd_content:/");
|
|
|
|
VirtualMountDevice("storage_odd_content2:/");
|
|
|
|
VirtualMountDevice("storage_slc:/");
|
|
|
|
VirtualMountDevice("storage_mlc:/");
|
|
|
|
VirtualMountDevice("storage_usb:/");
|
|
|
|
VirtualMountDevice("usb:/");
|
2021-04-13 19:53:46 +02:00
|
|
|
|
|
|
|
AddVirtualFSPath("vol", NULL, NULL);
|
|
|
|
AddVirtualFSVOLPath("external01", NULL, NULL);
|
|
|
|
AddVirtualFSVOLPath("content", NULL, NULL);
|
2019-11-24 14:20:08 +01:00
|
|
|
}
|
|
|
|
|
2021-01-01 01:52:20 +01:00
|
|
|
void UnmountVirtualPaths() {
|
|
|
|
uint32_t i = 0;
|
|
|
|
for (i = 0; i < MAX_VIRTUAL_PARTITIONS; i++) {
|
|
|
|
if (VIRTUAL_PARTITIONS[i].name) {
|
|
|
|
free(VIRTUAL_PARTITIONS[i].name);
|
|
|
|
}
|
|
|
|
if (VIRTUAL_PARTITIONS[i].alias) {
|
|
|
|
free(VIRTUAL_PARTITIONS[i].alias);
|
|
|
|
}
|
|
|
|
if (VIRTUAL_PARTITIONS[i].prefix) {
|
|
|
|
free(VIRTUAL_PARTITIONS[i].prefix);
|
|
|
|
}
|
|
|
|
}
|
2019-11-24 14:20:08 +01:00
|
|
|
|
2021-01-01 01:52:20 +01:00
|
|
|
for (i = 0; i < MAX_VIRTUAL_FS_VOL; i++) {
|
|
|
|
if (VIRTUAL_FS_VOL[i].name) {
|
|
|
|
free(VIRTUAL_FS_VOL[i].name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_VIRTUAL_FS; i++) {
|
|
|
|
if (VIRTUAL_FS[i].name) {
|
|
|
|
free(VIRTUAL_FS[i].name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIRTUAL_PARTITIONS) {
|
|
|
|
free(VIRTUAL_PARTITIONS);
|
|
|
|
}
|
|
|
|
if (VIRTUAL_FS_VOL) {
|
|
|
|
free(VIRTUAL_FS_VOL);
|
|
|
|
}
|
|
|
|
if (VIRTUAL_FS) {
|
|
|
|
free(VIRTUAL_FS);
|
|
|
|
}
|
|
|
|
VIRTUAL_PARTITIONS = NULL;
|
|
|
|
VIRTUAL_FS_VOL = NULL;
|
|
|
|
VIRTUAL_FS = NULL;
|
|
|
|
MAX_VIRTUAL_PARTITIONS = 0;
|
|
|
|
MAX_VIRTUAL_FS = 0;
|
|
|
|
MAX_VIRTUAL_FS_VOL = 0;
|
|
|
|
}
|