@dascandy There's #systemd's chase()/chaseat() [1] and @cyphar 's #libpathrs [2]. Both are pretty good and cover a lot of edge cases.
[1]: https://github.com/systemd/systemd/blob/main/src/basic/chase.c
[2]: https://github.com/cyphar/libpathrs/?tab=readme-ov-file