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

feat(mkvol programm done, we can now create a volume)

parent e018ea72
Branches
Tags
No related merge requests found
......@@ -13,7 +13,7 @@ LIBS = -L$(LIBDIR) -lhardware
###------------------------------
### Main targets
###------------------------------------------------------------
BINARIES= mkhd display_sector format_sector write_sector
BINARIES= mkhd display_sector format_sector write_sector mkvol
all: $(BINARIES) $(OBJECTS)
......@@ -31,6 +31,7 @@ mkhd: mkhd.o
display_sector: display_sector.o drive.o
format_sector: format_sector.o drive.o
write_sector: write_sector.o drive.o
mkvol: mkvol.o vol.o drive.o
###------------------------------
### Misc.
......
#include <stdio.h>
#include <stdlib.h>
#include "hardware.h"
#include "vol.h"
void create_vol(unsigned int nb_blocs, unsigned int cylinder, unsigned int sector, vol_t *volume)
{
if (cylinder + sector == 0)
{
printf("Impossible d'ecrire à cet endroit\n");
return;
}
volume->nb_blocs = nb_blocs;
volume->cylinder = cylinder;
volume->sector = sector;
volume->type = BASE;
}
static void
empty_it()
{
return;
}
int main(int argc, char const *argv[])
{
unsigned int i;
/* init hardware */
if (init_hardware("hwconfig.ini") == 0)
{
fprintf(stderr, "Error in hardware initialization\n");
exit(EXIT_FAILURE);
}
/* Interreupt handlers */
for (i = 0; i < 16; i++)
IRQVECTOR[i] = empty_it;
/* Allows all IT */
_mask(1);
if (argc != 4)
{
fprintf(stderr, "Usage: %s <number of blocs> <cylinder> <sector> \n", argv[0]);
exit(EXIT_FAILURE);
}
if (mbr.nb_vols == VOLS_MAX)
{
fprintf(stderr, "Le nombre de volumes maximal est atteint \n");
exit(EXIT_FAILURE);
}
load_mbr();
create_vol(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), mbr.vols + (mbr.nb_vols++));
save_mbr();
/* and exit! */
exit(EXIT_SUCCESS);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment