]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homework: don't bother with BLKRRPART on images that aren't block devices
authorLennart Poettering <lennart@poettering.net>
Fri, 15 Oct 2021 09:23:00 +0000 (11:23 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 15 Oct 2021 16:03:12 +0000 (18:03 +0200)
We currently call this ioctl even if we are backed by a regular file,
which is actually the common case. While this doesn't really hurt, it
does result in very confusing logs.

src/home/homework-luks.c

index 42546b686708feb41d6402c8344256acbb72540a..b38535ddc35b5ec544b1ea007f1a7122316917c1 100644 (file)
@@ -2881,7 +2881,7 @@ int home_resize_luks(
                 if (r > 0)
                         log_info("Growing of partition completed.");
 
-                if (ioctl(image_fd, BLKRRPART, 0) < 0)
+                if (S_ISBLK(st.st_mode) && ioctl(image_fd, BLKRRPART, 0) < 0)
                         log_debug_errno(errno, "BLKRRPART failed on block device, ignoring: %m");
 
                 /* Tell LUKS about the new bigger size too */
@@ -2955,7 +2955,7 @@ int home_resize_luks(
                 if (r > 0)
                         log_info("Shrinking of partition completed.");
 
-                if (ioctl(image_fd, BLKRRPART, 0) < 0)
+                if (S_ISBLK(st.st_mode) && ioctl(image_fd, BLKRRPART, 0) < 0)
                         log_debug_errno(errno, "BLKRRPART failed on block device, ignoring: %m");
         } else {
                 r = home_store_embedded_identity(new_home, setup->root_fd, h->uid, embedded_home);