parted/SOURCES/0038-partprobe-Open-the-device-once-for-probing.patch
2021-09-09 23:32:26 +00:00

44 lines
1.1 KiB
Diff

From f3cbda4bf581b407586f24c980cf2e5a9cb2b4b2 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 25 May 2016 09:00:04 -0700
Subject: [PATCH 38/38] partprobe: Open the device once for probing
Previously there were 3 open/close pairs for the device, which may
result in triggering extra udev actions. Instead, open it once at the
start of process_dev and close it at the end.
---
partprobe/partprobe.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/partprobe/partprobe.c b/partprobe/partprobe.c
index 34997fe..8f2190b 100644
--- a/partprobe/partprobe.c
+++ b/partprobe/partprobe.c
@@ -105,6 +105,9 @@ process_dev (PedDevice* dev)
PedDiskType* disk_type;
PedDisk* disk;
+ if (!ped_device_open (dev))
+ return 0;
+
disk_type = ped_disk_probe (dev);
if (!disk_type) {
/* Partition table not found, so create dummy,
@@ -128,11 +131,13 @@ process_dev (PedDevice* dev)
if (opt_summary)
summary (disk);
ped_disk_destroy (disk);
+ ped_device_close (dev);
return 1;
error_destroy_disk:
ped_disk_destroy (disk);
error:
+ ped_device_close (dev);
return 0;
}
--
2.5.5