On Thu, Mar 12, 2020 at 06:11:09PM +0100, Stefan Metzmacher wrote: > If that works safely for hardlinks and having another process doing a > rename between openat2() and unlinkat(), we could try that. > > My initial naive idea was to have one syscall instead of > linkat2/renameat3/unlinkat2. > > int xlinkat(int src_dfd, const char *src_path, > int dst_dfd, const char *dst_path, > const struct xlinkat_how *how, size_t how_size); > > struct xlinkat_how { > __u64 src_at_flags; > __u64 src_resolve_flags; > __u64 dst_at_flags; > __u64 dst_resolve_flags; > __u64 rename_flags; > __s32 src_fd; > }; > > With src_dfd=-1, src_path=NULL, how.src_fd = -1, this would be like > linkat(). > With dst_dfd=-1, dst_path=NULL, it would be like unlinkat(). > Otherwise a renameat2(). > > If how.src_fd is not -1, it would be checked to be the same path as > specified by src_dfd and src_path. "Checked" as in...? And is that the same path or another link to the same object, or...? The idea of dumping all 3 into the same syscall looks wrong - compare the effects of link() and rename() on the opened files, for starters, and try to come up with documentation for all of that. Multiplexors tend to be very bad, in large part because they have so bloody convoluted semantics...