From e4b01ac99b3d13c5d1057eacc04757cea957cbd7 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 2 Jan 2022 18:37:51 +0100 Subject: Read/write maybe more --- inc/spec.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'inc') diff --git a/inc/spec.h b/inc/spec.h index b13534c..5012789 100644 --- a/inc/spec.h +++ b/inc/spec.h @@ -16,6 +16,7 @@ #define MARFS_NAME_LENGTH 32 #define MARFS_ENTRY_SIZE 1024 +#define MARFS_EMPTY_ENTRY 0 #define MARFS_DIR_ENTRY 1 #define MARFS_FILE_ENTRY 2 @@ -29,8 +30,9 @@ struct marfs_header { char magic[6]; u32 version; u32 entry_size; + u32 entry_count; struct marfs_pointer main; - u8 padding[MARFS_ENTRY_SIZE - 22]; + u8 padding[MARFS_ENTRY_SIZE - 26]; } PACKED; struct marfs_entry_header { @@ -45,18 +47,27 @@ struct marfs_dir_entry_data { struct marfs_pointer pointer; } PACKED; -struct marfs_dir_entry { +struct marfs_dir_entry_info { struct marfs_entry_header header; u32 count; +} PACKED; + +struct marfs_dir_entry { + struct marfs_dir_entry_info info; struct marfs_dir_entry_data entries[MARFS_DIR_ENTRY_COUNT]; - u8 padding[MARFS_ENTRY_SIZE - sizeof(struct marfs_entry_header) - sizeof(u32) - + u8 padding[MARFS_ENTRY_SIZE - sizeof(struct marfs_dir_entry_info) - (MARFS_DIR_ENTRY_COUNT * sizeof(struct marfs_dir_entry_data))]; } PACKED; -struct marfs_file_entry { +struct marfs_file_entry_info { struct marfs_entry_header header; + u32 parent; u32 size; - u8 data[MARFS_ENTRY_SIZE - sizeof(struct marfs_entry_header) - sizeof(u32)]; +} PACKED; + +struct marfs_file_entry { + struct marfs_file_entry_info info; + u8 data[MARFS_ENTRY_SIZE - sizeof(struct marfs_file_entry_info)]; } PACKED; #endif -- cgit v1.2.3