mirror of
https://github.com/wiiu-env/wut.git
synced 2025-01-07 12:08:15 +01:00
Revert "Rename wutdevoptab to wutdevoptab_sd"
This reverts commit 865af4609c
.
Turns out it is for whole filesystem. oops.
This commit is contained in:
parent
91973a3b14
commit
690bd6ccbd
@ -25,7 +25,7 @@ The [share/wut.cmake](share/wut.cmake) file provides several helpers for your bu
|
|||||||
- `wut_enable_newlib(target)` - Links against the wut implementation of newlib, this is useful for using any function from the C standard library
|
- `wut_enable_newlib(target)` - Links against the wut implementation of newlib, this is useful for using any function from the C standard library
|
||||||
- `wut_enable_stdcpp(target)` - Links against the wut implementation of stdcpp, this is useful for using any function from the C++ standard library. This will call wut_enable_newlib if you have not already done so.
|
- `wut_enable_stdcpp(target)` - Links against the wut implementation of stdcpp, this is useful for using any function from the C++ standard library. This will call wut_enable_newlib if you have not already done so.
|
||||||
- `wut_default_malloc(target)` - By default newlib will allocate 90% of the default heap for use with sbrk & malloc, if this is unacceptable to you then you should use this as it replaces the newlib malloc functions which ones which redirect to the CafeOS default heap functions such as MEMAllocFromDefaultHeap.
|
- `wut_default_malloc(target)` - By default newlib will allocate 90% of the default heap for use with sbrk & malloc, if this is unacceptable to you then you should use this as it replaces the newlib malloc functions which ones which redirect to the CafeOS default heap functions such as MEMAllocFromDefaultHeap.
|
||||||
- `wut_enable_devoptab_sd(target)` - This links in wutdevoptab_sd which is useful for using the libc file functions with paths such as `fopen("sd:/file.txt", "r")` to read files from the sd card
|
- `wut_enable_devoptab(target)` - This links in wutdevoptab which is useful for using the libc file functions with paths such as `fopen("sd:/file.txt", "r")` to read files from the sd card
|
||||||
|
|
||||||
A minimal CMakeLists.txt file for a C++ project might look like:
|
A minimal CMakeLists.txt file for a C++ project might look like:
|
||||||
```
|
```
|
||||||
|
@ -11,7 +11,7 @@ add_subdirectory(libgfd)
|
|||||||
add_subdirectory(libwhb)
|
add_subdirectory(libwhb)
|
||||||
add_subdirectory(nn_swkbd)
|
add_subdirectory(nn_swkbd)
|
||||||
add_subdirectory(wutcrt)
|
add_subdirectory(wutcrt)
|
||||||
add_subdirectory(wutdevoptab_sd)
|
add_subdirectory(wutdevoptab)
|
||||||
add_subdirectory(wutmalloc)
|
add_subdirectory(wutmalloc)
|
||||||
add_subdirectory(wutnewlib)
|
add_subdirectory(wutnewlib)
|
||||||
add_subdirectory(wutstdc++)
|
add_subdirectory(wutstdc++)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
extern void __init_wut_devoptab_sd() __attribute__((weak));
|
|
||||||
extern void __init_wut_newlib() __attribute__((weak));
|
extern void __init_wut_newlib() __attribute__((weak));
|
||||||
|
extern void __init_wut_devoptab() __attribute__((weak));
|
||||||
extern void __init_wut_stdcpp() __attribute__((weak));
|
extern void __init_wut_stdcpp() __attribute__((weak));
|
||||||
|
|
||||||
extern void __fini_wut_devoptab_sd() __attribute__((weak));
|
extern void __fini_wut_devoptab() __attribute__((weak));
|
||||||
extern void __fini_wut_newlib() __attribute__((weak));
|
extern void __fini_wut_newlib() __attribute__((weak));
|
||||||
extern void __fini_wut_stdcpp() __attribute__((weak));
|
extern void __fini_wut_stdcpp() __attribute__((weak));
|
||||||
|
|
||||||
@ -13,8 +13,8 @@ __init_wut()
|
|||||||
__init_wut_newlib();
|
__init_wut_newlib();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__init_wut_devoptab_sd) {
|
if (__init_wut_devoptab) {
|
||||||
__init_wut_devoptab_sd();
|
__init_wut_devoptab();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__init_wut_stdcpp) {
|
if (__init_wut_stdcpp) {
|
||||||
@ -29,8 +29,8 @@ __fini_wut()
|
|||||||
__fini_wut_stdcpp();
|
__fini_wut_stdcpp();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__fini_wut_devoptab_sd) {
|
if (__fini_wut_devoptab) {
|
||||||
__fini_wut_devoptab_sd();
|
__fini_wut_devoptab();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__fini_wut_newlib) {
|
if (__fini_wut_newlib) {
|
||||||
|
34
libraries/wutdevoptab/CMakeLists.txt
Normal file
34
libraries/wutdevoptab/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.2)
|
||||||
|
project(wutdevoptab C)
|
||||||
|
|
||||||
|
add_library(wutdevoptab
|
||||||
|
devoptab_fs.c
|
||||||
|
devoptab_fs_chdir.c
|
||||||
|
devoptab_fs_chmod.c
|
||||||
|
devoptab_fs_close.c
|
||||||
|
devoptab_fs_dirclose.c
|
||||||
|
devoptab_fs_dirnext.c
|
||||||
|
devoptab_fs_diropen.c
|
||||||
|
devoptab_fs_dirreset.c
|
||||||
|
devoptab_fs_fchmod.c
|
||||||
|
devoptab_fs_fstat.c
|
||||||
|
devoptab_fs_fsync.c
|
||||||
|
devoptab_fs_getmtime.c
|
||||||
|
devoptab_fs_link.c
|
||||||
|
devoptab_fs_mkdir.c
|
||||||
|
devoptab_fs_open.c
|
||||||
|
devoptab_fs_read.c
|
||||||
|
devoptab_fs_rename.c
|
||||||
|
devoptab_fs_rmdir.c
|
||||||
|
devoptab_fs_seek.c
|
||||||
|
devoptab_fs_stat.c
|
||||||
|
devoptab_fs_statvfs.c
|
||||||
|
devoptab_fs_truncate.c
|
||||||
|
devoptab_fs_unlink.c
|
||||||
|
devoptab_fs_utils.c
|
||||||
|
devoptab_fs_write.c)
|
||||||
|
|
||||||
|
target_include_directories(wutdevoptab PRIVATE "${WUT_ROOT}/include")
|
||||||
|
|
||||||
|
install(TARGETS wutdevoptab
|
||||||
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
@ -1,9 +1,9 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
static devoptab_t
|
static devoptab_t
|
||||||
__wut_fs_devoptab =
|
__wut_fs_devoptab =
|
||||||
{
|
{
|
||||||
.name = "sd",
|
.name = "fs",
|
||||||
.structSize = sizeof(__wut_fs_file_t),
|
.structSize = sizeof(__wut_fs_file_t),
|
||||||
.open_r = __wut_fs_open,
|
.open_r = __wut_fs_open,
|
||||||
.close_r = __wut_fs_close,
|
.close_r = __wut_fs_close,
|
||||||
@ -29,18 +29,16 @@ __wut_fs_devoptab =
|
|||||||
.chmod_r = __wut_fs_chmod,
|
.chmod_r = __wut_fs_chmod,
|
||||||
.fchmod_r = __wut_fs_fchmod,
|
.fchmod_r = __wut_fs_fchmod,
|
||||||
.rmdir_r = __wut_fs_rmdir,
|
.rmdir_r = __wut_fs_rmdir,
|
||||||
// .lstat_r
|
|
||||||
// .utimes_r
|
|
||||||
};
|
};
|
||||||
|
|
||||||
FSClient *
|
FSClient *
|
||||||
__wut_devoptab_sd_client = NULL;
|
__wut_devoptab_fs_client = NULL;
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
__wut_fs_initialised = FALSE;
|
__wut_fs_initialised = FALSE;
|
||||||
|
|
||||||
FSStatus
|
FSStatus
|
||||||
__init_wut_devoptab_sd()
|
__init_wut_devoptab()
|
||||||
{
|
{
|
||||||
FSStatus rc = 0;
|
FSStatus rc = 0;
|
||||||
|
|
||||||
@ -48,17 +46,17 @@ __init_wut_devoptab_sd()
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
__wut_devoptab_sd_client = memalign(0x20, sizeof(FSClient));
|
__wut_devoptab_fs_client = memalign(0x20, sizeof(FSClient));
|
||||||
FSCmdBlock fsCmd;
|
FSCmdBlock fsCmd;
|
||||||
FSMountSource mountSource;
|
FSMountSource mountSource;
|
||||||
char mountPath[0x80];
|
char mountPath[0x80];
|
||||||
char workDir[0x83];
|
char workDir[0x83];
|
||||||
|
|
||||||
FSInit();
|
FSInit();
|
||||||
rc = FSAddClient(__wut_devoptab_sd_client, -1);
|
rc = FSAddClient(__wut_devoptab_fs_client, -1);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
free(__wut_devoptab_sd_client);
|
free(__wut_devoptab_fs_client);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,23 +70,23 @@ __init_wut_devoptab_sd()
|
|||||||
__wut_fs_initialised = TRUE;
|
__wut_fs_initialised = TRUE;
|
||||||
|
|
||||||
// Mount the SD card
|
// Mount the SD card
|
||||||
rc = FSGetMountSource(__wut_devoptab_sd_client, &fsCmd, FS_MOUNT_SOURCE_SD, &mountSource, -1);
|
rc = FSGetMountSource(__wut_devoptab_fs_client, &fsCmd, FS_MOUNT_SOURCE_SD, &mountSource, -1);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = FSMount(__wut_devoptab_sd_client, &fsCmd, &mountSource, mountPath, 0x80, -1);
|
rc = FSMount(__wut_devoptab_fs_client, &fsCmd, &mountSource, mountPath, 0x80, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
// chdir to SD root for general use
|
// chdir to SD root for general use
|
||||||
strcpy(workDir, "sd:");
|
strcpy(workDir, "fs:");
|
||||||
strcat(workDir, mountPath);
|
strcat(workDir, mountPath);
|
||||||
chdir(workDir);
|
chdir(workDir);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FSDelClient(__wut_devoptab_sd_client, -1);
|
FSDelClient(__wut_devoptab_fs_client, -1);
|
||||||
free(__wut_devoptab_sd_client);
|
free(__wut_devoptab_fs_client);
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +95,7 @@ __init_wut_devoptab_sd()
|
|||||||
}
|
}
|
||||||
|
|
||||||
FSStatus
|
FSStatus
|
||||||
__fini_wut_devoptab_sd()
|
__fini_wut_devoptab()
|
||||||
{
|
{
|
||||||
FSStatus rc = 0;
|
FSStatus rc = 0;
|
||||||
|
|
||||||
@ -105,7 +103,7 @@ __fini_wut_devoptab_sd()
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSDelClient(__wut_devoptab_sd_client, -1);
|
FSDelClient(__wut_devoptab_fs_client, -1);
|
||||||
free(__wut_devoptab_sd_client);
|
free(__wut_devoptab_fs_client);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
@ -46,7 +46,7 @@ typedef struct
|
|||||||
#define FS_DIRITER_MAGIC 0x77696975
|
#define FS_DIRITER_MAGIC 0x77696975
|
||||||
|
|
||||||
extern FSClient *
|
extern FSClient *
|
||||||
__wut_devoptab_sd_client;
|
__wut_devoptab_fs_client;
|
||||||
|
|
||||||
int __wut_fs_open(struct _reent *r, void *fileStruct, const char *path,
|
int __wut_fs_open(struct _reent *r, void *fileStruct, const char *path,
|
||||||
int flags, int mode);
|
int flags, int mode);
|
||||||
@ -78,6 +78,6 @@ int __wut_fs_chmod(struct _reent *r, const char *path, mode_t mode);
|
|||||||
int __wut_fs_fchmod(struct _reent *r, void *fd, mode_t mode);
|
int __wut_fs_fchmod(struct _reent *r, void *fd, mode_t mode);
|
||||||
int __wut_fs_rmdir(struct _reent *r, const char *name);
|
int __wut_fs_rmdir(struct _reent *r, const char *name);
|
||||||
|
|
||||||
// devoptab_sd_utils.c
|
// devoptab_fs_utils.c
|
||||||
char * __wut_fs_fixpath(struct _reent *r, const char *path);
|
char * __wut_fs_fixpath(struct _reent *r, const char *path);
|
||||||
int __wut_fs_translate_error(FSStatus error);
|
int __wut_fs_translate_error(FSStatus error);
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_chdir(struct _reent *r,
|
__wut_fs_chdir(struct _reent *r,
|
||||||
@ -21,7 +21,7 @@ __wut_fs_chdir(struct _reent *r,
|
|||||||
FSCmdBlock fsCmd;
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSChangeDir(__wut_devoptab_sd_client, &fsCmd, path, -1);
|
rc = FSChangeDir(__wut_devoptab_fs_client, &fsCmd, path, -1);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_chmod(struct _reent *r,
|
__wut_fs_chmod(struct _reent *r,
|
||||||
@ -17,7 +17,7 @@ __wut_fs_chmod(struct _reent *r,
|
|||||||
FSCmdBlock fsCmd;
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSChangeMode(__wut_devoptab_sd_client, &fsCmd, path_fix, (FSMode)mode, -1);
|
rc = FSChangeMode(__wut_devoptab_fs_client, &fsCmd, path_fix, (FSMode)mode, -1);
|
||||||
free(path_fix);
|
free(path_fix);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_close(struct _reent *r,
|
__wut_fs_close(struct _reent *r,
|
||||||
@ -11,7 +11,7 @@ __wut_fs_close(struct _reent *r,
|
|||||||
FSCmdBlock fsCmd;
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSCloseFile(__wut_devoptab_sd_client, &fsCmd, file->fd, -1);
|
rc = FSCloseFile(__wut_devoptab_fs_client, &fsCmd, file->fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_dirclose(struct _reent *r,
|
__wut_fs_dirclose(struct _reent *r,
|
||||||
@ -11,7 +11,7 @@ __wut_fs_dirclose(struct _reent *r,
|
|||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
__wut_fs_dir_t *dir = (__wut_fs_dir_t *)(dirState->dirStruct);
|
__wut_fs_dir_t *dir = (__wut_fs_dir_t *)(dirState->dirStruct);
|
||||||
rc = FSCloseDir(__wut_devoptab_sd_client, &fsCmd, dir->fd, -1);
|
rc = FSCloseDir(__wut_devoptab_fs_client, &fsCmd, dir->fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_dirnext(struct _reent *r,
|
__wut_fs_dirnext(struct _reent *r,
|
||||||
@ -15,7 +15,7 @@ __wut_fs_dirnext(struct _reent *r,
|
|||||||
|
|
||||||
// Fetch the next dir
|
// Fetch the next dir
|
||||||
memset(&dir->entry_data, 0, sizeof(dir->entry_data));
|
memset(&dir->entry_data, 0, sizeof(dir->entry_data));
|
||||||
rc = FSReadDir(__wut_devoptab_sd_client, &fsCmd, dir->fd, &dir->entry_data, -1);
|
rc = FSReadDir(__wut_devoptab_fs_client, &fsCmd, dir->fd, &dir->entry_data, -1);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
// There are no more entries; ENOENT signals end-of-directory
|
// There are no more entries; ENOENT signals end-of-directory
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
DIR_ITER *
|
DIR_ITER *
|
||||||
__wut_fs_diropen(struct _reent *r,
|
__wut_fs_diropen(struct _reent *r,
|
||||||
@ -24,7 +24,7 @@ __wut_fs_diropen(struct _reent *r,
|
|||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
__wut_fs_dir_t *dir = (__wut_fs_dir_t *)(dirState->dirStruct);
|
__wut_fs_dir_t *dir = (__wut_fs_dir_t *)(dirState->dirStruct);
|
||||||
rc = FSOpenDir(__wut_devoptab_sd_client, &fsCmd, path_fixed, &fd, -1);
|
rc = FSOpenDir(__wut_devoptab_fs_client, &fsCmd, path_fixed, &fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
dir->magic = FS_DIRITER_MAGIC;
|
dir->magic = FS_DIRITER_MAGIC;
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_dirreset(struct _reent *r,
|
__wut_fs_dirreset(struct _reent *r,
|
||||||
@ -11,7 +11,7 @@ __wut_fs_dirreset(struct _reent *r,
|
|||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
__wut_fs_dir_t *dir = (__wut_fs_dir_t *)(dirState->dirStruct);
|
__wut_fs_dir_t *dir = (__wut_fs_dir_t *)(dirState->dirStruct);
|
||||||
rc = FSRewindDir(__wut_devoptab_sd_client, &fsCmd, dir->fd, -1);
|
rc = FSRewindDir(__wut_devoptab_fs_client, &fsCmd, dir->fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_fchmod(struct _reent *r,
|
__wut_fs_fchmod(struct _reent *r,
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_fstat(struct _reent *r,
|
__wut_fs_fstat(struct _reent *r,
|
||||||
@ -13,7 +13,7 @@ __wut_fs_fstat(struct _reent *r,
|
|||||||
FSCmdBlock fsCmd;
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSGetStatFile(__wut_devoptab_sd_client, &fsCmd, file->fd, &fsstat, -1);
|
rc = FSGetStatFile(__wut_devoptab_fs_client, &fsCmd, file->fd, &fsstat, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
memset(st, 0, sizeof(struct stat));
|
memset(st, 0, sizeof(struct stat));
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_fsync(struct _reent *r,
|
__wut_fs_fsync(struct _reent *r,
|
||||||
@ -11,7 +11,7 @@ __wut_fs_fsync(struct _reent *r,
|
|||||||
FSCmdBlock fsCmd;
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSFlushFile(__wut_devoptab_sd_client, &fsCmd, file->fd, -1);
|
rc = FSFlushFile(__wut_devoptab_fs_client, &fsCmd, file->fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_getmtime(const char *name,
|
__wut_fs_getmtime(const char *name,
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_link(struct _reent *r,
|
__wut_fs_link(struct _reent *r,
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_mkdir(struct _reent *r,
|
__wut_fs_mkdir(struct _reent *r,
|
||||||
@ -23,7 +23,7 @@ __wut_fs_mkdir(struct _reent *r,
|
|||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// TODO: Use mode to set directory attributes.
|
// TODO: Use mode to set directory attributes.
|
||||||
rc = FSMakeDir(__wut_devoptab_sd_client, &fsCmd, path_fix, -1);
|
rc = FSMakeDir(__wut_devoptab_fs_client, &fsCmd, path_fix, -1);
|
||||||
free(path_fix);
|
free(path_fix);
|
||||||
|
|
||||||
if (rc == FS_ERROR_ALREADY_EXISTS) {
|
if (rc == FS_ERROR_ALREADY_EXISTS) {
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_open(struct _reent *r,
|
__wut_fs_open(struct _reent *r,
|
||||||
@ -48,12 +48,12 @@ __wut_fs_open(struct _reent *r,
|
|||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// Open the file
|
// Open the file
|
||||||
rc = FSOpenFile(__wut_devoptab_sd_client, &fsCmd, path_fixed, fs_mode, &fd, -1);
|
rc = FSOpenFile(__wut_devoptab_fs_client, &fsCmd, path_fixed, fs_mode, &fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
file->fd = fd;
|
file->fd = fd;
|
||||||
file->flags = (flags & (O_ACCMODE|O_APPEND|O_SYNC));
|
file->flags = (flags & (O_ACCMODE|O_APPEND|O_SYNC));
|
||||||
FSGetPosFile(__wut_devoptab_sd_client, &fsCmd, fd, &file->offset, -1);
|
FSGetPosFile(__wut_devoptab_fs_client, &fsCmd, fd, &file->offset, -1);
|
||||||
free(path_fixed);
|
free(path_fixed);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
__wut_fs_read(struct _reent *r,
|
__wut_fs_read(struct _reent *r,
|
||||||
@ -21,7 +21,7 @@ __wut_fs_read(struct _reent *r,
|
|||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
FSStat fsstat;
|
FSStat fsstat;
|
||||||
rc = FSGetStatFile(__wut_devoptab_sd_client, &fsCmd, file->fd, &fsstat, -1);
|
rc = FSGetStatFile(__wut_devoptab_fs_client, &fsCmd, file->fd, &fsstat, -1);
|
||||||
|
|
||||||
if(rc < 0) {
|
if(rc < 0) {
|
||||||
r->_errno = __wut_fs_translate_error(rc);
|
r->_errno = __wut_fs_translate_error(rc);
|
||||||
@ -39,7 +39,7 @@ __wut_fs_read(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the data
|
// Write the data
|
||||||
rc = FSReadFile(__wut_devoptab_sd_client, &fsCmd, tmp_buffer, 1, toRead, file->fd, 0, -1);
|
rc = FSReadFile(__wut_devoptab_fs_client, &fsCmd, tmp_buffer, 1, toRead, file->fd, 0, -1);
|
||||||
|
|
||||||
if(rc <= 0)
|
if(rc <= 0)
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_rename(struct _reent *r,
|
__wut_fs_rename(struct _reent *r,
|
||||||
@ -33,7 +33,7 @@ __wut_fs_rename(struct _reent *r,
|
|||||||
FSCmdBlock fsCmd;
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSRename(__wut_devoptab_sd_client, &fsCmd, path_old, path_new, -1);
|
rc = FSRename(__wut_devoptab_fs_client, &fsCmd, path_old, path_new, -1);
|
||||||
free(path_old);
|
free(path_old);
|
||||||
free(path_new);
|
free(path_new);
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_rmdir(struct _reent *r,
|
__wut_fs_rmdir(struct _reent *r,
|
||||||
@ -21,7 +21,7 @@ __wut_fs_rmdir(struct _reent *r,
|
|||||||
FSCmdBlock fsCmd;
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSRemove(__wut_devoptab_sd_client, &fsCmd, path_fix, -1);
|
rc = FSRemove(__wut_devoptab_fs_client, &fsCmd, path_fix, -1);
|
||||||
free(path_fix);
|
free(path_fix);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
__wut_fs_seek(struct _reent *r,
|
__wut_fs_seek(struct _reent *r,
|
||||||
@ -15,7 +15,7 @@ __wut_fs_seek(struct _reent *r,
|
|||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
FSStat fsstat;
|
FSStat fsstat;
|
||||||
rc = FSGetStatFile(__wut_devoptab_sd_client, &fsCmd, file->fd, &fsstat, -1);
|
rc = FSGetStatFile(__wut_devoptab_fs_client, &fsCmd, file->fd, &fsstat, -1);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
r->_errno = __wut_fs_translate_error(rc);
|
r->_errno = __wut_fs_translate_error(rc);
|
||||||
@ -54,7 +54,7 @@ __wut_fs_seek(struct _reent *r,
|
|||||||
|
|
||||||
// Update the current offset
|
// Update the current offset
|
||||||
file->offset = offset + pos;
|
file->offset = offset + pos;
|
||||||
FSStatus result = FSSetPosFile(__wut_devoptab_sd_client, &fsCmd, file->fd, file->offset, -1);
|
FSStatus result = FSSetPosFile(__wut_devoptab_fs_client, &fsCmd, file->fd, file->offset, -1);
|
||||||
|
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
return result;
|
return result;
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_stat(struct _reent *r,
|
__wut_fs_stat(struct _reent *r,
|
||||||
@ -17,23 +17,23 @@ __wut_fs_stat(struct _reent *r,
|
|||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// First try open as file
|
// First try open as file
|
||||||
rc = FSOpenFile(__wut_devoptab_sd_client, &fsCmd, file, "r", (FSFileHandle*)&fd, -1);
|
rc = FSOpenFile(__wut_devoptab_fs_client, &fsCmd, file, "r", (FSFileHandle*)&fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
__wut_fs_file_t tmpfd = { .fd = fd };
|
__wut_fs_file_t tmpfd = { .fd = fd };
|
||||||
rc = __wut_fs_fstat(r, &tmpfd, st);
|
rc = __wut_fs_fstat(r, &tmpfd, st);
|
||||||
FSCloseFile(__wut_devoptab_sd_client, &fsCmd, fd, -1);
|
FSCloseFile(__wut_devoptab_fs_client, &fsCmd, fd, -1);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// File failed, so lets try open as directory
|
// File failed, so lets try open as directory
|
||||||
rc = FSOpenDir(__wut_devoptab_sd_client, &fsCmd, file, (FSDirectoryHandle*)&fd, -1);
|
rc = FSOpenDir(__wut_devoptab_fs_client, &fsCmd, file, (FSDirectoryHandle*)&fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
memset(st, 0, sizeof(struct stat));
|
memset(st, 0, sizeof(struct stat));
|
||||||
st->st_nlink = 1;
|
st->st_nlink = 1;
|
||||||
st->st_mode = S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO;
|
st->st_mode = S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO;
|
||||||
FSCloseDir(__wut_devoptab_sd_client, &fsCmd, fd, -1);
|
FSCloseDir(__wut_devoptab_fs_client, &fsCmd, fd, -1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_statvfs(struct _reent *r,
|
__wut_fs_statvfs(struct _reent *r,
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_ftruncate(struct _reent *r,
|
__wut_fs_ftruncate(struct _reent *r,
|
||||||
@ -19,13 +19,13 @@ __wut_fs_ftruncate(struct _reent *r,
|
|||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// Set the new file size
|
// Set the new file size
|
||||||
rc = FSSetPosFile(__wut_devoptab_sd_client, &fsCmd, file->fd, len, -1);
|
rc = FSSetPosFile(__wut_devoptab_fs_client, &fsCmd, file->fd, len, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = FSTruncateFile(__wut_devoptab_sd_client, &fsCmd, file->fd, -1);
|
rc = FSTruncateFile(__wut_devoptab_fs_client, &fsCmd, file->fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
__wut_fs_unlink(struct _reent *r,
|
__wut_fs_unlink(struct _reent *r,
|
||||||
@ -21,7 +21,7 @@ __wut_fs_unlink(struct _reent *r,
|
|||||||
FSCmdBlock fsCmd;
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSRemove(__wut_devoptab_sd_client, &fsCmd, path_fix, -1);
|
rc = FSRemove(__wut_devoptab_fs_client, &fsCmd, path_fix, -1);
|
||||||
free(path_fix);
|
free(path_fix);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
char *
|
char *
|
||||||
__wut_fs_fixpath(struct _reent *r,
|
__wut_fs_fixpath(struct _reent *r,
|
@ -1,4 +1,4 @@
|
|||||||
#include "devoptab_sd.h"
|
#include "devoptab_fs.h"
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
__wut_fs_write(struct _reent *r,
|
__wut_fs_write(struct _reent *r,
|
||||||
@ -34,7 +34,7 @@ __wut_fs_write(struct _reent *r,
|
|||||||
FSInitCmdBlock(&fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// Write the data
|
// Write the data
|
||||||
rc = FSWriteFile(__wut_devoptab_sd_client, &fsCmd, tmp_buffer, 1, toWrite, file->fd, 0, -1);
|
rc = FSWriteFile(__wut_devoptab_fs_client, &fsCmd, tmp_buffer, 1, toWrite, file->fd, 0, -1);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
free(tmp_buffer);
|
free(tmp_buffer);
|
@ -1,34 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.2)
|
|
||||||
project(wutdevoptab_sd C)
|
|
||||||
|
|
||||||
add_library(wutdevoptab_sd
|
|
||||||
devoptab_sd.c
|
|
||||||
devoptab_sd_chdir.c
|
|
||||||
devoptab_sd_chmod.c
|
|
||||||
devoptab_sd_close.c
|
|
||||||
devoptab_sd_dirclose.c
|
|
||||||
devoptab_sd_dirnext.c
|
|
||||||
devoptab_sd_diropen.c
|
|
||||||
devoptab_sd_dirreset.c
|
|
||||||
devoptab_sd_fchmod.c
|
|
||||||
devoptab_sd_fstat.c
|
|
||||||
devoptab_sd_fsync.c
|
|
||||||
devoptab_sd_getmtime.c
|
|
||||||
devoptab_sd_link.c
|
|
||||||
devoptab_sd_mkdir.c
|
|
||||||
devoptab_sd_open.c
|
|
||||||
devoptab_sd_read.c
|
|
||||||
devoptab_sd_rename.c
|
|
||||||
devoptab_sd_rmdir.c
|
|
||||||
devoptab_sd_seek.c
|
|
||||||
devoptab_sd_stat.c
|
|
||||||
devoptab_sd_statvfs.c
|
|
||||||
devoptab_sd_truncate.c
|
|
||||||
devoptab_sd_unlink.c
|
|
||||||
devoptab_sd_utils.c
|
|
||||||
devoptab_sd_write.c)
|
|
||||||
|
|
||||||
target_include_directories(wutdevoptab_sd PRIVATE "${WUT_ROOT}/include")
|
|
||||||
|
|
||||||
install(TARGETS wutdevoptab_sd
|
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
|
@ -1,47 +0,0 @@
|
|||||||
#include "devoptab_sd.h"
|
|
||||||
|
|
||||||
char *
|
|
||||||
__wut_fs_fixpath(struct _reent *r,
|
|
||||||
const char *path)
|
|
||||||
{
|
|
||||||
char *p = strchr(path, ':')+1;
|
|
||||||
|
|
||||||
if(!strchr(path, ':')) {
|
|
||||||
p = (char*)path;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strlen(p) > PATH_MAX) {
|
|
||||||
r->_errno = ENAMETOOLONG;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *__fixedpath = memalign(0x40, PATH_MAX+1);
|
|
||||||
|
|
||||||
if (__fixedpath == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cwd is handled by coreinit, so just strip the 'fs:' if it exists
|
|
||||||
strcpy(__fixedpath, p);
|
|
||||||
return __fixedpath;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
__wut_fs_translate_error(FSStatus error)
|
|
||||||
{
|
|
||||||
switch (error) {
|
|
||||||
case FS_STATUS_CANCELLED:
|
|
||||||
return EINVAL;
|
|
||||||
case FS_STATUS_EXISTS:
|
|
||||||
return EEXIST;
|
|
||||||
case FS_STATUS_NOT_FOUND:
|
|
||||||
return ENOENT;
|
|
||||||
case FS_STATUS_STORAGE_FULL:
|
|
||||||
return ENOSPC;
|
|
||||||
case FS_ERROR_INVALID_PATH:
|
|
||||||
return ENAMETOOLONG;
|
|
||||||
default:
|
|
||||||
return (int)error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -25,14 +25,14 @@ macro(wut_enable_stdcpp target)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Links against devoptab_sd
|
# Links against devoptab
|
||||||
macro(wut_enable_devoptab_sd target)
|
macro(wut_enable_devoptab target)
|
||||||
get_property(ENABLED_DEVOPTAB_SD TARGET ${target} PROPERTY WUT_ENABLE_DEVOPTAB_SD)
|
get_property(ENABLED_DEVOPTAB TARGET ${target} PROPERTY WUT_ENABLE_DEVOPTAB)
|
||||||
if(NOT DEFINED ENABLED_DEVOPTAB_SD)
|
if(NOT DEFINED ENABLED_DEVOPTAB)
|
||||||
target_link_libraries(${target}
|
target_link_libraries(${target}
|
||||||
-Wl,--whole-archive wutdevoptab_sd -Wl,--no-whole-archive)
|
-Wl,--whole-archive wutdevoptab -Wl,--no-whole-archive)
|
||||||
|
|
||||||
set_target_properties(${target} PROPERTIES WUT_ENABLE_DEVOPTAB_SD 1)
|
set_target_properties(${target} PROPERTIES WUT_ENABLE_DEVOPTAB 1)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user