diff --git a/tpfs/Makefile b/tpfs/Makefile index 9d177ab5ff5f1e208fde1754ce38ce07d9b515c0..393143bb39836099b6e067e0fd469f68492094e4 100644 --- a/tpfs/Makefile +++ b/tpfs/Makefile @@ -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. diff --git a/tpfs/mkvol.c b/tpfs/mkvol.c new file mode 100644 index 0000000000000000000000000000000000000000..ad8831b55b36a13ebe2600080273b87779f127b7 --- /dev/null +++ b/tpfs/mkvol.c @@ -0,0 +1,62 @@ +#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); +}