-
Notifications
You must be signed in to change notification settings - Fork 1
3. Data and Memory Structure
Images are handled as two types; either as the root image or a storage image. The root image contains filesystem meta data, image MD5 sums, and file meta data – this information is required to reconstitute the filesystem as it was before it was last unmounted. To prevent any possibility of misreads, the root image is completely cleared before writing a current filesystem state to it.
There is only one filesystem meta data structure. This structure contains the filesystem name, encryption key, a pointer to the files array, a pointer to the images array, a pointer to the root image, and other valuable filesystem information which can be referenced and set by any function in the application.
Each image file included in the file system has data stored in two locations, with the exception of the root image. As each image is read a structure containing its filename, MD5 sum, width, height, bit depth, channels, a pointer to each row, file state, libpng structures, and other data is populated. A storage image is then appended to the filesystems images array and it’s MD5 sum set to be written to the root image to later be read for filesystem reconstitution.
Each file in the filesystem has data stored in two locations. A files meta data - its offset, size, and file name - is maintained in the filesystems files array and stored in its entirety in the root image. The offset of a file is the files distance in bytes from the beginning of the filesystem, and similarly a files size is the size of the file in bytes. The name of the file stored includes the relative path of the file, which will always be the root filesystem directory.
Fuse operations used to control and maintain the filesystem are stored in a structure provided in the fuse library containing pointers to each filesystem function defined in the application.