diff --git a/tpfs/vol.c b/tpfs/vol.c index e1a8f44ce7d0ce93ecd2cb32aee5e3f6f518e673..8f5f430bcf8531d4b69ad8765b33bc4474dfb5c7 100644 --- a/tpfs/vol.c +++ b/tpfs/vol.c @@ -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); diff --git a/tpfs/vol.h b/tpfs/vol.h index 77abccbfd3a41b2154002ec714768dccac6c8d47..e16cbe854be0ce12964a97254c66032e3b215e1e 100644 --- a/tpfs/vol.h +++ b/tpfs/vol.h @@ -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);