From: Daan De Meyer Date: Thu, 16 Mar 2023 21:10:50 +0000 (+0100) Subject: repart: Make sure we seek to beginning of partition target before copy X-Git-Tag: v254-rc1~991^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6eccec00fb50e1a35f5a11e3339d634541bcc3a8;p=thirdparty%2Fsystemd.git repart: Make sure we seek to beginning of partition target before copy --- diff --git a/src/partition/repart.c b/src/partition/repart.c index 2b1fbbdae2d..e6314649984 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -3266,6 +3266,9 @@ static int partition_target_sync(Context *context, Partition *p, PartitionTarget if (lseek(whole_fd, p->offset, SEEK_SET) == (off_t) -1) return log_error_errno(errno, "Failed to seek to partition offset: %m"); + if (lseek(t->fd, 0, SEEK_SET) == (off_t) -1) + return log_error_errno(errno, "Failed to seek to start of temporary file: %m"); + r = copy_bytes(t->fd, whole_fd, UINT64_MAX, COPY_REFLINK|COPY_HOLES|COPY_FSYNC); if (r < 0) return log_error_errno(r, "Failed to copy bytes to partition: %m");