File objects – representing open files
Similar to dentry objects, file objects are an in-memory representation of open files. The file object represents a process’s view of an open file. Like dentry objects, file objects also do not correspond to any on-disk structures. When we covered system calls in Chapter 1, it was mentioned that the user-space programs interact with VFS through the system call interface. These system calls are generic functions for performing common operations such as read
and write
. The idea behind all this is to ensure that user-space programs don’t have to worry about filesystems and their data structures.
When applications generate a system call to access a file, such as open ()
, a file object gets created in memory. Similarly, when the application no longer needs access to the file and decides to close it using close ()
, the file object is discarded. It’s important to note that VFS can create multiple file objects for a particular...