Re: [PATCH 01/14] VFS: Add additional RESOLVE_* flags [ver #18]

From: Al Viro
Date: Thu Mar 12 2020 - 15:26:37 EST


On Thu, Mar 12, 2020 at 09:24:49AM -0700, Linus Torvalds wrote:
> Would that be basically just an AT_EMPTY_PATH kind of thing? IOW,
> you'd be able to remove a file by doing
>
> fd = open(path.., O_PATH);
> unlinkat(fd, "", AT_EMPTY_PATH);
>
> Hmm. We have _not_ allowed filesystem changes without that last
> component lookup. Of course, with our dentry model, we *can* do it,
> but this smells fairly fundamental to me.

That's a bloody bad idea. It breeds fuckloads of corner cases, it does not
match the locking model at all and I don't want to even think of e.g.
the interplay with open-by-fhandle ("Parent? What parent?"), etc.

Fundamentally, there are operations on objects and there are operations
on links to objects. Mixing those is the recipe for massive headache.

> It might avoid some of the extra system calls (ie you could use
> openat2() to do the path walking part, and then
> unlinkat(AT_EMPTY_PATH) to remove it, and have a "fstat()" etc in
> between the verify that it's the right type of file or whatever - and
> you'd not need an unlinkat2() with resolve flags).
>
> I think Al needs to ok this kind of change. Maybe you've already
> discussed it with him and I just missed it.

They have not. And IME samba folks tend to present the set of
primitives they want without bothering to explain what do they
want to factorize that way, let alone why it should be factorized
that way...