osGetSystemVersionData causes file access to fail
It appears that after using osGetSystemVersionData I can no longer open files. Here's some example code that shows the bug: https://gist.github.com/svanheulen/c02033d70f674c2a3169 The first attempt to open the file will succeed (remember to make the "test.txt" file) Then the second attempt, after osGetSystemVersionData is used, will fail.
I can confirm this. errno is set to ENOSYS
It appears that sdmc_open() is not being called for the second fopen(), even if I set the path to "sdmc:/test.txt"
After calling osGetSystemVersionData(), FindDevice("sdmc:") returns -1.
I can confirm that before osGetSystemVersionData(), the devoptab_list[] has the following contents: devoptab_list[1] -> con devoptab_list[2] -> con devoptab_list[3] -> sdmc
After osGetSystemVersionData(), the devoptab_list[] has the following contents: devoptab_list[1] -> con devoptab_list[2] -> con devoptab_list[3] -> dotab_stdnull devoptab_list[4] -> romfs
osGetSystemVersionData() calls __read_versionbin() __read_versionbin() calls romfsInitFromFile()/romfsExit() but after romfsExit() the sdmc dev is gone but romfs dev is still there. problem in newlib or libctru?
I noticed in __read_versionbin() it calls FSUSER_OpenFileDirectly but never calls FSFILE_Close on that handle. Could that be an issue?
Fixed with 07f0fe7e6
It probably is a bug that the file handle isn't closed, but that wasn't the cause of this issue.
I noticed in __read_versionbin() it calls FSUSER_OpenFileDirectly but never calls FSFILE_Close on that handle. Could that be an issue?
Nope, the file is closed by romfsExit() here https://github.com/smealum/ctrulib/blob/master/libctru/source/romfs_dev.c#L228
Awesome! Thanks for fixing that so fast!
No problem, I'm glad it wasn't something harder to debug.