]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homed: switch from raw BLKRRPART to rereadpt_fd()
authorLennart Poettering <lennart@poettering.net>
Mon, 20 Oct 2025 13:18:42 +0000 (15:18 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 22 Oct 2025 20:56:01 +0000 (22:56 +0200)
src/home/homework-luks.c

index a0b4368a2aaf7d761f8bb5a0d18acdeae0a1f377..25b3c191ddab71e04ef4900214aaf3b02421c913 100644 (file)
@@ -53,6 +53,7 @@
 #include "path-util.h"
 #include "process-util.h"
 #include "random-util.h"
+#include "reread-partition-table.h"
 #include "resize-fs.h"
 #include "string-util.h"
 #include "strv.h"
@@ -2497,7 +2498,7 @@ int home_create_luks(
 
         if (disk_uuid_path)
                 /* Reread partition table if this is a block device */
-                (void) ioctl(setup->image_fd, BLKRRPART, 0);
+                (void) reread_partition_table_fd(setup->image_fd, /* flags= */ 0);
         else {
                 assert(setup->temporary_image_path);
 
@@ -3469,8 +3470,8 @@ int home_resize_luks(
                 if (r > 0)
                         log_info("Growing of partition completed.");
 
-                if (S_ISBLK(st.st_mode) && ioctl(image_fd, BLKRRPART, 0) < 0)
-                        log_debug_errno(errno, "BLKRRPART failed on block device, ignoring: %m");
+                if (S_ISBLK(st.st_mode))
+                        (void) reread_partition_table_fd(image_fd, /* flags= */ 0);
 
                 /* Tell LUKS about the new bigger size too */
                 r = sym_crypt_resize(setup->crypt_device, setup->dm_name, new_fs_size / 512U);
@@ -3569,8 +3570,8 @@ int home_resize_luks(
                 if (r > 0)
                         log_info("Shrinking of partition completed.");
 
-                if (S_ISBLK(st.st_mode) && ioctl(image_fd, BLKRRPART, 0) < 0)
-                        log_debug_errno(errno, "BLKRRPART failed on block device, ignoring: %m");
+                if (S_ISBLK(st.st_mode))
+                        (void) reread_partition_table_fd(image_fd, /* flags= */ 0);
 
         } else { /* → Grow */
                 if (!FLAGS_SET(flags, HOME_SETUP_RESIZE_DONT_SYNC_IDENTITIES)) {