mirror of
https://github.com/wiiu-env/wut.git
synced 2025-01-22 05:21:15 +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 *fsCmd;
|
||||
|
||||
static bool sdmcInitialised = false;
|
||||
static bool fsInitialised = false;
|
||||
|
||||
/* Initialize SDMC device */
|
||||
/* Initialize device */
|
||||
FSStatus fsDevInit(void)
|
||||
{
|
||||
FSStatus rc = 0;
|
||||
|
||||
if(sdmcInitialised)
|
||||
if(fsInitialised)
|
||||
return rc;
|
||||
|
||||
fsClient = memalign(0x20, 0x1700);
|
||||
@ -119,33 +119,39 @@ FSStatus fsDevInit(void)
|
||||
}
|
||||
|
||||
FSInitCmdBlock(fsCmd);
|
||||
|
||||
// Mount the SD card
|
||||
rc = FSGetMountSource(fsClient, fsCmd, FS_MOUNT_SOURCE_SD, (void*)mountSource, -1);
|
||||
if(rc < 0)
|
||||
return rc;
|
||||
|
||||
rc = FSMount(fsClient, fsCmd, (void*)mountSource, mountPath, 0x80, -1);
|
||||
|
||||
if(rc >= 0)
|
||||
{
|
||||
sdmcInitialised = true;
|
||||
|
||||
int dev = AddDevice(&fs_devoptab);
|
||||
|
||||
if(dev != -1)
|
||||
{
|
||||
setDefaultDevice(dev);
|
||||
fsInitialised = true;
|
||||
|
||||
// chdir to SD root for general use
|
||||
strcpy(workDir, "fs:");
|
||||
strcat(workDir, mountPath);
|
||||
chdir(workDir);
|
||||
// Mount the SD card
|
||||
rc = FSGetMountSource(fsClient, fsCmd, FS_MOUNT_SOURCE_SD, (void*)mountSource, -1);
|
||||
if(rc < 0)
|
||||
return rc;
|
||||
|
||||
rc = FSMount(fsClient, fsCmd, (void*)mountSource, mountPath, 0x80, -1);
|
||||
if(rc >= 0)
|
||||
{
|
||||
// chdir to SD root for general use
|
||||
strcpy(workDir, "fs:");
|
||||
strcat(workDir, mountPath);
|
||||
chdir(workDir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FSDelClient(fsClient, -1);
|
||||
free(fsClient);
|
||||
free(fsCmd);
|
||||
return dev;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -187,7 +193,7 @@ FSStatus fsDevExit(void)
|
||||
{
|
||||
FSStatus rc = 0;
|
||||
|
||||
if(!sdmcInitialised) return rc;
|
||||
if(!fsInitialised) return rc;
|
||||
|
||||
FSDelClient(fsClient, -1);
|
||||
free(fsClient);
|
||||
|
Loading…
x
Reference in New Issue
Block a user