News for hackers. Stuff that matters.
Re:Towards userspaceification of POSIX – part I: signal hand... by layer8 on Saturday August 03, 2024 @11:03AM (#41146974)
When you write “file description”, do you mean “file descriptor”?
Re:Towards userspaceification of POSIX – part I: signal hand... by mananaysiempre on Saturday August 03, 2024 @11:57AM (#41147330)
Crucially, no.

“File descriptions” (or “open file descriptions”; classically, struct file[1]) are what file descriptors designate. The whole hubbub is because a file description is not just a device number, an inode number, and a set of already-checked permissions; they are all that and a position in the file, and that position gets shared along with the rest of the description when you dup(), fork(), or sendmsg() the file descriptor—but not if you open() the same file again, not even[2] via /proc/self/fd.

As I’ve said, I think the most helpful way to think about this is that a file description is a seekable stream object on top of the underlying random-access disk file, and a reference to that stream object is what you’re passing around when you’re handling (hah) file descriptors.

[1] https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/sys/sys/fi...

[2] https://blog.gnoack.org/post/proc-fd-is-not-dup/

Re:Towards userspaceification of POSIX – part I: signal hand... by 4lDO2 on Saturday August 03, 2024 @11:20AM (#41147088)
File descriptors and file descriptions are not the same thing. Descriptors are references to descriptions, along with some metadata, and multiple descriptors can point to the same description.
Re:Towards userspaceification of POSIX – part I: signal hand... by layer8 on Saturday August 03, 2024 @11:33AM (#41147174)
> multiple descriptors can point to the same descriptor.

You mean to the same description?

And is this the same as what is referred to as “open file description” in the open(2) man page, or are there also other “file descriptions”?

Re:Towards userspaceification of POSIX – part I: signal hand... by 4lDO2 on Saturday August 03, 2024 @11:36AM (#41147189)
Yes, and yes.