aboutsummaryrefslogtreecommitdiffstats
path: root/src/clone_extents.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/clone_extents.c')
-rw-r--r--src/clone_extents.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/clone_extents.c b/src/clone_extents.c
index 09c639b..4c13185 100644
--- a/src/clone_extents.c
+++ b/src/clone_extents.c
@@ -1,9 +1,9 @@
#include "project.h"
-static int allocate_extent (ext2_filsys fs, ext2_ino_t i_num, ext2_extent_handle_t eh, blk64_t l_start, blk64_t len, __u32 flags)
+int allocate_extent (ext2_filsys fs, ext2_ino_t i_num, ext2_extent_handle_t eh, blk64_t l_start, blk64_t len, __u32 flags)
{
- blk64_t goal, start, size, want,max;
+ blk64_t goal, start, size, want, max;
dgrp_t group;
int ret;
struct ext2fs_extent e;
@@ -12,7 +12,7 @@ static int allocate_extent (ext2_filsys fs, ext2_ino_t i_num, ext2_extent_handle
goal = ext2fs_group_first_block2 (fs, group);
- max = (flags & EXT2_EXTENT_FLAGS_UNINIT) ? EXT_UNINIT_MAX_LEN:EXT_INIT_MAX_LEN;
+ max = (flags & EXT2_EXTENT_FLAGS_UNINIT) ? EXT_UNINIT_MAX_LEN : EXT_INIT_MAX_LEN;
ret = 0;
@@ -41,11 +41,11 @@ static int allocate_extent (ext2_filsys fs, ext2_ino_t i_num, ext2_extent_handle
if (ret) {
- fprintf(stderr,"Failed extent was:\n");
- fprintf(stderr," e.e_pblk = %lld\n",(long long int) e.e_pblk);
- fprintf(stderr," e.e_lblk = %lld\n",(long long int) e.e_lblk);
- fprintf(stderr," e.e_len = %lld\n",(long long int) e.e_len);
- fprintf(stderr," e.e_flags = 0x%llx\n",(long long int) e.e_flags);
+ fprintf (stderr, "Failed extent was:\n");
+ fprintf (stderr, " e.e_pblk = %lld\n", (long long int) e.e_pblk);
+ fprintf (stderr, " e.e_lblk = %lld\n", (long long int) e.e_lblk);
+ fprintf (stderr, " e.e_len = %lld\n", (long long int) e.e_len);
+ fprintf (stderr, " e.e_flags = 0x%llx\n", (long long int) e.e_flags);
break;
}
@@ -99,10 +99,12 @@ int clone_extents (ext2_filsys src_fs, ext2_filsys dst_fs, ext2_ino_t i_num, str
if (e.e_flags & EXT2_EXTENT_FLAGS_LEAF) {
- if (!l_len)
+ if (!l_len) {
+ l_start = e.e_lblk;
flags = e.e_flags;
+ }
- if (((l_start + l_len) != e.e_lblk) || (flags != e.e_flags) ) {
+ if (((l_start + l_len) != e.e_lblk) || (flags != e.e_flags)) {
ret = allocate_extent (dst_fs, i_num, dst_e, l_start, l_len, flags);
if (ret) break;