User:Superleaf1995/lowFS: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
No edit summary
(just realized there is already a fs with that name :/)
Line 1: Line 1:
{{stub}}
uniFS stands for '''Universal FileSystem'''.

lowFS stands for '''Universal FileSystem'''.


Is a table-filesystem designed by me (Superleaf1995) because why not?
Is a table-filesystem designed by me (Superleaf1995) because why not?


In this filesystem each entry points to a portion of a file, this allows loading parts of the file progressively. If any of the tables is damaged, a checksum every 8 entries is made to ensure nothing is wrong. uniFS assumes the disk is a plain array of bytes.
In this filesystem each entry points to a portion of a file, this allows loading parts of the file progressively. If any of the tables is damaged, a checksum every 8 entries is made to ensure nothing is wrong. lowFS assumes the disk is a plain array of bytes.


This filesystem also tries to be simple as possible, and be compatible with 16-bit hosts as well as 64-bit ones.
This filesystem also tries to be simple as possible, and be compatible with 16-bit hosts as well as 64-bit ones.

== Bootsector ==
There are three ways to identify a lowFS disk: checking byte 0x02, checking the last 4 bytes of sector 4 or checking the last 4 bytes of the disk. It should contain the label '_LF_' (ASCII). It should always be in big endian. Followed by a table:
<source lang="c">
struct lowFS_megatable {
uint8_t attribute; // Attribute byte
uint64_t nlb; // Number of LBAs
uint8_t version; // lowFS version
};
</source>

Attribute:
{| {{wikitable}}
|-
! Bit
! Purpose
|-
| 0
| If set, the disk is in big endian, if clear, the disk is in little endian
|-
| 1
| If set, disk has bad sectors
|-
| 2-7
| TBD
|}


== Entry ==
== Entry ==
The entry header is basically like a FAT entry, however, this is a header ''for entries'' not for files.
The entry header is basically like a FAT entry, however, this is a header ''for entries'' not for files.
<source lang="c">
<source lang="c">
struct unifs_entry_header {
struct lowFS_entry_header {
uint8_t reserved; // Should always be 0xCC
uint8_t reserved; // Should always be 0xCC
uint8_t entry_type; // Type of entry
uint8_t entry_type; // Type of entry
Line 17: Line 45:
uint64_t previous; // Previous entry header in the chain (pointer)
uint64_t previous; // Previous entry header in the chain (pointer)
uint64_t next_entry; // Next entry header in the chain (pointer)
uint64_t next_entry; // Next entry header in the chain (pointer)
uint64_t size; // Size of entry (unifs_entry struct not included). If set to 0, the host must know the size parsing entry type
uint64_t size; // Size of entry (lowFS_entry struct not included). If set to 0, the host must know the size parsing entry type
};
};
</source>
</source>
Line 29: Line 57:
If entry_type is set to '''ENTRY_TYPE_FILEMETADATA''' (0xF0):
If entry_type is set to '''ENTRY_TYPE_FILEMETADATA''' (0xF0):
<source lang="c">
<source lang="c">
struct unifs_entry_filemetadata {
struct lowFS_entry_filemetadata {
uint64_t filename_len; // length of filename
uint64_t filename_len; // length of filename
uint64_t len; // length of file in bytes
uint64_t len; // length of file in bytes
uint8_t filename[filename_len]; // variable size, kernel should alloc memory for incoming filename
uint8_t filename[filename_len]; // variable size, kernel should alloc memory for incoming filename
uint8_t encrypt; // If it's nonzero, the file is encrypted with some TBD encryption system
uint8_t encrypt; // If it's nonzero, the file is encrypted with some TBD encryption system
uint8_t perm; // use for unix permissions
};
};
</source>
</source>
Line 40: Line 69:
If entry_type is set to '''ENTRY_TYPE_FILEPART''' (0xF2):
If entry_type is set to '''ENTRY_TYPE_FILEPART''' (0xF2):
<source lang="c">
<source lang="c">
struct unifs_entry_filepart {
struct lowFS_entry_filepart {
uint64_t clen; // Length of the bytes of the file
uint64_t clen; // Length of the bytes of the file
uint8_t content[clen]; // variable size, kernel should alloc memory for incoming file content
uint8_t content[clen]; // variable size, kernel should alloc memory for incoming file content
uint16_t checksum; // verifies that the data in the file is correct (First byte of content ANDed by the last one)
uint16_t checksum; // verifies that the data in the file is correct (First byte of content ANDed by the last one)
uint8_t perm; // use for unix permissions
};
};
</source>
</source>
Line 50: Line 78:
If entry type is set to '''ENTRY_TYPE_DIRECTORYMETADATA''' (0xF4):
If entry type is set to '''ENTRY_TYPE_DIRECTORYMETADATA''' (0xF4):
<source lang="c">
<source lang="c">
struct unifs_entry_directorymetadata {
struct lowFS_entry_directorymetadata {
uint64_t dirname_len; // length of dirname
uint64_t dirname_len; // length of dirname
uint8_t dirname[dirname_len]; // variable size, kernel should alloc memory for incoming dirname
uint8_t dirname[dirname_len]; // variable size, kernel should alloc memory for incoming dirname
Line 69: Line 97:


<source lang="c">
<source lang="c">
struct unifs_checksum {
struct lowFS_checksum {
uint16_t val; // 0x53BC
uint16_t val; // 0x53BC
uint16_t bf; // Previous 2 bytes anded with 0x53BC
uint16_t bf; // Previous 2 bytes ANDed with 0x53BC
uint32_t fp; // FILEPART size high bytes
uint32_t fp; // FILEPART size high bytes
};
};