2 * freefs.c --- free an ext2 filesystem
4 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
21 void ext2fs_free(ext2_filsys fs)
23 if (!fs || (fs->magic != EXT2_ET_MAGIC_EXT2FS_FILSYS))
25 if (fs->image_io != fs->io) {
27 io_channel_close(fs->image_io);
30 io_channel_close(fs->io);
33 ext2fs_free_mem(&fs->device_name);
35 ext2fs_free_mem(&fs->super);
37 ext2fs_free_mem(&fs->orig_super);
39 ext2fs_free_mem(&fs->group_desc);
41 ext2fs_free_block_bitmap(fs->block_map);
43 ext2fs_free_inode_bitmap(fs->inode_map);
45 ext2fs_free_mem(&fs->image_header);
48 ext2fs_badblocks_list_free(fs->badblocks);
52 ext2fs_free_dblist(fs->dblist);
55 ext2fs_free_inode_cache(fs->icache);
58 ext2fs_free_mem(&fs->mmp_buf);
60 ext2fs_free_mem(&fs->mmp_cmp);
64 ext2fs_zero_blocks2(NULL, 0, 0, NULL, NULL);
69 * This procedure frees a badblocks list.
71 void ext2fs_u32_list_free(ext2_u32_list bb)
73 if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST)
77 ext2fs_free_mem(&bb->list);
82 void ext2fs_badblocks_list_free(ext2_badblocks_list bb)
84 ext2fs_u32_list_free((ext2_u32_list) bb);
89 * Free a directory block list
91 void ext2fs_free_dblist(ext2_dblist dblist)
93 if (!dblist || (dblist->magic != EXT2_ET_MAGIC_DBLIST))
97 ext2fs_free_mem(&dblist->list);
99 if (dblist->fs && dblist->fs->dblist == dblist)
100 dblist->fs->dblist = 0;
102 ext2fs_free_mem(&dblist);