How does the Unix kernel convert file offset?

As the name implies, itโ€™s hard for me to understand how the Unix kernel converts the logical offset of the file into the logical block number, and then extracts it from the i-node.

As a reference, I ask for a more detailed explanation of the bmap algorithm, described first in Maurice J. Bach's UNIX Operating System Project.

Thanks..

+4
source share
1 answer

Unfortunately, I cannot help you with the original implementation of UNIX; but the task of comparing a high-level directory hierarchy with a representation on disk and for assigning ranges on a block device to files usually refers to one or more file systems. The POSIX specification makes some high-level file system requirements, but what actually ends up on disk is completely specific to each file system.

The ext2 file system is relatively simple, but a detailed explanation still fills the entire chapter of the book โ€” one of which is Understanding the Linux Kernel by Daniel P. Beauvais and Marco Cesati.

A shorter introductory text at a higher level comes with the Linux kernel, and can also be found here . This directory also contains documentation for other Linux file systems , as well as a VFS layer that handles many higher-level aspects that are common to all or most file systems. The ext2 Wikipedia article also covers it at a high level. It also contains some links to more detailed descriptions on the Internet.

This, unfortunately, is not a topic that will fit into the SO answer, but I hope the above pointers help you get started.

+4
source

Source: https://habr.com/ru/post/1414166/


All Articles