On Thu Feb 15 20:45:58 2024 +0000, Zebediah Figura wrote:
Well, the race condition exists as soon as you're calling readlink() even once, and I don't think they're meaningful anyway (what's the application going to do with this information?) But I also don't understand why returning a symlink instead of the target is important?
I think there's a misunderstanding here. I'll try with an example maybe it's clearer. Let's say the file's path is `/path/to/file` and we want to retrieve it.
With F_GETPATH, we just call it on the fd and we get /path/to/file — we're done.
On Linux we need to do something like readlink("/proc/self/fd/42"), because `/proc/self/fd/42` is a symlink to `/path/to/file` (or whatever).
How do you want to avoid checking for linux here? If we call readlink unconditionally, then we'll end up with readlink("/path/to/file") on other platforms which is the thing I was mentioning being wrong.