File open and close operations

When a user process attempts to open a file, it invokes the open operation of the filesystem with appropriate arguments, which include path and name of the file. The filesystem traverses through directories specified in the path until it reaches the immediate parent directory that contains the requested file's record. Lookup into the file record produces the inode number of the specified file. However, specific logic and efficiency of lookup operation depends on the data structure chosen by the particular filesystem implementation for organizing file records in a directory block.

Once the filesystem retrieves the related inode number of the file, it initiates appropriate sanity checks to enforce access control validation on the calling context. If the caller process is cleared for file access, the filesystem then instantiates an in-memory structure called file descriptor to maintain file access state and attributes. Upon successful completion, the open operation returns the reference of the file descriptor structure to the caller process, which serves as a handle to the file for the caller process to initiate other file operations such as read, write, and close.

Upon initiating a close operation, the file descriptor structure is destroyed and the file's reference count is decremented. The caller process will no longer be able to initiate any other file operation until it can open the file all over again.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.81.240