- if (idx->removed)
- {
- struct bitmap *free_map;
-
- free_map = bitmap_create (disk_size (filesys_disk));
- if (free_map != NULL)
- {
- disk_sector_t start, end;
-
- bitmap_read (free_map, free_map_file);
-
- /* Reset inode sector bit. */
- bitmap_reset (free_map, idx->sector);
-
- /* Reset inode data sector bits. */
- start = idx->data.first_sector;
- end = start + DIV_ROUND_UP (idx->data.length, DISK_SECTOR_SIZE);
- bitmap_set_multiple (free_map, start, end, false);
-
- bitmap_write (free_map, free_map_file);
- bitmap_destroy (free_map);
- }
- else
- printf ("inode_close(): can't free blocks");
- }
+ /* Deallocate blocks if removed. */
+ if (idx->removed)
+ deallocate_inode (idx);
+
+ /* Remove from inode list and free memory. */