/* Unregisters a disk and all registered fs's * on disk TODO * Close all files currently open */ void VfsUnregisterDisk(DevId_t DiskId, uint32_t Forced) { /* Need this for the iteration */ list_node_t *lNode; /* Keep iterating untill no more FS's are present on disk */ lNode = list_get_node_by_id(GlbFileSystems, DiskId, 0); while (lNode != NULL) { /* Remove it from list */ list_remove_by_node(GlbFileSystems, lNode); /* Cast */ MCoreFileSystem_t *Fs = (MCoreFileSystem_t*)lNode->data; /* Destruct the FS */ if (Fs->Destory(lNode->data, Forced) != OsOk) LogFatal("VFSM", "UnregisterDisk:: Failed to destroy filesystem"); /* Free */ MStringDestroy(Fs->Identifier); MutexDestruct(Fs->Lock); kfree(Fs); kfree(lNode); /* Get next */ lNode = list_get_node_by_id(GlbFileSystems, DiskId, 0); } }
int main(void) { list_t *list = NULL; printf("----- Print add elements -----\n"); list_add_node_front(&list, "J"); list_add_node_front(&list, "I"); list_add_node_front(&list, "H"); list_add_node_front(&list, "G"); list_add_node_front(&list, "F"); list_add_node_front(&list, "E"); list_add_node_front(&list, "D"); list_add_node_front(&list, "C"); list_add_node_front(&list, "B"); list_add_node_front(&list, "A"); printf("----- Print list -----\n"); list_print(list, print_callback); printf("----- Access elements -----\n"); printf("The element number %u of the list is %s\n", 0, (char *)list_get_node_by_id(list, 0)); printf("The element number %u of the list is %s\n", 1, (char *)list_get_node_by_id(list, 1)); printf("The element number %u of the list is %s\n", 5, (char *)list_get_node_by_id(list, 5)); printf("The element number %u of the list is %s\n", 9, (char *)list_get_node_by_id(list, 9)); // The last id is 9 so 10 is out of range printf("The element number %u of the list is %s\n", 10,(char *)list_get_node_by_id(list, 10)); printf("----- Delete last element -----\n"); list_del_node_by_id(&list, 9); printf("----- Print list -----\n"); list_print(list, print_callback); printf("----- Delete first element -----\n"); list_del_node_by_id(&list, 0); printf("----- Print list -----\n"); list_print(list, print_callback); uint32_t size = list_get_size(list); printf("----- Size of the list: %u -----\n", size); printf("----- Delete all element -----\n"); uint32_t i; for (i = 0; i < size ; i++) { list_del_node_by_id(&list, 0); } printf("----- Print list -----\n"); list_print(list, print_callback); list_add_node_back(&list, "A"); list_add_node_back(&list, "B"); list_add_node_back(&list, "C"); list_add_node_back(&list, "D"); printf("----- Print list -----\n"); list_print(list, print_callback); printf("----- Reverse the list -----\n"); list_reverse_order(&list); printf("----- Print list -----\n"); list_print(list, print_callback); printf("----- Clean list -----\n"); list_cleanup(&list); i = 0; while (1) { list_add_node_back(&list, "A"); printf("add_elem %u\n", i); ++i; } return (0); }