Changes between Version 49 and Version 50 of file_system


Ignore:
Timestamp:
Feb 3, 2016, 7:56:02 PM (9 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • file_system

    v49 v50  
    1919
    2020This implementation defines four data structures:
    21  * The '''File-Cache''' and '''Fat-Cache''' are dynamically allocated memory caches, implemented in the distributed kernel heap. There is actually one independent cache per file (called File_Cache), and one cache for the FAT itself (called Fat_Cache). The cache size is not fixed: it is dynamically increased from the kernel heap as required by the read / write access to the files or to the FAT itself. The memory allocated to a given File-Cache is only released when the file is closed by all threads that have a reference on it.
    22 
    23  * The '''Inode-Tree''' is an internal representation of the FAT. It is a sub-tree of the File System tree. Each node define a file or a directory, and contains a pointer on the associated File-Cache. This Inode-Tree is dynamically increased (from the distributed kernel heap) when a new file or a directory is accessed. The memory allocated to the Inode-Tree is only released in case of system crash.
    24 
    25  * The '''File-Descriptor-Array''' is a statically defined array of file descriptors. A private file descriptor is allocated to each thread requiring to open the file, and contains mainly the current file pointer (called ''offset''). The max number of file descriptors is defined by the GIET_OPEN_FILES_MAX global variable (in the ''get_config.h'' file).
     21 * The '''File-Cache''' and '''Fat-Cache''' are dynamically allocated memory caches, implemented in the distributed kernel heap. There is actually one independent cache for each file or directory (called File_Cache), and one cache for the FAT itself (called Fat_Cache). The cache size is not fixed: it is dynamically increased from the kernel heap as required by the read / write access to the files, or when new entries are introduced in directories. the directories. Similarly, the Fat-Cache size is dynamically increased as required by the read/write access to the FAT itself. For a file, the memory dynamically allocated to the File-Cache is released when the file is closed by all threads that have a reference on it. For a directory, the memory dynamically allocated to the File-Cache is only released when the directory is removed from the file system. For The Fat-Cache, the memory dynamically allocated is only released at system shut-down.
     22
     23 * The '''Inode-Tree''' is an internal representation of the FAT. It is a sub-tree of the File System tree. Each inode define a file or a directory, and contains a pointer on the associated File-Cache. This Inode-Tree is dynamically increased (from the distributed kernel heap) when a new file or a directory is accessed. The memory allocated to the Inode-Tree is only released when the corresponding file or directory is removed from
     24the file system.
     25
     26 * The '''File-Descriptor-Array''' is a statically defined array of file descriptors. A private file descriptor is allocated to each thread requiring to open the file, and contains mainly the current file pointer (called ''offset''). The max number of file descriptors is defined by the GIET_OPEN_FILES_MAX global variable (in the ''get_config.h'' file). This array of file descriptors is shared by all applications.
    2627
    2728 * The global '''Fat-Descriptor''' contains general information such as the FAT region lba and size, the DATA region lba and size,  pointers on the Fat-Cache and Inode-Tree, the File-Descriptor-Array, and the locks protecting the FAT shared structures. It contains also a single block buffer (512 bytes) used in the initialization phase, and for FS_INFO sector update.
     
    3233'''WARNING 1''': A node name (file or directory) cannot be larger than 31 characters.
    3334
    34 '''WARNING 2''': A directory occupy one and only one cluster in the Cache-File (1024 directory entries).
    35 
    36 '''WARNING 3''': There is no rescue mechanism (at the moment) in case of kernel heap overflow, when allocating memory for the File-Caches : The system crash with a nice error message on the kernel terminal if the heap defined in the mapping is too small...
     35'''WARNING 2''': There is no rescue mechanism (at the moment) in case of kernel heap overflow, when allocating memory for the File-Caches : The system crash with a nice error message on the kernel terminal if the heap defined in the mapping is too small...
    3736
    3837== 2) Cache Structure & Write Policy ==
     
    5958(i.e. when new clusters are allocated to an existing file, or when a new file (or directory) is created, the modifications are written in the fat_cache (that must be updated in case of miss), and are immediately reported to the block device,
    6059for each modified cluster.
     60
     61== 3) Implementation Notes
     62
     63=== __'''File / directory size'''__ ===
     64 For a file, the number of occupied clusters on block device can be directly obtained from the  <size>. The <size> attribute is a number of bytes stored on block device (in the directory entry), and copied in memory as a specific field in  the associated inode.
     65 For a directory, the size attribute must be set to 0. The number of occupied clusters on block device can be obtained from the <is_dir> field in the associated inode: This field is set to 0 for a file, and contain the number of occupied clusters, that cannot be zero, because a directory contains always the '.' and '..' entries.
     66
     67=== __'''File / directory names'''__ ===
     68This implementation supports the LFN (long file name) extension, up to 31 characters. Therefore, each file or directory contained in a parent directory occupies several 32 bytes directory entries:
     69 * short names (up to 13 characters) occupy 2 entries: one LFN and one NORMAL.
     70 * medium names (from 14 to 26 characters) occupy 3 entries: two LFN and one NORMAL.
     71 * large names (from 27 to 31 characters) occupy 4 entries: three LFN and one NORMAL.
     72When new names are created, a legal 8-3 SFN (Short File Name) alias is generated from the complete new name, and is stored in the NORMAL directory entry, to produce a legal FAT32 image. But this alias SFN is never used by the FAT32 library for file identification.
    6173
    6274== 4) Extern Functions ==