-
-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chdir does not work with/crashes when given relative paths #138
Comments
The newlib code is supposed to handle relative path components before passing a path down to the driver's code. It would be interesting to see what path is passed to sdmc_chdir(). |
So this is what I have found: https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/patches/newlib-2.2.0.patch#L779 https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/patches/newlib-2.2.0.patch#L782 https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/patches/newlib-2.2.0.patch#L785 |
I think this would probably work: strncpy (temp_cwd, _current_working_directory, PATH_MAX);
}
- pathPosition = strchr (temp_cwd , ':') + 1;
+ pathPosition = strchr (temp_cwd , ':');
+ if (pathPosition == NULL)
+ pathPosition = temp_cwd;
+ else
+ ++pathPosition;
/* Make sure the path starts in the root directory */
if (pathPosition[0] != DIRECTORY_SEPARATOR_CHAR) { |
For what it's worth, this has nothing to do with relative directories. You can recreate it by simply performing the first chdir() with any path which does not have a colon ":". |
While reworking my gpsp port's file code I found that chdir has a borked behavior in that it cannot chdir to relative file locations. As an example, doing a
chdir(".");
will actually cause ctrulib to crash to home. Same withchdir("..");
. Even if you try to chdir to an exiting directory within the current working directory, it will crash. A simple test to check against this bug is just achdir(".")
after initializing sdmc.Also, getcwd seems to return "/" initially rather than "sdmc:/", up until you explicitly
chdir("sdmc:/")
. Doesn't seem to affect anything, but it's there. I believe @mtheall is the one I should be talking with on this issue.The text was updated successfully, but these errors were encountered: