From 8272aa245bcca1a82c295bfa8e2db62625319c9b Mon Sep 17 00:00:00 2001 From: Emma Nora Theuer Date: Wed, 23 Oct 2024 03:00:36 +0200 Subject: [PATCH] Commit code from several developing sessions] --- inode.h | 21 ++++++++++++++++++++- util.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/inode.h b/inode.h index 9dffb31..48495f7 100644 --- a/inode.h +++ b/inode.h @@ -16,6 +16,8 @@ enum permissions { X = 4 }; +// NOTE: Add handling for the block bitmap for when a file is deleted and created. That's how you solve the issue of when a block is usable. + struct inode_table { // the following keyword spam purely exist so I definitely see it with highlighting. // NOTE, TODO, FIXME, DEPRECATED, HACK, IMPORTANT: always initialize all values to be null when the inode table is created!!!! @@ -44,8 +46,25 @@ struct Inode { tm created; tm last_modified; + // needed to determine file size uint16_t block_count; - block* data_block; + + // Data block pointers!! + struct data_block* first_data_block; + struct data_block* second_data_block; + struct data_block* third_data_block; + struct data_block* fourth_data_block; + struct data_block* fifth_data_block; + struct data_block* sixth_data_block; + struct data_block* seventh_data_block; + struct data_block* eighth_data_block; + struct data_block* nineth_data_block; + struct data_block* tenth_data_block; + struct data_block* eleventh_data_block; + struct data_block* twelveth_data_block; + struct indirect_data_block* file_indirect_data_block; + struct doubly_indirect_data_block* file_doubly_indirect_data_block; + struct trebly_indirect_data_block* file_trebly_indirect_data_block; }; Inode* create_inode(char name[64], uint8_t user_permissions, uint8_t group_permissions, uint16_t owner, uint16_t group, block* data_block); diff --git a/util.h b/util.h index 417314b..55fdb83 100644 --- a/util.h +++ b/util.h @@ -10,12 +10,56 @@ #define BITS_PER_INODE 16384 typedef struct tm tm; -typedef struct block block; -struct block { +struct data_block { char data[BLOCKSIZE]; }; +struct indirect_data_block { + struct data_block* first_data_block; + struct data_block* second_data_block; + struct data_block* third_data_block; + struct data_block* fourth_data_block; + struct data_block* fifth_data_block; + struct data_block* sixth_data_block; + struct data_block* seventh_data_block; + struct data_block* eighth_data_block; + struct data_block* nineth_data_block; + struct data_block* tenth_data_block; + struct data_block* eleventh_data_block; + struct data_block* twelveth_data_block; +}; + +struct doubly_indirect_data_block { + struct data_block* first_indirect_data_block; + struct data_block* second_indirect_data_block; + struct data_block* third_indirect_data_block; + struct data_block* fourth_indirect_data_block; + struct data_block* fifth_indirect_data_block; + struct data_block* sixth_indirect_data_block; + struct data_block* seventh_indirect_data_block; + struct data_block* eighth_indirect_data_block; + struct data_block* nineth_indirect_data_block; + struct data_block* tenth_indirect_data_block; + struct data_block* eleventh_indirect_data_block; + struct data_block* twelveth_indirect_data_block; +}; + +struct trebly_indirect_data_block { + struct data_block* first_doubly_indirect_data_block; + struct data_block* second_doubly_indirect_data_block; + struct data_block* third_doubly_indirect_data_block; + struct data_block* fourth_doubly_indirect_data_block; + struct data_block* fifth_doubly_indirect_data_block; + struct data_block* sixth_doubly_indirect_data_block; + struct data_block* seventh_doubly_indirect_data_block; + struct data_block* eighth_doubly_indirect_data_block; + struct data_block* nineth_doubly_indirect_data_block; + struct data_block* tenth_doubly_indirect_data_block; + struct data_block* eleventh_doubly_indirect_data_block; + struct data_block* twelveth_doubly_indirect_data_block; +}; + struct tm *local_time; // Global Variables