|
|
8dc857 |
From e3f74af78b774b235123b9d5fa40fead3b003bb2 Mon Sep 17 00:00:00 2001
|
|
|
8dc857 |
From: "Brian C. Lane" <bcl@redhat.com>
|
|
|
8dc857 |
Date: Fri, 20 Jan 2012 15:31:43 -0800
|
|
|
8dc857 |
Subject: [PATCH] libparted: use dm_udev_wait (#698121)
|
|
|
8dc857 |
|
|
|
8dc857 |
This applies Peter Rajnoha's patch to use dm_udev_wait to
|
|
|
8dc857 |
synchronize with udev.
|
|
|
8dc857 |
|
|
|
8dc857 |
This requires libdevmapper v1.02.39 and higher.
|
|
|
8dc857 |
|
|
|
8dc857 |
Patch is from:
|
|
|
8dc857 |
https://lists.gnu.org/archive/html/bug-parted/2010-09/msg00007.html
|
|
|
8dc857 |
|
|
|
8dc857 |
Resolves: rhbz#698121
|
|
|
8dc857 |
---
|
|
|
8dc857 |
libparted/arch/linux.c | 16 +++++++++++++++-
|
|
|
8dc857 |
1 files changed, 15 insertions(+), 1 deletions(-)
|
|
|
8dc857 |
|
|
|
8dc857 |
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
|
|
8dc857 |
index e2c4139..1fcbcad 100644
|
|
|
8dc857 |
--- a/libparted/arch/linux.c
|
|
|
8dc857 |
+++ b/libparted/arch/linux.c
|
|
|
8dc857 |
@@ -1319,6 +1319,10 @@ linux_new (const char* path)
|
|
|
8dc857 |
dev->dirty = 0;
|
|
|
8dc857 |
dev->boot_dirty = 0;
|
|
|
8dc857 |
|
|
|
8dc857 |
+#ifdef ENABLE_DEVICE_MAPPER
|
|
|
8dc857 |
+ dm_udev_set_sync_support(1);
|
|
|
8dc857 |
+#endif
|
|
|
8dc857 |
+
|
|
|
8dc857 |
if (!_device_probe_type (dev))
|
|
|
8dc857 |
goto error_free_arch_specific;
|
|
|
8dc857 |
|
|
|
8dc857 |
@@ -2676,16 +2680,21 @@ static int
|
|
|
8dc857 |
_dm_remove_map_name(char *name)
|
|
|
8dc857 |
{
|
|
|
8dc857 |
struct dm_task *task = NULL;
|
|
|
8dc857 |
- int rc;
|
|
|
8dc857 |
+ int rc = 0;
|
|
|
8dc857 |
+ uint32_t cookie = 0;
|
|
|
8dc857 |
|
|
|
8dc857 |
task = dm_task_create(DM_DEVICE_REMOVE);
|
|
|
8dc857 |
if (!task)
|
|
|
8dc857 |
return 1;
|
|
|
8dc857 |
|
|
|
8dc857 |
dm_task_set_name (task, name);
|
|
|
8dc857 |
+ if (!dm_task_set_cookie(task, &cookie, 0))
|
|
|
8dc857 |
+ goto err;
|
|
|
8dc857 |
|
|
|
8dc857 |
rc = dm_task_run(task);
|
|
|
8dc857 |
+ dm_udev_wait(cookie);
|
|
|
8dc857 |
dm_task_update_nodes();
|
|
|
8dc857 |
+err:
|
|
|
8dc857 |
dm_task_destroy(task);
|
|
|
8dc857 |
if (!rc)
|
|
|
8dc857 |
return 1;
|
|
|
8dc857 |
@@ -2796,6 +2805,7 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
|
|
|
8dc857 |
const char* dev_name = NULL;
|
|
|
8dc857 |
char* params = NULL;
|
|
|
8dc857 |
LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
|
|
|
8dc857 |
+ uint32_t cookie = 0;
|
|
|
8dc857 |
|
|
|
8dc857 |
/* Get map name from devicemapper */
|
|
|
8dc857 |
struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
|
|
|
8dc857 |
@@ -2832,14 +2842,18 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
|
|
|
8dc857 |
dm_task_set_name (task, vol_name);
|
|
|
8dc857 |
dm_task_add_target (task, 0, part->geom.length,
|
|
|
8dc857 |
"linear", params);
|
|
|
8dc857 |
+ if (!dm_task_set_cookie(task, &cookie, 0))
|
|
|
8dc857 |
+ goto err;
|
|
|
8dc857 |
if (dm_task_run (task)) {
|
|
|
8dc857 |
//printf("0 %ld linear %s\n", part->geom.length, params);
|
|
|
8dc857 |
+ dm_udev_wait(cookie);
|
|
|
8dc857 |
dm_task_update_nodes();
|
|
|
8dc857 |
dm_task_destroy(task);
|
|
|
8dc857 |
free(params);
|
|
|
8dc857 |
free(vol_name);
|
|
|
8dc857 |
return 1;
|
|
|
8dc857 |
} else {
|
|
|
8dc857 |
+ dm_udev_wait(cookie);
|
|
|
8dc857 |
_dm_remove_map_name(vol_name);
|
|
|
8dc857 |
}
|
|
|
8dc857 |
err:
|
|
|
8dc857 |
--
|
|
|
8dc857 |
1.7.7.6
|
|
|
8dc857 |
|