[parted-devel] [PATCH] libparted: Fix probing AIX disks on other arches
Brian C. Lane
bcl at redhat.com
Sat May 7 00:12:26 UTC 2016
Not a likely scenario, but make sure the magic check works everywhere.
---
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
More information about the parted-devel
mailing list