Skip to content

Commit

Permalink
mke2fs: modify the fallback path for copying data
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
allisonkarlitskaya committed Nov 25, 2024
1 parent ad56cca commit a21b0bc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions misc/create_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a21b0bc

Please sign in to comment.