diff --git a/tpfs/mkvol.c b/tpfs/mkvol.c
index ad8831b55b36a13ebe2600080273b87779f127b7..f8eec43212971aec8bba25296eb782ae08aa1cad 100644
--- a/tpfs/mkvol.c
+++ b/tpfs/mkvol.c
@@ -3,14 +3,55 @@
 
 #include "hardware.h"
 #include "vol.h"
+#include "drive.h"
 
-void create_vol(unsigned int nb_blocs, unsigned int cylinder, unsigned int sector, vol_t *volume)
+void create_vol(unsigned int nb_blocs, unsigned int cylinder, unsigned int sector)
 {
-    if (cylinder + sector == 0)
+    int i, abs_nbloc, remaining_blocs;
+    vol_t *volume;
+
+    if (mbr.nb_vols == VOLS_MAX)
+    {
+        fprintf(stderr, "Le nombre de volumes maximal est atteint \n");
+        return;
+    }
+
+    if (cylinder + sector == 0 ||
+        cylinder >= HDA_MAXCYLINDER ||
+        sector >= HDA_MAXSECTOR)
     {
-        printf("Impossible d'ecrire à cet endroit\n");
+        fprintf(stderr, "Impossible d'ecrire à cet endroit \n");
         return;
     }
+
+    abs_nbloc = cylinder * HDA_MAXSECTOR + sector;
+    remaining_blocs = HDA_MAXSECTOR * HDA_MAXCYLINDER - abs_nbloc;
+
+    if (abs_nbloc > remaining_blocs)
+        nb_blocs = remaining_blocs;
+
+    for (i = 0; i < mbr.nb_vols; i++)
+    {
+        vol_t vol = mbr.vols[i];
+        int vol_abs_nbloc = vol.cylinder * HDA_MAXSECTOR + vol.sector;
+        /*
+        * Les deux commencent sur le même bloc
+        * Les deux se terminent sur le même bloc
+        * Si le debut de l'un se trouve entre le debut et la fin de l'autre
+        */
+        printf("%d %d %d %d\n", abs_nbloc, abs_nbloc + nb_blocs, vol_abs_nbloc, vol_abs_nbloc + vol.nb_blocs);
+        if (abs_nbloc == vol_abs_nbloc ||
+            (abs_nbloc + nb_blocs) == (vol_abs_nbloc + vol.nb_blocs) ||
+            ((abs_nbloc < vol_abs_nbloc) && (vol_abs_nbloc < abs_nbloc + nb_blocs)) ||
+            ((vol_abs_nbloc < abs_nbloc) && (abs_nbloc < vol_abs_nbloc + vol.nb_blocs)))
+        {
+
+            fprintf(stderr, "Le volume %d occupe déjà cet emplacement \n", i);
+            return;
+        }
+    }
+
+    volume = mbr.vols + (mbr.nb_vols++);
     volume->nb_blocs = nb_blocs;
     volume->cylinder = cylinder;
     volume->sector = sector;
@@ -47,14 +88,8 @@ int main(int argc, char const *argv[])
         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++));
+    create_vol(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
     save_mbr();
 
     /* and exit! */