From e524e4b80c4360d3fefd51eef6791d6950d97fe0 Mon Sep 17 00:00:00 2001 From: Bah Thierno-Souleymane <thiernosouleymane.bah.etu@univ-lille.fr> Date: Fri, 19 Mar 2021 08:22:06 +0100 Subject: [PATCH] feat(format vol function done) --- tpfs/vol.c | 12 ++++++++++++ tpfs/vol.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/tpfs/vol.c b/tpfs/vol.c index c177583..e1a8f44 100644 --- a/tpfs/vol.c +++ b/tpfs/vol.c @@ -71,4 +71,16 @@ void write_bloc(unsigned int vol, unsigned int nbloc, const unsigned char *buffe { int sector_cylinder[2] = get_sector_cylinder(vol, nbloc); // [sector, cylinder] write_sector(sector_cylinder[1], sector_cylinder[0], buffer); +} + +void format_vol(unsigned int vol) +{ + int nbloc; + vol_t current_vol = mbr.vols[vol]; + + for (nbloc = 0; nbloc < current_vol.nb_sectors; nbloc++) + { + int sector_cylinder[2] = get_sector_cylinder(vol, nbloc); + format_sector(sector_cylinder[1], sector_cylinder[1], FMT_SIZE, FMT_DATA); + } } \ No newline at end of file diff --git a/tpfs/vol.h b/tpfs/vol.h index 9966fc1..77abccb 100644 --- a/tpfs/vol.h +++ b/tpfs/vol.h @@ -3,6 +3,8 @@ #define VOLS_MAX 8 #define MBR_MAGIC 0xCAFE // Savoir si le mbr a déjà été initialisé ou non +#define FMT_DATA 0xCAFEBABE +#define FMT_SIZE 0x1 static mbr_t mbr; -- GitLab