2 * dupfs.c --- duplicate a ext2 filesystem handle
4 * Copyright (C) 1997, 1998, 2001, 2003, 2005 by Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
23 errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
28 EXT2_CHECK_MAGIC(src, EXT2_ET_MAGIC_EXT2FS_FILSYS);
30 retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
44 io_channel_bumpcount(fs->io);
46 fs->icache->refcount++;
48 retval = ext2fs_get_mem(strlen(src->device_name)+1, &fs->device_name);
51 strcpy(fs->device_name, src->device_name);
53 retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->super);
56 memcpy(fs->super, src->super, SUPERBLOCK_SIZE);
58 retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->orig_super);
61 memcpy(fs->orig_super, src->orig_super, SUPERBLOCK_SIZE);
63 retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
67 memcpy(fs->group_desc, src->group_desc,
68 (size_t) fs->desc_blocks * fs->blocksize);
71 retval = ext2fs_copy_bitmap(src->inode_map, &fs->inode_map);
76 retval = ext2fs_copy_bitmap(src->block_map, &fs->block_map);
81 retval = ext2fs_badblocks_copy(src->badblocks, &fs->badblocks);
86 retval = ext2fs_copy_dblist(src->dblist, &fs->dblist);