parted/0110-libparted-give-correct-partition-device-name-on-loop.patch
Brian C. Lane 5dcb73843d - Add some missing patches from master and the loop label fixes
- tests: test loop labels (psusi)
- libparted: don't trash filesystem when writing loop label (psusi)
- libparted: give correct partition device name on loop labels (psusi)
- partprobe: do not skip loop labels (psusi)
- libparted: don't create partition on loop label (psusi)
- libparted: fix loop labels to not vanish (psusi)
- libparted: remove all old partitions, even if new label allows less (psusi)
- libparted: remove old partitions *first* before adding new ones (psusi)
- libparted: don't detect fat and ntfs boot sectors as dos MBR (psusi)
- Fix filesystem detection on non 512 byte sectors (psusi)
- tests: fix t2310-dos-extended-2-sector-min-offset.sh (psusi)
- libparted: remove last_usable_if_grown (psusi)
2014-05-22 15:03:30 -07:00

81 lines
2.7 KiB
Diff

From 998e09d5698777cfbb9b7aacc9059209c7816d60 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Fri, 2 May 2014 21:50:49 -0400
Subject: [PATCH 206/208] libparted: give correct partition device name on loop
labels
ped_partition_get_path() was returning "/dev/foo1" instead of
"/dev/foo" on loop labels. This caused gparted to run tools like mkfs on
a device node that did not actually exist.
---
NEWS | 3 +++
libparted/arch/linux.c | 10 ++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index d79292f..0a04942 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,9 @@ GNU parted NEWS -*- outline -*-
Fix filesystem detection on non 512 byte sector sizes
+ libparted: ped_partition_get_path() was returning "/dev/foo1" instead
+ of "/dev/foo" for loop labels.
+
partprobe: when called on a disk that has become a loop label,
remove any partitions left over from a previous label.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 9ae6d64..f2e2abc 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -48,6 +48,7 @@
#include "../architecture.h"
#include "dirname.h"
#include "xstrtol.h"
+#include "xalloc.h"
#if ENABLE_NLS
# include <libintl.h>
@@ -2356,6 +2357,9 @@ _device_get_part_path (PedDevice const *dev, int num)
static char*
linux_partition_get_path (const PedPartition* part)
{
+ /* loop label means use the whole disk */
+ if (strcmp (part->disk->type->name, "loop") == 0)
+ return xstrdup (part->disk->dev->path);
return _device_get_part_path (part->disk->dev, part->num);
}
@@ -2424,6 +2428,8 @@ linux_partition_is_busy (const PedPartition* part)
PED_ASSERT (part != NULL);
+ if (strcmp (part->disk->type->name, "loop") == 0)
+ return linux_is_busy (part->disk->dev);
if (_partition_is_mounted (part))
return 1;
if (part->type == PED_PARTITION_EXTENDED) {
@@ -2546,7 +2552,7 @@ _sysfs_ull_entry_from_part(PedPartition const* part, const char *entry,
unsigned long long *val)
{
char path[128];
- char *part_name = linux_partition_get_path(part);
+ char *part_name = _device_get_part_path (part->disk->dev, part->num);
if (!part_name)
return false;
@@ -2581,7 +2587,7 @@ _kernel_get_partition_start_and_length(PedPartition const *part,
PED_ASSERT(start);
PED_ASSERT(length);
- char *dev_name = linux_partition_get_path (part);
+ char *dev_name = _device_get_part_path (part->disk->dev, part->num);
if (!dev_name)
return false;
--
1.9.0