mirror of
https://github.com/systemd/systemd.git
synced 2026-11-07 13:57:10 +00:00
repart: copy --copy-from= partitions at their offset
With --copy-from=, we seek the source image to each partition before copying its blocks. All partitions that are copied from the same image share one file offset. Let's pass the partition offset to copy_bytes_full() instead, so we don't have to move the file offset.
This commit is contained in:
1 parent
9cee108506
commit
f2e6cd4dbc
1 file changed
+2
-6
+2
-6
@@ -6642,14 +6642,10 @@ static int context_copy_blocks(Context *context) {
|
||||
if (p->copy_blocks_offset == UINT64_MAX)
|
||||
log_info("Copying in '%s' (%s) on block level into future partition %" PRIu64 ".",
|
||||
p->copy_blocks_path, FORMAT_BYTES(p->copy_blocks_size), p->partno);
|
||||
else {
|
||||
else
|
||||
log_info("Copying in '%s' @ %" PRIu64 " (%s) on block level into future partition %" PRIu64 ".",
|
||||
p->copy_blocks_path, p->copy_blocks_offset, FORMAT_BYTES(p->copy_blocks_size), p->partno);
|
||||
|
||||
if (lseek(p->copy_blocks_fd, p->copy_blocks_offset, SEEK_SET) < 0)
|
||||
return log_error_errno(errno, "Failed to seek to copy blocks offset in %s: %m", p->copy_blocks_path);
|
||||
}
|
||||
|
||||
/* We call copy_bytes_full() instead of copy_file_range() directly, because copy_file_range()
|
||||
* needs to be called with a size limit to allow for progress updates. But we don't want that
|
||||
* for cloning, we want one big massive reflink if possible, and unfortunately we can't know
|
||||
@@ -6658,7 +6654,7 @@ static int context_copy_blocks(Context *context) {
|
||||
* clone, and then falls back to copying in chunks. */
|
||||
r = copy_bytes_full(
|
||||
p->copy_blocks_fd,
|
||||
/* foffset= */ NULL,
|
||||
/* foffset= */ p->copy_blocks_offset == UINT64_MAX ? NULL : &(uint64_t) { p->copy_blocks_offset },
|
||||
partition_target_fd(t),
|
||||
/* toffset= */ NULL,
|
||||
p->copy_blocks_size,
|
||||
|
||||
Reference in new issue
Block a user