[parted-devel] remove-dev_t_dep.patch
Jim Meyering
jim at meyering.net
Tue May 10 10:22:23 UTC 2011
Phillip Susi wrote:
> From: Phillip Susi <psusi at cfl.rr.com>
> Description: All partitions on dmraid disks and partition numbers
> >= 16 on regular scsi disks were not being detected as in use.
> This was because assumptions were being made about the dev node
> major/minor numbers and how they relate to the partition number.
> These assumptions break entirely on dmraid devices, and on normal
> disks with >= 16 partitions. Removed _partition_get_part_dev()
> and rewrote _partition_is_mounted() to use
> _partition_is_mounted_by_path() instead of _by_dev.
Thanks for the patch.
I've squashed the following mostly-syntactic changes
into your patch, rewrote the commit log
and will wait for your ACK before pushing.
I also wrote a test and added a NEWS entry, which I'll post separately.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 727862a..b56ce2b 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2281,21 +2281,19 @@ _partition_is_mounted_by_path (const char *path)
return _partition_is_mounted_by_dev (part_stat.st_rdev);
}
+/* If partition PART is mounted, or if we encounter an out-of-memory error
+ while trying to determine its status, return 1. Otherwise, return 0. */
static int
_partition_is_mounted (const PedPartition *part)
{
- char *part_name;
- int status;
- if (!ped_partition_is_active (part))
- return 0;
- part_name = _device_get_part_path (part->disk->dev, part->num);
+ if (!ped_partition_is_active (part))
+ return 0;
+ char *part_name = _device_get_part_path (part->disk->dev, part->num);
if (!part_name)
return 1;
- status = _partition_is_mounted_by_path (part_name);
+ int status = _partition_is_mounted_by_path (part_name);
free (part_name);
- if (status)
- return 1;
- return 0;
+ return !!status;
}
static int
Here's the result:
More information about the parted-devel
mailing list