From 61c4848a06ec2d16406f716f10cf2cada2a91964 Mon Sep 17 00:00:00 2001 From: Bah Thierno-Souleymane <thiernosouleymane.bah.etu@univ-lille.fr> Date: Fri, 26 Mar 2021 01:53:19 +0100 Subject: [PATCH] feat(load_super function added) --- tpfs/vol.c | 10 ++++++++++ tpfs/vol.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/tpfs/vol.c b/tpfs/vol.c index fcc58c3..490cdc2 100644 --- a/tpfs/vol.c +++ b/tpfs/vol.c @@ -179,3 +179,13 @@ void init_volume(unsigned int vol) write_bloc(vol, i, &blockchain); } } + +int load_super(unsigned int vol) +{ + unsigned char buffer[sizeof(vsuper_t)]; + + read_bloc(vol, SUPER_BLOC, buffer); + memcpy(&super, buffer, sizeof(vsuper_t)); + + assert(super.magic == MAGIC); +} \ No newline at end of file diff --git a/tpfs/vol.h b/tpfs/vol.h index ab076af..a155d88 100644 --- a/tpfs/vol.h +++ b/tpfs/vol.h @@ -40,6 +40,8 @@ typedef struct vsuper_s unsigned int first_free; } vsuper_t; +vsuper_t super; + typedef struct vblockchain_s { unsigned int next; @@ -58,5 +60,6 @@ void display_vols(); void remove_vol(); void init_volume(unsigned int vol); +int load_super(unsigned int vol); #endif -- GitLab