]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: Set sector size of loopback devices
authorMichael A Cassaniti <michael@cassaniti.id.au>
Fri, 21 Jul 2023 01:41:09 +0000 (11:41 +1000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 21 Jul 2023 10:04:39 +0000 (11:04 +0100)
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.

src/partition/repart.c

index 5e167d4a4601631b7ae91d6adc4f42e1ab0cbd1a..f68918a7315497da65816dcee539e549fc230473 100644 (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);
                 }