3 ms·
Crucially, no. “File descriptions” (or “open file descriptions”; classically, struct file[1]) are what file descriptors designate. The whole hubbub is because
by mananaysiempre 2y ago
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/fio.c 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/ https://blog.gnoack.org/post/proc-fd-is-not-dup/