]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: fdisk_deassign_device: only sync(2) blockdevs
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Sat, 13 Jan 2024 22:35:31 +0000 (23:35 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 15 Jan 2024 09:39:31 +0000 (10:39 +0100)
When not editing a blockdev, syncing disks provides no benefit
(we already fsync() above), takes a long time,
and affects unrelated caches.

BLKRRPART is similarly gated on !S_ISBLK(st_mode) in
fdisk_reread_partition_table.

libfdisk/src/context.c

index 0d221242e506271184a1a147bde4ecd0500683e1..463a60f863a3501b49a8a090b957199e3b3cdb6f 100644 (file)
@@ -773,7 +773,7 @@ int fdisk_deassign_device(struct fdisk_context *cxt, int nosync)
                                        cxt->dev_path);
                        return -errno;
                }
-               if (!nosync) {
+               if (S_ISBLK(cxt->dev_st.st_mode) && !nosync) {
                        fdisk_info(cxt, _("Syncing disks."));
                        sync();
                }