From 59627048c1b5b6e6aed9198bb11c397b3ad8cddd Mon Sep 17 00:00:00 2001 From: Petr Uzel Date: Fri, 14 Feb 2014 09:18:32 +0100 Subject: [PATCH] Revert "libparted: remove now-worse-than-useless _kernel_reread_part_table" This reverts commit 1223b9fc07859cb619c80dc057bd05458f9b5669. --- libparted/arch/linux.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) Index: parted-3.1/libparted/arch/linux.c =================================================================== --- parted-3.1.orig/libparted/arch/linux.c +++ parted-3.1/libparted/arch/linux.c @@ -2897,6 +2897,34 @@ _dm_reread_part_table (PedDisk* disk) #endif static int +_kernel_reread_part_table (PedDevice* dev) +{ + LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); + int retry_count = 9; + + sync(); + while (ioctl (arch_specific->fd, BLKRRPART)) { + retry_count--; + sync(); + if (retry_count == 3) + sleep(1); /* Pause to allow system to settle */ + + if (!retry_count) { + ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_IGNORE, + _("WARNING: the kernel failed to re-read the partition " + "table on %s (%s). As a result, it may not " + "reflect all of your changes until after reboot."), + dev->path, strerror (errno)); + return 0; + } + } + + return 1; +} + +static int _have_blkpg () { static int have_blkpg = -1; @@ -2931,6 +2959,8 @@ linux_disk_commit (PedDisk* disk) ok = 0; } + if (!_kernel_reread_part_table (disk->dev)) + ok = 0; return ok; }