- libparted: Fix probing AIX disks on other arches

- partprobe: Open the device once for probing
This commit is contained in:
Brian C. Lane 2016-05-26 12:05:08 -07:00
parent 6ad4b6c092
commit bdb87d14b5
3 changed files with 106 additions and 1 deletions

View File

@ -0,0 +1,56 @@
From 85cec179048914d165e3a11b1d8d8c759725d236 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 6 May 2016 14:39:09 -0700
Subject: [PATCH 37/38] libparted: Fix probing AIX disks on other arches
Not a likely scenario, but make sure the magic check works everywhere.
(cherry picked from commit 24cd71c0a7c4b2abdfff04be5a088a44ab5df2fe)
---
libparted/labels/aix.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/libparted/labels/aix.c b/libparted/labels/aix.c
index 0fa6fe7..a831d95 100644
--- a/libparted/labels/aix.c
+++ b/libparted/labels/aix.c
@@ -34,23 +34,11 @@
# define _(String) (String)
#endif /* ENABLE_NLS */
-#define AIX_LABEL_MAGIC 0xc9c2d4c1
+#define AIX_LABEL_MAGIC (0xc9c2d4c1UL)
#define MAX_TOTAL_PART 16
static PedDiskType aix_disk_type;
-static inline int
-aix_label_magic_get (const char *label)
-{
- return *(unsigned int *)label;
-}
-
-static inline void
-aix_label_magic_set (char *label, int magic_val)
-{
- *(unsigned int *)label = magic_val;
-}
-
static int
aix_probe (const PedDevice *dev)
{
@@ -59,9 +47,9 @@ aix_probe (const PedDevice *dev)
void *label;
if (!ptt_read_sector (dev, 0, &label))
return 0;
- unsigned int magic = aix_label_magic_get (label);
+ bool found = PED_BE32_TO_CPU(*(uint32_t *)label) == AIX_LABEL_MAGIC;
free (label);
- return magic == AIX_LABEL_MAGIC;
+ return found;
}
static PedDisk*
--
2.5.5

View File

@ -0,0 +1,43 @@
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

View File

@ -4,7 +4,7 @@
Summary: The GNU disk partition manipulation program Summary: The GNU disk partition manipulation program
Name: parted Name: parted
Version: 3.2 Version: 3.2
Release: 19%{?dist} Release: 20%{?dist}
License: GPLv3+ License: GPLv3+
Group: Applications/System Group: Applications/System
URL: http://www.gnu.org/software/parted URL: http://www.gnu.org/software/parted
@ -50,6 +50,8 @@ Patch0033: 0033-Use-disk-geometry-as-basis-for-ext2-sector-sizes.patch
Patch0034: 0034-docs-Add-list-of-filesystems-for-fs-type-1311596.patch Patch0034: 0034-docs-Add-list-of-filesystems-for-fs-type-1311596.patch
Patch0035: 0035-parted-Display-details-of-partition-alignment-failur.patch Patch0035: 0035-parted-Display-details-of-partition-alignment-failur.patch
Patch0036: 0036-libparted-Remove-fdasd-geometry-code-from-alloc_meta.patch Patch0036: 0036-libparted-Remove-fdasd-geometry-code-from-alloc_meta.patch
Patch0037: 0037-libparted-Fix-probing-AIX-disks-on-other-arches.patch
Patch0038: 0038-partprobe-Open-the-device-once-for-probing.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: e2fsprogs-devel BuildRequires: e2fsprogs-devel
@ -186,6 +188,10 @@ fi
%changelog %changelog
* Thu May 26 2016 Brian C. Lane <bcl@redhat.com> - 3.2-20
- libparted: Fix probing AIX disks on other arches
- partprobe: Open the device once for probing
* Tue Apr 12 2016 Brian C. Lane <bcl@redhat.com> 3.2-19 * Tue Apr 12 2016 Brian C. Lane <bcl@redhat.com> 3.2-19
- libparted: Remove fdasd geometry code from alloc_metadata (#1244833) (bcl) - libparted: Remove fdasd geometry code from alloc_metadata (#1244833) (bcl)
- parted: Display details of partition alignment failure (#726856) (bcl) - parted: Display details of partition alignment failure (#726856) (bcl)