diff --git a/tpfs/vol.c b/tpfs/vol.c index f8c8f1d4cb69014977c7d729c1e2b51076da8c20..70f97f93fc1aaa1856ad7e5ed17b9a3493478892 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 a090f2c369ca4a8e4ddf47d697027aae02f65f5c..8dd80e135f7494646ce6ba59396c3a66324f0453 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