How does the Unix kernel convert a file offset?

1k views Asked by At

As the title suggests, i'm having trouble figuring out how the Unix kernel converts a logical file offset into a logical block number and then retrieves it from the i-node.

As a reference, i'm asking a more detailed explanation of the "bmap" algorithm described first in "The Design of the UNIX Operating System" by Maurice J. Bach.

Thank you..

1

There are 1 answers

0
pmdj On BEST ANSWER

I unfortunately can't help you with the original implementation of UNIX; but the job of mapping the high-level directory hierarchy to an on-disk representation, and for assigning ranges on the bare block device to files normally falls to one or more file systems. The POSIX spec makes some high-level demands on the file system, but what actually ends up on disk is completely specific to each file system.

The ext2 file system is comparatively simple, but a detailed explanation of it still fills an entire chapter of a book - one such book is Understanding the Linux Kernel by Daniel P. Bovet and Marco Cesati.

A more brief, higher-level introductory text comes with the Linux kernel itself, and can also be found here. That directory also contains documentation on other Linux file systems and also the "VFS" layer, which handles a lot of the higher-level aspects which are common to all or most file systems. Wikipedia's ext2 article also covers it at a high level. It also provides some links to more detailed online descriptions.

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