mirror of
https://github.com/wiiu-env/wut.git
synced 2025-01-22 10:41:12 +01:00
Deinit client and cmd block if device cannot be added, allow device to be added in environments without SD access
This commit is contained in:
parent
0aa7a3e021
commit
6f015ad41e
@ -93,14 +93,14 @@ fs_devoptab =
|
|||||||
void *fsClient;
|
void *fsClient;
|
||||||
void *fsCmd;
|
void *fsCmd;
|
||||||
|
|
||||||
static bool sdmcInitialised = false;
|
static bool fsInitialised = false;
|
||||||
|
|
||||||
/* Initialize SDMC device */
|
/* Initialize device */
|
||||||
FSStatus fsDevInit(void)
|
FSStatus fsDevInit(void)
|
||||||
{
|
{
|
||||||
FSStatus rc = 0;
|
FSStatus rc = 0;
|
||||||
|
|
||||||
if(sdmcInitialised)
|
if(fsInitialised)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
fsClient = memalign(0x20, 0x1700);
|
fsClient = memalign(0x20, 0x1700);
|
||||||
@ -120,31 +120,37 @@ FSStatus fsDevInit(void)
|
|||||||
|
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(fsCmd);
|
||||||
|
|
||||||
|
if(rc >= 0)
|
||||||
|
{
|
||||||
|
int dev = AddDevice(&fs_devoptab);
|
||||||
|
|
||||||
|
if(dev != -1)
|
||||||
|
{
|
||||||
|
setDefaultDevice(dev);
|
||||||
|
fsInitialised = true;
|
||||||
|
|
||||||
// Mount the SD card
|
// Mount the SD card
|
||||||
rc = FSGetMountSource(fsClient, fsCmd, FS_MOUNT_SOURCE_SD, (void*)mountSource, -1);
|
rc = FSGetMountSource(fsClient, fsCmd, FS_MOUNT_SOURCE_SD, (void*)mountSource, -1);
|
||||||
if(rc < 0)
|
if(rc < 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
rc = FSMount(fsClient, fsCmd, (void*)mountSource, mountPath, 0x80, -1);
|
rc = FSMount(fsClient, fsCmd, (void*)mountSource, mountPath, 0x80, -1);
|
||||||
|
|
||||||
if(rc >= 0)
|
if(rc >= 0)
|
||||||
{
|
{
|
||||||
sdmcInitialised = true;
|
|
||||||
|
|
||||||
int dev = AddDevice(&fs_devoptab);
|
|
||||||
|
|
||||||
if(dev != -1)
|
|
||||||
{
|
|
||||||
setDefaultDevice(dev);
|
|
||||||
|
|
||||||
// chdir to SD root for general use
|
// chdir to SD root for general use
|
||||||
strcpy(workDir, "fs:");
|
strcpy(workDir, "fs:");
|
||||||
strcat(workDir, mountPath);
|
strcat(workDir, mountPath);
|
||||||
chdir(workDir);
|
chdir(workDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FSDelClient(fsClient, -1);
|
||||||
|
free(fsClient);
|
||||||
|
free(fsCmd);
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -187,7 +193,7 @@ FSStatus fsDevExit(void)
|
|||||||
{
|
{
|
||||||
FSStatus rc = 0;
|
FSStatus rc = 0;
|
||||||
|
|
||||||
if(!sdmcInitialised) return rc;
|
if(!fsInitialised) return rc;
|
||||||
|
|
||||||
FSDelClient(fsClient, -1);
|
FSDelClient(fsClient, -1);
|
||||||
free(fsClient);
|
free(fsClient);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user