diff options
author | Marvin Borner | 2021-12-30 17:23:51 +0100 |
---|---|---|
committer | Marvin Borner | 2021-12-30 17:23:51 +0100 |
commit | 028755c57007c3241e287b9927c6810814eecde1 (patch) | |
tree | c4c5a8826390f651f975425f96e275395db43c19 /inc/spec.h | |
parent | 6236c3d88ccba4429cbb4020ea0ed02816282451 (diff) |
Makemake crakecrake
Diffstat (limited to 'inc/spec.h')
-rw-r--r-- | inc/spec.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/inc/spec.h b/inc/spec.h new file mode 100644 index 0000000..7991866 --- /dev/null +++ b/inc/spec.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021, Marvin Borner <melvix@marvinborner.de> + * SPDX-License-Identifier: MIT + */ + +#ifndef MARFS_SPEC +#define MARFS_SPEC + +#include <def.h> + +#define MARFS_POINT(head, tail) ((struct marfs_pointer){ (head), (tail) }) +#define MARFS_MAGIC "MarFS" +#define MARFS_SPEC_VERSION 1 + +#define MARFS_END 0xffffffff +#define MARFS_NAME_LENGTH 32 +#define MARFS_ENTRY_SIZE 1024 + +#define MARFS_DIR_ENTRY 1 +#define MARFS_FILE_ENTRY 2; + +#define MARFS_DIR_ENTRY_COUNT (MARFS_ENTRY_SIZE / sizeof(struct marfs_dir_entry_data)) + +struct marfs_pointer { + u32 head, tail; +} PACKED; + +struct marfs_header { + char magic[6]; + u32 version; + u32 entry_size; + struct marfs_pointer main; + u8 padding[MARFS_ENTRY_SIZE - 22]; +} PACKED; + +struct marfs_entry_header { + u32 type; + u32 prev, next; // MARFS_END if end +} PACKED; + +struct marfs_dir_entry_data { + char name[MARFS_NAME_LENGTH]; + struct marfs_pointer pointer; +} PACKED; + +struct marfs_dir_entry { + struct marfs_entry_header header; + struct marfs_dir_entry_data entries[MARFS_DIR_ENTRY_COUNT]; + u8 padding[MARFS_ENTRY_SIZE - sizeof(struct marfs_entry_header) - + (MARFS_DIR_ENTRY_COUNT * sizeof(struct marfs_dir_entry_data))]; +} PACKED; + +struct marfs_file_entry { + struct marfs_entry_header header; + u8 data[MARFS_ENTRY_SIZE - sizeof(struct marfs_entry_header)]; +} PACKED; + +#endif |