// only for saves on sdcard DECL(int, FSRenameAsync, void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error, void *asyncParams) { int client = GetCurClient(pClient); if (client != -1) { // log fs_log_string(bss.socket_fs[client], oldPath, BYTE_RENAME); fs_log_string(bss.socket_fs[client], newPath, BYTE_RENAME); // change path if it is a save folder int pathType = getPathType(oldPath); if (pathType == PATH_TYPE_SAVE) { // old path int len_base = getNewPathLen(pathType); int len_old = strlen(oldPath); char new_old_path[len_old + len_base + 1]; compute_new_path(new_old_path, oldPath, len_old, pathType); // new path int len_new = strlen(newPath); char new_new_path[len_new + len_base + 1]; compute_new_path(new_new_path, newPath, len_new, pathType); // log new path fs_log_string(bss.socket_fs[client], new_old_path, BYTE_LOG_STR); fs_log_string(bss.socket_fs[client], new_new_path, BYTE_LOG_STR); return real_FSRenameAsync(pClient, pCmd, new_old_path, new_new_path, error, asyncParams); } } return real_FSRenameAsync(pClient, pCmd, oldPath, newPath, error, asyncParams); }
DECL(int, FSGetFreeSpaceSizeAsync, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error, void *asyncParams) { int client = GetCurClient(pClient); if (client != -1) { // log //fs_log_string(bss.socket_fs[client], path, BYTE_REMOVE); char buffer[200]; __os_snprintf(buffer, sizeof(buffer), "FSGetFreeSpaceSizeAsync: %s", path); fs_log_string(bss.global_sock, buffer, BYTE_LOG_STR); // change path if it is a save folder int pathType = getPathType(path); if (pathType == PATH_TYPE_SAVE) { int len = strlen(path); int len_base = getNewPathLen(pathType); char new_path[len + len_base + 1]; compute_new_path(new_path, path, len, pathType); // log new path fs_log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR); return real_FSGetFreeSpaceSizeAsync(pClient, pCmd, new_path, returnedFreeSize, error, asyncParams); } } return real_FSGetFreeSpaceSizeAsync(pClient, pCmd, path, returnedFreeSize, error, asyncParams); }
void fs_log(const char *format, ...) { va_list ap; va_start(ap, format); char *buffer = g_strdup_vprintf(format, ap); va_end(ap); fs_log_string(buffer); g_free(buffer); }
DECL(int, OSDynLoad_GetModuleName, unsigned int *handle, char *name_buffer, int *name_buffer_size) { int result = real_OSDynLoad_GetModuleName(handle, name_buffer, name_buffer_size); if ((int)bss_ptr != 0x0a000000) { char buffer[200]; __os_snprintf(buffer, sizeof(buffer), "OSDynLoad_GetModuleName: %s result %i", (name_buffer && result == 0) ? name_buffer : "NULL", result); fs_log_string(bss.global_sock, buffer, BYTE_LOG_STR); } return result; }
DECL(int, OSDynLoad_IsModuleLoaded, char* rpl, unsigned int *handle, int r5 __attribute__((unused))) { int result = real_OSDynLoad_IsModuleLoaded(rpl, handle, 1); if ((int)bss_ptr != 0x0a000000) { char buffer[200]; __os_snprintf(buffer, sizeof(buffer), "OSDynLoad_IsModuleLoaded: %s result %i", rpl, result); fs_log_string(bss.global_sock, buffer, BYTE_LOG_STR); } return result; }
// only for saves on sdcard DECL(int, FSMakeDir, void *pClient, void *pCmd, const char *path, int error) { int client = GetCurClient(pClient); if (client != -1) { // log fs_log_string(bss.socket_fs[client], path, BYTE_MAKE_DIR); // change path if it is a save folder int pathType = getPathType(path); if (pathType == PATH_TYPE_SAVE) { int len = strlen(path); int len_base = getNewPathLen(pathType); char new_path[len + len_base + 1]; compute_new_path(new_path, path, len, pathType); // log new path fs_log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR); return real_FSMakeDir(pClient, pCmd, new_path, error); } } return real_FSMakeDir(pClient, pCmd, path, error); }
DECL(int, FSRollbackQuota, void *pClient, void *pCmd, const char *path, int error) { int client = GetCurClient(pClient); if (client != -1) { // log char buffer[200]; __os_snprintf(buffer, sizeof(buffer), "FSRollbackQuota: %s", path); fs_log_string(bss.global_sock, buffer, BYTE_LOG_STR); // change path if it is a save folder int pathType = getPathType(path); if (pathType == PATH_TYPE_SAVE) { int len = strlen(path); int len_base = getNewPathLen(pathType); char new_path[len + len_base + 1]; compute_new_path(new_path, path, len, pathType); // log new path fs_log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR); return real_FSRollbackQuota(pClient, pCmd, new_path, error); } } return real_FSRollbackQuota(pClient, pCmd, path, error); }
DECL(int, FSGetVolumeState_log, void *pClient) { int result = real_FSGetVolumeState_log(pClient); if ((int)bss_ptr != 0x0a000000) { if (result > 1) { int error = real_FSGetLastError_log(pClient); char buffer[200]; __os_snprintf(buffer, sizeof(buffer), "FSGetVolumeState: %i, last error = %i", result, error); fs_log_string(bss.global_sock, buffer, BYTE_LOG_STR); } } return result; }
void fs_config_set_log_file(const char *path) { fs_log("switch to log file %s\n", path); fs_mutex_lock(log.mutex); if (log.file) { fclose(log.file); } log.file = g_fopen(path, "w"); if (log.file) { printf("LOG: %s\n", path); if (log.initial_path) { FILE *f = g_fopen(log.initial_path, "r"); if (f) { char *buffer = (char *) g_malloc(1024); int read = fread(buffer, 1, 1024, f); while (read > 0) { fwrite(buffer, 1, read, log.file); read = fread(buffer, 1, 1024, f); } g_free(buffer); fclose(f); } } } /* All options should have been read, so we can no check log options */ if (fs_config_get_boolean("flush_log") == 1) { log.flush = 1; } fs_mutex_unlock(log.mutex); if (log.flush) { fs_log_string("flush_log: will flush log after each log line\n"); } }
static void log_to_libfsemu(const char *message) { fs_log_string(message); }