diff --git a/libraries/wutdevoptab/devoptab_fsa_utils.cpp b/libraries/wutdevoptab/devoptab_fsa_utils.cpp index b5de3bcc9..d09de7295 100644 --- a/libraries/wutdevoptab/devoptab_fsa_utils.cpp +++ b/libraries/wutdevoptab/devoptab_fsa_utils.cpp @@ -73,10 +73,16 @@ time_t __wut_fsa_translate_time(FSTime timeValue) { return (timeValue /1000000) + EPOCH_DIFF_SECS(WIIU_FSTIME_EPOCH_YEAR); } -void __wut_fsa_translate_stat(FSAClientHandle handle, FSStat* fsStat, struct stat* posStat) { +static int __wut_fsa_info_fake_value_t = 0; +void __wut_fsa_translate_stat(FSAClientHandle clientHandle, FSStat* fsStat, struct stat* posStat) { memset(posStat, 0, sizeof(struct stat)); - posStat->st_ino = fsStat->entryId; - posStat->st_dev = (dev_t) handle; + posStat->st_dev = (dev_t) clientHandle; + // To have std::filesystem::copy support, we have to have unique st_ino values for two different files + // It's not really possible to get a unique value per file on Wii U, so instead we give everything a unique value. + // This means identifying the same file by st_ino would not work properly, but Cafe OS only allows us to open each file + // only once anyway. + // TODO: replace with hash of canonicalized path + posStat->st_ino = __wut_fsa_info_fake_value_t++; posStat->st_mode = __wut_fsa_translate_stat_mode(fsStat); posStat->st_nlink = 1; posStat->st_uid = fsStat->owner;