[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Possible enumeration approach



Hey list.


This is a hack that hans proposed for the parted issue.  Don't see this
causing any problems.
clumens: what do you think of this for a temporary solution for the
enumeration issue?

Comments appreciated.

PS : I tested and it seems to do just fine :)


Regards.

-- 
Joel Andres Granados
Brno, Czech Republic, Red Hat.
diff --git a/include/parted/disk.h b/include/parted/disk.h
index 691f413..29a2009 100644
--- a/include/parted/disk.h
+++ b/include/parted/disk.h
@@ -234,6 +234,8 @@ struct _PedDiskArchOps {
         int (*disk_commit) (PedDisk* disk);
 };
 
+extern int ped_disk_toggle_do_enumerate ();
+extern int ped_disk_enumerate_on ();
 extern void ped_disk_type_register (PedDiskType* type);
 extern void ped_disk_type_unregister (PedDiskType* type);
 
diff --git a/libparted/disk.c b/libparted/disk.c
index 5fb8060..55101d2 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -65,6 +65,23 @@ static int _disk_raw_add (PedDisk* disk, PedPartition* part);
 
 static PedDiskType*	disk_types = NULL;
 
+int ped_disk_do_enumerate = 0;
+
+int
+ped_disk_toggle_do_enumerate ()
+{
+    if (ped_disk_do_enumerate == 0)
+        return ped_disk_do_enumerate = 1;
+    else
+        return ped_disk_do_enumerate = 0;
+}
+
+int
+ped_disk_enumerate_on ()
+{
+    return ped_disk_do_enumerate;
+}
+
 void
 ped_disk_type_register (PedDiskType* disk_type)
 {
@@ -1887,7 +1904,8 @@ ped_disk_remove_partition (PedDisk* disk, PedPartition* part)
 	PED_ASSERT (part->part_list == NULL, goto error);
 	_disk_raw_remove (disk, part);
 	_disk_pop_update_mode (disk);
-	ped_disk_enumerate_partitions (disk);
+    if (ped_disk_do_enumerate)
+        ped_disk_enumerate_partitions (disk);
 	return 1;
 
 error:
diff --git a/parted/parted.c b/parted/parted.c
index 5f2f2aa..2c92eef 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1866,6 +1866,9 @@ do_rm (PedDevice** dev)
         PedDisk*                disk;
         PedPartition*           part = NULL;
 
+        if (ped_disk_enumerate_on())
+            ped_disk_toggle_do_enumerate();
+
         disk = ped_disk_new (*dev);
         if (!disk)
                 goto error;
@@ -1882,11 +1885,15 @@ do_rm (PedDevice** dev)
         if ((*dev)->type != PED_DEVICE_FILE)
                 disk_is_modified = 1;
 
+        if (!ped_disk_enumerate_on())
+            ped_disk_toggle_do_enumerate();
         return 1;
 
 error_destroy_disk:
         ped_disk_destroy (disk);
 error:
+        if (!ped_disk_enumerate_on())
+            ped_disk_toggle_do_enumerate();
         return 0;
 }
 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]