2 * dupfs.c --- duplicate a ext2 filesystem handle
4 * Copyright (C) 1997 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
23 #include <linux/ext2_fs.h>
27 errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
32 EXT2_CHECK_MAGIC(src, EXT2_ET_MAGIC_EXT2FS_FILSYS);
34 fs = (ext2_filsys) malloc(sizeof(struct struct_ext2_filsys));
47 io_channel_bumpcount(fs->io);
49 fs->icache->refcount++;
52 fs->device_name = malloc(strlen(src->device_name)+1);
55 strcpy(fs->device_name, src->device_name);
57 fs->super = malloc(SUPERBLOCK_SIZE);
60 memcpy(fs->super, src->super, SUPERBLOCK_SIZE);
62 fs->group_desc = malloc(fs->desc_blocks * fs->blocksize);
65 memcpy(fs->group_desc, src->group_desc,
66 fs->desc_blocks * fs->blocksize);
69 retval = ext2fs_copy_bitmap(src->inode_map, &fs->inode_map);
74 retval = ext2fs_copy_bitmap(src->block_map, &fs->block_map);
79 retval = ext2fs_badblocks_copy(src->badblocks, &fs->badblocks);
84 retval = ext2fs_copy_dblist(src->dblist, &fs->dblist);