diff --git a/Makefile b/Makefile index 19bf442..4ac3d0a 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions ASFLAGS := -g $(ARCH) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lxml2 -lz -lusbhsfsd -lnx -ljson-c -lm `freetype-config --libs` -lturbojpeg +LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lxml2 -lz -lusbhsfs -lnx -ljson-c -lm `freetype-config --libs` -lturbojpeg #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/build.sh b/build.sh index af9462a..da14b42 100644 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/bash cd "$(dirname "${BASH_SOURCE[0]}")" -tar_filename="nxdumptool-rewrite_poc_$(shell git rev-parse --short HEAD).tar.bz2" +tar_filename="nxdumptool-rewrite_poc_$(git rev-parse --short HEAD).tar.bz2" rm -f ./*.tar.bz2 diff --git a/code_templates/nsp_dumper_sd.c b/code_templates/nsp_dumper_sd.c index 812fab8..8668849 100644 --- a/code_templates/nsp_dumper_sd.c +++ b/code_templates/nsp_dumper_sd.c @@ -681,7 +681,7 @@ end: { fclose(fd); if (!success) utilsRemoveConcatenationFile(path); - utilsCommitFileSystemChangesByPath(path); + utilsCommitSdCardFileSystemChanges(); } pfsFreeFileContext(&pfs_file_ctx); diff --git a/code_templates/system_title_dumper.c b/code_templates/system_title_dumper.c index 31702dd..630f474 100644 --- a/code_templates/system_title_dumper.c +++ b/code_templates/system_title_dumper.c @@ -118,7 +118,7 @@ end: remove(path); } - if (*path) utilsCommitFileSystemChangesByPath(path); + if (*path) utilsCommitSdCardFileSystemChanges(); pfsFreeContext(&pfs_ctx); } @@ -194,7 +194,7 @@ end: remove(path); } - if (*path) utilsCommitFileSystemChangesByPath(path); + if (*path) utilsCommitSdCardFileSystemChanges(); romfsFreeContext(&romfs_ctx); } diff --git a/source/utils.c b/source/utils.c index 92d19fd..71d66fe 100644 --- a/source/utils.c +++ b/source/utils.c @@ -69,8 +69,6 @@ static bool _utilsIsDevelopmentUnit(void); static bool utilsMountEmmcBisSystemPartitionStorage(void); static void utilsUnmountEmmcBisSystemPartitionStorage(void); -static bool utilsGetDeviceFileSystemAndFilePathFromAbsolutePath(const char *path, FsFileSystem **out_fs, char **out_filepath); - static void utilsOverclockSystemAppletHook(AppletHookType hook, void *param); bool utilsInitializeResources(void) @@ -583,46 +581,11 @@ void utilsGenerateFormattedSizeString(u64 size, char *dst, size_t dst_size) } } -bool utilsGetFreeSpaceFromFileSystem(FsFileSystem *fs, u64 *out) -{ - if (!fs || !serviceIsActive(&(fs->s)) || !out) - { - LOGFILE("Invalid parameters!"); - return false; - } - - Result rc = fsFsGetFreeSpace(fs, "/", (s64*)out); - if (R_FAILED(rc)) LOGFILE("fsFsGetFreeSpace failed! (0x%08X).", rc); - - return R_SUCCEEDED(rc); -} - -bool utilsGetFreeSpaceFromFileSystemByPath(const char *path, u64 *out) -{ - FsFileSystem *fs = NULL; - - if (!utilsGetDeviceFileSystemAndFilePathFromAbsolutePath(path, &fs, NULL) || !out) - { - LOGFILE("Invalid parameters!"); - return false; - } - - return utilsGetFreeSpaceFromFileSystem(fs, out); -} - bool utilsGetFreeSdCardFileSystemSpace(u64 *out) { - return utilsGetFreeSpaceFromFileSystem(g_sdCardFileSystem, out); -} - -bool utilsCommitFileSystemChangesByPath(const char *path) -{ - Result rc = 0; - FsFileSystem *fs = NULL; - - if (!utilsGetDeviceFileSystemAndFilePathFromAbsolutePath(path, &fs, NULL)) return false; - - rc = fsFsCommit(fs); + if (!g_sdCardFileSystem) return false; + Result rc = fsFsGetFreeSpace(g_sdCardFileSystem, "/", (s64*)out); + if (R_FAILED(rc)) LOGFILE("fsFsGetFreeSpace failed! (0x%08X).", rc); return R_SUCCEEDED(rc); } @@ -670,8 +633,6 @@ bool utilsCreateConcatenationFile(const char *path) Result rc = fsdevCreateFile(path, 0, FsCreateOption_BigFile); if (R_FAILED(rc)) LOGFILE("fsdevCreateFile failed for \"%s\"! (0x%08X).", path, rc); - utilsCommitFileSystemChangesByPath(path); - return R_SUCCEEDED(rc); } @@ -696,8 +657,6 @@ void utilsCreateDirectoryTree(const char *path, bool create_last_element) if (create_last_element) mkdir(path, 0777); free(tmp); - - utilsCommitFileSystemChangesByPath(path); } char *utilsGeneratePath(const char *prefix, const char *filename, const char *extension) @@ -861,25 +820,6 @@ static void utilsUnmountEmmcBisSystemPartitionStorage(void) } } -static bool utilsGetDeviceFileSystemAndFilePathFromAbsolutePath(const char *path, FsFileSystem **out_fs, char **out_filepath) -{ - FsFileSystem *fs = NULL; - char *name_end = NULL, *filepath = NULL, name[32] = {0}; - - if (!path || !*path || !(name_end = strchr(path, ':')) || (size_t)(name_end - path) >= MAX_ELEMENTS(name) || (!out_fs && !out_filepath) || \ - (out_filepath && *(filepath = (name_end + 1)) != '/')) return false; - - sprintf(name, "%.*s", (int)(name_end - path), path); - - fs = fsdevGetDeviceFileSystem(name); - if (!fs) return false; - - if (out_fs) *out_fs = fs; - if (out_filepath) *out_filepath = filepath; - - return true; -} - static void utilsOverclockSystemAppletHook(AppletHookType hook, void *param) { (void)param; diff --git a/source/utils.h b/source/utils.h index e7e9144..2aa8c19 100644 --- a/source/utils.h +++ b/source/utils.h @@ -102,11 +102,7 @@ void utilsGenerateHexStringFromData(char *dst, size_t dst_size, const void *src, void utilsGenerateFormattedSizeString(u64 size, char *dst, size_t dst_size); -bool utilsGetFreeSpaceFromFileSystem(FsFileSystem *fs, u64 *out); -bool utilsGetFreeSpaceFromFileSystemByPath(const char *path, u64 *out); bool utilsGetFreeSdCardFileSystemSpace(u64 *out); - -bool utilsCommitFileSystemChangesByPath(const char *path); bool utilsCommitSdCardFileSystemChanges(void); bool utilsCheckIfFileExists(const char *path);