From: Michael A Cassaniti Date: Fri, 21 Jul 2023 01:41:09 +0000 (+1000) Subject: repart: Set sector size of loopback devices X-Git-Tag: v254-rc3~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=66a8c74c3598dc5fb8e2e6dea7ade4e12ba1e650;p=thirdparty%2Fsystemd.git repart: Set sector size of loopback devices When an explicit sector size is set by the user it is also necessary to set the sector size of any loopback devices. If the sector size is not set for loopback devices then it can cause file system creation to fail or run into odd issues. --- diff --git a/src/partition/repart.c b/src/partition/repart.c index 5e167d4a460..f68918a7315 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -3306,7 +3306,7 @@ static int partition_target_prepare( * also to cut out sections of block devices into new block devices. */ if (arg_offline <= 0) { - r = loop_device_make(whole_fd, O_RDWR, p->offset, size, 0, 0, LOCK_EX, &d); + r = loop_device_make(whole_fd, O_RDWR, p->offset, size, context->sector_size, 0, LOCK_EX, &d); if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)))) return log_error_errno(r, "Failed to make loopback device of future partition %" PRIu64 ": %m", p->partno); if (r >= 0) { @@ -5721,7 +5721,7 @@ static int context_minimize(Context *context) { FORMAT_BYTES(1024ULL * 1024ULL * 1024ULL * 1024ULL)); if (arg_offline <= 0) { - r = loop_device_make(fd, O_RDWR, 0, UINT64_MAX, 0, 0, LOCK_EX, &d); + r = loop_device_make(fd, O_RDWR, 0, UINT64_MAX, context->sector_size, 0, LOCK_EX, &d); if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)))) return log_error_errno(r, "Failed to make loopback device of %s: %m", temp); } @@ -5812,7 +5812,7 @@ static int context_minimize(Context *context) { return log_error_errno(errno, "Failed to truncate temporary file to %s: %m", FORMAT_BYTES(fsz)); if (arg_offline <= 0) { - r = loop_device_make(fd, O_RDWR, 0, UINT64_MAX, 0, 0, LOCK_EX, &d); + r = loop_device_make(fd, O_RDWR, 0, UINT64_MAX, context->sector_size, 0, LOCK_EX, &d); if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)))) return log_error_errno(r, "Failed to make loopback device of %s: %m", temp); }