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.
22 errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
27 EXT2_CHECK_MAGIC(src, EXT2_ET_MAGIC_EXT2FS_FILSYS);
29 retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
43 io_channel_bumpcount(fs->io);
45 fs->icache->refcount++;
47 retval = ext2fs_get_mem(strlen(src->device_name)+1, &fs->device_name);
50 strcpy(fs->device_name, src->device_name);
52 retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->super);
55 memcpy(fs->super, src->super, SUPERBLOCK_SIZE);
57 retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->orig_super);
60 memcpy(fs->orig_super, src->orig_super, SUPERBLOCK_SIZE);
62 retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
66 memcpy(fs->group_desc, src->group_desc,
67 (size_t) fs->desc_blocks * fs->blocksize);
70 retval = ext2fs_copy_bitmap(src->inode_map, &fs->inode_map);
75 retval = ext2fs_copy_bitmap(src->block_map, &fs->block_map);
80 retval = ext2fs_badblocks_copy(src->badblocks, &fs->badblocks);
85 retval = ext2fs_copy_dblist(src->dblist, &fs->dblist);