File Descriptors, File Descriptor Tables, and File Structures

Linux: The different structures pointing to an open file

TechExplorer
3 min readJan 16, 2022

Yes, to access a file, the file system go through multiple structures. Among them, we find the three elements mentioned in the title. I use the word “element” here since the file descriptor is not a structure but merely a number identifying an open file. Without further ado let’s demystify those confusing terms.

File Descriptor

A file descriptor is an element returned by an open(2) system call. It is a number that can have a value between 0 and N. The value of N depends on the system. To find this value, we can execute this command (on my system the command returns 4096):

$ ulimit -Hn
4096

The file descriptor effectively identifies an open file. Once obtained through the open(2) system call, it can be used to access the opened file with the read(2) and write(2) system calls. Once the file is no longer needed, it can be closed with the close(2) system call.

File Descriptor Table

The file descriptor is an index of the “file descriptor table”. The content of the table is a set of pointers to an (open) file structure. The below figure shows the relation between these elements:

Relation between the different elements identifying to an (open) file structures

--

--

TechExplorer

Tech enthusiast with an interest in software and a love for cryptocurrencies. Check out my crypto donation page at: https://rb.gy/mqd43h