From a21b0bc2c47adf0efc2d1b171b2b821fcf4de2a0 Mon Sep 17 00:00:00 2001 From: Allison Karlitskaya Date: Mon, 25 Nov 2024 09:46:30 +0100 Subject: [PATCH] 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 --- misc/create_inode.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/misc/create_inode.c b/misc/create_inode.c index 4e292a2d2..f61d41163 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -599,18 +599,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);