ext2fs_inode_bitmap inode_map;
ext2fs_block_bitmap block_map;
ext2_badblocks_list badblocks;
+ ext2_dblist dblist;
dest_io = dest->io;
dest_image_io = dest->image_io;
inode_map = dest->inode_map;
block_map = dest->block_map;
badblocks = dest->badblocks;
+ dblist = dest->dblist;
memcpy(dest, src, sizeof(struct struct_ext2_filsys));
dest->io = dest_io;
dest->inode_map = inode_map;
dest->block_map = block_map;
dest->badblocks = badblocks;
+ dest->dblist = dblist;
if (dest->dblist)
dest->dblist->fs = dest;
if (retval)
goto out;
+ if (src->dblist) {
+ if (dest->dblist) {
+ retval = ext2fs_merge_dblist(src->dblist,
+ dest->dblist);
+ if (retval)
+ goto out;
+ } else {
+ dest->dblist = src->dblist;
+ dest->dblist->fs = dest;
+ src->dblist = NULL;
+ }
+ }
+
if (src->badblocks) {
if (dest->badblocks == NULL)
retval = ext2fs_badblocks_copy(src->badblocks,
ext2fs_free_generic_bmap(src->block_map);
if (src->badblocks)
ext2fs_badblocks_list_free(src->badblocks);
+ if (src->dblist)
+ ext2fs_free_dblist(src->dblist);
+
return retval;
}
}
/*
+ * Merge a directory block list @src to @dest
+ */
+errcode_t ext2fs_merge_dblist(ext2_dblist src, ext2_dblist dest)
+{
+ unsigned long long src_count = src->count;
+ unsigned long long dest_count = dest->count;
+ unsigned long long size = src_count + dest_count;
+ size_t size_entry = sizeof(struct ext2_db_entry2);
+ struct ext2_db_entry2 *array, *array2;
+ errcode_t retval;
+
+ if (src_count == 0)
+ return 0;
+
+ if (src->sorted || (dest->sorted && dest_count != 0))
+ return EINVAL;
+
+ retval = ext2fs_get_array(size, size_entry, &array);
+ if (retval)
+ return retval;
+
+ array2 = array;
+ memcpy(array, src->list, src_count * size_entry);
+ array += src_count;
+ memcpy(array, dest->list, dest_count * size_entry);
+ ext2fs_free_mem(&dest->list);
+
+ dest->list = array2;
+ dest->count = src_count + dest_count;
+ dest->size = size;
+ dest->sorted = 0;
+
+ return 0;
+}
+
+/*
* Close a directory block list
*
* (moved to closefs.c)
blk_t blk, int blockcnt);
extern errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
blk64_t blk, e2_blkcnt_t blockcnt);
+extern errcode_t ext2fs_merge_dblist(ext2_dblist src, ext2_dblist dest);
extern void ext2fs_dblist_sort(ext2_dblist dblist,
EXT2_QSORT_TYPE (*sortfunc)(const void *,
const void *));