Hi all, I'm using "parted 2.3" and "kernel 2.6.15", I found the "_disk_sync_part_table" not return correct value in "linux_disk_commit" function (even kernel update successfully it still return "0", I see /proc/partitiond is updated). But the return value of old "_kernel_reread_part_table" function is correct. So I revert 1223b9fc07859cb619c80dc057bd05458f9b5669 and do some refine as the following
two patches. Thanks, Hsuan-Ting. >From 7046cad06d1d7b0d1572e08c2365a1cdc0a854fe Mon Sep 17 00:00:00 2001 From: Hsuan-Ting <ach...@cs.ccu.edu.tw> Date: Fri, 12 Nov 2010 11:58:30 +0800 Subject: [PATCH 1/2] kernel 2.6.15 still need this reread function to get the correct return value Revert "libparted: remove now-worse-than-useless _kernel_reread_part_table" This reverts commit 1223b9fc07859cb619c80dc057bd05458f9b5669. --- libparted/arch/linux.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c index b1f7dc9..e73ca7a 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c @@ -2786,6 +2786,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; @@ -2823,6 +2851,8 @@ linux_disk_commit (PedDisk* disk) ok = 0; } + if (!_kernel_reread_part_table (disk->dev)) + ok = 0; return ok; } -- 1.7.0.4 >From 312fb0552f35acf97123d295d7d9f335bdd63ea4 Mon Sep 17 00:00:00 2001 From: Hsuan-Ting <ach...@cs.ccu.edu.tw> Date: Fri, 12 Nov 2010 12:08:20 +0800 Subject: [PATCH 2/2] Correct the linux_disk_commit return value --- libparted/arch/linux.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c index e73ca7a..b70b874 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c @@ -2851,8 +2851,9 @@ linux_disk_commit (PedDisk* disk) ok = 0; } - if (!_kernel_reread_part_table (disk->dev)) - ok = 0; + if (0 == ok && _kernel_reread_part_table (disk->dev)) { + ok = 1; + } return ok; } -- 1.7.0.4
_______________________________________________ bug-parted mailing list bug-parted@gnu.org http://lists.gnu.org/mailman/listinfo/bug-parted