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 |
| 24 | the 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. |
| 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'''__ === |
| 68 | This 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. |
| 72 | When 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. |