From f0b9e0cb15d597eed37adb150223bd07c3e6264f Mon Sep 17 00:00:00 2001 From: Bah Thierno-Souleymane <thiernosouleymane.bah.etu@univ-lille.fr> Date: Fri, 26 Mar 2021 02:13:54 +0100 Subject: [PATCH] feat(free_bloc function added) --- tpfs/vol.c | 12 ++++++++++++ tpfs/vol.h | 1 + 2 files changed, 13 insertions(+) diff --git a/tpfs/vol.c b/tpfs/vol.c index f8c8f1d..70f97f9 100644 --- a/tpfs/vol.c +++ b/tpfs/vol.c @@ -217,4 +217,16 @@ unsigned int new_bloc() super.first_free = blockchain.next; return new_bloc; +} + +void free_bloc(unsigned int bloc) +{ + unsigned char buffer[sizeof(vblockchain_t)]; + vblockchain_t blockchain; + + blockchain.next = super.first_free; + super.first_free = bloc; + + memcpy(buffer, &blockchain, sizeof(vblockchain_t)); + write_bloc(super.id, bloc, buffer); } \ No newline at end of file diff --git a/tpfs/vol.h b/tpfs/vol.h index a090f2c..8dd80e1 100644 --- a/tpfs/vol.h +++ b/tpfs/vol.h @@ -63,5 +63,6 @@ void init_volume(unsigned int vol); int load_super(unsigned int vol); void save_super(); unsigned int new_bloc(); +void free_bloc(unsigned int bloc); #endif -- GitLab