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.
22 void ext2fs_free(ext2_filsys fs)
24 if (!fs || (fs->magic != EXT2_ET_MAGIC_EXT2FS_FILSYS))
26 if (fs->image_io != fs->io) {
28 io_channel_close(fs->image_io);
31 io_channel_close(fs->io);
34 ext2fs_free_mem(&fs->device_name);
36 ext2fs_free_mem(&fs->super);
38 ext2fs_free_mem(&fs->orig_super);
40 ext2fs_free_mem(&fs->group_desc);
42 ext2fs_free_block_bitmap(fs->block_map);
44 ext2fs_free_inode_bitmap(fs->inode_map);
46 ext2fs_free_mem(&fs->image_header);
49 ext2fs_badblocks_list_free(fs->badblocks);
53 ext2fs_free_dblist(fs->dblist);
56 ext2fs_free_inode_cache(fs->icache);
59 ext2fs_free_mem(&fs->mmp_buf);
61 ext2fs_free_mem(&fs->mmp_cmp);
63 if (fs->block_sha_map)
64 ext2fs_hashmap_free(fs->block_sha_map);
68 ext2fs_zero_blocks2(NULL, 0, 0, NULL, NULL);
73 * This procedure frees a badblocks list.
75 void ext2fs_u32_list_free(ext2_u32_list bb)
77 if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST)
81 ext2fs_free_mem(&bb->list);
86 void ext2fs_badblocks_list_free(ext2_badblocks_list bb)
88 ext2fs_u32_list_free((ext2_u32_list) bb);
93 * Free a directory block list
95 void ext2fs_free_dblist(ext2_dblist dblist)
97 if (!dblist || (dblist->magic != EXT2_ET_MAGIC_DBLIST))
101 ext2fs_free_mem(&dblist->list);
103 if (dblist->fs && dblist->fs->dblist == dblist)
104 dblist->fs->dblist = 0;
106 ext2fs_free_mem(&dblist);