#include #include #include #include #include #include #include static void emptyIT() { return; } static void hddIT() { return; } int main(int argc, char *argv[]) { unsigned int i; /* init hardware */ if(initHardware("hardware.ini") == 0) { fprintf(stderr, "Error in hardware initialization\n"); exit(EXIT_FAILURE); } /* Interreupt handlers */ for(i=0; i<16; i++) IRQVECTOR[i] = emptyIT; IRQVECTOR[HDA_IRQ] = hddIT; /* Allows all IT */ _mask(1); if ( argc < 3 ) { printf("Utilisation : %s VOLUME CHEMIN\n", argv[0]); return EXIT_FAILURE; } unsigned int volume = atoi(argv[1]); if ( mount(volume) < 0 ) { printf("Erreur de montage du volume!\n"); return EXIT_FAILURE; } struct file_desc_t fd; open_file(&fd, argv[2]); /* Si c'est un répertoire, il doit être vide */ if ( fd.type == FILET_DIR ) { struct entry_t ent; while ( read_file(&fd, &ent, sizeof(struct entry_t)) > 0 ) { if ( ent.ent_inumber != 0 ) { if ( strcmp(ent.ent_basename, ".") == 0 ) continue; if ( strcmp(ent.ent_basename, "..") == 0 ) continue; else { close_file(&fd); printf("Répertoire non vide!\n"); umount(); return EXIT_FAILURE; } } } } close_file(&fd); if ( delete_file(argv[2]) == 0 ) printf("Fichier supprimé!\n"); else printf("Ce fichier n'existe pas!\n"); umount(); return EXIT_SUCCESS; }