|
|
Log in / Subscribe / Register

The trouble with symbolic links

The trouble with symbolic links

Posted Jul 9, 2022 3:31 UTC (Sat) by Subsentient (guest, #142918)
Parent article: The trouble with symbolic links

I *love* symlinks as they are, and I use them constantly, but the author makes some good points, especially with the race condition. This should all be fixable with new system calls/libc functions. Please don't mess with symlinks in general.

I personally don't *want* most userspace programs to be able to tell if something is a link. I've much more often had issues with a program that saw a symlink and refused to dereference it, than I ever have with a program that used them implicitly.

Note to other userspace developers: Please use stat() instead of lstat() whenever possible. You don't know if there's a good reason it's a symlink, for example, a .config folder could be pointing into an sshfs network drive so my settings are synced between machines. I put symlinks in weird places if I think they're useful, and the only times it hurts me are when some application is using lstat() and/or looking for symlinks some other way.


to post comments

The trouble with symbolic links

Posted Jul 9, 2022 11:55 UTC (Sat) by mathstuf (subscriber, #69389) [Link]

> Please use stat() instead of lstat() whenever possible.

One place you can't is when asking "does this path exist?" because `stat` will return "no" for broken (or looped) symlinks while `lstat` will say "yes".


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds