parted/parted-1.9.0-commit-without-close.patch

45 lines
1.1 KiB
Diff
Raw Normal View History

From 50898ea17a25c92c3b0ab3c0f12ea867a6ff1ff9 Mon Sep 17 00:00:00 2001
From: Joel Granados Moreno <jgranado@redhat.com>
Date: Mon, 31 Aug 2009 13:42:47 +0200
Subject: [PATCH 2/3] Commit without close
---
libparted/disk.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/libparted/disk.c b/libparted/disk.c
index 27611eb..b01ac70 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -513,9 +513,25 @@ error:
int
ped_disk_commit (PedDisk* disk)
{
+ /* Open the device here, so that the underlying fd is not closed
+ between commit_to_dev and commit_to_os (closing causes unwanted
+ udev events to be send under Linux). */
+ if (!ped_device_open (disk->dev))
+ goto error;
+
if (!ped_disk_commit_to_dev (disk))
- return 0;
- return ped_disk_commit_to_os (disk);
+ goto error_close_dev;
+
+ if (!ped_disk_commit_to_os (disk))
+ goto error_close_dev;
+
+ ped_device_close (disk->dev);
+ return 1;
+
+error_close_dev:
+ ped_device_close (disk->dev);
+error:
+ return 0;
}
/**
--
1.6.4