On Fri Feb 7 00:00:01 2025 +0000, Jinoh Kang wrote:
I think `lookup_unix_name` is supposed to reject trailing slashes with `OBJECT_NAME_INVALID`, because it's just a special case of an empty path component. This is just a suggestion, so it's not necessary to take my code as-is. I still think that it's better to (1) adopt an unambiguous function name, and (2) try not to modify the argument at all but instead allocate a separate buffer for that (modifying and reverting is error-prone in general). For completeness, `fd->unix_name` is returned by realpath(), so not a concern. Correct me if I'm wrong, though.
Sorry it took a bit, I only had some time to look through it again today. I made a combination of your method and mine. I basically put everything into the new function instead of just checking the dentry, because we need to act based on what was found anyway.
I also used relative paths (*at functions) to make it simpler and reduce the race conditions, keeping the dir fd open. Obviously it's impossible to be atomic, but I tried to make it have as few syscalls as possible.
There's still one problem: hardlinks don't work on directories, so I think for dirs we need something else. I mean the whole "rename temporary then hardlink into dest" thing. For files I tested and it works fine.