Skip to content
Snippets Groups Projects
Commit 8b495e92 authored by Thierno souleymane Bah's avatar Thierno souleymane Bah
Browse files

fix(get_sector_cylinder function patched, absolute bloc n° of a volume is now ...

fix(get_sector_cylinder function patched, absolute bloc n° of a volume is now  calculated by cylinder and sector)
parent e524e4b8
No related branches found
No related tags found
No related merge requests found
......@@ -50,12 +50,16 @@ void save_mbr()
write_sector(0, 0, buffer);
}
unsigned int *get_sector_cylinder(int vol, int nbloc)
unsigned int *get_sector_cylinder(unsigned int vol, unsigned int nbloc)
{
assert(vol < mbr.nb_vols);
assert(nbloc < mbr.vols[vol].nb_sectors);
int sector_cylinder[2], absolute_nbloc;
absolute_nbloc = (mbr.vols[vol].sector + nbloc);
vol_t volume;
assert(vol < mbr.nb_vols);
volume = mbr.vols[vol];
assert(nbloc < volume.nb_sectors);
absolute_nbloc = (volume.cylinder * HDA_MAXSECTOR + volume.sector + nbloc);
sector_cylinder[0] = absolute_nbloc % HDA_MAXSECTOR;
sector_cylinder[1] = absolute_nbloc / HDA_MAXCYLINDER;
return sector_cylinder;
......@@ -75,10 +79,10 @@ void write_bloc(unsigned int vol, unsigned int nbloc, const unsigned char *buffe
void format_vol(unsigned int vol)
{
int nbloc;
vol_t current_vol = mbr.vols[vol];
unsigned int nbloc;
vol_t volume = mbr.vols[vol];
for (nbloc = 0; nbloc < current_vol.nb_sectors; nbloc++)
for (nbloc = 0; nbloc < volume.nb_sectors; nbloc++)
{
int sector_cylinder[2] = get_sector_cylinder(vol, nbloc);
format_sector(sector_cylinder[1], sector_cylinder[1], FMT_SIZE, FMT_DATA);
......
......@@ -32,7 +32,7 @@ typedef struct mbr_s
void load_mbr(void);
void save_mbr(void);
unsigned int *get_sector_cylinder(int volume, int bloc);
unsigned int *get_sector_cylinder(unsigned int vol, unsigned int nbloc);
void read_bloc(unsigned int vol, unsigned int nbloc, unsigned char *buffer);
void write_bloc(unsigned int vol, unsigned int nbloc, const unsigned char *buffer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment