- What is the correspondence/difference between file descriptors and open file descriptions?
- What is the correspondence/difference between file descriptions and inodes?
- 242,166
-
Typo: descripttors, what is an open file description? – James Risner Nov 16 '22 at 18:13
-
I am guessing the OP is referring to file descriptors and have edited accordingly. – terdon Nov 16 '22 at 18:28
-
@terdon Open File Description – Kamil Maciorowski Nov 16 '22 at 18:52
-
Oh. Well, TIL! Thanks, @KamilMaciorowski. – terdon Nov 16 '22 at 18:53
2 Answers
Off the top of my head... a file descriptor is a numeric reference held by a process which references an "open file description" in the kernel. The open file description holds information about which file is open, what mode (read/write) and where in the file the next read or write will be applied to.
Inodes are not directly linked to any process. They are a feature of the file system. They hold meta data such as file ownership. If a file has multiple file names (it has been hard linked) then it will still only have one inode.
- 138,973
- 18,733
File descriptor is an element in the array which OS gives your application. You always have such array - OS creates it when starts a new process. OS often fills first three elements with pointers to stdin, stdout, and stderr.
Open file descriptor is an array element which points to some file. You call open(), OS looks for a an empty element in the array and use it. Conversely, closed/not opened file descriptor is an array element which is empty (or logically empty).
inode - unique (inside the drive) identifier for a file on that drive.
- 5,129