3 ms·
When you write “file description”, do you mean “file descriptor”?
by layer8 2y ago
When you write “file description”, do you mean “file descriptor”?
- 4lDO2 2y agoFile 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.
- mananaysiempre 2y agoCrucially, 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/