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

feat(init_volume function added)

parent 447d3063
No related branches found
No related tags found
No related merge requests found
...@@ -14,9 +14,9 @@ void load_mbr() ...@@ -14,9 +14,9 @@ void load_mbr()
/* read_sector(buffer, 0, 0); */ /* read_sector(buffer, 0, 0); */
read_sector_n(buffer, 0, 0, sizeof(mbr_t)); read_sector_n(buffer, 0, 0, sizeof(mbr_t));
memcpy(&mbr, buffer, sizeof(mbr_t)); memcpy(&mbr, buffer, sizeof(mbr_t));
if (mbr.magic != MBR_MAGIC) if (mbr.magic != MAGIC)
{ {
mbr.magic = MBR_MAGIC; mbr.magic = MAGIC;
mbr.nb_vols = 0; mbr.nb_vols = 0;
} }
} }
...@@ -159,3 +159,23 @@ void remove_vol(int vol) ...@@ -159,3 +159,23 @@ void remove_vol(int vol)
mbr.vols[i] = mbr.vols[i + 1]; mbr.vols[i] = mbr.vols[i + 1];
mbr.nb_vols--; mbr.nb_vols--;
} }
void init_volume(unsigned int vol)
{
int i;
vsuper_t super;
super.magic = MAGIC;
super.serie = vol;
sprintf(super.name, "volume %i", vol);
super.id = vol;
super.first_free = 1;
write_bloc(vol, SUPER_BLOC, &super);
for (int i = 1; i < HDA_SECTORSIZE; i++)
{
vblockchain_t blockchain;
blockchain.next = (i + 1) % HDA_SECTORSIZE;
write_bloc(vol, i, &blockchain);
}
}
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
#define VOL_H #define VOL_H
#define VOLS_MAX 8 #define VOLS_MAX 8
#define MBR_MAGIC 0xCAFE /* Savoir si le mbr a déjà été initialisé ou non */ #define MAGIC 0xCAFE /* Savoir si le mbr a déjà été initialisé ou non */
#define FMT_DATA 0xCAFEBABE #define FMT_DATA 0xCAFEBABE
#define FMT_SIZE 0x1 #define FMT_SIZE 0x1
#define SUPER_BLOC 0
typedef enum typedef enum
{ {
...@@ -30,6 +31,20 @@ typedef struct mbr_s ...@@ -30,6 +31,20 @@ typedef struct mbr_s
mbr_t mbr; mbr_t mbr;
typedef struct vsuper_s
{
unsigned int magic;
unsigned int serie;
unsigned char *name;
unsigned int id;
unsigned int first_free;
} vsuper_t;
typedef struct vblockchain_s
{
unsigned int next;
} vblockchain_t;
void load_mbr(void); void load_mbr(void);
void save_mbr(void); void save_mbr(void);
void get_sector_cylinder(unsigned int vol, unsigned int nbloc, unsigned int *sector_cylinder); void get_sector_cylinder(unsigned int vol, unsigned int nbloc, unsigned int *sector_cylinder);
...@@ -42,4 +57,6 @@ void create_vol(unsigned int nb_blocs, unsigned int cylinder, unsigned int secto ...@@ -42,4 +57,6 @@ void create_vol(unsigned int nb_blocs, unsigned int cylinder, unsigned int secto
void display_vols(); void display_vols();
void remove_vol(); void remove_vol();
void init_volume(unsigned int vol);
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment