OSDN Git Service

ped_partition_busy: do not call the libparted exception handler
authorHans de Goede <hdegoede@redhat.com>
Tue, 6 Oct 2009 09:31:14 +0000 (11:31 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 6 Oct 2009 10:14:39 +0000 (12:14 +0200)
Modify libparted/arch/linux.c _partition_get_part_dev() to not call
_device_stat() but instead use stat directly, as _device_stat() calls
the libparted exception handler, and we don't want this here, the only
caller of _partition_get_part_dev() is _partition_is_mounted(), which
in turn only gets called by linux_partition_is_busy(), and we don't
want to "throw" exceptions from ped_partition_busy().

This issue was noticed in combination with pyparted as used by
anaconda, see: http://bugzilla.redhat.com/527035#c10

NEWS
libparted/arch/linux.c

diff --git a/NEWS b/NEWS
index 89e8804..04741a2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ GNU parted NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  ped_partition_is_busy no longer calls libparted's exception handler,
+  since doing so caused trouble with anaconda/pyparted when operating on
+  dmraid devices.
+
   Partitions in a GPT table are no longer assigned the "microsoft
   reserved partition" type.  Before this change, each partition would
   be listed with a type of "msftres" by default.
index 52f7d21..6a3c6b3 100644 (file)
@@ -2127,7 +2127,7 @@ _partition_get_part_dev (const PedPartition* part)
         struct stat dev_stat;
         int dev_major, dev_minor;
 
-        if (!_device_stat (part->disk->dev, &dev_stat))
+        if (stat (part->disk->dev->path, &dev_stat))
                 return (dev_t)0;
         dev_major = major (dev_stat.st_rdev);
         dev_minor = minor (dev_stat.st_rdev);
@@ -2184,6 +2184,8 @@ _partition_is_mounted (const PedPartition *part)
         if (!ped_partition_is_active (part))
                 return 0;
         dev = _partition_get_part_dev (part);
+        if (!dev)
+                return 0;
         return _partition_is_mounted_by_dev (dev);
 }