static int free_inodes(void) { struct list_head list, *entry, *freeable = &list; int found = 0; INIT_LIST_HEAD(freeable); entry = inode_in_use.next; while (entry != &inode_in_use) { struct list_head *tmp = entry; entry = entry->next; if (!CAN_UNUSE(INODE(tmp))) continue; list_del(tmp); list_del(&INODE(tmp)->i_hash); INIT_LIST_HEAD(&INODE(tmp)->i_hash); list_add(tmp, freeable); list_entry(tmp, struct inode, i_list)->i_state = I_FREEING; found = 1; } if (found) dispose_list(freeable); return found; }
ext2_directory_t *open_dir(uint8_t *fs, ext2_inode_t *inode_table, uint32_t inode) { ext2_directory_t *root; uint32_t block = inode_table[INODE(inode)].i_block[0]; // printf("dir block %i\n", block); root = (ext2_directory_t *)&fs[BLOCK(block)]; return root; }