mirror of
https://github.com/wiiu-env/libromfs_wiiu.git
synced 2025-02-21 12:07:08 +01:00
Guard usage of __component because we don't have TLS yet
This commit is contained in:
parent
4b7f2a1e1b
commit
1d023a1c17
@ -1,5 +1,6 @@
|
|||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
#include <coreinit/filesystem.h>
|
#include <coreinit/filesystem.h>
|
||||||
|
#include <coreinit/mutex.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@ -29,6 +30,7 @@ typedef struct romfs_mount {
|
|||||||
char name[32];
|
char name[32];
|
||||||
FSFileHandle cafe_fd;
|
FSFileHandle cafe_fd;
|
||||||
FSClient cafe_client;
|
FSClient cafe_client;
|
||||||
|
OSMutex cafe_mutex;
|
||||||
} romfs_mount;
|
} romfs_mount;
|
||||||
|
|
||||||
extern int __system_argc;
|
extern int __system_argc;
|
||||||
@ -256,6 +258,8 @@ int32_t romfsMount(const char *name, const char *filepath, RomfsSource source) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (mount->fd_type == RomfsSource_FileDescriptor_CafeOS) {
|
} else if (mount->fd_type == RomfsSource_FileDescriptor_CafeOS) {
|
||||||
|
memset(&mount->cafe_mutex, 0, sizeof(OSMutex));
|
||||||
|
OSInitMutex(&mount->cafe_mutex);
|
||||||
memset(&mount->cafe_client, 0, sizeof(FSClient));
|
memset(&mount->cafe_client, 0, sizeof(FSClient));
|
||||||
if (FSAddClient(&mount->cafe_client, FS_ERROR_FLAG_ALL) != FS_STATUS_OK) {
|
if (FSAddClient(&mount->cafe_client, FS_ERROR_FLAG_ALL) != FS_STATUS_OK) {
|
||||||
romfs_free(mount);
|
romfs_free(mount);
|
||||||
@ -468,6 +472,7 @@ static int navigateToDir(romfs_mount *mount, romfs_dir **ppDir, const char **pPa
|
|||||||
(*pPath)++;
|
(*pPath)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSLockMutex(&mount->cafe_mutex);
|
||||||
while (**pPath) {
|
while (**pPath) {
|
||||||
char *slashPos = strchr(*pPath, '/');
|
char *slashPos = strchr(*pPath, '/');
|
||||||
char *component = __component;
|
char *component = __component;
|
||||||
@ -475,9 +480,11 @@ static int navigateToDir(romfs_mount *mount, romfs_dir **ppDir, const char **pPa
|
|||||||
if (slashPos) {
|
if (slashPos) {
|
||||||
uint32_t len = slashPos - *pPath;
|
uint32_t len = slashPos - *pPath;
|
||||||
if (!len) {
|
if (!len) {
|
||||||
|
OSUnlockMutex(&mount->cafe_mutex);
|
||||||
return EILSEQ;
|
return EILSEQ;
|
||||||
}
|
}
|
||||||
if (len > PATH_MAX) {
|
if (len > PATH_MAX) {
|
||||||
|
OSUnlockMutex(&mount->cafe_mutex);
|
||||||
return ENAMETOOLONG;
|
return ENAMETOOLONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,6 +495,7 @@ static int navigateToDir(romfs_mount *mount, romfs_dir **ppDir, const char **pPa
|
|||||||
component = (char *) *pPath;
|
component = (char *) *pPath;
|
||||||
*pPath += strlen(component);
|
*pPath += strlen(component);
|
||||||
} else {
|
} else {
|
||||||
|
OSUnlockMutex(&mount->cafe_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,6 +504,7 @@ static int navigateToDir(romfs_mount *mount, romfs_dir **ppDir, const char **pPa
|
|||||||
if (component[1] == '.' && !component[2]) {
|
if (component[1] == '.' && !component[2]) {
|
||||||
*ppDir = romFS_dir(mount, (*ppDir)->parent);
|
*ppDir = romFS_dir(mount, (*ppDir)->parent);
|
||||||
if (!*ppDir) {
|
if (!*ppDir) {
|
||||||
|
OSUnlockMutex(&mount->cafe_mutex);
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -504,9 +513,11 @@ static int navigateToDir(romfs_mount *mount, romfs_dir **ppDir, const char **pPa
|
|||||||
|
|
||||||
int ret = searchForDir(mount, *ppDir, (uint8_t *) component, strlen(component), ppDir);
|
int ret = searchForDir(mount, *ppDir, (uint8_t *) component, strlen(component), ppDir);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
OSUnlockMutex(&mount->cafe_mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
OSUnlockMutex(&mount->cafe_mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user