From: Allison Karlitskaya Date: Mon, 25 Nov 2024 08:46:30 +0000 (+0100) Subject: mke2fs: modify the fallback path for copying data X-Git-Tag: v1.47.3-rc1~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cddc1ddbe815ba7cb132ca6be3e67d46d97ed63e;p=thirdparty%2Fe2fsprogs.git mke2fs: modify the fallback path for copying data Right now we jump to the end as soon as we've found a method that works. This is a reasonable approach because it's the last operation in the function, but soon it won't be. Switch to a logically-equivalent alternative approach: keep trying until we find the approach that works, dropping the `goto out`. Now we can add code after this. Signed-off-by: Allison Karlitskaya --- diff --git a/misc/create_inode.c b/misc/create_inode.c index d3136df9..ca03c184 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -600,18 +600,18 @@ static errcode_t copy_file(ext2_filsys fs, int fd, struct stat *statbuf, #if defined(SEEK_DATA) && defined(SEEK_HOLE) err = try_lseek_copy(fs, fd, statbuf, e2_file, buf, zerobuf); - if (err != EXT2_ET_UNIMPLEMENTED) - goto out; +#else + err = EXT2_ET_UNIMPLEMENTED; #endif #if defined(FS_IOC_FIEMAP) - err = try_fiemap_copy(fs, fd, e2_file, buf, zerobuf); - if (err != EXT2_ET_UNIMPLEMENTED) - goto out; + if (err == EXT2_ET_UNIMPLEMENTED) + err = try_fiemap_copy(fs, fd, e2_file, buf, zerobuf); #endif - err = copy_file_chunk(fs, fd, e2_file, 0, statbuf->st_size, buf, - zerobuf); + if (err == EXT2_ET_UNIMPLEMENTED) + err = copy_file_chunk(fs, fd, e2_file, 0, statbuf->st_size, buf, + zerobuf); out: ext2fs_free_mem(&zerobuf); ext2fs_free_mem(&buf);