Final Year Project: Using Linux Filesystems Under Windows   Chris Bryden BEng. Electronics and Software Engineering    School of Computer Science   University of Birmingham 21 4.  Ext2lib Design 4.1  The Multi-layer Design of Ext2lib     In designing ext2lib, it seemed appropriate to divide the construction into three distinct layers:   · =Layer 0 - The hardware access layer · =Layer 1 - The ext2fs translation layer · =Layer 2 - The application interface layer The reason for this is mainly one of safety. The functions in layer 0 could potentially cause hard disk corruption, as they perform access  to  the  hard  disk  at  a  low  level.  This  design provides  a  level  of  abstraction  between  the  interface to the calling application and any functions that could compromise the integrity of a hard disk. The functions that are exported from the library are all contained in layer   2,   the   application   interfrace   layer,      and   any functions   that   perform   low   level   access   to   disk hardware are in layer  0. So there is no way that the calling   application   can   execute   possibly   damaging functions.   Layer    1    holds    all    the    functions    that    are necessary to convert the raw data read from the disk by    functions    in    layer    0    into    useful    filesystem information such as directory listings and files. This information is then used by functions in layer 2 to implement the basic filesystem commands ls, cd and cp. It is these commands that will form the basis of layer 2. Layer 2 is to provide what can be thought of as a ‘command line’ that can be used by the calling application to perform operations on the ext2 filesystem.    This  three  layer  structure  also  provides  modularity  within  the  program code, which makes it easier to update and maintain, and therefore more stable.      4.2  Layer 0 - The Hardware Access Layer The function of layer 0 is to provide layer 1 with a function that can read a logical sector from a specified drive and partition. To achieve this, layer 0 has to be able to: · =Read a physical sector from any disk connected to the PC. · =Read and process the partition tables from any disk connected to the PC. Calling Application layer 2 Application Interface layer layer 1 Ext2fs Translation Layer layer 0 Hardware access layer Hardware