Final Year Project: Using Linux Filesystems Under Windows   Chris Bryden BEng. Electronics and Software Engineering    School of Computer Science   University of Birmingham 22 The   task   that   layer   0   has   to   perform   forms   the   base   of   the   whole application, as reading from the hard disk forms the basis of any operation that the   ext2lib   library   will   have   to   perform.   It   is   essential,   therefore,   that   the mechanism that is used is both reliable and efficient. The layer needs to consist of  three  distinct  functions:  A  function  to  read  a  physical  sector  from  disk,  a function to read the partition tables from disk, and a function that can be called by functions in  layer  1  to  read  a  logical  sector  from  a partition. It is this function alone that provides the interface to layer 1 from layer 0.   The   diagram   on   the   left   shows   this arrangement. This provides a reliable structure  for  layer  0,  it  is,  however,  not  the most    efficient.    The    partition    tables    are extremely  unlikely  to  be altered whilst ext2lib is in operation, so it is inefficient to read them from  disk  each  time  they  are  needed  by  the read   logical   sector   function.   The   partition tables  are  therefore  read  into  memory  when  ext2lib  is  first  loaded,  and  are buffered  there  until  ext2lib  is  unloaded.  Any  time  that  the  read  logical  sector function  need  access  them,  they  are  stored  in  memory  and  do  not  have  to  be read  form  disk,  this  provides  a  great  performance  increase.  This  forms  the   structure of layer 0, and is illustrated below Read Physical Sector From Disk Read Logical Sector from Partition Read Partition Table Information PC BIOS Layer 1 Read Physical Sector From Disk Read Logical Sector from Partition On startup read partition table Information into memory buffer PC BIOS Layer 1 Read partition tables from memory buffer The Structure of Layer 0