1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-15 09:57:39 +03:00

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.
This commit is contained in:
Michael A Cassaniti 2023-07-21 11:41:09 +10:00 committed by Luca Boccassi
parent 01b030c201
commit 66a8c74c35

View File

@ -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);
}