A file descriptor represents an open file. It is a unique number assigned by the operating system to each file. It is an πππ¬ππ«ππππ’π¨π§ for working with files. We need to use file descriptors to read from or write to files in our program.
Each process maintains its own file descriptor table.
The diagram below shows the layered architecture in Linux filesystem. Letβs take process 1234 as an example.
The diagram below shows the layered architecture in Linux filesystem. Letβs take process 1234 as an example.
The file pointer points to an entry in the π¨π©ππ§ ππ’π₯π ππππ₯π, which has information about open files across all processes. Multiple file descriptors can point to the same file table entry. For example, file descriptor 0,1 and 2 point to the same open file table entry.
Over to you: When we close a file in a program, do you know which entries are deleted in these data structures?
Thanks for reading! Follow me at @alexxubyte to get more threads like this.
Thanks for reading! Follow me at @alexxubyte to get more threads like this.
Loading suggestions...