diff --git a/Makefile b/Makefile index 31867f5..7e28341 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ MAKEFLAGS += --no-print-directory #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lgcc -lgd -lpng -lz -lfreetype -lvorbisidec +LIBS := -lgcc -lgd -lpng -lz -lfreetype -lvorbisidec -liosuhax #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/src/dynamic_libs/os_functions.c b/src/dynamic_libs/os_functions.c index b492bc0..93c4f5f 100644 --- a/src/dynamic_libs/os_functions.c +++ b/src/dynamic_libs/os_functions.c @@ -74,6 +74,10 @@ EXPORT_DECL(int, OSScreenFlipBuffersEx, unsigned int bufferNum); EXPORT_DECL(int, OSScreenPutFontEx, unsigned int bufferNum, unsigned int posX, unsigned int posY, const char * buffer); EXPORT_DECL(int, OSScreenEnableEx, unsigned int bufferNum, int enable); +EXPORT_DECL(int, IOS_Ioctl,int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len); +EXPORT_DECL(int, IOS_Open,char *path, unsigned int mode); +EXPORT_DECL(int, IOS_Close,int fd); + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Memory functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -162,5 +166,11 @@ void InitOSFunctionPointers(void) OS_FIND_EXPORT(coreinit_handle, MEMCreateExpHeapEx); OS_FIND_EXPORT(coreinit_handle, MEMDestroyExpHeap); OS_FIND_EXPORT(coreinit_handle, MEMFreeToExpHeap); -} + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //! Other function addresses + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + OS_FIND_EXPORT(coreinit_handle, IOS_Ioctl); + OS_FIND_EXPORT(coreinit_handle, IOS_Open); + OS_FIND_EXPORT(coreinit_handle, IOS_Close); +} diff --git a/src/dynamic_libs/os_functions.h b/src/dynamic_libs/os_functions.h index f890521..11c46b6 100644 --- a/src/dynamic_libs/os_functions.h +++ b/src/dynamic_libs/os_functions.h @@ -105,6 +105,9 @@ extern void (* DCFlushRange)(const void *addr, u32 length); extern void (* ICInvalidateRange)(const void *addr, u32 length); extern void* (* OSEffectiveToPhysical)(const void*); extern int (* __os_snprintf)(char* s, int n, const char * format, ...); +extern int (*IOS_Ioctl)(int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len); +extern int (*IOS_Open)(char *path, unsigned int mode); +extern int (*IOS_Close)(int fd); extern void (*OSScreenInit)(void); extern unsigned int (*OSScreenGetBufferSizeEx)(unsigned int bufferNum); diff --git a/src/main.c b/src/main.c index 258adba..a394868 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,9 @@ #include #include #include +#include +#include +#include #include "dynamic_libs/os_functions.h" #include "dynamic_libs/fs_functions.h" #include "dynamic_libs/gx2_functions.h" @@ -109,6 +112,27 @@ int Menu_Main(void) log_printf("Mount SD partition\n"); mount_sd_fat("sd"); + int res = IOSUHAX_Open(); + if(res < 0) + { + log_printf("IOSUHAX_open failed\n"); + } + + int fsaFd = IOSUHAX_FSA_Open(); + if(fsaFd < 0) + { + log_printf("IOSUHAX_FSA_Open failed\n"); + } + + mount_fs("slccmpt01", fsaFd, "/dev/slccmpt01", "/vol/storage_slccmpt01"); + mount_fs("storage_odd_tickets", fsaFd, "/dev/odd01", "/vol/storage_odd_tickets"); + mount_fs("storage_odd_updates", fsaFd, "/dev/odd02", "/vol/storage_odd_updates"); + mount_fs("storage_odd_content", fsaFd, "/dev/odd03", "/vol/storage_odd_content"); + mount_fs("storage_odd_content2", fsaFd, "/dev/odd04", "/vol/storage_odd_content2"); + mount_fs("storage_slc", fsaFd, NULL, "/vol/system"); + mount_fs("storage_mlc", fsaFd, NULL, "/vol/storage_mlc01"); + mount_fs("storage_usb", fsaFd, NULL, "/vol/storage_usb01"); + for(int i = 0; i < MAX_CONSOLE_LINES_TV; i++) consoleArrayTv[i] = NULL; @@ -194,6 +218,18 @@ int Menu_Main(void) log_printf("Unmount SD\n"); unmount_sd_fat("sd"); + + unmount_fs("slccmpt01"); + unmount_fs("storage_odd_tickets"); + unmount_fs("storage_odd_updates"); + unmount_fs("storage_odd_content"); + unmount_fs("storage_odd_content2"); + unmount_fs("storage_slc"); + unmount_fs("storage_mlc"); + unmount_fs("storage_usb"); + IOSUHAX_FSA_Close(fsaFd); + IOSUHAX_Close(); + log_printf("Release memory\n"); //memoryRelease(); log_deinit(); diff --git a/src/virtualpath.c b/src/virtualpath.c index 9dafb60..4d6eda8 100644 --- a/src/virtualpath.c +++ b/src/virtualpath.c @@ -94,6 +94,14 @@ void AddVirtualPath(const char *name, const char *alias, const char *prefix) void MountVirtualDevices() { VirtualMountDevice("sd:/"); + 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:/"); } void UnmountVirtualPaths() diff --git a/src/vrt.c b/src/vrt.c index 5f22aa0..e4ed863 100644 --- a/src/vrt.c +++ b/src/vrt.c @@ -191,8 +191,12 @@ FILE *vrt_fopen(char *cwd, char *path, char *mode) { int vrt_stat(char *cwd, char *path, struct stat *st) { char *real_path = to_real_path(cwd, path); - if (!real_path) return -1; - else if (!*real_path) { + if (!real_path) + { + return -1; + } + else if (!*real_path || (strcmp(path, ".") == 0) || (strlen(cwd) == 1) || ((strlen(cwd) > 1) && (strcmp(path, "..") == 0))) + { st->st_mode = S_IFDIR; st->st_size = 31337; return 0;