]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sfdisk: wait before re-read
authorKarel Zak <kzak@redhat.com>
Tue, 2 Jan 2018 13:48:01 +0000 (14:48 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 2 Jan 2018 13:48:01 +0000 (14:48 +0100)
The original old (v2.13) fdisk had sleep(2) beany ideafore re-read ioctl. It
seems overkill, but short sleep is probably a good idea as we call
re-read on sfdisk start and at the end. It's possible that sfdisk is
too fast and the initial re-read is not gone yet.

It would be nice to have something more elegant than sleep, any idea?

Addresses: https://github.com/karelzak/util-linux/issues/557
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/sfdisk.c

index d769ed8db091f33ba908b385163fb8b64a097c77..513a1152a56ba9fd399614d8f83caba555666e9f 100644 (file)
@@ -546,8 +546,15 @@ static int write_changes(struct sfdisk *sf)
                        rc = move_partition_data(sf, sf->partno, sf->orig_pa);
                if (!rc) {
                        fdisk_info(sf->cxt, _("\nThe partition table has been altered."));
-                       if (!sf->notell)
+                       if (!sf->notell) {
+                               /* Let's wait a little bit. It's possible that our
+                                * system is still busy with a previous re-read
+                                * ioctl (on sfdisk start) or with another task
+                                * related to the write to the device.
+                                */
+                               xusleep(250000);
                                fdisk_reread_partition_table(sf->cxt);
+                       }
                }
        }
        if (!rc)