Skip to content

Restore old symlink behaviour on Linux - #2558

Draft
Castor215 wants to merge 1 commit into
ares-emulator:masterfrom
Castor215:restore-symlink-behaviour
Draft

Castor215 wants to merge 1 commit into
ares-emulator:masterfrom
Castor215:restore-symlink-behaviour

Conversation

@Castor215

Copy link
Copy Markdown

Closes #2557

As expressed in the issue, this needs feedback from other Linux users. Did pre-v148 ares not handle symlinks on your distro? Did the changes in v148 fix any issues? I don't want to cause any regressions so I'm opening this as a draft pending feedback.

@remutro

remutro commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

I plan on reviewing behavior again. I think there is likely more changes that we might want to make even if this works, but I'll know more when I have some time to spend on it.

@bsdcode

bsdcode commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

I can confirm v148 on FreeBSD is also affected. Didn't test previous versions. I couldn't test the proposed fix yet, but an additional || defined (PLATFORM_BSD) would probably be necessary.

@Castor215
Castor215 force-pushed the restore-symlink-behaviour branch from 1f90126 to 9c98201 Compare June 2, 2026 15:21
@Castor215

Copy link
Copy Markdown
Author

I plan on reviewing behavior again. I think there is likely more changes that we might want to make even if this works, but I'll know more when I have some time to spend on it.

Fair enough. If it helps, this is the problematic line in nall/nall/directory.cpp

158        if(readlink(result.data(), buffer, PATH_MAX) < PATH_MAX) {

readlink is returning relative links "as is" i.e. keeping them relative. The only way I can see around this is detecting if the first character is not /, finding the path of the link itself in that case and constructing the path contained in the link manually.

When execution returns to Emulator::load, you would need to detect if location is a symlink (absolute or otherwise) or not so the last used directory gets set to the symlink's location.

@bsdcode

bsdcode commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Fix is working on FreeBSD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Relative symlinks broken on Linux; absolute symlinks change last used directory

3 participants