Basic partition indexing system

main
~erin 2023-04-19 12:54:32 -04:00
parent 8c59e825f8
commit b25983dcd6
Signed by: erin
GPG Key ID: 9A8E308CEFA37A47
1 changed files with 9 additions and 6 deletions

View File

@ -24,19 +24,22 @@ It's identified simply by numerical order.
const BOOT_SIZE: u64; // How large the BOOT partition will be const BOOT_SIZE: u64; // How large the BOOT partition will be
const LABEL_SIZE: u64; // Number of characters that can be used in the partition label const LABEL_SIZE: u64; // Number of characters that can be used in the partition label
let NUM_CHUNLKS: u64; // Number of chunks in a specific partition
struct PartitionHeader { struct PartitionHeader {
boot: bool, // Boot flag boot: bool, // Boot flag
label: [char; LABEL_SIZE], // Human-readable label. Not UTF-8 though :/ label: [char; LABEL_SIZE], // Human-readable label. Not UTF-8 though :/
num_chunks: u64, // Chunks in this partition index: [(u64, Uuid); NUM_CHUNKS], // Array of tuples mapping Actor UUID's to chunk indexes
// TODO: What if a Uuid is on multiple chunks?
num_chunks: NUM_CHUNKS, // Chunks in this partition
} }
``` ```
### Chunk ### Chunk
Small pieces that each partition is split into. Small pieces that each partition is split into.
Contains fixed-length metadata (checksum, extension flag, uuid) at the beginning, and then arbitrary data afterwards. Contains fixed-length metadata (checksum, extension flag) at the beginning, and then arbitrary data afterwards.
If the saved data exceeds past a single chunk, the `extends` flag is set. If the saved data exceeds past a single chunk, the `extends` flag is set.
Additionally, it has a **UUID** generated via [lolid](https://lib.rs/crates/lolid) to enable identifying a specific chunk. <!-- Additionally, it has a **UUID** generated via [lolid](https://lib.rs/crates/lolid) to enable identifying a specific chunk. -->
```rust ```rust
const CHUNK_SIZE: u64; // Example static chunk size const CHUNK_SIZE: u64; // Example static chunk size
@ -45,7 +48,6 @@ struct ChunkHeader {
checksum: u64, checksum: u64,
extends: bool, extends: bool,
encrypted: bool, encrypted: bool,
uuid: Uuid,
modified: u64, // Timestamp of last modified modified: u64, // Timestamp of last modified
} }
@ -75,6 +77,7 @@ Basically, `part1_offset = BOOT_PARTITION_SIZE`, `part1_data_start = part1_offse
### Writing ### Writing
Writing uses a similar process. An *Actor* can request to write data. If it has proper capabilties, we serialize the data, allocate a free chunk[^free_chunk], and write to it. Writing uses a similar process. An *Actor* can request to write data. If it has proper capabilties, we serialize the data, allocate a free chunk[^free_chunk], and write to it.
We *hash* the data first to generate a checksum, and set proper metadata if the data extends past the `CHUNK_SIZE`. We *hash* the data first to generate a checksum, and set proper metadata if the data extends past the `CHUNK_SIZE`.
Then the `ParitionHeader` *index* is updated to contain the new chunk(s) being used.
### Permissions ### Permissions
Again, whether actors can: Again, whether actors can:
@ -116,6 +119,6 @@ struct PackedExecutable {
[^encryption]: Specific details to be figured out later [^encryption]: Specific details to be figured out later
[^find_chunk]: Currently via magic. I have no idea how to do this other than a simple search. Maybe generate an index, or use a **UUID**? [^find_chunk]: The `PartitionHeader` has a tuple `(Uuid, u64)` which maps each `Actor` to a chunk number, allowing for easy finding of a specific chunk from an actor-provided `Uuid`.
[^free_chunk]: Again, no idea how. [^free_chunk]: Because we know which chunks are used, we know which ones aren't.