Re: fd == 0 means AT_FDCWD BPF_OBJ_GET commands

Linus Torvalds
2023-05-18T18:57:31Z

[-- Attachment #1: Type: text/plain, Size: 2091 bytes --]

[ Out walking for health - sorry for html crud ]

On Thu, May 18, 2023, 11:26 Alexei Starovoitov <alexei.starovoitov@gmail.com>
wrote:

>
> User space cares what they refer to.
> Unix made integer FD into broken abstraction.
>

Stop trying to blame anybody else.

The unix people came up with a good abstraction, and you've screwed up.
That is nobody's fault but your own, and you should just admit it rather
than trying to double down on being wrong.

Integer file descriptions are fine. Negative ones are invalid, and people
who wanted to use "root" and "cwd" have already done so using them for
decades. Look up openat().

You just picked completely the wrong invalid number.

That's on you. Nobody else.

regular files need one set of syscalls to work with such 'integer FDs'.
> sockets need another set of syscalls.
>

None of that has anything to do with file descriptors, which are a unified
format.

The reason sockets have extra system calls is that you're can just do extra
things with them. That's no different from ioctl's, and they could have
been done that way, but the extra system calls are cleaner.

While user space sees an integer without type and that a root cause of the
> bugs.
> And that's particularly bad for integers 0,1,2 where user space assumes
> that
> regular files are behind them.
>

Stop making yourself look any more stupid than necessary.

The 0/1/2 file descriptors are not at all special. They are a shell
pipeline default, nothing more. They are not the argument your think they
are, and you should stop trying to make them an argument.

It only makes you look bad.

Imagine C++ project where base class is called 'FD' while children
>

Ok, now you've just gone totally off the rails.

Stop this silliness.

You did something bad from ignorance. That's fine. But making excuses for
it turns ignorance to willful stupidity. Stop digging yourself deeper in
that hole.

The system call interface is not some C++ object interface. And we should
all be grateful that it isn't.

Linus

[-- Attachment #2: Type: text/html, Size: 3875 bytes --]